replacing installed / uninstalled icons by action buttons

This commit is contained in:
Vinicius Moreira
2019-08-01 14:36:09 -03:00
parent ed1ad7d3d3
commit ff98b40506
6 changed files with 50 additions and 29 deletions

View File

@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- search results sorting takes an average of 35% less time, reaching 60% in some scenarios - search results sorting takes an average of 35% less time, reaching 60% in some scenarios
- app boot takes an average of 80% less time - app boot takes an average of 80% less time
- showing a warning popup after initialization when no Flatpak remotes are set - showing a warning popup after initialization when no Flatpak remotes are set
- installed / uninstalled icons replaced by install / uninstall button
### Fixes: ### Fixes:
- apps table not showing empty descriptions - apps table not showing empty descriptions
- replacing default app icons by null icons - replacing default app icons by null icons

View File

@@ -3,9 +3,10 @@ manage_window.columns.latest_version=Latest Version
manage_window.columns.update=Upgrade ? manage_window.columns.update=Upgrade ?
manage_window.apps_table.row.actions.info=Information manage_window.apps_table.row.actions.info=Information
manage_window.apps_table.row.actions.history=History manage_window.apps_table.row.actions.history=History
manage_window.apps_table.row.actions.uninstall=Uninstall
manage_window.apps_table.row.actions.uninstall.popup.title=Uninstall manage_window.apps_table.row.actions.uninstall.popup.title=Uninstall
manage_window.apps_table.row.actions.uninstall.popup.body=Remove {} ? manage_window.apps_table.row.actions.uninstall.popup.body=Remove {} ?
manage_window.apps_table.row.actions.install.popup.title=Installation
manage_window.apps_table.row.actions.install.popup.body=Do you wish to install {} ?
manage_window.apps_table.row.actions.downgrade=Downgrade manage_window.apps_table.row.actions.downgrade=Downgrade
manage_window.apps_table.row.actions.downgrade.popup.body=Do you really want to downgrade {} ? manage_window.apps_table.row.actions.downgrade.popup.body=Do you really want to downgrade {} ?
manage_window.apps_table.row.actions.install=Install manage_window.apps_table.row.actions.install=Install
@@ -103,4 +104,6 @@ version.unknown=not informed
app.name=application name app.name=application name
warning=warning warning=warning
snap.notification.snapd_unavailable=snapd seems not to be enabled. snap packages will not be available. 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. flatpak.notification.no_remotes=No Flatpak remotes set. It will not be possible to search for Flatpak apps.
install=install
uninstall=uninstall

View File

@@ -7,6 +7,8 @@ manage_window.apps_table.row.actions.history=Historia
manage_window.apps_table.row.actions.uninstall=Desinstalar manage_window.apps_table.row.actions.uninstall=Desinstalar
manage_window.apps_table.row.actions.uninstall.popup.title=Desinstalación manage_window.apps_table.row.actions.uninstall.popup.title=Desinstalación
manage_window.apps_table.row.actions.uninstall.popup.body=¿Eliminar {}? manage_window.apps_table.row.actions.uninstall.popup.body=¿Eliminar {}?
manage_window.apps_table.row.actions.install.popup.title=Instalación
manage_window.apps_table.row.actions.install.popup.body=Desea instalar {} ?
manage_window.apps_table.row.actions.downgrade=Revertir versión manage_window.apps_table.row.actions.downgrade=Revertir versión
manage_window.apps_table.row.actions.downgrade.popup.body=¿Realmente quieres revertir la versión actual de {}? manage_window.apps_table.row.actions.downgrade.popup.body=¿Realmente quieres revertir la versión actual de {}?
manage_window.apps_table.row.actions.install=Instalar manage_window.apps_table.row.actions.install=Instalar
@@ -104,4 +106,6 @@ version.unknown=versión no informada
app.name=nombre del aplicativo app.name=nombre del aplicativo
warning=aviso warning=aviso
snap.notification.snapd_unavailable=snapd no parece estar habilitado. los paquetes snap estarán indisponibles. 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. flatpak.notification.no_remotes=No hay repositorios (remotes) Flatpak configurados. No será posible buscar aplicativos Flatpak.
install=instalar
uninstall=desinstalar

View File

