Compare commits

...

2 Commits

Author SHA1 Message Date
36e644a736 Support Qt6 2021-11-17 18:56:14 +01:00
75bac84888 Fix app closing on closing last window 2021-11-17 18:43:09 +01:00
10 changed files with 52 additions and 23 deletions

View File

@ -15,7 +15,7 @@ classifiers =
package_dir = package_dir =
= src = src
packages = find: packages = find:
python_requires = >=3.6 python_requires = >=3.8
install_requires = install_requires =
requests requests
requests-futures requests-futures

View File

@ -1,6 +1,9 @@
from configparser import ConfigParser from configparser import ConfigParser
from pathlib import Path from pathlib import Path
try:
from PySide6 import QtCore
except ImportError:
from PySide2 import QtCore from PySide2 import QtCore
from fime.exceptions import FimeException from fime.exceptions import FimeException

View File

@ -7,6 +7,9 @@ from datetime import datetime, date, timedelta
from threading import Thread, Event from threading import Thread, Event
from typing import List from typing import List
try:
from PySide6 import QtCore
except ImportError:
from PySide2 import QtCore from PySide2 import QtCore
data_dir_path = os.path.join(QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.AppDataLocation), data_dir_path = os.path.join(QtCore.QStandardPaths.writableLocation(QtCore.QStandardPaths.AppDataLocation),

View File

@ -3,6 +3,9 @@
# Created by: The Resource Compiler for Qt version 5.15.2 # Created by: The Resource Compiler for Qt version 5.15.2
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
try:
from PySide6 import QtCore
except ImportError:
from PySide2 import QtCore from PySide2 import QtCore
qt_resource_data = b"\ qt_resource_data = b"\

View File

@ -1,3 +1,6 @@
try:
from PySide6 import QtGui, QtWidgets
except ImportError:
from PySide2 import QtGui, QtWidgets from PySide2 import QtGui, QtWidgets
from fime.task_completer import TaskCompleter from fime.task_completer import TaskCompleter

View File

@ -4,8 +4,12 @@ import signal
import sys import sys
from functools import partial from functools import partial
try:
from PySide6 import QtCore, QtWidgets
PYSIDE_6 = True
except ImportError:
from PySide2 import QtCore, QtWidgets from PySide2 import QtCore, QtWidgets
from PySide2.QtWidgets import QMessageBox PYSIDE_6 = False
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
import fime.icons import fime.icons
@ -20,6 +24,7 @@ from fime.util import get_screen_height, get_icon
class App: class App:
def __init__(self): def __init__(self):
self.app = QtWidgets.QApplication(sys.argv) self.app = QtWidgets.QApplication(sys.argv)
self.app.setQuitOnLastWindowClosed(False)
data = Data() data = Data()
self.tasks = Tasks(data) self.tasks = Tasks(data)
@ -28,7 +33,7 @@ class App:
icon = get_icon("appointment-new") icon = get_icon("appointment-new")
self.menu = QtWidgets.QMenu() self.menu = QtWidgets.QMenu(None)
self.import_task = ImportTask(None) self.import_task = ImportTask(None)
self.import_task.accepted.connect(self.new_task_imported) self.import_task.accepted.connect(self.new_task_imported)
@ -116,7 +121,8 @@ class App:
exit_action = self.menu.addAction("Close") exit_action = self.menu.addAction("Close")
exit_action.triggered.connect(self.app.quit) exit_action.triggered.connect(self.app.quit)
def sigterm_handler(self, _signo, _frame): def sigterm_handler(self, signo, _frame):
print(f'handling signal "{signal.strsignal(signo)}"')
self.app.quit() self.app.quit()
def run(self): def run(self):
@ -126,6 +132,9 @@ class App:
timer.start(500) timer.start(500)
signal.signal(signal.SIGTERM, self.sigterm_handler) signal.signal(signal.SIGTERM, self.sigterm_handler)
signal.signal(signal.SIGINT, self.sigterm_handler) signal.signal(signal.SIGINT, self.sigterm_handler)
if PYSIDE_6:
self.app.exec()
else:
self.app.exec_() self.app.exec_()
@QtCore.Slot() @QtCore.Slot()
@ -149,7 +158,7 @@ def main():
app = App() app = App()
app.run() app.run()
except FimeException as e: except FimeException as e:
QMessageBox.critical(None, "Error", str(e), QMessageBox.Ok) QtWidgets.QMessageBox.critical(None, "Error", str(e), QtWidgets.QMessageBox.Ok)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -1,9 +1,10 @@
try:
from PySide6 import QtCore, QtGui, QtWidgets
except ImportError:
from PySide2 import QtCore, QtGui, QtWidgets from PySide2 import QtCore, QtGui, QtWidgets
from datetime import datetime from datetime import datetime
from PySide2.QtWidgets import QHeaderView
from fime.data import Tasks from fime.data import Tasks
from fime.util import get_screen_height, get_icon from fime.util import get_screen_height, get_icon
@ -41,9 +42,9 @@ class Report(QtWidgets.QDialog):
self.tableWidget.setItemDelegateForColumn(0, Report.TaskItemCompleter(self._tasks, self)) self.tableWidget.setItemDelegateForColumn(0, Report.TaskItemCompleter(self._tasks, self))
self.header = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Horizontal) self.header = QtWidgets.QHeaderView(QtCore.Qt.Orientation.Horizontal)
self.header.setMinimumSectionSize(1) self.header.setMinimumSectionSize(1)
self.header.setSectionResizeMode(QHeaderView.ResizeToContents) self.header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
self.tableWidget.setHorizontalHeader(self.header) self.tableWidget.setHorizontalHeader(self.header)
self.header.setSectionResizeMode(self.header.logicalIndex(0), QHeaderView.Stretch) self.header.setSectionResizeMode(self.header.logicalIndex(0), QtWidgets.QHeaderView.Stretch)
self.previous_button = QtWidgets.QPushButton() self.previous_button = QtWidgets.QPushButton()
self.previous_button.setText("Previous") self.previous_button.setText("Previous")

