remove MainWindow
This commit is contained in:
@@ -1,19 +1,8 @@
|
||||
DEFAULT_SETTINGS = {
|
||||
"logging/level": "Disabled",
|
||||
"MainWindow/start_minimized": True,
|
||||
"MainWindow/theme": "default",
|
||||
"MainWidget/status_image/size": 28,
|
||||
"MessageWidget/image/show": True,
|
||||
"MessageWidget/image/size": 33,
|
||||
"MessageWidget/font/title": "Noto Sans,17,-1,5,75,0,0,0,0,0,Bold",
|
||||
"MessageWidget/font/date": "Noto Sans,11,-1,5,50,1,0,0,0,0,Italic",
|
||||
"MessageWidget/font/content": "Noto Sans,11,-1,5,50,0,0,0,0,0,Regular",
|
||||
"ApplicationModelItem/icon/show": True,
|
||||
"ApplicationModelItem/icon/size": 33,
|
||||
"MainApplication/theme": "default",
|
||||
"tray/notifications/enabled": True,
|
||||
"tray/notifications/priority": 5,
|
||||
"tray/show": True,
|
||||
"tray/minimize": True,
|
||||
"tray/notifications/duration_ms": 5000,
|
||||
"tray/notifications/icon/show": True,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import enum
|
||||
|
||||
from typing import Optional, Union
|
||||
from typing import Optional
|
||||
from PyQt6 import QtCore, QtGui
|
||||
from gotify_tray import gotify
|
||||
from gotify_tray.database import Settings
|
||||
@@ -36,13 +36,6 @@ class ApplicationModelItem(QtGui.QStandardItem):
|
||||
)
|
||||
|
||||
|
||||
class ApplicationAllMessagesItem(QtGui.QStandardItem):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ApplicationAllMessagesItem, self).__init__("ALL MESSAGES")
|
||||
self.setDropEnabled(False)
|
||||
self.setDragEnabled(False)
|
||||
|
||||
|
||||
class ApplicationModel(QtGui.QStandardItemModel):
|
||||
def __init__(self):
|
||||
super(ApplicationModel, self).__init__()
|
||||
@@ -50,17 +43,10 @@ class ApplicationModel(QtGui.QStandardItemModel):
|
||||
ApplicationModelItem(gotify.GotifyApplicationModel({"name": ""}), None)
|
||||
)
|
||||
|
||||
def setItem(
|
||||
self,
|
||||
row: int,
|
||||
column: int,
|
||||
item: Union[ApplicationModelItem, ApplicationAllMessagesItem],
|
||||
) -> None:
|
||||
def setItem(self, row: int, column: int, item: ApplicationModelItem,) -> None:
|
||||
super(ApplicationModel, self).setItem(row, column, item)
|
||||
|
||||
def itemFromIndex(
|
||||
self, index: QtCore.QModelIndex
|
||||
) -> Union[ApplicationModelItem, ApplicationAllMessagesItem]:
|
||||
def itemFromIndex(self, index: QtCore.QModelIndex) -> ApplicationModelItem:
|
||||
return super(ApplicationModel, self).itemFromIndex(index)
|
||||
|
||||
def itemFromId(self, appid: int) -> Optional[ApplicationModelItem]:
|
||||
@@ -71,14 +57,3 @@ class ApplicationModel(QtGui.QStandardItemModel):
|
||||
if item.data(ApplicationItemDataRole.ApplicationRole).id == appid:
|
||||
return item
|
||||
return None
|
||||
|
||||
def save_order(self, *args):
|
||||
try:
|
||||
application_ids = [
|
||||
self.item(i, 0).data(ApplicationItemDataRole.ApplicationRole).id
|
||||
for i in range(1, self.rowCount())
|
||||
]
|
||||
except AttributeError:
|
||||
return
|
||||
|
||||
settings.setValue("ApplicationModel/order", application_ids)
|
||||
|
||||
195
gotify_tray/gui/MainApplication.py
Normal file
195
gotify_tray/gui/MainApplication.py
Normal file
@@ -0,0 +1,195 @@
|
||||
import getpass
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from typing import List
|
||||
|
||||
from gotify_tray import gotify
|
||||
from gotify_tray.__version__ import __title__
|
||||
from gotify_tray.database import Downloader, Settings
|
||||
from gotify_tray.tasks import GetApplicationsTask, ServerConnectionWatchdogTask
|
||||
from gotify_tray.utils import verify_server
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from ..__version__ import __title__
|
||||
from .ApplicationModel import (
|
||||
ApplicationItemDataRole,
|
||||
ApplicationModel,
|
||||
ApplicationModelItem,
|
||||
)
|
||||
from .SettingsDialog import SettingsDialog
|
||||
from .themes import set_theme
|
||||
from .Tray import Tray
|
||||
|
||||
settings = Settings("gotify-tray")
|
||||
logger = logging.getLogger("gotify-tray")
|
||||
downloader = Downloader()
|
||||
|
||||
if (level := settings.value("logging/level", type=str)) != "Disabled":
|
||||
logger.setLevel(level)
|
||||
else:
|
||||
logging.disable()
|
||||
|
||||
|
||||
title = __title__.replace(" ", "-")
|
||||
|
||||
|
||||
def init_logger():
|
||||
logdir = QtCore.QStandardPaths.standardLocations(
|
||||
QtCore.QStandardPaths.StandardLocation.AppDataLocation
|
||||
)[0]
|
||||
if not os.path.exists(logdir):
|
||||
os.mkdir(logdir)
|
||||
logging.basicConfig(
|
||||
filename=os.path.join(logdir, f"{title}.log"),
|
||||
format="%(levelname)s > %(name)s > %(asctime)s > %(message)s",
|
||||
)
|
||||
|
||||
|
||||
class MainApplication(QtWidgets.QApplication):
|
||||
def __init__(self, argv: List):
|
||||
super(MainApplication, self).__init__(argv)
|
||||
self.shutting_down = False
|
||||
|
||||
def init_ui(self):
|
||||
self.setApplicationName(title)
|
||||
self.setQuitOnLastWindowClosed(False)
|
||||
self.setWindowIcon(QtGui.QIcon("gotify_tray/gui/images/gotify-small.png"))
|
||||
self.setStyle("fusion")
|
||||
|
||||
init_logger()
|
||||
|
||||
self.gotify_client = gotify.GotifyClient(
|
||||
settings.value("Server/url", type=str),
|
||||
settings.value("Server/client_token", type=str),
|
||||
)
|
||||
|
||||
set_theme(self, settings.value("MainApplication/theme", type=str))
|
||||
|
||||
self.application_model = ApplicationModel()
|
||||
self.refresh_applications()
|
||||
|
||||
self.tray = Tray()
|
||||
self.tray.show()
|
||||
|
||||
self.gotify_client.listen(
|
||||
new_message_callback=self.new_message_callback,
|
||||
opened_callback=self.listener_opened_callback,
|
||||
closed_callback=self.listener_closed_callback,
|
||||
)
|
||||
|
||||
self.watchdog = ServerConnectionWatchdogTask(self.gotify_client)
|
||||
self.watchdog.closed.connect(lambda: self.listener_closed_callback(None, None))
|
||||
self.watchdog.start()
|
||||
|
||||
self.link_callbacks()
|
||||
|
||||
def refresh_applications(self):
|
||||
self.application_model.clear()
|
||||
|
||||
def get_applications_callback(
|
||||
applications: List[gotify.GotifyApplicationModel],
|
||||
):
|
||||
for i, application in enumerate(applications):
|
||||
icon = QtGui.QIcon(
|
||||
downloader.get_filename(
|
||||
f"{self.gotify_client.url}/{application.image}"
|
||||
)
|
||||
)
|
||||
self.application_model.setItem(
|
||||
i, 0, ApplicationModelItem(application, icon),
|
||||
)
|
||||
|
||||
self.get_applications_task = GetApplicationsTask(self.gotify_client)
|
||||
self.get_applications_task.success.connect(get_applications_callback)
|
||||
self.get_applications_task.start()
|
||||
|
||||
def listener_opened_callback(self):
|
||||
self.tray.set_icon_ok()
|
||||
# self.tray.actionReconnect.setEnabled(True)
|
||||
|
||||
def listener_closed_callback(self, close_status_code: int, close_msg: str):
|
||||
self.tray.set_icon_error()
|
||||
if not self.shutting_down:
|
||||
self.gotify_client.reconnect()
|
||||
|
||||
def refresh_callback(self):
|
||||
# self.tray.actionReconnect.setDisabled(True)
|
||||
if not self.gotify_client.is_listening():
|
||||
self.gotify_client.listener.reset_wait_time()
|
||||
else:
|
||||
self.gotify_client.stop(reset_wait=True)
|
||||
self.gotify_client.reconnect(increase_wait_time=False)
|
||||
|
||||
def new_message_callback(self, message: gotify.GotifyMessageModel):
|
||||
# Show a notification
|
||||
if not (application_item := self.application_model.itemFromId(message.appid)):
|
||||
logger.error(
|
||||
f"MainWindow.new_message_callback: App id {message.appid} could not be found. Refreshing applications."
|
||||
)
|
||||
self.refresh_applications()
|
||||
return
|
||||
|
||||
if message.priority >= settings.value("tray/notifications/priority", type=int):
|
||||
image_url = f"{self.gotify_client.url}/{application_item.data(ApplicationItemDataRole.ApplicationRole).image}"
|
||||
self.tray.showMessage(
|
||||
message.title,
|
||||
message.message,
|
||||
QtGui.QIcon(downloader.get_filename(image_url))
|
||||
if settings.value("tray/notifications/icon/show", type=bool)
|
||||
else QtWidgets.QSystemTrayIcon.MessageIcon.Information,
|
||||
msecs=settings.value("tray/notifications/duration_ms", type=int),
|
||||
)
|
||||
|
||||
def settings_callback(self):
|
||||
settings_dialog = SettingsDialog(self)
|
||||
accepted = settings_dialog.exec()
|
||||
|
||||
if accepted and settings_dialog.settings_changed:
|
||||
settings_dialog.apply_settings()
|
||||
|
||||
if settings_dialog.server_changed:
|
||||
mb = QtWidgets.QMessageBox(
|
||||
QtWidgets.QMessageBox.Icon.Information,
|
||||
"Restart",
|
||||
"Restart to apply server changes",
|
||||
QtWidgets.QMessageBox.StandardButton.Yes
|
||||
| QtWidgets.QMessageBox.StandardButton.Cancel,
|
||||
)
|
||||
|
||||
r = mb.exec()
|
||||
if r == QtWidgets.QMessageBox.StandardButton.Yes:
|
||||
self.quit()
|
||||
|
||||
def link_callbacks(self):
|
||||
self.tray.actionQuit.triggered.connect(self.quit)
|
||||
self.tray.actionSettings.triggered.connect(self.settings_callback)
|
||||
self.tray.actionReconnect.triggered.connect(self.refresh_callback)
|
||||
|
||||
def acquire_lock(self) -> bool:
|
||||
temp_dir = tempfile.gettempdir()
|
||||
lock_filename = os.path.join(
|
||||
temp_dir, __title__ + "-" + getpass.getuser() + ".lock"
|
||||
)
|
||||
self.lock_file = QtCore.QLockFile(lock_filename)
|
||||
self.lock_file.setStaleLockTime(0)
|
||||
return self.lock_file.tryLock()
|
||||
|
||||
def quit(self) -> None:
|
||||
self.tray.hide()
|
||||
|
||||
self.lock_file.unlock()
|
||||
|
||||
self.shutting_down = True
|
||||
self.gotify_client.stop()
|
||||
super(MainApplication, self).quit()
|
||||
|
||||
|
||||
def start_gui():
|
||||
app = MainApplication(sys.argv)
|
||||
|
||||
# prevent multiple instances
|
||||
if (app.acquire_lock() or "--no-lock" in sys.argv) and verify_server():
|
||||
app.init_ui()
|
||||
sys.exit(app.exec())
|
||||
@@ -1,505 +0,0 @@
|
||||
import getpass
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from typing import List
|
||||
|
||||
from gotify_tray import gotify
|
||||
from gotify_tray.__version__ import __title__
|
||||
from gotify_tray.database import Downloader, Settings
|
||||
from gotify_tray.tasks import (
|
||||
DeleteAllMessagesTask,
|
||||
DeleteApplicationMessagesTask,
|
||||
DeleteMessageTask,
|
||||
GetApplicationMessagesTask,
|
||||
GetApplicationsTask,
|
||||
GetMessagesTask,
|
||||
ServerConnectionWatchdogTask,
|
||||
)
|
||||
from gotify_tray.utils import verify_server
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from ..__version__ import __title__
|
||||
from .ApplicationModel import (
|
||||
ApplicationAllMessagesItem,
|
||||
ApplicationItemDataRole,
|
||||
ApplicationModel,
|
||||
ApplicationModelItem,
|
||||
)
|
||||
from .designs.widget_main import Ui_Form as Ui_Main
|
||||
from .MessagesModel import MessageItemDataRole, MessagesModel, MessagesModelItem
|
||||
from .MessageWidget import MessageWidget
|
||||
from .SettingsDialog import SettingsDialog
|
||||
from .themes import set_theme
|
||||
from .Tray import Tray
|
||||
|
||||
settings = Settings("gotify-tray")
|
||||
logger = logging.getLogger("gotify-tray")
|
||||
downloader = Downloader()
|
||||
|
||||
if (level := settings.value("logging/level", type=str)) != "Disabled":
|
||||
logger.setLevel(level)
|
||||
else:
|
||||
logging.disable()
|
||||
|
||||
|
||||
class MainWidget(QtWidgets.QWidget, Ui_Main):
|
||||
def __init__(
|
||||
self, application_model: ApplicationModel, messages_model: MessagesModel
|
||||
):
|
||||
super(MainWidget, self).__init__()
|
||||
self.setupUi(self)
|
||||
|
||||
self.listView_messages.setModel(messages_model)
|
||||
self.listView_applications.setModel(application_model)
|
||||
self.listView_applications.setFixedWidth(180)
|
||||
icon_size = settings.value("ApplicationModelItem/icon/size", type=int)
|
||||
self.listView_applications.setIconSize(QtCore.QSize(icon_size, icon_size))
|
||||
|
||||
label_size = settings.value("MainWidget/status_image/size", type=int)
|
||||
self.label_status.setFixedSize(QtCore.QSize(label_size, label_size))
|
||||
self.label_status_connecting()
|
||||
|
||||
def label_status_active(self):
|
||||
self.label_status.setToolTip("Listening for new messages")
|
||||
self.label_status.setStyleSheet("QLabel {background-color: green;}")
|
||||
|
||||
def label_status_connecting(self):
|
||||
self.label_status.setToolTip("Connecting...")
|
||||
self.label_status.setStyleSheet("QLabel {background-color: orange;}")
|
||||
|
||||
def label_status_inactive(self):
|
||||
self.label_status.setToolTip("Listener inactive")
|
||||
self.label_status.setStyleSheet("QLabel {background-color: grey;}")
|
||||
|
||||
def label_status_error(self):
|
||||
self.label_status.setToolTip("Listener error")
|
||||
self.label_status.setStyleSheet("QLabel {background-color: red;}")
|
||||
|
||||
|
||||
class MainWindow(QtWidgets.QMainWindow):
|
||||
def __init__(self, app: QtWidgets.QApplication):
|
||||
super(MainWindow, self).__init__()
|
||||
self.app = app
|
||||
self.shutting_down = False
|
||||
|
||||
def init_ui(self):
|
||||
self.gotify_client = gotify.GotifyClient(
|
||||
settings.value("Server/url", type=str),
|
||||
settings.value("Server/client_token", type=str),
|
||||
)
|
||||
|
||||
self.setWindowTitle(__title__)
|
||||
self.resize(800, 600)
|
||||
set_theme(self.app, settings.value("MainWindow/theme", type=str))
|
||||
|
||||
self.application_model = ApplicationModel()
|
||||
self.messages_model = MessagesModel()
|
||||
|
||||
self.main_widget = MainWidget(self.application_model, self.messages_model)
|
||||
self.setCentralWidget(self.main_widget)
|
||||
|
||||
self.refresh_applications()
|
||||
|
||||
self.tray = Tray()
|
||||
self.tray.show()
|
||||
|
||||
self.restore_window_state()
|
||||
|
||||
self.gotify_client.listen(
|
||||
new_message_callback=self.new_message_callback,
|
||||
opened_callback=self.listener_opened_callback,
|
||||
closed_callback=self.listener_closed_callback,
|
||||
)
|
||||
|
||||
self.watchdog = ServerConnectionWatchdogTask(self.gotify_client)
|
||||
self.watchdog.closed.connect(lambda: self.listener_closed_callback(None, None))
|
||||
self.watchdog.start()
|
||||
|
||||
self.link_callbacks()
|
||||
|
||||
self.show()
|
||||
self.window_state_to_restore = QtCore.Qt.WindowState.WindowNoState
|
||||
|
||||
if settings.value("MainWindow/start_minimized", type=bool) and settings.value(
|
||||
"tray/show", type=bool
|
||||
):
|
||||
self.tray_activated_callback(
|
||||
QtWidgets.QSystemTrayIcon.ActivationReason.Trigger
|
||||
)
|
||||
|
||||
def refresh_applications(self):
|
||||
self.application_model.clear()
|
||||
self.messages_model.clear()
|
||||
|
||||
self.main_widget.listView_applications.clearSelection()
|
||||
self.main_widget.listView_applications.setEnabled(False)
|
||||
self.application_model.setItem(0, 0, ApplicationAllMessagesItem())
|
||||
|
||||
def get_applications_callback(
|
||||
applications: List[gotify.GotifyApplicationModel],
|
||||
):
|
||||
stored_application_ids_order = [
|
||||
int(x) for x in settings.value("ApplicationModel/order", type=list)
|
||||
]
|
||||
fetched_application_ids = [application.id for application in applications]
|
||||
# Remove ids from stored_application_ids that are not in fetched_application_ids
|
||||
application_ids_order = list(
|
||||
filter(
|
||||
lambda x: x in fetched_application_ids, stored_application_ids_order
|
||||
)
|
||||
)
|
||||
# Add new ids to the back of the list
|
||||
application_ids_order += list(
|
||||
filter(
|
||||
lambda x: x not in stored_application_ids_order,
|
||||
fetched_application_ids,
|
||||
)
|
||||
)
|
||||
|
||||
for i, application_id in enumerate(application_ids_order):
|
||||
application = list(
|
||||
filter(
|
||||
lambda application: application.id == application_id,
|
||||
applications,
|
||||
)
|
||||
)[0]
|
||||
|
||||
icon = (
|
||||
QtGui.QIcon(
|
||||
downloader.get_filename(
|
||||
f"{self.gotify_client.url}/{application.image}"
|
||||
)
|
||||
)
|
||||
if settings.value("ApplicationModelItem/icon/show", type=bool)
|
||||
else None
|
||||
)
|
||||
self.application_model.setItem(
|
||||
i + 1, 0, ApplicationModelItem(application, icon),
|
||||
)
|
||||
|
||||
self.application_model.save_order()
|
||||
|
||||
self.get_applications_task = GetApplicationsTask(self.gotify_client)
|
||||
self.get_applications_task.success.connect(get_applications_callback)
|
||||
self.get_applications_task.finished.connect(
|
||||
self.get_applications_finished_callback
|
||||
)
|
||||
self.get_applications_task.start()
|
||||
|
||||
def get_applications_finished_callback(self):
|
||||
self.main_widget.listView_applications.setEnabled(True)
|
||||
self.main_widget.listView_applications.setCurrentIndex(
|
||||
self.application_model.index(0, 0)
|
||||
)
|
||||
|
||||
def insert_message(
|
||||
self,
|
||||
row: int,
|
||||
message: gotify.GotifyMessageModel,
|
||||
application: gotify.GotifyApplicationModel,
|
||||
):
|
||||
message_item = MessagesModelItem(message)
|
||||
self.messages_model.insertRow(row, message_item)
|
||||
|
||||
message_widget = MessageWidget(
|
||||
message_item,
|
||||
image_path=downloader.get_filename(
|
||||
f"{self.gotify_client.url}/{application.image}"
|
||||
)
|
||||
if settings.value("MessageWidget/image/show", type=bool)
|
||||
else "",
|
||||
)
|
||||
self.main_widget.listView_messages.setIndexWidget(
|
||||
self.messages_model.indexFromItem(message_item), message_widget
|
||||
)
|
||||
message_widget.deletion_requested.connect(
|
||||
self.message_deletion_requested_callback
|
||||
)
|
||||
|
||||
def listener_opened_callback(self):
|
||||
self.main_widget.label_status_active()
|
||||
self.tray.set_icon_ok()
|
||||
|
||||
def listener_closed_callback(self, close_status_code: int, close_msg: str):
|
||||
self.main_widget.label_status_connecting()
|
||||
self.tray.set_icon_error()
|
||||
if not self.shutting_down:
|
||||
self.gotify_client.reconnect()
|
||||
|
||||
def application_selection_changed(
|
||||
self, current: QtCore.QModelIndex, previous: QtCore.QModelIndex
|
||||
):
|
||||
if item := self.application_model.itemFromIndex(current):
|
||||
self.main_widget.label_selected.setText(item.text())
|
||||
self.messages_model.clear()
|
||||
|
||||
if isinstance(item, ApplicationModelItem):
|
||||
|
||||
def get_application_messages_callback(
|
||||
page: gotify.GotifyPagedMessagesModel,
|
||||
):
|
||||
for i, message in enumerate(page.messages):
|
||||
self.insert_message(
|
||||
i,
|
||||
message,
|
||||
item.data(ApplicationItemDataRole.ApplicationRole),
|
||||
)
|
||||
|
||||
self.get_application_messages_task = GetApplicationMessagesTask(
|
||||
item.data(ApplicationItemDataRole.ApplicationRole).id,
|
||||
self.gotify_client,
|
||||
)
|
||||
self.get_application_messages_task.success.connect(
|
||||
get_application_messages_callback
|
||||
)
|
||||
self.get_application_messages_task.start()
|
||||
|
||||
elif isinstance(item, ApplicationAllMessagesItem):
|
||||
|
||||
def get_messages_callback(page: gotify.GotifyPagedMessagesModel):
|
||||
for i, message in enumerate(page.messages):
|
||||
if item := self.application_model.itemFromId(message.appid):
|
||||
self.insert_message(
|
||||
i,
|
||||
message,
|
||||
item.data(ApplicationItemDataRole.ApplicationRole),
|
||||
)
|
||||
|
||||
self.get_messages_task = GetMessagesTask(self.gotify_client)
|
||||
self.get_messages_task.success.connect(get_messages_callback)
|
||||
self.get_messages_task.start()
|
||||
|
||||
def refresh_callback(self):
|
||||
self.application_model.save_order()
|
||||
self.refresh_applications()
|
||||
if not self.gotify_client.listener.running:
|
||||
self.gotify_client.listener.reset_wait_time()
|
||||
else:
|
||||
self.gotify_client.stop(reset_wait=True)
|
||||
self.gotify_client.reconnect(increase_wait_time=False)
|
||||
|
||||
def delete_all_callback(self):
|
||||
selection_model = self.main_widget.listView_applications.selectionModel()
|
||||
if item := self.application_model.itemFromIndex(selection_model.currentIndex()):
|
||||
self.messages_model.clear()
|
||||
|
||||
if isinstance(item, ApplicationModelItem):
|
||||
self.delete_application_messages_task = DeleteApplicationMessagesTask(
|
||||
item.data(ApplicationItemDataRole.ApplicationRole).id,
|
||||
self.gotify_client,
|
||||
)
|
||||
self.delete_application_messages_task.start()
|
||||
elif isinstance(item, ApplicationAllMessagesItem):
|
||||
self.delete_all_messages_task = DeleteAllMessagesTask(
|
||||
self.gotify_client
|
||||
)
|
||||
self.delete_all_messages_task.start()
|
||||
|
||||
def new_message_callback(self, message: gotify.GotifyMessageModel):
|
||||
# Show a notification
|
||||
if not (application_item := self.application_model.itemFromId(message.appid)):
|
||||
logger.error(
|
||||
f"MainWindow.new_message_callback: App id {message.appid} could not be found. Refreshing applications."
|
||||
)
|
||||
self.application_model.save_order()
|
||||
self.refresh_applications()
|
||||
return
|
||||
|
||||
if not self.isActiveWindow() and message.priority >= settings.value(
|
||||
"tray/notifications/priority", type=int
|
||||
):
|
||||
image_url = f"{self.gotify_client.url}/{application_item.data(ApplicationItemDataRole.ApplicationRole).image}"
|
||||
self.tray.showMessage(
|
||||
message.title,
|
||||
message.message,
|
||||
QtGui.QIcon(downloader.get_filename(image_url))
|
||||
if settings.value("tray/notifications/icon/show", type=bool)
|
||||
else QtWidgets.QSystemTrayIcon.MessageIcon.Information,
|
||||
msecs=settings.value("tray/notifications/duration_ms", type=int),
|
||||
)
|
||||
|
||||
# Add the message to the message_model, if its corresponding application is selected
|
||||
application_index = (
|
||||
self.main_widget.listView_applications.selectionModel().currentIndex()
|
||||
)
|
||||
if selected_application_item := self.application_model.itemFromIndex(
|
||||
application_index
|
||||
):
|
||||
if isinstance(selected_application_item, ApplicationModelItem):
|
||||
# A single application is selected
|
||||
if (
|
||||
message.appid
|
||||
== selected_application_item.data(
|
||||
ApplicationItemDataRole.ApplicationRole
|
||||
).id
|
||||
):
|
||||
self.insert_message(
|
||||
0,
|
||||
message,
|
||||
application_item.data(ApplicationItemDataRole.ApplicationRole),
|
||||
)
|
||||
elif isinstance(selected_application_item, ApplicationAllMessagesItem):
|
||||
# "All messages' is selected
|
||||
self.insert_message(
|
||||
0,
|
||||
message,
|
||||
application_item.data(ApplicationItemDataRole.ApplicationRole),
|
||||
)
|
||||
|
||||
def message_deletion_requested_callback(self, message_item: MessagesModelItem):
|
||||
self.delete_message_task = DeleteMessageTask(
|
||||
message_item.data(MessageItemDataRole.MessageRole).id, self.gotify_client
|
||||
)
|
||||
self.messages_model.removeRow(message_item.row())
|
||||
self.delete_message_task.start()
|
||||
|
||||
def tray_activated_callback(
|
||||
self, reason: QtWidgets.QSystemTrayIcon.ActivationReason
|
||||
):
|
||||
if reason == QtWidgets.QSystemTrayIcon.ActivationReason.Trigger:
|
||||
if self.windowState() & QtCore.Qt.WindowState.WindowMinimized or self.windowState() == (
|
||||
QtCore.Qt.WindowState.WindowMinimized
|
||||
| QtCore.Qt.WindowState.WindowMaximized
|
||||
):
|
||||
self.bring_to_front()
|
||||
else:
|
||||
window_state_temp = self.windowState()
|
||||
self.setWindowState(QtCore.Qt.WindowState.WindowMinimized)
|
||||
self.hide()
|
||||
self.window_state_to_restore = window_state_temp
|
||||
|
||||
def message_clicked_callback(self):
|
||||
self.main_widget.listView_messages.scrollToTop()
|
||||
self.setWindowState(
|
||||
self.window_state_to_restore | QtCore.Qt.WindowState.WindowActive
|
||||
)
|
||||
self.show()
|
||||
|
||||
def settings_callback(self):
|
||||
settings_dialog = SettingsDialog(self.app)
|
||||
accepted = settings_dialog.exec()
|
||||
|
||||
if accepted and settings_dialog.settings_changed:
|
||||
settings_dialog.apply_settings()
|
||||
|
||||
if settings_dialog.server_changed:
|
||||
mb = QtWidgets.QMessageBox(
|
||||
QtWidgets.QMessageBox.Icon.Information,
|
||||
"Restart",
|
||||
"Restart to apply server changes",
|
||||
QtWidgets.QMessageBox.StandardButton.Yes
|
||||
| QtWidgets.QMessageBox.StandardButton.Cancel,
|
||||
parent=self,
|
||||
)
|
||||
|
||||
r = mb.exec()
|
||||
if r == QtWidgets.QMessageBox.StandardButton.Yes:
|
||||
self.close()
|
||||
|
||||
def link_callbacks(self):
|
||||
self.main_widget.listView_applications.selectionModel().currentChanged.connect(
|
||||
self.application_selection_changed
|
||||
)
|
||||
self.main_widget.pb_refresh.clicked.connect(self.refresh_callback)
|
||||
self.main_widget.pb_delete_all.clicked.connect(self.delete_all_callback)
|
||||
|
||||
self.tray.actionQuit.triggered.connect(self.close)
|
||||
self.tray.actionSettings.triggered.connect(self.settings_callback)
|
||||
self.tray.actionToggleWindow.triggered.connect(
|
||||
lambda: self.tray_activated_callback(
|
||||
QtWidgets.QSystemTrayIcon.ActivationReason.Trigger
|
||||
)
|
||||
)
|
||||
self.tray.messageClicked.connect(self.message_clicked_callback)
|
||||
self.tray.activated.connect(self.tray_activated_callback)
|
||||
|
||||
def acquire_lock(self) -> bool:
|
||||
temp_dir = tempfile.gettempdir()
|
||||
lock_filename = os.path.join(
|
||||
temp_dir, __title__ + "-" + getpass.getuser() + ".lock"
|
||||
)
|
||||
self.lock_file = QtCore.QLockFile(lock_filename)
|
||||
self.lock_file.setStaleLockTime(0)
|
||||
return self.lock_file.tryLock()
|
||||
|
||||
def restore_window_state(self):
|
||||
window_geometry = settings.value("MainWindow/geometry", type=QtCore.QByteArray)
|
||||
window_state = settings.value("MainWindow/state", type=QtCore.QByteArray)
|
||||
|
||||
if window_geometry:
|
||||
self.restoreGeometry(window_geometry)
|
||||
if window_state:
|
||||
self.restoreState(window_state)
|
||||
|
||||
def save_window_state(self):
|
||||
settings.setValue("MainWindow/geometry", self.saveGeometry())
|
||||
settings.setValue("MainWindow/state", self.saveState())
|
||||
|
||||
def bring_to_front(self):
|
||||
self.ensurePolished()
|
||||
self.setWindowState(
|
||||
self.window_state_to_restore & ~QtCore.Qt.WindowState.WindowMinimized
|
||||
| QtCore.Qt.WindowState.WindowActive
|
||||
)
|
||||
self.show()
|
||||
self.activateWindow()
|
||||
|
||||
def changeEvent(self, event: QtCore.QEvent) -> None:
|
||||
if event.type() == QtCore.QEvent.Type.WindowStateChange:
|
||||
if settings.value("tray/show", type=bool) and settings.value(
|
||||
"tray/minimize", type=bool
|
||||
):
|
||||
if self.windowState() & QtCore.Qt.WindowState.WindowMinimized:
|
||||
self.window_state_to_restore = (
|
||||
self.windowState() & ~QtCore.Qt.WindowState.WindowMinimized
|
||||
| QtCore.Qt.WindowState.WindowActive
|
||||
)
|
||||
self.hide()
|
||||
|
||||
super(MainWindow, self).changeEvent(event)
|
||||
|
||||
def closeEvent(self, e: QtGui.QCloseEvent) -> None:
|
||||
self.save_window_state()
|
||||
self.application_model.save_order()
|
||||
|
||||
if settings.value("tray/show", type=bool):
|
||||
self.tray.hide()
|
||||
|
||||
self.lock_file.unlock()
|
||||
|
||||
self.shutting_down = True
|
||||
self.gotify_client.stop()
|
||||
super(MainWindow, self).closeEvent(e)
|
||||
self.app.quit()
|
||||
|
||||
|
||||
def start_gui():
|
||||
title = __title__.replace(" ", "-")
|
||||
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
app.setApplicationName(title)
|
||||
app.setQuitOnLastWindowClosed(False)
|
||||
app.setWindowIcon(QtGui.QIcon("gotify_tray/gui/images/gotify-small.png"))
|
||||
app.setStyle("fusion")
|
||||
|
||||
logdir = QtCore.QStandardPaths.standardLocations(
|
||||
QtCore.QStandardPaths.StandardLocation.AppDataLocation
|
||||
)[0]
|
||||
if not os.path.exists(logdir):
|
||||
os.mkdir(logdir)
|
||||
logging.basicConfig(
|
||||
filename=os.path.join(logdir, f"{title}.log"),
|
||||
format="%(levelname)s > %(name)s > %(asctime)s > %(message)s",
|
||||
)
|
||||
|
||||
# import from gui has to happen after 'setApplicationName' to make sure the correct cache directory is created
|
||||
from gotify_tray.gui import MainWindow
|
||||
|
||||
window = MainWindow(app)
|
||||
|
||||
# prevent multiple instances
|
||||
if (window.acquire_lock() or "--no-lock" in sys.argv) and verify_server():
|
||||
window.init_ui()
|
||||
sys.exit(app.exec())
|
||||
@@ -1,84 +0,0 @@
|
||||
import re
|
||||
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
from .MessagesModel import MessageItemDataRole, MessagesModelItem
|
||||
from .designs.widget_message import Ui_Form
|
||||
from gotify_tray.database import Settings
|
||||
|
||||
|
||||
settings = Settings("gotify-tray")
|
||||
|
||||
|
||||
def convert_links(text):
|
||||
_link = re.compile(
|
||||
r'(?:(https://|http://)|(www\.))(\S+\b/?)([!"#$%&\'()*+,\-./:;<=>?@[\\\]^_`{|}~]*)(\s|$)',
|
||||
re.I,
|
||||
)
|
||||
|
||||
def replace(match):
|
||||
groups = match.groups()
|
||||
protocol = groups[0] or "" # may be None
|
||||
www_lead = groups[1] or "" # may be None
|
||||
return '<a href="http://{1}{2}" rel="nofollow">{0}{1}{2}</a>{3}{4}'.format(
|
||||
protocol, www_lead, *groups[2:]
|
||||
)
|
||||
|
||||
return _link.sub(replace, text)
|
||||
|
||||
|
||||
class MessageWidget(QtWidgets.QWidget, Ui_Form):
|
||||
deletion_requested = QtCore.pyqtSignal(MessagesModelItem)
|
||||
|
||||
def __init__(self, message_item: MessagesModelItem, image_path: str = ""):
|
||||
super(MessageWidget, self).__init__()
|
||||
self.setupUi(self)
|
||||
self.setAutoFillBackground(True)
|
||||
|
||||
self.message_item = message_item
|
||||
message = message_item.data(MessageItemDataRole.MessageRole)
|
||||
|
||||
# Fonts
|
||||
font_title = QtGui.QFont()
|
||||
font_date = QtGui.QFont()
|
||||
font_content = QtGui.QFont()
|
||||
font_title.fromString(settings.value("MessageWidget/font/title", type=str))
|
||||
font_date.fromString(settings.value("MessageWidget/font/date", type=str))
|
||||
font_content.fromString(settings.value("MessageWidget/font/content", type=str))
|
||||
self.label_title.setFont(font_title)
|
||||
self.label_date.setFont(font_date)
|
||||
self.text_message.setFont(font_content)
|
||||
|
||||
self.label_title.setText(message.title)
|
||||
self.label_date.setText(message.date.strftime("%Y-%m-%d, %H:%M"))
|
||||
|
||||
if markdown := message.get("extras", {}).get("client::display", {}).get("contentType") == "text/markdown":
|
||||
self.text_message.setTextFormat(QtCore.Qt.TextFormat.MarkdownText)
|
||||
self.text_message.setText(convert_links(message.message))
|
||||
|
||||
if image_path:
|
||||
image_size = settings.value("MessageWidget/image/size", type=int)
|
||||
self.label_image.setFixedSize(QtCore.QSize(image_size, image_size))
|
||||
pixmap = QtGui.QPixmap(image_path).scaled(image_size, image_size, aspectRatioMode=QtCore.Qt.AspectRatioMode.KeepAspectRatioByExpanding)
|
||||
self.label_image.setPixmap(pixmap)
|
||||
else:
|
||||
self.label_image.hide()
|
||||
|
||||
# Set MessagesModelItem's size hint based on the size of this widget
|
||||
self.gridLayout_frame.setContentsMargins(10, 5, 10, 5)
|
||||
self.gridLayout.setContentsMargins(5, 15, 5, 15)
|
||||
self.adjustSize()
|
||||
size_hint = self.message_item.sizeHint()
|
||||
self.message_item.setSizeHint(
|
||||
QtCore.QSize(
|
||||
size_hint.width(),
|
||||
self.height()
|
||||
)
|
||||
)
|
||||
self.pb_delete.setIcon(QtGui.QIcon("gotify_tray/gui/images/trashcan.svg"))
|
||||
self.pb_delete.setIconSize(QtCore.QSize(24, 24))
|
||||
|
||||
self.link_callbacks()
|
||||
|
||||
def link_callbacks(self):
|
||||
self.pb_delete.clicked.connect(lambda: self.deletion_requested.emit(self.message_item))
|
||||
@@ -1,23 +0,0 @@
|
||||
import enum
|
||||
|
||||
from typing import cast
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
from gotify_tray import gotify
|
||||
|
||||
|
||||
class MessageItemDataRole(enum.IntEnum):
|
||||
MessageRole = QtCore.Qt.ItemDataRole.UserRole + 1
|
||||
|
||||
|
||||
class MessagesModelItem(QtGui.QStandardItem):
|
||||
def __init__(self, message: gotify.GotifyMessageModel, *args, **kwargs):
|
||||
super(MessagesModelItem, self).__init__()
|
||||
self.setData(message, MessageItemDataRole.MessageRole)
|
||||
|
||||
|
||||
class MessagesModel(QtGui.QStandardItemModel):
|
||||
def setItem(self, row: int, column: int, item: MessagesModelItem) -> None:
|
||||
super(MessagesModel, self).setItem(row, column, item)
|
||||
|
||||
def itemFromIndex(self, index: QtCore.QModelIndex) -> MessagesModelItem:
|
||||
return cast(MessagesModelItem, super(MessagesModel, self).itemFromIndex(index))
|
||||
@@ -34,20 +34,13 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Apply
|
||||
).setEnabled(False)
|
||||
|
||||
# Fonts
|
||||
self.set_font_labels()
|
||||
|
||||
# Theme
|
||||
self.combo_theme.addItems(["default", "dark"])
|
||||
self.combo_theme.setCurrentText(settings.value("MainWindow/theme", type=str))
|
||||
self.combo_theme.setCurrentText(
|
||||
settings.value("MainApplication/theme", type=str)
|
||||
)
|
||||
|
||||
# Icons
|
||||
self.cb_icons_application.setChecked(
|
||||
settings.value("ApplicationModelItem/icon/show", type=bool)
|
||||
)
|
||||
self.cb_icons_message.setChecked(
|
||||
settings.value("MessageWidget/image/show", type=bool)
|
||||
)
|
||||
self.cb_icons_notification.setChecked(
|
||||
settings.value("tray/notifications/icon/show", type=bool)
|
||||
)
|
||||
@@ -73,31 +66,6 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
)
|
||||
self.combo_logging.setCurrentText(settings.value("logging/level", type=str))
|
||||
|
||||
def set_font_labels(self):
|
||||
self.label_font_message_title.setText(
|
||||
settings.value("MessageWidget/font/title", type=str)
|
||||
)
|
||||
self.label_font_message_date.setText(
|
||||
settings.value("MessageWidget/font/date", type=str)
|
||||
)
|
||||
self.label_font_message_content.setText(
|
||||
settings.value("MessageWidget/font/content", type=str)
|
||||
)
|
||||
|
||||
def change_font_callback(self, key: str):
|
||||
font = QtGui.QFont()
|
||||
font.fromString(settings.value(key, type=str))
|
||||
font, accepted = QtWidgets.QFontDialog.getFont(font, self, "Select font")
|
||||
|
||||
if not accepted:
|
||||
return
|
||||
|
||||
self.settings_changed_callback()
|
||||
label: QtWidgets.QLabel = getattr(
|
||||
self, "label_font_message_" + key.split("/")[-1]
|
||||
)
|
||||
label.setText(font.toString())
|
||||
|
||||
def change_server_info_callback(self):
|
||||
self.server_changed = verify_server(force_new=True)
|
||||
|
||||
@@ -124,23 +92,10 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
QtWidgets.QDialogButtonBox.StandardButton.Apply
|
||||
).clicked.connect(self.apply_settings)
|
||||
|
||||
# Fonts
|
||||
self.pb_font_message_title.clicked.connect(
|
||||
lambda: self.change_font_callback("MessageWidget/font/title")
|
||||
)
|
||||
self.pb_font_message_date.clicked.connect(
|
||||
lambda: self.change_font_callback("MessageWidget/font/date")
|
||||
)
|
||||
self.pb_font_message_content.clicked.connect(
|
||||
lambda: self.change_font_callback("MessageWidget/font/content")
|
||||
)
|
||||
|
||||
# Theme
|
||||
self.combo_theme.currentTextChanged.connect(self.settings_changed_callback)
|
||||
|
||||
# Icons
|
||||
self.cb_icons_application.stateChanged.connect(self.settings_changed_callback)
|
||||
self.cb_icons_message.stateChanged.connect(self.settings_changed_callback)
|
||||
self.cb_icons_notification.stateChanged.connect(self.settings_changed_callback)
|
||||
|
||||
# Notifications
|
||||
@@ -157,26 +112,11 @@ class SettingsDialog(QtWidgets.QDialog, Ui_Dialog):
|
||||
)
|
||||
|
||||
def apply_settings(self):
|
||||
# Fonts
|
||||
settings.setValue(
|
||||
"MessageWidget/font/title", self.label_font_message_title.text()
|
||||
)
|
||||
settings.setValue(
|
||||
"MessageWidget/font/date", self.label_font_message_date.text()
|
||||
)
|
||||
settings.setValue(
|
||||
"MessageWidget/font/content", self.label_font_message_content.text()
|
||||
)
|
||||
|
||||
# Theme
|
||||
settings.setValue("MainWindow/theme", self.combo_theme.currentText())
|
||||
settings.setValue("MainApplication/theme", self.combo_theme.currentText())
|
||||
set_theme(self.app, self.combo_theme.currentText())
|
||||
|
||||
# Icons
|
||||
settings.setValue(
|
||||
"ApplicationModelItem/icon/show", self.cb_icons_application.isChecked()
|
||||
)
|
||||
settings.setValue("MessageWidget/image/show", self.cb_icons_message.isChecked())
|
||||
settings.setValue(
|
||||
"tray/notifications/icon/show", self.cb_icons_notification.isChecked()
|
||||
)
|
||||
|
||||
@@ -17,8 +17,8 @@ class Tray(QtWidgets.QSystemTrayIcon):
|
||||
|
||||
menu.addSeparator()
|
||||
|
||||
self.actionToggleWindow = QtGui.QAction("Toggle Window", self)
|
||||
menu.addAction(self.actionToggleWindow)
|
||||
self.actionReconnect = QtGui.QAction("Reconnect", self)
|
||||
menu.addAction(self.actionReconnect)
|
||||
|
||||
menu.addSeparator()
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
from .MainWindow import MainWindow, start_gui
|
||||
from .MainApplication import start_gui
|
||||
from .ServerInfoDialog import ServerInfoDialog
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
# Form implementation generated from reading ui file 'gotify_tray/gui/designs\widget_main.ui'
|
||||
#
|
||||
# Created by: PyQt6 UI code generator 6.1.1
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
||||
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
|
||||
class Ui_Form(object):
|
||||
def setupUi(self, Form):
|
||||
Form.setObjectName("Form")
|
||||
Form.resize(809, 572)
|
||||
self.gridLayout_2 = QtWidgets.QGridLayout(Form)
|
||||
self.gridLayout_2.setObjectName("gridLayout_2")
|
||||
self.listView_applications = QtWidgets.QListView(Form)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.listView_applications.sizePolicy().hasHeightForWidth())
|
||||
self.listView_applications.setSizePolicy(sizePolicy)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(13)
|
||||
self.listView_applications.setFont(font)
|
||||
self.listView_applications.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||
self.listView_applications.setDragEnabled(True)
|
||||
self.listView_applications.setDragDropMode(QtWidgets.QAbstractItemView.DragDropMode.InternalMove)
|
||||
self.listView_applications.setWordWrap(True)
|
||||
self.listView_applications.setObjectName("listView_applications")
|
||||
self.gridLayout_2.addWidget(self.listView_applications, 0, 0, 1, 1)
|
||||
self.gridLayout = QtWidgets.QGridLayout()
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
self.pb_delete_all = QtWidgets.QPushButton(Form)
|
||||
self.pb_delete_all.setMinimumSize(QtCore.QSize(0, 32))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(10)
|
||||
self.pb_delete_all.setFont(font)
|
||||
self.pb_delete_all.setObjectName("pb_delete_all")
|
||||
self.gridLayout.addWidget(self.pb_delete_all, 0, 5, 1, 1)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout.addItem(spacerItem, 0, 3, 1, 1)
|
||||
self.label_selected = QtWidgets.QLabel(Form)
|
||||
self.label_selected.setMinimumSize(QtCore.QSize(0, 32))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(15)
|
||||
font.setBold(True)
|
||||
self.label_selected.setFont(font)
|
||||
self.label_selected.setText("")
|
||||
self.label_selected.setObjectName("label_selected")
|
||||
self.gridLayout.addWidget(self.label_selected, 0, 2, 1, 1)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout.addItem(spacerItem1, 0, 1, 1, 1)
|
||||
self.pb_refresh = QtWidgets.QPushButton(Form)
|
||||
self.pb_refresh.setMinimumSize(QtCore.QSize(0, 32))
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(10)
|
||||
self.pb_refresh.setFont(font)
|
||||
self.pb_refresh.setObjectName("pb_refresh")
|
||||
self.gridLayout.addWidget(self.pb_refresh, 0, 4, 1, 1)
|
||||
self.label_status = QtWidgets.QLabel(Form)
|
||||
self.label_status.setText("")
|
||||
self.label_status.setObjectName("label_status")
|
||||
self.gridLayout.addWidget(self.label_status, 0, 0, 1, 1)
|
||||
self.listView_messages = QtWidgets.QListView(Form)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.MinimumExpanding, QtWidgets.QSizePolicy.Policy.Expanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.listView_messages.sizePolicy().hasHeightForWidth())
|
||||
self.listView_messages.setSizePolicy(sizePolicy)
|
||||
self.listView_messages.setVerticalScrollMode(QtWidgets.QAbstractItemView.ScrollMode.ScrollPerPixel)
|
||||
self.listView_messages.setObjectName("listView_messages")
|
||||
self.gridLayout.addWidget(self.listView_messages, 1, 0, 1, 6)
|
||||
self.gridLayout_2.addLayout(self.gridLayout, 0, 1, 1, 1)
|
||||
|
||||
self.retranslateUi(Form)
|
||||
QtCore.QMetaObject.connectSlotsByName(Form)
|
||||
Form.setTabOrder(self.pb_refresh, self.pb_delete_all)
|
||||
Form.setTabOrder(self.pb_delete_all, self.listView_messages)
|
||||
Form.setTabOrder(self.listView_messages, self.listView_applications)
|
||||
|
||||
def retranslateUi(self, Form):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Form.setWindowTitle(_translate("Form", "Form"))
|
||||
self.pb_delete_all.setText(_translate("Form", "Delete All"))
|
||||
self.pb_refresh.setText(_translate("Form", "Refresh"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
Form = QtWidgets.QWidget()
|
||||
ui = Ui_Form()
|
||||
ui.setupUi(Form)
|
||||
Form.show()
|
||||
sys.exit(app.exec())
|
||||
@@ -1,159 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>809</width>
|
||||
<height>572</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QListView" name="listView_applications">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="5">
|
||||
<widget class="QPushButton" name="pb_delete_all">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_selected">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>15</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="pb_refresh">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_status">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="6">
|
||||
<widget class="QListView" name="listView_messages">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>pb_refresh</tabstop>
|
||||
<tabstop>pb_delete_all</tabstop>
|
||||
<tabstop>listView_messages</tabstop>
|
||||
<tabstop>listView_applications</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,94 +0,0 @@
|
||||
# Form implementation generated from reading ui file 'gotify_tray/gui/designs\widget_message.ui'
|
||||
#
|
||||
# Created by: PyQt6 UI code generator 6.1.1
|
||||
#
|
||||
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
|
||||
# run again. Do not edit this file unless you know what you are doing.
|
||||
|
||||
|
||||
from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
|
||||
class Ui_Form(object):
|
||||
def setupUi(self, Form):
|
||||
Form.setObjectName("Form")
|
||||
Form.resize(454, 122)
|
||||
self.gridLayout = QtWidgets.QGridLayout(Form)
|
||||
self.gridLayout.setSizeConstraint(QtWidgets.QLayout.SizeConstraint.SetMinimumSize)
|
||||
self.gridLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
self.frame = QtWidgets.QFrame(Form)
|
||||
self.frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
|
||||
self.frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
|
||||
self.frame.setObjectName("frame")
|
||||
self.gridLayout_frame = QtWidgets.QGridLayout(self.frame)
|
||||
self.gridLayout_frame.setSizeConstraint(QtWidgets.QLayout.SizeConstraint.SetMinimumSize)
|
||||
self.gridLayout_frame.setContentsMargins(-1, 0, -1, 0)
|
||||
self.gridLayout_frame.setObjectName("gridLayout_frame")
|
||||
self.label_title = QtWidgets.QLabel(self.frame)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.label_title.sizePolicy().hasHeightForWidth())
|
||||
self.label_title.setSizePolicy(sizePolicy)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(17)
|
||||
font.setBold(False)
|
||||
font.setWeight(50)
|
||||
self.label_title.setFont(font)
|
||||
self.label_title.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.LinksAccessibleByMouse|QtCore.Qt.TextInteractionFlag.TextSelectableByMouse)
|
||||
self.label_title.setObjectName("label_title")
|
||||
self.gridLayout_frame.addWidget(self.label_title, 0, 1, 1, 1)
|
||||
self.text_message = QtWidgets.QLabel(self.frame)
|
||||
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.MinimumExpanding)
|
||||
sizePolicy.setHorizontalStretch(0)
|
||||
sizePolicy.setVerticalStretch(0)
|
||||
sizePolicy.setHeightForWidth(self.text_message.sizePolicy().hasHeightForWidth())
|
||||
self.text_message.setSizePolicy(sizePolicy)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(11)
|
||||
self.text_message.setFont(font)
|
||||
self.text_message.setWordWrap(True)
|
||||
self.text_message.setOpenExternalLinks(True)
|
||||
self.text_message.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.LinksAccessibleByMouse|QtCore.Qt.TextInteractionFlag.TextSelectableByMouse)
|
||||
self.text_message.setObjectName("text_message")
|
||||
self.gridLayout_frame.addWidget(self.text_message, 3, 1, 1, 3)
|
||||
self.label_date = QtWidgets.QLabel(self.frame)
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(11)
|
||||
self.label_date.setFont(font)
|
||||
self.label_date.setTextInteractionFlags(QtCore.Qt.TextInteractionFlag.LinksAccessibleByMouse|QtCore.Qt.TextInteractionFlag.TextSelectableByMouse)
|
||||
self.label_date.setObjectName("label_date")
|
||||
self.gridLayout_frame.addWidget(self.label_date, 2, 1, 1, 1)
|
||||
self.pb_delete = QtWidgets.QPushButton(self.frame)
|
||||
self.pb_delete.setText("")
|
||||
self.pb_delete.setFlat(True)
|
||||
self.pb_delete.setObjectName("pb_delete")
|
||||
self.gridLayout_frame.addWidget(self.pb_delete, 0, 3, 1, 1)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_frame.addItem(spacerItem, 0, 2, 1, 1)
|
||||
self.label_image = QtWidgets.QLabel(self.frame)
|
||||
self.label_image.setText("")
|
||||
self.label_image.setObjectName("label_image")
|
||||
self.gridLayout_frame.addWidget(self.label_image, 0, 0, 1, 1)
|
||||
self.gridLayout.addWidget(self.frame, 0, 0, 1, 1)
|
||||
|
||||
self.retranslateUi(Form)
|
||||
QtCore.QMetaObject.connectSlotsByName(Form)
|
||||
|
||||
def retranslateUi(self, Form):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Form.setWindowTitle(_translate("Form", "Form"))
|
||||
self.label_title.setText(_translate("Form", "Title"))
|
||||
self.text_message.setText(_translate("Form", "TextLabel"))
|
||||
self.label_date.setText(_translate("Form", "Date"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
Form = QtWidgets.QWidget()
|
||||
ui = Ui_Form()
|
||||
ui.setupUi(Form)
|
||||
Form.show()
|
||||
sys.exit(app.exec())
|
||||
@@ -1,152 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>454</width>
|
||||
<height>122</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_frame">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_title">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>17</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="3">
|
||||
<widget class="QLabel" name="text_message">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_date">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Date</string>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="pb_delete">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_image">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -15,10 +15,6 @@ class Ui_Dialog(object):
|
||||
Dialog.resize(300, 130)
|
||||
self.gridLayout = QtWidgets.QGridLayout(Dialog)
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
self.label_server_info = QtWidgets.QLabel(Dialog)
|
||||
self.label_server_info.setText("")
|
||||
self.label_server_info.setObjectName("label_server_info")
|
||||
self.gridLayout.addWidget(self.label_server_info, 1, 2, 1, 1)
|
||||
self.pb_test = QtWidgets.QPushButton(Dialog)
|
||||
self.pb_test.setObjectName("pb_test")
|
||||
self.gridLayout.addWidget(self.pb_test, 1, 4, 1, 1)
|
||||
@@ -44,6 +40,10 @@ class Ui_Dialog(object):
|
||||
self.gridLayout.addWidget(self.buttonBox, 2, 4, 1, 1)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout.addItem(spacerItem, 1, 3, 1, 1)
|
||||
self.label_server_info = QtWidgets.QLabel(Dialog)
|
||||
self.label_server_info.setText("")
|
||||
self.label_server_info.setObjectName("label_server_info")
|
||||
self.gridLayout.addWidget(self.label_server_info, 1, 1, 1, 2)
|
||||
|
||||
self.retranslateUi(Dialog)
|
||||
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
|
||||
|
||||
@@ -12,51 +12,9 @@ from PyQt6 import QtCore, QtGui, QtWidgets
|
||||
class Ui_Dialog(object):
|
||||
def setupUi(self, Dialog):
|
||||
Dialog.setObjectName("Dialog")
|
||||
Dialog.resize(375, 606)
|
||||
Dialog.resize(375, 392)
|
||||
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
|
||||
self.verticalLayout.setObjectName("verticalLayout")
|
||||
self.groupBox = QtWidgets.QGroupBox(Dialog)
|
||||
self.groupBox.setObjectName("groupBox")
|
||||
self.gridLayout = QtWidgets.QGridLayout(self.groupBox)
|
||||
self.gridLayout.setObjectName("gridLayout")
|
||||
self.groupBox_2 = QtWidgets.QGroupBox(self.groupBox)
|
||||
self.groupBox_2.setObjectName("groupBox_2")
|
||||
self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox_2)
|
||||
self.gridLayout_2.setObjectName("gridLayout_2")
|
||||
self.label_3 = QtWidgets.QLabel(self.groupBox_2)
|
||||
self.label_3.setObjectName("label_3")
|
||||
self.gridLayout_2.addWidget(self.label_3, 2, 0, 1, 1)
|
||||
self.label_2 = QtWidgets.QLabel(self.groupBox_2)
|
||||
self.label_2.setObjectName("label_2")
|
||||
self.gridLayout_2.addWidget(self.label_2, 1, 0, 1, 1)
|
||||
self.pb_font_message_content = QtWidgets.QPushButton(self.groupBox_2)
|
||||
self.pb_font_message_content.setMaximumSize(QtCore.QSize(30, 16777215))
|
||||
self.pb_font_message_content.setObjectName("pb_font_message_content")
|
||||
self.gridLayout_2.addWidget(self.pb_font_message_content, 2, 1, 1, 1)
|
||||
self.pb_font_message_date = QtWidgets.QPushButton(self.groupBox_2)
|
||||
self.pb_font_message_date.setMaximumSize(QtCore.QSize(30, 16777215))
|
||||
self.pb_font_message_date.setObjectName("pb_font_message_date")
|
||||
self.gridLayout_2.addWidget(self.pb_font_message_date, 1, 1, 1, 1)
|
||||
self.label = QtWidgets.QLabel(self.groupBox_2)
|
||||
self.label.setObjectName("label")
|
||||
self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)
|
||||
self.label_font_message_title = QtWidgets.QLabel(self.groupBox_2)
|
||||
self.label_font_message_title.setObjectName("label_font_message_title")
|
||||
self.gridLayout_2.addWidget(self.label_font_message_title, 0, 2, 1, 1)
|
||||
self.pb_font_message_title = QtWidgets.QPushButton(self.groupBox_2)
|
||||
self.pb_font_message_title.setMaximumSize(QtCore.QSize(30, 16777215))
|
||||
self.pb_font_message_title.setObjectName("pb_font_message_title")
|
||||
self.gridLayout_2.addWidget(self.pb_font_message_title, 0, 1, 1, 1)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_2.addItem(spacerItem, 0, 3, 1, 1)
|
||||
self.label_font_message_date = QtWidgets.QLabel(self.groupBox_2)
|
||||
self.label_font_message_date.setObjectName("label_font_message_date")
|
||||
self.gridLayout_2.addWidget(self.label_font_message_date, 1, 2, 1, 1)
|
||||
self.label_font_message_content = QtWidgets.QLabel(self.groupBox_2)
|
||||
self.label_font_message_content.setObjectName("label_font_message_content")
|
||||
self.gridLayout_2.addWidget(self.label_font_message_content, 2, 2, 1, 1)
|
||||
self.gridLayout.addWidget(self.groupBox_2, 0, 0, 1, 1)
|
||||
self.verticalLayout.addWidget(self.groupBox)
|
||||
self.groupBox_6 = QtWidgets.QGroupBox(Dialog)
|
||||
self.groupBox_6.setObjectName("groupBox_6")
|
||||
self.gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_6)
|
||||
@@ -64,19 +22,13 @@ class Ui_Dialog(object):
|
||||
self.combo_theme = QtWidgets.QComboBox(self.groupBox_6)
|
||||
self.combo_theme.setObjectName("combo_theme")
|
||||
self.gridLayout_5.addWidget(self.combo_theme, 0, 0, 1, 1)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_5.addItem(spacerItem1, 0, 1, 1, 1)
|
||||
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_5.addItem(spacerItem, 0, 1, 1, 1)
|
||||
self.verticalLayout.addWidget(self.groupBox_6)
|
||||
self.groupBox_3 = QtWidgets.QGroupBox(Dialog)
|
||||
self.groupBox_3.setObjectName("groupBox_3")
|
||||
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.groupBox_3)
|
||||
self.verticalLayout_2.setObjectName("verticalLayout_2")
|
||||
self.cb_icons_application = QtWidgets.QCheckBox(self.groupBox_3)
|
||||
self.cb_icons_application.setObjectName("cb_icons_application")
|
||||
self.verticalLayout_2.addWidget(self.cb_icons_application)
|
||||
self.cb_icons_message = QtWidgets.QCheckBox(self.groupBox_3)
|
||||
self.cb_icons_message.setObjectName("cb_icons_message")
|
||||
self.verticalLayout_2.addWidget(self.cb_icons_message)
|
||||
self.cb_icons_notification = QtWidgets.QCheckBox(self.groupBox_3)
|
||||
self.cb_icons_notification.setObjectName("cb_icons_notification")
|
||||
self.verticalLayout_2.addWidget(self.cb_icons_notification)
|
||||
@@ -91,8 +43,8 @@ class Ui_Dialog(object):
|
||||
self.spin_priority.setProperty("value", 5)
|
||||
self.spin_priority.setObjectName("spin_priority")
|
||||
self.gridLayout_4.addWidget(self.spin_priority, 0, 1, 1, 1)
|
||||
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_4.addItem(spacerItem2, 0, 2, 1, 1)
|
||||
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_4.addItem(spacerItem1, 0, 2, 1, 1)
|
||||
self.label_4 = QtWidgets.QLabel(self.groupBox_5)
|
||||
self.label_4.setObjectName("label_4")
|
||||
self.gridLayout_4.addWidget(self.label_4, 0, 0, 1, 1)
|
||||
@@ -116,8 +68,8 @@ class Ui_Dialog(object):
|
||||
self.pb_change_server_info = QtWidgets.QPushButton(self.groupBox_4)
|
||||
self.pb_change_server_info.setObjectName("pb_change_server_info")
|
||||
self.gridLayout_3.addWidget(self.pb_change_server_info, 0, 0, 1, 1)
|
||||
spacerItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_3.addItem(spacerItem3, 0, 1, 1, 1)
|
||||
spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_3.addItem(spacerItem2, 0, 1, 1, 1)
|
||||
self.verticalLayout.addWidget(self.groupBox_4)
|
||||
self.groupBox_7 = QtWidgets.QGroupBox(Dialog)
|
||||
self.groupBox_7.setObjectName("groupBox_7")
|
||||
@@ -133,8 +85,8 @@ class Ui_Dialog(object):
|
||||
self.pb_open_log.setMaximumSize(QtCore.QSize(30, 16777215))
|
||||
self.pb_open_log.setObjectName("pb_open_log")
|
||||
self.gridLayout_6.addWidget(self.pb_open_log, 0, 2, 1, 1)
|
||||
spacerItem4 = QtWidgets.QSpacerItem(190, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_6.addItem(spacerItem4, 0, 3, 1, 1)
|
||||
spacerItem3 = QtWidgets.QSpacerItem(190, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
|
||||
self.gridLayout_6.addItem(spacerItem3, 0, 3, 1, 1)
|
||||
self.verticalLayout.addWidget(self.groupBox_7)
|
||||
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
|
||||
self.buttonBox.setOrientation(QtCore.Qt.Orientation.Horizontal)
|
||||
@@ -146,33 +98,18 @@ class Ui_Dialog(object):
|
||||
self.buttonBox.accepted.connect(Dialog.accept) # type: ignore
|
||||
self.buttonBox.rejected.connect(Dialog.reject) # type: ignore
|
||||
QtCore.QMetaObject.connectSlotsByName(Dialog)
|
||||
Dialog.setTabOrder(self.pb_font_message_title, self.pb_font_message_date)
|
||||
Dialog.setTabOrder(self.pb_font_message_date, self.pb_font_message_content)
|
||||
Dialog.setTabOrder(self.pb_font_message_content, self.cb_icons_application)
|
||||
Dialog.setTabOrder(self.cb_icons_application, self.cb_icons_message)
|
||||
Dialog.setTabOrder(self.cb_icons_message, self.cb_icons_notification)
|
||||
Dialog.setTabOrder(self.combo_theme, self.cb_icons_notification)
|
||||
Dialog.setTabOrder(self.cb_icons_notification, self.spin_priority)
|
||||
Dialog.setTabOrder(self.spin_priority, self.spin_duration)
|
||||
Dialog.setTabOrder(self.spin_duration, self.pb_change_server_info)
|
||||
Dialog.setTabOrder(self.pb_change_server_info, self.combo_logging)
|
||||
Dialog.setTabOrder(self.combo_logging, self.pb_open_log)
|
||||
|
||||
def retranslateUi(self, Dialog):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
|
||||
self.groupBox.setTitle(_translate("Dialog", "Fonts"))
|
||||
self.groupBox_2.setTitle(_translate("Dialog", "Message"))
|
||||
self.label_3.setText(_translate("Dialog", "Content"))
|
||||
self.label_2.setText(_translate("Dialog", "Date"))
|
||||
self.pb_font_message_content.setText(_translate("Dialog", "..."))
|
||||
self.pb_font_message_date.setText(_translate("Dialog", "..."))
|
||||
self.label.setText(_translate("Dialog", "Title"))
|
||||
self.label_font_message_title.setText(_translate("Dialog", "TextLabel"))
|
||||
self.pb_font_message_title.setText(_translate("Dialog", "..."))
|
||||
self.label_font_message_date.setText(_translate("Dialog", "TextLabel"))
|
||||
self.label_font_message_content.setText(_translate("Dialog", "TextLabel"))
|
||||
self.groupBox_6.setTitle(_translate("Dialog", "Theme"))
|
||||
self.groupBox_3.setTitle(_translate("Dialog", "Icons"))
|
||||
self.cb_icons_application.setText(_translate("Dialog", "Show application icons"))
|
||||
self.cb_icons_message.setText(_translate("Dialog", "Show message icons"))
|
||||
self.cb_icons_notification.setText(_translate("Dialog", "Show notification icons"))
|
||||
self.groupBox_5.setTitle(_translate("Dialog", "Notifications"))
|
||||
self.label_4.setText(_translate("Dialog", "Minimum priority to show notifications:"))
|
||||
|
||||
@@ -7,125 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>375</width>
|
||||
<height>606</height>
|
||||
<height>392</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Fonts</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Message</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Content</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Date</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="pb_font_message_content">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pb_font_message_date">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_font_message_title">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pb_font_message_title">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="label_font_message_date">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="label_font_message_content">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
@@ -157,20 +45,6 @@
|
||||
<string>Icons</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_icons_application">
|
||||
<property name="text">
|
||||
<string>Show application icons</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_icons_message">
|
||||
<property name="text">
|
||||
<string>Show message icons</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_icons_notification">
|
||||
<property name="text">
|
||||
@@ -340,15 +214,13 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>pb_font_message_title</tabstop>
|
||||
<tabstop>pb_font_message_date</tabstop>
|
||||
<tabstop>pb_font_message_content</tabstop>
|
||||
<tabstop>cb_icons_application</tabstop>
|
||||
<tabstop>cb_icons_message</tabstop>
|
||||
<tabstop>combo_theme</tabstop>
|
||||
<tabstop>cb_icons_notification</tabstop>
|
||||
<tabstop>spin_priority</tabstop>
|
||||
<tabstop>spin_duration</tabstop>
|
||||
<tabstop>pb_change_server_info</tabstop>
|
||||
<tabstop>combo_logging</tabstop>
|
||||
<tabstop>pb_open_log</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
||||
@@ -36,32 +36,6 @@ class BaseTask(QtCore.QThread):
|
||||
self.running = False
|
||||
|
||||
|
||||
class DeleteMessageTask(BaseTask):
|
||||
deleted = pyqtSignal(bool)
|
||||
|
||||
def __init__(self, message_id: int, gotify_client: gotify.GotifyClient):
|
||||
super(DeleteMessageTask, self).__init__()
|
||||
self.message_id = message_id
|
||||
self.gotify_client = gotify_client
|
||||
|
||||
def task(self):
|
||||
success = self.gotify_client.delete_message(self.message_id)
|
||||
self.deleted.emit(success)
|
||||
|
||||
|
||||
class DeleteApplicationMessagesTask(BaseTask):
|
||||
deleted = pyqtSignal(bool)
|
||||
|
||||
def __init__(self, appid: int, gotify_client: gotify.GotifyClient):
|
||||
super(DeleteApplicationMessagesTask, self).__init__()
|
||||
self.appid = appid
|
||||
self.gotify_client = gotify_client
|
||||
|
||||
def task(self):
|
||||
success = self.gotify_client.delete_application_messages(self.appid)
|
||||
self.deleted.emit(success)
|
||||
|
||||
|
||||
class DeleteAllMessagesTask(BaseTask):
|
||||
deleted = pyqtSignal(bool)
|
||||
|
||||
@@ -90,39 +64,6 @@ class GetApplicationsTask(BaseTask):
|
||||
self.success.emit(result)
|
||||
|
||||
|
||||
class GetApplicationMessagesTask(BaseTask):
|
||||
success = pyqtSignal(gotify.GotifyPagedMessagesModel)
|
||||
error = pyqtSignal(gotify.GotifyErrorModel)
|
||||
|
||||
def __init__(self, appid: int, gotify_client: gotify.GotifyClient):
|
||||
super(GetApplicationMessagesTask, self).__init__()
|
||||
self.appid = appid
|
||||
self.gotify_client = gotify_client
|
||||
|
||||
def task(self):
|
||||
result = self.gotify_client.get_application_messages(self.appid)
|
||||
if isinstance(result, gotify.GotifyErrorModel):
|
||||
self.error.emit(result)
|
||||
else:
|
||||
self.success.emit(result)
|
||||
|
||||
|
||||
class GetMessagesTask(BaseTask):
|
||||
success = pyqtSignal(gotify.GotifyPagedMessagesModel)
|
||||
error = pyqtSignal(gotify.GotifyErrorModel)
|
||||
|
||||
def __init__(self, gotify_client: gotify.GotifyClient):
|
||||
super(GetMessagesTask, self).__init__()
|
||||
self.gotify_client = gotify_client
|
||||
|
||||
def task(self):
|
||||
result = self.gotify_client.get_messages()
|
||||
if isinstance(result, gotify.GotifyErrorModel):
|
||||
self.error.emit(result)
|
||||
else:
|
||||
self.success.emit(result)
|
||||
|
||||
|
||||
class VerifyServerInfoTask(BaseTask):
|
||||
success = pyqtSignal(GotifyVersionModel)
|
||||
incorrect_token = pyqtSignal(GotifyVersionModel)
|
||||
|
||||
Reference in New Issue
Block a user