From b1b759b5790f5cb1e12bc6ef0a1c8642efc80f8a Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 2 Aug 2019 22:26:26 -0300 Subject: [PATCH] new update button --- fpakman/resources/locale/en | 4 +++- fpakman/resources/locale/es | 4 +++- fpakman/resources/locale/pt | 4 +++- fpakman/view/qt/apps_table.py | 41 +++++++++++++++++++++++++---------- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/fpakman/resources/locale/en b/fpakman/resources/locale/en index 4ba9818b..0f652326 100644 --- a/fpakman/resources/locale/en +++ b/fpakman/resources/locale/en @@ -106,4 +106,6 @@ warning=warning snap.notification.snapd_unavailable=snapd seems not to be enabled. snap packages will not be available. flatpak.notification.no_remotes=No Flatpak remotes set. It will not be possible to search for Flatpak apps. install=install -uninstall=uninstall \ No newline at end of file +uninstall=uninstall +bt.app_upgrade=Upgrade +bt.app_not_upgrade=Don't upgrade \ No newline at end of file diff --git a/fpakman/resources/locale/es b/fpakman/resources/locale/es index 96044efd..4299eea2 100644 --- a/fpakman/resources/locale/es +++ b/fpakman/resources/locale/es @@ -108,4 +108,6 @@ warning=aviso snap.notification.snapd_unavailable=snapd no parece estar habilitado. los paquetes snap estarán indisponibles. flatpak.notification.no_remotes=No hay repositorios (remotes) Flatpak configurados. No será posible buscar aplicativos Flatpak. install=instalar -uninstall=desinstalar \ No newline at end of file +uninstall=desinstalar +bt.app_upgrade=Actualizar +bt.app_not_upgrade=No actualizar \ No newline at end of file diff --git a/fpakman/resources/locale/pt b/fpakman/resources/locale/pt index e7ea8f01..34579fd2 100644 --- a/fpakman/resources/locale/pt +++ b/fpakman/resources/locale/pt @@ -108,4 +108,6 @@ warning=aviso snap.notification.snapd_unavailable=snapd não parece estar habilitado. os pacotes snap estarão indisponíveis. flatpak.notification.no_remotes=Não há repositórios (remotes) Flatpak configurados. Não será possível buscar aplicativos Flatpak. install=instalar -uninstall=desinstalar \ No newline at end of file +uninstall=desinstalar +bt.app_upgrade=Atualizar +bt.app_not_upgrade=Não atualizar \ No newline at end of file diff --git a/fpakman/view/qt/apps_table.py b/fpakman/view/qt/apps_table.py index e98983b6..4719977c 100644 --- a/fpakman/view/qt/apps_table.py +++ b/fpakman/view/qt/apps_table.py @@ -5,7 +5,7 @@ from typing import List from PyQt5.QtCore import Qt, QUrl from PyQt5.QtGui import QPixmap, QIcon, QCursor from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest -from PyQt5.QtWidgets import QTableWidget, QTableView, QMenu, QAction, QTableWidgetItem, QToolButton, QWidget, \ +from PyQt5.QtWidgets import QTableWidget, QTableView, QMenu, QAction, QTableWidgetItem, QWidget, \ QHeaderView, QLabel, QHBoxLayout, QPushButton from fpakman.core import resource @@ -15,29 +15,46 @@ from fpakman.util.cache import Cache from fpakman.view.qt import dialog from fpakman.view.qt.view_model import ApplicationView, ApplicationViewStatus -INSTALL_BT_STYLE = 'background: {back}; color: white; font-size: 9px; font-weight: bold' +INSTALL_BT_STYLE = 'background: {back}; color: white; font-size: 10px; font-weight: bold' -class UpdateToggleButton(QToolButton): +class UpdateToggleButton(QWidget): def __init__(self, app_view: ApplicationView, root: QWidget, locale_keys: dict, checked: bool = True): super(UpdateToggleButton, self).__init__() self.app_view = app_view self.root = root - self.setCheckable(True) - self.clicked.connect(self.change_state) - self.icon_on = QIcon(resource.get_path('img/toggle_on.svg')) - self.icon_off = QIcon(resource.get_path('img/toggle_off.svg')) - self.setIcon(self.icon_on) - self.setStyleSheet('QToolButton { border: 0px; }') - self.setToolTip(locale_keys['manage_window.apps_table.upgrade_toggle.tooltip']) + self.locale_keys = locale_keys + self.on = { + 'text': self.locale_keys['bt.app_upgrade'], + 'style': 'QPushButton { ' + INSTALL_BT_STYLE.format(back='#04B404') + ' }' + } + self.off = { + 'text': self.locale_keys['bt.app_not_upgrade'], + 'style': 'QPushButton { ' + INSTALL_BT_STYLE.format(back='gray') + ' }' + } + + layout = QHBoxLayout() + layout.setContentsMargins(3, 3, 3, 3) + layout.setAlignment(Qt.AlignCenter) + self.setLayout(layout) + + self.bt = QPushButton() + self.bt.setText(self.on['text']) + self.bt.setStyleSheet(self.on['style']) + self.bt.setCheckable(True) + self.bt.clicked.connect(self.change_state) + layout.addWidget(self.bt) if not checked: - self.click() + self.bt.click() def change_state(self, not_checked: bool): self.app_view.update_checked = not not_checked - self.setIcon(self.icon_on if not not_checked else self.icon_off) + + state = self.on if not not_checked else self.off + self.bt.setText(state['text']) + self.bt.setStyleSheet(state['style']) self.root.change_update_state(change_filters=False)