handling no gem set for the tray mode

This commit is contained in:
Vinicius Moreira
2019-09-11 18:25:52 -03:00
parent fb779cd650
commit 33708f054b
10 changed files with 39 additions and 24 deletions

View File

@@ -48,7 +48,7 @@ else:
enabled_managers = [m for m in managers if m.is_enabled()]
if not user_config.gems and enabled_managers:
if not user_config.gems and enabled_managers and not args.tray:
gem_panel = GemSelectorPanel(enabled_managers, i18n, managers_set=None)
gem_panel.show()
else:
@@ -67,13 +67,17 @@ else:
context=context)
if args.tray:
trayIcon = TrayIcon(locale_keys=i18n,
manager=manager,
manage_window=manage_window,
check_interval=args.check_interval,
update_notification=bool(args.update_notification))
manage_window.tray_icon = trayIcon
trayIcon.show()
tray_icon = TrayIcon(locale_keys=i18n,
manager=manager,
manage_window=manage_window,
check_interval=args.check_interval,
update_notification=bool(args.update_notification),
config=user_config)
manage_window.tray_icon = tray_icon
tray_icon.show()
if args.show_panel:
tray_icon.show_manage_window()
else:
manage_window.refresh_apps()
manage_window.show()

View File

@@ -35,6 +35,7 @@ def read() -> Namespace:
parser.add_argument('--sugs', action="store", default=os.getenv('BAUH_SUGGESTIONS', 1), choices=[0, 1], type=int, help='If app suggestions should be displayed if no application package is installed (runtimes / libraries do not count as apps). Default: %(default)s')
parser.add_argument('-md', '--max-displayed', action="store", default=os.getenv('BAUH_MAX_DISPLAYED', 100), choices=[0, 1], type=int, help='Maximum number of displayed packages in the management panel table. Default: %(default)s')
parser.add_argument('--logs', action="store", default=int(os.getenv('BAUH_LOGS', 0)), choices=[0, 1], type=int, help='If the application logs should be displayed. Default: %(default)s')
parser.add_argument('--show-panel', action="store_true", help='Shows the management panel after the app icon is attached to the tray.')
return parser.parse_args()

View File

@@ -244,8 +244,6 @@ class GenericSoftwareManager(SoftwareManager):
warnings = []
warnings.extend(man_warnings)
else:
warnings.append(self.i18n['warning.no_managers'])
return warnings

View File

@@ -86,7 +86,6 @@ bt.app_not_upgrade=Don't upgrade
manage_window.upgrade_all.popup.title=Upgrade
manage_window.upgrade_all.popup.body=Upgrade all selected applications ?
manage_window.settings.about=About
warning.no_managers=There are no installed extensions. It will not be possible to intall and manage applications.
confirmation=confirmation
and=and
error=error

View File

@@ -88,7 +88,6 @@ bt.app_not_upgrade=No actualizar
manage_window.upgrade_all.popup.title=Actualizar
manage_window.upgrade_all.popup.body=¿Actualizar todos los aplicativos seleccionados?
manage_window.settings.about=Sobre
warning.no_managers=No hay extensiones instaladas. No será posible instalar y administrar aplicaciones.
confirmation=confirmación
and=y
error=error

View File

@@ -88,7 +88,6 @@ bt.app_not_upgrade=Não atualizar
manage_window.upgrade_all.popup.title=Atualizar
manage_window.upgrade_all.popup.body=Atualizar todos os aplicativos selecionados ?
manage_window.settings.about=Sobre
warning.no_managers=Não há nenhuma extensão instalada. Não será possível instalar e gerenciar aplicações.
confirmation=confirmação
and=e
error=erro

View File

@@ -354,8 +354,8 @@ class AppsTable(QTableWidget):
publisher = publisher.strip()
full_publisher = publisher
if len(publisher) > 10:
publisher = full_publisher[0:10] + '...'
if len(publisher) > 20:
publisher = full_publisher[0:20] + '...'
if not publisher:
if not pkg.model.installed:

View File

