diff --git a/bauh/resources/img/app_play.png b/bauh/resources/img/app_play.png new file mode 100755 index 00000000..b98062b5 Binary files /dev/null and b/bauh/resources/img/app_play.png differ diff --git a/bauh/resources/locale/en b/bauh/resources/locale/en index 4b4137d9..1c9637ff 100644 --- a/bauh/resources/locale/en +++ b/bauh/resources/locale/en @@ -25,6 +25,7 @@ manage_window.status.history=Retrieving history manage_window.status.searching=Searching manage_window.status.installing=Installing manage_window.status.refreshing_app=Refreshing +manage_window.status.running_app=Running {} manage_window.bt.refresh.tooltip=Reload the data about installed applications manage_window.bt.upgrade.tooltip=Upgrade all checked applications manage_window.checkbox.show_details=Show details @@ -91,3 +92,4 @@ show=show ask.continue=Continue ? cancel=cancel status.caching_data=Caching {} data to disk +action.run.tooltip=Click here to start this application diff --git a/bauh/resources/locale/es b/bauh/resources/locale/es index ef3eab97..79799719 100644 --- a/bauh/resources/locale/es +++ b/bauh/resources/locale/es @@ -27,6 +27,7 @@ manage_window.status.history=Obteniendo la historia manage_window.status.searching=Buscando manage_window.status.installing=Instalando manage_window.status.refreshing_app=Actualizando +manage_window.status.running_app=Ejecutando {} manage_window.bt.refresh.tooltip=Recarga los datos sobre los aplicativos instalados manage_window.bt.upgrade.tooltip=Actualiza todos los aplicativos marcados manage_window.checkbox.show_details=Mostrar detalles @@ -92,4 +93,5 @@ back=volver show=mostrar ask.continue=¿Continuar ? cancel=cancelar -status.caching_data=Cacheando los datos de {} para el disco \ No newline at end of file +status.caching_data=Cacheando los datos de {} para el disco +action.run.tooltip=Haces clic aqui para iniciar este aplicativo \ No newline at end of file diff --git a/bauh/resources/locale/pt b/bauh/resources/locale/pt index c5833120..84582685 100644 --- a/bauh/resources/locale/pt +++ b/bauh/resources/locale/pt @@ -27,6 +27,7 @@ manage_window.status.history=Obtendo histórico manage_window.status.searching=Buscando manage_window.status.installing=Instalando manage_window.status.refreshing_app=Atualizando +manage_window.status.running_app=Iniciando {} manage_window.bt.refresh.tooltip=Recarrega os dados sobre os aplicativos instalados manage_window.bt.upgrade.tooltip=Atualiza todos os aplicativos marcados manage_window.checkbox.show_details=Mostrar detalhes @@ -92,4 +93,5 @@ back=voltar show=mostrar ask.continue=Continuar ? cancel=cancelar -status.caching_data=Cacheando dados de {} para o disco \ No newline at end of file +status.caching_data=Cacheando dados de {} para o disco +action.run.tooltip=Clique aqui para iniciar esse aplicativo \ No newline at end of file diff --git a/bauh/view/qt/apps_table.py b/bauh/view/qt/apps_table.py index ef0527b6..3b0611e2 100644 --- a/bauh/view/qt/apps_table.py +++ b/bauh/view/qt/apps_table.py @@ -1,4 +1,5 @@ import os +import subprocess from threading import Lock from typing import List @@ -367,6 +368,13 @@ class AppsTable(QTableWidget): def _set_col_settings(self, idx: int, app_v: ApplicationView): tb = QToolBar() + if app_v.model.can_be_run() and app_v.model.get_command(): + + def run(): + self.window.run_app(app_v) + + tb.addWidget(IconButton(icon_path=resource.get_path('img/app_play.png'), action=run, background='#088A08', tooltip=self.window.locale_keys['action.run.tooltip'])) + if app_v.model.has_info(): def get_info(): diff --git a/bauh/view/qt/thread.py b/bauh/view/qt/thread.py index 899a0247..dba2f722 100644 --- a/bauh/view/qt/thread.py +++ b/bauh/view/qt/thread.py @@ -1,3 +1,4 @@ +import subprocess import time from datetime import datetime, timedelta from typing import List @@ -342,3 +343,20 @@ class ListWarnings(QThread): warnings = self.man.list_warnings() if warnings: self.signal_warnings.emit(warnings) + + +class RunApp(AsyncAction): + + def __init__(self, app: ApplicationView = None): + super(RunApp, self).__init__() + self.app = app + + def run(self): + + if self.app: + try: + time.sleep(0.5) + subprocess.Popen(self.app.model.get_command().split(' ')) + self.notify_finished(True) + except: + self.notify_finished(False) diff --git a/bauh/view/qt/window.py b/bauh/view/qt/window.py index 01478b00..ed945992 100755 --- a/bauh/view/qt/window.py +++ b/bauh/view/qt/window.py @@ -23,7 +23,7 @@ from bauh.view.qt.info import InfoDialog from bauh.view.qt.root import is_root, ask_root_password from bauh.view.qt.thread import UpdateSelectedApps, RefreshApps, UninstallApp, DowngradeApp, GetAppInfo, \ GetAppHistory, SearchApps, InstallApp, AnimateProgress, VerifyModels, RefreshApp, FindSuggestions, ListWarnings, \ - AsyncAction + AsyncAction, RunApp from bauh.view.qt.view_model import ApplicationView DARK_ORANGE = '#FF4500' @@ -163,6 +163,7 @@ class ManageWindow(QWidget): self.thread_downgrade = self._bind_async_action(DowngradeApp(self.manager, self.locale_keys), finished_call=self._finish_downgrade) self.thread_refresh_app = self._bind_async_action(RefreshApp(manager=self.manager), finished_call=self._finish_refresh) self.thread_suggestions = self._bind_async_action(FindSuggestions(man=self.manager), finished_call=self._finish_search, only_finished=True) + self.thread_run_app = self._bind_async_action(RunApp(), finished_call=self._finish_run_app, only_finished=False) self.thread_install = InstallApp(manager=self.manager, disk_cache=self.disk_cache, icon_cache=self.icon_cache, locale_keys=self.locale_keys) self._bind_async_action(self.thread_install, finished_call=self._finish_install) @@ -334,6 +335,11 @@ class ManageWindow(QWidget): self.thread_uninstall.root_password = pwd self.thread_uninstall.start() + def run_app(self, app: ApplicationView): + self._begin_action(self.locale_keys['manage_window.status.running_app'].format(app.model.base_data.name)) + self.thread_run_app.app = app + self.thread_run_app.start() + def refresh(self, app: ApplicationView): pwd = None requires_root = self.manager.requires_root('refresh', app.model) @@ -739,3 +745,6 @@ class ManageWindow(QWidget): def _update_progress(self, value: int): self.progress_bar.setValue(value) + + def _finish_run_app(self, success: bool): + self.finish_action()