View File

@ -5,15 +5,16 @@ from functools import reduce
from queue import Queue, Empty from queue import Queue, Empty
from urllib.parse import urlparse, parse_qs from urllib.parse import urlparse, parse_qs
from PySide2 import QtCore try:
from PySide2.QtCore import QTimer from PySide6 import QtCore, QtWidgets
from PySide2.QtWidgets import QCompleter except ImportError:
from PySide2 import QtCore, QtWidgets
from requests_futures.sessions import FuturesSession from requests_futures.sessions import FuturesSession
from fime.config import Config from fime.config import Config
class TaskCompleter(QCompleter): class TaskCompleter(QtWidgets.QCompleter):
def __init__(self, parent=None, *args, **kwargs): def __init__(self, parent=None, *args, **kwargs):
super().__init__([], parent, *args, **kwargs) super().__init__([], parent, *args, **kwargs)
self.setFilterMode(QtCore.Qt.MatchFlag.MatchContains) self.setFilterMode(QtCore.Qt.MatchFlag.MatchContains)
@ -26,7 +27,7 @@ class TaskCompleter(QCompleter):
self.response_text = "" self.response_text = ""
self.model_data = set() self.model_data = set()
self.escalate = False self.escalate = False
self.update_timer = QTimer(self) self.update_timer = QtCore.QTimer(self)
self.update_timer.timeout.connect(self.process_response) self.update_timer.timeout.connect(self.process_response)
self.update_timer.setInterval(250) self.update_timer.setInterval(250)
self.queue = Queue() self.queue = Queue()

View File

@ -1,3 +1,6 @@
try:
from PySide6 import QtCore, QtGui, QtWidgets
except ImportError:
from PySide2 import QtCore, QtGui, QtWidgets from PySide2 import QtCore, QtGui, QtWidgets
from fime.util import get_icon from fime.util import get_icon

View File

@ -1,3 +1,6 @@
try:
from PySide6 import QtGui
except ImportError:
from PySide2 import QtGui from PySide2 import QtGui