@@ -7,6 +7,8 @@ manage_window.apps_table.row.actions.history=Histórico
manage_window.apps_table.row.actions.uninstall=Desinstalar manage_window.apps_table.row.actions.uninstall=Desinstalar
manage_window.apps_table.row.actions.uninstall.popup.title=Desinstalação manage_window.apps_table.row.actions.uninstall.popup.title=Desinstalação
manage_window.apps_table.row.actions.uninstall.popup.body=Remover {} ? manage_window.apps_table.row.actions.uninstall.popup.body=Remover {} ?
manage_window.apps_table.row.actions.install.popup.title=Instalação
manage_window.apps_table.row.actions.install.popup.body=Deseja instalar {} ?
manage_window.apps_table.row.actions.downgrade=Reverter versão manage_window.apps_table.row.actions.downgrade=Reverter versão
manage_window.apps_table.row.actions.downgrade.popup.body=Você realmente quer reverter a versão atual de {} ? manage_window.apps_table.row.actions.downgrade.popup.body=Você realmente quer reverter a versão atual de {} ?
manage_window.apps_table.row.actions.install=Instalar manage_window.apps_table.row.actions.install=Instalar
@@ -104,4 +106,6 @@ version.unknown=versão não informada
app.name=nome do aplicativo app.name=nome do aplicativo
warning=aviso warning=aviso
snap.notification.snapd_unavailable=snapd não parece estar habilitado. os pacotes snap estarão indisponíveis. 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. flatpak.notification.no_remotes=Não há repositórios (remotes) Flatpak configurados. Não será possível buscar aplicativos Flatpak.
install=instalar
uninstall=desinstalar

View File

