mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 02:24:16 +02:00
info adding a 'show' button for larger fields
This commit is contained in:
@@ -84,4 +84,7 @@ warning.no_managers=There are no installed extensions. It will not be possible t
|
||||
confirmation=confirmation
|
||||
and=and
|
||||
error=error
|
||||
action.cancelled=operation cancelled by the user
|
||||
action.cancelled=operation cancelled by the user
|
||||
copy=copy
|
||||
back=back
|
||||
show=show
|
||||
@@ -86,4 +86,7 @@ warning.no_managers=No hay extensiones instaladas. No será posible instalar y a
|
||||
confirmation=confirmación
|
||||
and=y
|
||||
error=error
|
||||
action.cancelled=operación cancelada por el usuario
|
||||
action.cancelled=operación cancelada por el usuario
|
||||
copy=copiar
|
||||
back=volver
|
||||
show=mostrar
|
||||
@@ -86,4 +86,7 @@ warning.no_managers=Não há nenhuma extensão instalada. Não será possível i
|
||||
confirmation=confirmação
|
||||
and=e
|
||||
error=erro
|
||||
action.cancelled=operação cancelada pelo usuário
|
||||
action.cancelled=operação cancelada pelo usuário
|
||||
copy=copiar
|
||||
back=voltar
|
||||
show=mostrar
|
||||
@@ -1,6 +1,6 @@
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QRadioButton, QFormLayout, QGroupBox, QCheckBox, QComboBox, QGridLayout, QWidget, \
|
||||
QVBoxLayout, QLabel
|
||||
QVBoxLayout, QLabel, QSizePolicy
|
||||
from bauh_api.abstract.view import SingleSelectComponent, SelectOption, MultipleSelectComponent, SelectViewType
|
||||
|
||||
|
||||
@@ -135,3 +135,8 @@ def new_single_select(model: SingleSelectComponent):
|
||||
else:
|
||||
raise Exception("Unsupported type {}".format(model.type))
|
||||
|
||||
|
||||
def new_spacer() -> QWidget:
|
||||
spacer = QWidget()
|
||||
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
return spacer
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from PyQt5.QtCore import QSize
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QFormLayout, QGroupBox, \
|
||||
QLineEdit, QLabel
|
||||
from PyQt5.QtWidgets import QDialog, QVBoxLayout, QGroupBox, \
|
||||
QLineEdit, QLabel, QGridLayout, QPushButton, QPlainTextEdit, QToolBar
|
||||
from bauh_api.util.cache import Cache
|
||||
|
||||
from bauh.util import util
|
||||
@@ -15,15 +15,29 @@ class InfoDialog(QDialog):
|
||||
super(InfoDialog, self).__init__()
|
||||
self.setWindowTitle(app['__app__'].model.base_data.name)
|
||||
self.screen_size = screen_size
|
||||
self.i18n = locale_keys
|
||||
layout = QVBoxLayout()
|
||||
self.setLayout(layout)
|
||||
self.full_vals = []
|
||||
|
||||
gbox_info = QGroupBox()
|
||||
gbox_info.setMaximumHeight(self.screen_size.height() - self.screen_size.height() * 0.1)
|
||||
gbox_info_layout = QFormLayout()
|
||||
gbox_info.setLayout(gbox_info_layout)
|
||||
self.toolbar_field = QToolBar()
|
||||
self.bt_back = QPushButton(locale_keys['back'].capitalize())
|
||||
self.bt_back.clicked.connect(self.back_to_info)
|
||||
self.toolbar_field.addWidget(self.bt_back)
|
||||
self.layout().addWidget(self.toolbar_field)
|
||||
self.toolbar_field.hide()
|
||||
|
||||
layout.addWidget(gbox_info)
|
||||
# shows complete field string
|
||||
self.text_field = QPlainTextEdit()
|
||||
self.layout().addWidget(self.text_field)
|
||||
self.text_field.hide()
|
||||
|
||||
self.gbox_info = QGroupBox()
|
||||
self.gbox_info.setMaximumHeight(self.screen_size.height() - self.screen_size.height() * 0.1)
|
||||
self.gbox_info_layout = QGridLayout()
|
||||
self.gbox_info.setLayout(self.gbox_info_layout)
|
||||
|
||||
layout.addWidget(self.gbox_info)
|
||||
|
||||
icon_data = icon_cache.get(app['__app__'].model.base_data.icon_url)
|
||||
|
||||
@@ -32,10 +46,11 @@ class InfoDialog(QDialog):
|
||||
else:
|
||||
self.setWindowIcon(QIcon(app['__app__'].model.get_type_icon_path()))
|
||||
|
||||
for attr in sorted(app.keys()):
|
||||
for idx, attr in enumerate(sorted(app.keys())):
|
||||
if attr not in IGNORED_ATTRS and app[attr]:
|
||||
i18n_key = app['__app__'].model.get_type() + '.info.' + attr.lower()
|
||||
val = str(app[attr]).strip()
|
||||
full_val = None
|
||||
|
||||
i18n_val = locale_keys.get('{}.{}'.format(i18n_key, val.lower()))
|
||||
|
||||
@@ -45,9 +60,11 @@ class InfoDialog(QDialog):
|
||||
text = QLineEdit()
|
||||
text.setToolTip(val)
|
||||
|
||||
if len(val) > 40:
|
||||
if len(val) > 80:
|
||||
full_val = val
|
||||
self.full_vals.append(full_val)
|
||||
val = util.strip_html(val)
|
||||
val = val[0:40] + '...'
|
||||
val = val[0:80] + '...'
|
||||
|
||||
text.setText(val)
|
||||
text.setCursorPosition(0)
|
||||
@@ -57,6 +74,28 @@ class InfoDialog(QDialog):
|
||||
label = QLabel("{}: ".format(locale_keys.get(i18n_key, attr)).capitalize())
|
||||
label.setStyleSheet("font-weight: bold")
|
||||
|
||||
gbox_info_layout.addRow(label, text)
|
||||
self.gbox_info_layout.addWidget(label, idx, 0)
|
||||
self.gbox_info_layout.addWidget(text, idx, 1)
|
||||
|
||||
if full_val is not None:
|
||||
self._gen_show_button(idx, full_val)
|
||||
|
||||
self.adjustSize()
|
||||
|
||||
def _gen_show_button(self, idx: int, val):
|
||||
|
||||
def show_full_field():
|
||||
self.gbox_info.hide()
|
||||
self.toolbar_field.show()
|
||||
self.text_field.show()
|
||||
self.text_field.appendHtml(val)
|
||||
|
||||
bt_full_field = QPushButton(self.i18n['show'].capitalize())
|
||||
bt_full_field.clicked.connect(show_full_field)
|
||||
self.gbox_info_layout.addWidget(bt_full_field, idx, 2)
|
||||
|
||||
def back_to_info(self):
|
||||
self.text_field.setPlainText("")
|
||||
self.text_field.hide()
|
||||
self.toolbar_field.hide()
|
||||
self.gbox_info.show()
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing import List, Set
|
||||
from PyQt5.QtCore import QEvent, Qt, QSize, pyqtSignal
|
||||
from PyQt5.QtGui import QIcon, QWindowStateChangeEvent, QPixmap
|
||||
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QCheckBox, QHeaderView, QToolButton, QToolBar, \
|
||||
QSizePolicy, QLabel, QPlainTextEdit, QLineEdit, QProgressBar, QHBoxLayout
|
||||
QLabel, QPlainTextEdit, QLineEdit, QProgressBar, QHBoxLayout
|
||||
from bauh_api.abstract.controller import ApplicationManager
|
||||
from bauh_api.abstract.model import Application
|
||||
from bauh_api.util.cache import Cache
|
||||
@@ -15,6 +15,7 @@ from bauh.util import util
|
||||
from bauh.view.qt import dialog
|
||||
from bauh.view.qt.about import AboutDialog
|
||||
from bauh.view.qt.apps_table import AppsTable
|
||||
from bauh.view.qt.components import new_spacer
|
||||
from bauh.view.qt.confirmation import ConfirmationDialog
|
||||
from bauh.view.qt.history import HistoryDialog
|
||||
from bauh.view.qt.info import InfoDialog
|
||||
@@ -53,7 +54,7 @@ class ManageWindow(QWidget):
|
||||
self.setLayout(self.layout)
|
||||
|
||||
self.toolbar_top = QToolBar()
|
||||
self.toolbar_top.addWidget(self._new_spacer())
|
||||
self.toolbar_top.addWidget(new_spacer())
|
||||
|
||||
self.label_status = QLabel()
|
||||
self.label_status.setText('')
|
||||
@@ -83,7 +84,7 @@ class ManageWindow(QWidget):
|
||||
self.toolbar_search.addWidget(label_pos_search)
|
||||
|
||||
self.ref_toolbar_search = self.toolbar_top.addWidget(self.toolbar_search)
|
||||
self.toolbar_top.addWidget(self._new_spacer())
|
||||
self.toolbar_top.addWidget(new_spacer())
|
||||
self.layout.addWidget(self.toolbar_top)
|
||||
|
||||
toolbar = QToolBar()
|
||||
@@ -103,7 +104,7 @@ class ManageWindow(QWidget):
|
||||
self.extra_filters.setLayout(QHBoxLayout())
|
||||
toolbar.addWidget(self.extra_filters)
|
||||
|
||||
toolbar.addWidget(self._new_spacer())
|
||||
toolbar.addWidget(new_spacer())
|
||||
|
||||
self.bt_refresh = QToolButton()
|
||||
self.bt_refresh.setToolTip(locale_keys['manage_window.bt.refresh.tooltip'])
|
||||
@@ -133,7 +134,7 @@ class ManageWindow(QWidget):
|
||||
self.checkbox_console.setVisible(False)
|
||||
self.ref_checkbox_console = toolbar_console.addWidget(self.checkbox_console)
|
||||
|
||||
toolbar_console.addWidget(self._new_spacer())
|
||||
toolbar_console.addWidget(new_spacer())
|
||||
|
||||
self.layout.addWidget(toolbar_console)
|
||||
|
||||
@@ -145,10 +146,10 @@ class ManageWindow(QWidget):
|
||||
self.textarea_output.setReadOnly(True)
|
||||
|
||||
self.toolbar_substatus = QToolBar()
|
||||
self.toolbar_substatus.addWidget(self._new_spacer())
|
||||
self.toolbar_substatus.addWidget(new_spacer())
|
||||
self.label_substatus = QLabel()
|
||||
self.toolbar_substatus.addWidget(self.label_substatus)
|
||||
self.toolbar_substatus.addWidget(self._new_spacer())
|
||||
self.toolbar_substatus.addWidget(new_spacer())
|
||||
self.layout.addWidget(self.toolbar_substatus)
|
||||
self._change_label_substatus('')
|
||||
|
||||
@@ -177,13 +178,13 @@ class ManageWindow(QWidget):
|
||||
self.label_updates = QLabel()
|
||||
self.ref_label_updates = self.toolbar_bottom.addWidget(self.label_updates)
|
||||
|
||||
self.toolbar_bottom.addWidget(self._new_spacer())
|
||||
self.toolbar_bottom.addWidget(new_spacer())
|
||||
|
||||
self.progress_bar = QProgressBar()
|
||||
self.progress_bar.setTextVisible(False)
|
||||
self.ref_progress_bar = self.toolbar_bottom.addWidget(self.progress_bar)
|
||||
|
||||
self.toolbar_bottom.addWidget(self._new_spacer())
|
||||
self.toolbar_bottom.addWidget(new_spacer())
|
||||
|
||||
bt_about = QToolButton()
|
||||
bt_about.setStyleSheet('QToolButton { border: 0px; }')
|
||||
@@ -263,11 +264,6 @@ class ManageWindow(QWidget):
|
||||
def _notify_model_data_change(self):
|
||||
self.table_apps.fill_async_data()
|
||||
|
||||
def _new_spacer(self):
|
||||
spacer = QWidget()
|
||||
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
return spacer
|
||||
|
||||
def changeEvent(self, e: QEvent):
|
||||
if isinstance(e, QWindowStateChangeEvent):
|
||||
self._maximized = self.isMaximized()
|
||||
|
||||
Reference in New Issue
Block a user