@@ -16,14 +16,15 @@ from bauh.view.qt.components import MultipleSelectQt, CheckboxQt, new_spacer
class GemSelectorPanel(QWidget):
def __init__(self, managers: List[SoftwareManager], i18n: dict, managers_set: List[str], exit_on_close: bool = True):
def __init__(self, managers: List[SoftwareManager], i18n: dict, managers_set: List[str], show_panel_after_restart: bool = False):
super(GemSelectorPanel, self).__init__()
self.managers = managers
self.setLayout(QGridLayout())
self.setWindowIcon(QIcon(resource.get_path('img/logo.svg', ROOT_DIR)))
self.setWindowTitle(i18n['welcome'].capitalize() if not managers_set else i18n['gem_selector.title'])
self.resize(400, 400)
self.exit_on_close = exit_on_close
self.exit_on_close = not managers_set
self.show_panel_after_restart = show_panel_after_restart
self.label_question = QLabel(i18n['gem_selector.question'])
self.label_question.setStyleSheet('QLabel { font-weight: bold}')
@@ -74,7 +75,13 @@ class GemSelectorPanel(QWidget):
def save(self):
config = Configuration(gems=[o.value for o in self.gem_select_model.values])
save(config)
subprocess.Popen([sys.executable, *sys.argv])
restart_cmd = [sys.executable, *sys.argv]
if self.show_panel_after_restart:
restart_cmd.append('--show-panel')
subprocess.Popen(restart_cmd)
QCoreApplication.exit()
def exit(self):

View File

@@ -9,6 +9,7 @@ from bauh.api.abstract.model import PackageUpdate
from bauh import __app_name__
from bauh.api.abstract.controller import SoftwareManager
from bauh.core.config import Configuration
from bauh.util import util, resource
from bauh.view.qt.about import AboutDialog
from bauh.view.qt.window import ManageWindow
@@ -33,10 +34,11 @@ class UpdateCheck(QThread):
class TrayIcon(QSystemTrayIcon):
def __init__(self, locale_keys: dict, manager: SoftwareManager, manage_window: ManageWindow, check_interval: int = 60, update_notification: bool = True):
def __init__(self, locale_keys: dict, manager: SoftwareManager, manage_window: ManageWindow, config: Configuration, check_interval: int = 60, update_notification: bool = True):
super(TrayIcon, self).__init__()
self.locale_keys = locale_keys
self.manager = manager
self.config = config
self.icon_default = QIcon(resource.get_path('img/logo.png'))
self.icon_update = QIcon(resource.get_path('img/logo_update.png'))
@@ -116,8 +118,12 @@ class TrayIcon(QSystemTrayIcon):
if self.manage_window.isMinimized():
self.manage_window.setWindowState(Qt.WindowNoState)
elif not self.manage_window.isVisible():
self.manage_window.refresh_apps()
self.manage_window.show()
if self.config.gems:
self.manage_window.refresh_apps()
self.manage_window.show()
else:
self.manage_window.show()
self.manage_window.show_gems_selector()
def show_about(self):

View File

@@ -901,10 +901,12 @@ class ManageWindow(QWidget):
else:
self.checkbox_console.setChecked(True)
def _show_gems_selector(self):
def show_gems_selector(self):
managers = gems.load_managers(context=self.context, locale=None)
enabled_managers = [m for m in managers if m.is_enabled()]
gem_panel = GemSelectorPanel(managers=enabled_managers, i18n=self.i18n, managers_set=self.config.gems, exit_on_close=False)
gem_panel = GemSelectorPanel(managers=enabled_managers, i18n=self.i18n,
managers_set=self.config.gems,
show_panel_after_restart=bool(self.tray_icon))
gem_panel.show()
def _show_settings_menu(self):
@@ -913,7 +915,7 @@ class ManageWindow(QWidget):
action_gems = QAction(self.i18n['manage_window.settings.gems'])
action_gems.setIcon(self.icon_app)
action_gems.triggered.connect(self._show_gems_selector)
action_gems.triggered.connect(self.show_gems_selector)
menu_row.addAction(action_gems)
action_about = QAction(self.i18n['manage_window.settings.about'])