@@ -6,7 +6,7 @@ from PyQt5.QtCore import Qt, QUrl
from PyQt5.QtGui import QPixmap, QIcon, QCursor from PyQt5.QtGui import QPixmap, QIcon, QCursor
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest 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, QToolButton, QWidget, \
QHeaderView, QLabel, QHBoxLayout QHeaderView, QLabel, QHBoxLayout, QPushButton
from fpakman.core import resource from fpakman.core import resource
from fpakman.core.model import ApplicationStatus from fpakman.core.model import ApplicationStatus
@@ -15,6 +15,8 @@ from fpakman.util.cache import Cache
from fpakman.view.qt import dialog from fpakman.view.qt import dialog
from fpakman.view.qt.view_model import ApplicationView, ApplicationViewStatus from fpakman.view.qt.view_model import ApplicationView, ApplicationViewStatus
INSTALL_BT_STYLE = 'background: {back}; color: white; margin-top: 6px; padding: 1px; font-size: 9px; font-weight: bold'
class UpdateToggleButton(QToolButton): class UpdateToggleButton(QToolButton):
@@ -76,12 +78,6 @@ class AppsTable(QTableWidget):
menu_row = QMenu() menu_row = QMenu()
if not app.model.installed and app.model.can_be_installed():
action_install = QAction(self.window.locale_keys["manage_window.apps_table.row.actions.install"])
action_install.setIcon(QIcon(resource.get_path('img/install.svg')))
action_install.triggered.connect(self._install_app)
menu_row.addAction(action_install)
if app.model.has_info(): if app.model.has_info():
action_info = QAction(self.window.locale_keys["manage_window.apps_table.row.actions.info"]) action_info = QAction(self.window.locale_keys["manage_window.apps_table.row.actions.info"])
action_info.setIcon(QIcon(resource.get_path('img/info.svg'))) action_info.setIcon(QIcon(resource.get_path('img/info.svg')))
@@ -102,12 +98,6 @@ class AppsTable(QTableWidget):
action_history.triggered.connect(self._get_app_history) action_history.triggered.connect(self._get_app_history)
menu_row.addAction(action_history) menu_row.addAction(action_history)
if app.model.can_be_uninstalled():
action_uninstall = QAction(self.window.locale_keys["manage_window.apps_table.row.actions.uninstall"])
action_uninstall.setIcon(QIcon(resource.get_path('img/uninstall.svg')))
action_uninstall.triggered.connect(self._uninstall_app)
menu_row.addAction(action_uninstall)
if app.model.can_be_downgraded(): if app.model.can_be_downgraded():
action_downgrade = QAction(self.window.locale_keys["manage_window.apps_table.row.actions.downgrade"]) action_downgrade = QAction(self.window.locale_keys["manage_window.apps_table.row.actions.downgrade"])
action_downgrade.triggered.connect(self._downgrade_app) action_downgrade.triggered.connect(self._downgrade_app)
@@ -149,7 +139,7 @@ class AppsTable(QTableWidget):
selected_app = self.get_selected_app() selected_app = self.get_selected_app()
if dialog.ask_confirmation(title=self.window.locale_keys['manage_window.apps_table.row.actions.uninstall.popup.title'], if dialog.ask_confirmation(title=self.window.locale_keys['manage_window.apps_table.row.actions.uninstall.popup.title'],
body=self.window.locale_keys['manage_window.apps_table.row.actions.uninstall.popup.body'].format(selected_app.model.base_data.name), body=self.window.locale_keys['manage_window.apps_table.row.actions.uninstall.popup.body'].format(selected_app),
locale_keys=self.window.locale_keys): locale_keys=self.window.locale_keys):
self.window.uninstall_app(selected_app) self.window.uninstall_app(selected_app)
@@ -171,7 +161,14 @@ class AppsTable(QTableWidget):
self.window.get_app_history(self.get_selected_app()) self.window.get_app_history(self.get_selected_app())
def _install_app(self): def _install_app(self):
self.window.install_app(self.get_selected_app()) selected_app = self.get_selected_app()
if dialog.ask_confirmation(
title=self.window.locale_keys['manage_window.apps_table.row.actions.install.popup.title'],
body=self.window.locale_keys['manage_window.apps_table.row.actions.install.popup.body'].format(selected_app),
locale_keys=self.window.locale_keys):
self.window.install_app(self.get_selected_app())
def _load_icon_and_cache(self, http_response): def _load_icon_and_cache(self, http_response):
icon_url = http_response.url().toString() icon_url = http_response.url().toString()
@@ -222,20 +219,29 @@ class AppsTable(QTableWidget):
self.setCellWidget(idx, 5, col_update) self.setCellWidget(idx, 5, col_update)
def _set_col_installed(self, idx: int, app_v: ApplicationView): def _set_col_installed(self, idx: int, app_v: ApplicationView):
col_installed = QLabel()
if app_v.model.installed: if app_v.model.installed:
img_name = 'checked' if app_v.model.can_be_uninstalled():
tooltip = self.window.locale_keys['installed'] col = QPushButton()
col.setText(self.window.locale_keys['uninstall'].capitalize())
col.setStyleSheet('QPushButton { ' + INSTALL_BT_STYLE.format(back='#cc0000') + '}')
col.setMaximumHeight(20)
col.clicked.connect(self._uninstall_app)
else:
col = QLabel()
col.setPixmap((QPixmap(resource.get_path('img/checked.svg'))))
col.setAlignment(Qt.AlignCenter)
col.setToolTip(self.window.locale_keys['installed'])
elif app_v.model.can_be_installed():
col = QPushButton()
col.setText(self.window.locale_keys['install'].capitalize())
col.setStyleSheet('QPushButton { ' + INSTALL_BT_STYLE.format(back='green') + '}')
col.setMaximumHeight(20)
col.clicked.connect(self._install_app)
else: else:
img_name = 'red_cross' col = None
tooltip = self.window.locale_keys['not_installed']
col_installed.setPixmap((QPixmap(resource.get_path('img/{}.svg'.format(img_name))))) self.setCellWidget(idx, 4, col)
col_installed.setAlignment(Qt.AlignCenter)
col_installed.setToolTip(tooltip)
self.setCellWidget(idx, 4, col_installed)
def _set_col_type(self, idx: int, app_v: ApplicationView): def _set_col_type(self, idx: int, app_v: ApplicationView):
col_type = QLabel() col_type = QLabel()

View File

@@ -15,3 +15,6 @@ class ApplicationView:
self.update_checked = model.update self.update_checked = model.update
self.visible = visible self.visible = visible
self.status = ApplicationViewStatus.LOADING self.status = ApplicationViewStatus.LOADING
def __repr__(self):
return '{} ( {} )'.format(self.model.base_data.name, self.model.get_type())