run button

This commit is contained in:
Vinicius Moreira
2019-08-27 18:08:30 -03:00
parent caf5ac4883
commit 82145a35a3
7 changed files with 44 additions and 3 deletions

BIN
bauh/resources/img/app_play.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

View File

@@ -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

View File

@@ -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
status.caching_data=Cacheando los datos de {} para el disco
action.run.tooltip=Haces clic aqui para iniciar este aplicativo

View File

@@ -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
status.caching_data=Cacheando dados de {} para o disco
action.run.tooltip=Clique aqui para iniciar esse aplicativo

View File

@@ -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():

View File

@@ -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)

View File

@@ -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()