pytodo-qt 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pytodo-qt might be problematic. Click here for more details.
- {pytodo-qt-0.2.0/src/pytodo_qt.egg-info → pytodo-qt-0.2.1}/PKG-INFO +3 -3
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/pyproject.toml +3 -3
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1/src/pytodo_qt.egg-info}/PKG-INFO +3 -3
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/pytodo_qt.egg-info/SOURCES.txt +1 -1
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/pytodo_qt.egg-info/requires.txt +1 -1
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/__main__.py +9 -10
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/core/Logger.py +1 -0
- pytodo-qt-0.2.0/src/todo/core/TodoDataBase.py → pytodo-qt-0.2.1/src/todo/core/TodoDatabase.py +5 -5
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/core/__init__.py +4 -4
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/core/json_helpers.py +2 -2
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/core/settings.py +1 -1
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/crypto/AESCipher.py +1 -1
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/gui/AddTodoDialog.py +20 -14
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/gui/MainWindow.py +148 -197
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/gui/SyncDialog.py +24 -22
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/net/__init__.py +1 -1
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/net/tcp_client_lib.py +5 -6
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/net/tcp_server_lib.py +8 -7
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/COPYING +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/README.md +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/setup.cfg +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/pytodo_qt.egg-info/dependency_links.txt +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/pytodo_qt.egg-info/entry_points.txt +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/pytodo_qt.egg-info/top_level.txt +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/__init__.py +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/crypto/__init__.py +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/gui/__init__.py +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/gui/icons/minus.png +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/gui/icons/plus.png +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/gui/icons/todo.png +0 -0
- {pytodo-qt-0.2.0 → pytodo-qt-0.2.1}/src/todo/net/sync_operations.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pytodo-qt
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary: A simple To-Do list app written in
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A simple To-Do list app written in PyQt6
|
|
5
5
|
Author-email: Michael Berry <trismegustis@gmail.com>
|
|
6
6
|
License: GPLv3
|
|
7
7
|
Project-URL: Homepage, https://github.com/berrym/todo
|
|
@@ -11,7 +11,7 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.8
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: COPYING
|
|
14
|
-
Requires-Dist:
|
|
14
|
+
Requires-Dist: PyQt6
|
|
15
15
|
Requires-Dist: pycryptodomex
|
|
16
16
|
|
|
17
17
|
# To-Do
|
|
@@ -11,14 +11,14 @@ todo = ["*.png"]
|
|
|
11
11
|
|
|
12
12
|
[project]
|
|
13
13
|
name = "pytodo-qt"
|
|
14
|
-
version = "0.2.
|
|
15
|
-
description = "A simple To-Do list app written in
|
|
14
|
+
version = "0.2.1"
|
|
15
|
+
description = "A simple To-Do list app written in PyQt6"
|
|
16
16
|
readme = "README.md"
|
|
17
17
|
authors = [
|
|
18
18
|
{name = "Michael Berry", email = "trismegustis@gmail.com"},
|
|
19
19
|
]
|
|
20
20
|
dependencies = [
|
|
21
|
-
"
|
|
21
|
+
"PyQt6",
|
|
22
22
|
"pycryptodomex",
|
|
23
23
|
]
|
|
24
24
|
classifiers = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pytodo-qt
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary: A simple To-Do list app written in
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A simple To-Do list app written in PyQt6
|
|
5
5
|
Author-email: Michael Berry <trismegustis@gmail.com>
|
|
6
6
|
License: GPLv3
|
|
7
7
|
Project-URL: Homepage, https://github.com/berrym/todo
|
|
@@ -11,7 +11,7 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.8
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: COPYING
|
|
14
|
-
Requires-Dist:
|
|
14
|
+
Requires-Dist: PyQt6
|
|
15
15
|
Requires-Dist: pycryptodomex
|
|
16
16
|
|
|
17
17
|
# To-Do
|
|
@@ -10,7 +10,7 @@ src/pytodo_qt.egg-info/top_level.txt
|
|
|
10
10
|
src/todo/__init__.py
|
|
11
11
|
src/todo/__main__.py
|
|
12
12
|
src/todo/core/Logger.py
|
|
13
|
-
src/todo/core/
|
|
13
|
+
src/todo/core/TodoDatabase.py
|
|
14
14
|
src/todo/core/__init__.py
|
|
15
15
|
src/todo/core/json_helpers.py
|
|
16
16
|
src/todo/core/settings.py
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
PyQt6
|
|
2
2
|
pycryptodomex
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
1
|
"""__main__.py
|
|
4
2
|
|
|
5
3
|
A to-do list program written in Python using Qt5
|
|
@@ -23,11 +21,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
23
21
|
import argparse
|
|
24
22
|
import os
|
|
25
23
|
import sys
|
|
26
|
-
from PyQt5 import QtWidgets
|
|
27
24
|
|
|
28
|
-
from
|
|
29
|
-
|
|
30
|
-
from
|
|
25
|
+
from PyQt6.QtWidgets import QApplication
|
|
26
|
+
|
|
27
|
+
from .core.Logger import Logger
|
|
28
|
+
from .core import settings, TodoDatabase
|
|
29
|
+
from .gui import MainWindow
|
|
31
30
|
|
|
32
31
|
|
|
33
32
|
logger = Logger(__name__)
|
|
@@ -50,8 +49,8 @@ def main():
|
|
|
50
49
|
# create a command line arg_parser
|
|
51
50
|
arg_parser = argparse.ArgumentParser(
|
|
52
51
|
prog="To-Do",
|
|
53
|
-
description="To-Do List
|
|
54
|
-
epilog="Copyright Michael Berry
|
|
52
|
+
description="To-Do List Application written in Python with Qt6",
|
|
53
|
+
epilog="Copyright Michael Berry 2024",
|
|
55
54
|
)
|
|
56
55
|
|
|
57
56
|
# add network server command group
|
|
@@ -107,10 +106,10 @@ def main():
|
|
|
107
106
|
settings.options[k] = v
|
|
108
107
|
|
|
109
108
|
# create a to-do database
|
|
110
|
-
settings.db =
|
|
109
|
+
settings.db = TodoDatabase.CreateTodoDatabase()
|
|
111
110
|
|
|
112
111
|
# create a QApplication, the main window, then hand over control to Qt
|
|
113
|
-
app =
|
|
112
|
+
app = QApplication(sys.argv)
|
|
114
113
|
_ = MainWindow.CreateMainWindow()
|
|
115
114
|
sys.exit(app.exec())
|
|
116
115
|
|
pytodo-qt-0.2.0/src/todo/core/TodoDataBase.py → pytodo-qt-0.2.1/src/todo/core/TodoDatabase.py
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""TodoDatabase.py
|
|
2
2
|
|
|
3
3
|
This module implements the to-do database.
|
|
4
4
|
"""
|
|
@@ -8,15 +8,15 @@ import os
|
|
|
8
8
|
import sys
|
|
9
9
|
import threading
|
|
10
10
|
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
11
|
+
from ..core import settings
|
|
12
|
+
from ..core.Logger import Logger
|
|
13
|
+
from ..net import tcp_server_lib, tcp_client_lib
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
logger = Logger(__name__)
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
class
|
|
19
|
+
class CreateTodoDatabase:
|
|
20
20
|
"""Maintains a database of to-do lists."""
|
|
21
21
|
|
|
22
22
|
def __init__(self):
|
|
@@ -5,10 +5,10 @@ todo.core: A decorator to make security checks on the to-do database.
|
|
|
5
5
|
|
|
6
6
|
import sys
|
|
7
7
|
|
|
8
|
-
from
|
|
8
|
+
from PyQt6.QtWidgets import QMessageBox
|
|
9
9
|
|
|
10
|
-
from
|
|
11
|
-
from
|
|
10
|
+
from ..core import settings
|
|
11
|
+
from ..core.Logger import Logger
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def error_on_none_db(func):
|
|
@@ -28,7 +28,7 @@ def error_on_none_db(func):
|
|
|
28
28
|
return
|
|
29
29
|
else:
|
|
30
30
|
msg = "Database does not exist, exiting"
|
|
31
|
-
|
|
31
|
+
QMessageBox.critical(None, "Database Error", msg)
|
|
32
32
|
logger.log.exception(msg)
|
|
33
33
|
sys.exit(1)
|
|
34
34
|
|
|
@@ -3,16 +3,24 @@
|
|
|
3
3
|
Simple dialog to create a to-do.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from
|
|
6
|
+
from PyQt6.QtWidgets import (
|
|
7
|
+
QDialog,
|
|
8
|
+
QLabel,
|
|
9
|
+
QLineEdit,
|
|
10
|
+
QComboBox,
|
|
11
|
+
QPushButton,
|
|
12
|
+
QVBoxLayout,
|
|
13
|
+
QMessageBox,
|
|
14
|
+
)
|
|
7
15
|
|
|
8
|
-
from
|
|
9
|
-
from
|
|
16
|
+
from ..core import error_on_none_db, settings
|
|
17
|
+
from ..core.Logger import Logger
|
|
10
18
|
|
|
11
19
|
|
|
12
20
|
logger = Logger(__name__)
|
|
13
21
|
|
|
14
22
|
|
|
15
|
-
class AddTodoDialog(
|
|
23
|
+
class AddTodoDialog(QDialog):
|
|
16
24
|
"""Create a new to-do."""
|
|
17
25
|
|
|
18
26
|
def __init__(self):
|
|
@@ -25,20 +33,20 @@ class AddTodoDialog(QtWidgets.QDialog):
|
|
|
25
33
|
super().__init__()
|
|
26
34
|
|
|
27
35
|
# reminder
|
|
28
|
-
reminder_label =
|
|
29
|
-
self.reminder_field =
|
|
36
|
+
reminder_label = QLabel("Reminder", self)
|
|
37
|
+
self.reminder_field = QLineEdit(self)
|
|
30
38
|
|
|
31
39
|
# priority
|
|
32
|
-
priority_label =
|
|
33
|
-
self.priority_field =
|
|
40
|
+
priority_label = QLabel("Priority", self)
|
|
41
|
+
self.priority_field = QComboBox(self)
|
|
34
42
|
self.priority_field.addItems(["Low", "Normal", "High"])
|
|
35
43
|
|
|
36
44
|
# add button
|
|
37
|
-
self.add_button =
|
|
45
|
+
self.add_button = QPushButton("Add to-do", self)
|
|
38
46
|
self.add_button.clicked.connect(self.get_todo)
|
|
39
47
|
|
|
40
48
|
# create a vertical box layout
|
|
41
|
-
v_box =
|
|
49
|
+
v_box = QVBoxLayout()
|
|
42
50
|
v_box.addWidget(reminder_label)
|
|
43
51
|
v_box.addWidget(self.reminder_field)
|
|
44
52
|
v_box.addWidget(priority_label)
|
|
@@ -53,13 +61,11 @@ class AddTodoDialog(QtWidgets.QDialog):
|
|
|
53
61
|
logger.log.info("Add to-do dialog created")
|
|
54
62
|
|
|
55
63
|
@error_on_none_db
|
|
56
|
-
def get_todo(self):
|
|
64
|
+
def get_todo(self, *args, **kwargs):
|
|
57
65
|
"""Get to-do information and append it to the current list."""
|
|
58
66
|
reminder = self.reminder_field.text()
|
|
59
67
|
if reminder == "":
|
|
60
|
-
|
|
61
|
-
self, "Empty reminder", "Reminder cannot be empty"
|
|
62
|
-
)
|
|
68
|
+
QMessageBox.information(self, "Empty reminder", "Reminder cannot be empty")
|
|
63
69
|
return
|
|
64
70
|
|
|
65
71
|
# get to-do information
|
|
@@ -6,134 +6,132 @@ This module implements the GUI for To-Do.
|
|
|
6
6
|
import os
|
|
7
7
|
import sys
|
|
8
8
|
|
|
9
|
-
from
|
|
10
|
-
|
|
11
|
-
from
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
from PyQt6.QtCore import QPersistentModelIndex
|
|
10
|
+
from PyQt6.QtGui import QAction, QIcon, QFont
|
|
11
|
+
from PyQt6.QtWidgets import (
|
|
12
|
+
QMainWindow,
|
|
13
|
+
QMenu,
|
|
14
|
+
QTableWidget,
|
|
15
|
+
QComboBox,
|
|
16
|
+
QToolTip,
|
|
17
|
+
QMessageBox,
|
|
18
|
+
QProgressBar,
|
|
19
|
+
QLabel,
|
|
20
|
+
QLineEdit,
|
|
21
|
+
QSystemTrayIcon,
|
|
22
|
+
)
|
|
23
|
+
from PyQt6.QtPrintSupport import QPrinter
|
|
24
|
+
|
|
25
|
+
from ..core import error_on_none_db, settings, json_helpers
|
|
26
|
+
from ..core.Logger import Logger
|
|
27
|
+
from ..gui.AddTodoDialog import AddTodoDialog
|
|
28
|
+
from ..gui.SyncDialog import SyncDialog
|
|
29
|
+
from ..net.sync_operations import sync_operations
|
|
16
30
|
|
|
17
31
|
|
|
18
32
|
logger = Logger(__name__)
|
|
19
33
|
|
|
20
34
|
|
|
21
|
-
class CreateMainWindow(
|
|
35
|
+
class CreateMainWindow(QMainWindow):
|
|
22
36
|
"""This class implements the bulk of the gui functionality in To-Do.
|
|
23
37
|
|
|
24
38
|
It creates the main window, and helps to facilitate management of the
|
|
25
39
|
list database for the user.
|
|
26
40
|
"""
|
|
27
41
|
|
|
28
|
-
def __init__(self, *args):
|
|
42
|
+
def __init__(self, *args, **kwargs):
|
|
29
43
|
"""Create the window, make a table, fill table with to-do data."""
|
|
30
44
|
logger.log.info("Creating the main window")
|
|
31
45
|
|
|
32
46
|
# create the window, set title and tooltip, resize and center window
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
# QMainWindow.__init__(self)
|
|
48
|
+
super().__init__()
|
|
49
|
+
self.setWindowIcon(QIcon("gui/icons/todo.png"))
|
|
35
50
|
self.setWindowTitle("To-Do")
|
|
36
51
|
self.setToolTip("Python3 + Qt5 = Happy <u>To-Do</u> Programmer!")
|
|
37
|
-
|
|
52
|
+
QToolTip.setFont(QFont("Helvetica", 10))
|
|
38
53
|
self.resize(800, 500)
|
|
39
54
|
self.center()
|
|
40
55
|
|
|
41
56
|
# create our special font
|
|
42
|
-
self.complete_font =
|
|
57
|
+
self.complete_font = QFont("Helvetica", 10)
|
|
58
|
+
self.complete_font.setBold(True)
|
|
43
59
|
self.complete_font.setStrikeOut(True)
|
|
44
60
|
|
|
45
61
|
# create our normal font
|
|
46
|
-
self.normal_font =
|
|
62
|
+
self.normal_font = QFont("Helvetica", 10)
|
|
47
63
|
self.normal_font.setStrikeOut(False)
|
|
48
64
|
|
|
49
65
|
# create some actions
|
|
50
|
-
printer =
|
|
66
|
+
printer = QAction(QIcon(), "Print", self)
|
|
51
67
|
printer.setShortcut("Ctrl+P")
|
|
52
|
-
printer.triggered.connect(self.
|
|
68
|
+
printer.triggered.connect(self.printlist)
|
|
53
69
|
|
|
54
|
-
export =
|
|
70
|
+
export = QAction(QIcon(), "Export to Text File", self)
|
|
55
71
|
export.setShortcut("Ctrl+E")
|
|
56
72
|
export.triggered.connect(self.export_list)
|
|
57
73
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
74
|
+
quit = QAction(QIcon(), "Exit", self)
|
|
75
|
+
quit.setShortcut("Ctrl+Q")
|
|
76
|
+
quit.triggered.connect(self.close)
|
|
61
77
|
|
|
62
78
|
# to-do actions
|
|
63
|
-
add =
|
|
64
|
-
QtGui.QIcon("gui/icons/plus.png"), "Add new to-do", self
|
|
65
|
-
)
|
|
79
|
+
add = QAction(QIcon("gui/icons/plus.png"), "Add new to-do", self)
|
|
66
80
|
add.setShortcut("+")
|
|
67
81
|
add.triggered.connect(self.add_todo)
|
|
68
82
|
|
|
69
|
-
delete =
|
|
70
|
-
QtGui.QIcon("gui/icons/minus.png"), "Delete to-do", self
|
|
71
|
-
)
|
|
83
|
+
delete = QAction(QIcon("gui/icons/minus.png"), "Delete to-do", self)
|
|
72
84
|
delete.setShortcut("-")
|
|
73
85
|
delete.triggered.connect(self.delete_todo)
|
|
74
86
|
|
|
75
|
-
toggle =
|
|
76
|
-
QtGui.QIcon("gui/icons/todo.png"), "Toggle to-do Status", self
|
|
77
|
-
)
|
|
87
|
+
toggle = QAction(QIcon("gui/icons/todo.png"), "Toggle to-do Status", self)
|
|
78
88
|
toggle.setShortcut("%")
|
|
79
89
|
toggle.triggered.connect(self.toggle_todo)
|
|
80
90
|
|
|
81
91
|
# list actions
|
|
82
|
-
list_add =
|
|
92
|
+
list_add = QAction(QIcon(), "Add new list", self)
|
|
83
93
|
list_add.setShortcut("Ctrl++")
|
|
84
94
|
list_add.triggered.connect(self.add_list)
|
|
85
95
|
|
|
86
|
-
list_delete =
|
|
87
|
-
QtGui.QIcon("gui/icons/minus.png"), "Delete list", self
|
|
88
|
-
)
|
|
96
|
+
list_delete = QAction(QIcon("gui/icons/minus.png"), "Delete list", self)
|
|
89
97
|
|
|
90
98
|
list_delete.setShortcut("Ctrl+-")
|
|
91
99
|
list_delete.triggered.connect(self.delete_list)
|
|
92
100
|
|
|
93
|
-
list_rename =
|
|
101
|
+
list_rename = QAction(QIcon(), "Rename list", self)
|
|
94
102
|
list_rename.setShortcut("Ctrl+R")
|
|
95
103
|
list_rename.triggered.connect(self.rename_list)
|
|
96
104
|
|
|
97
|
-
list_switch =
|
|
105
|
+
list_switch = QAction(QIcon(), "Switch List", self)
|
|
98
106
|
list_switch.setShortcut("Ctrl+L")
|
|
99
107
|
list_switch.triggered.connect(self.switch_list)
|
|
100
108
|
|
|
101
|
-
sync_pull =
|
|
102
|
-
QtGui.QIcon(), "Get lists from another computer", self
|
|
103
|
-
)
|
|
109
|
+
sync_pull = QAction(QIcon(), "Get lists from another computer", self)
|
|
104
110
|
sync_pull.setShortcut("F6")
|
|
105
111
|
sync_pull.triggered.connect(self.db_sync_pull)
|
|
106
112
|
|
|
107
|
-
sync_push =
|
|
108
|
-
QtGui.QIcon(), "Send lists to another computer", self
|
|
109
|
-
)
|
|
113
|
+
sync_push = QAction(QIcon(), "Send lists to another computer", self)
|
|
110
114
|
sync_push.setShortcut("F7")
|
|
111
115
|
sync_push.triggered.connect(self.db_sync_push)
|
|
112
116
|
|
|
113
117
|
# network server actions
|
|
114
|
-
start_server =
|
|
115
|
-
QtGui.QIcon(), "Start the network server", self
|
|
116
|
-
)
|
|
118
|
+
start_server = QAction(QIcon(), "Start the network server", self)
|
|
117
119
|
start_server.triggered.connect(self.db_start_server)
|
|
118
120
|
|
|
119
|
-
stop_server =
|
|
121
|
+
stop_server = QAction(QIcon(), "Stop the network server", self)
|
|
120
122
|
stop_server.triggered.connect(self.db_stop_server)
|
|
121
123
|
|
|
122
|
-
change_port =
|
|
123
|
-
QtGui.QIcon(), "Change network server port", self
|
|
124
|
-
)
|
|
124
|
+
change_port = QAction(QIcon(), "Change network server port", self)
|
|
125
125
|
change_port.triggered.connect(self.db_server_port)
|
|
126
126
|
|
|
127
|
-
change_bind_address =
|
|
128
|
-
QtGui.QIcon(), "Change network server address", self
|
|
129
|
-
)
|
|
127
|
+
change_bind_address = QAction(QIcon(), "Change network server address", self)
|
|
130
128
|
change_bind_address.triggered.connect(self.db_server_bind_address)
|
|
131
129
|
|
|
132
130
|
# fanfare
|
|
133
|
-
about =
|
|
131
|
+
about = QAction(QIcon(), "About To-Do", self)
|
|
134
132
|
about.triggered.connect(self.about_todo)
|
|
135
133
|
|
|
136
|
-
about_qt =
|
|
134
|
+
about_qt = QAction(QIcon(), "About Qt", self)
|
|
137
135
|
about_qt.triggered.connect(self.about_qt)
|
|
138
136
|
|
|
139
137
|
# create a menu bar
|
|
@@ -143,18 +141,12 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
143
141
|
if main_menu is not None:
|
|
144
142
|
main_menu.addAction(printer)
|
|
145
143
|
main_menu.addAction(export)
|
|
146
|
-
main_menu.addAction(
|
|
144
|
+
main_menu.addAction(quit)
|
|
147
145
|
else:
|
|
148
146
|
msg = "Could not populate main menu, exiting"
|
|
149
|
-
|
|
147
|
+
QMessageBox.warning(self, "Creation Error", msg)
|
|
150
148
|
logger.log.exception(msg)
|
|
151
|
-
else:
|
|
152
|
-
msg = "Could not create menu bar, exiting"
|
|
153
|
-
QtWidgets.QMessageBox.warning(self, "Creation Error", msg)
|
|
154
|
-
logger.log.exception(msg)
|
|
155
|
-
sys.exit(1)
|
|
156
149
|
|
|
157
|
-
if menu_bar is not None:
|
|
158
150
|
todo_menu = menu_bar.addMenu("&To-Do")
|
|
159
151
|
if todo_menu is not None:
|
|
160
152
|
todo_menu.addAction(add)
|
|
@@ -162,16 +154,10 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
162
154
|
todo_menu.addAction(toggle)
|
|
163
155
|
else:
|
|
164
156
|
msg = "Could not populate to-do menu, exiting"
|
|
165
|
-
|
|
157
|
+
QMessageBox.warning(self, "Creation Error", msg)
|
|
166
158
|
logger.log.exception(msg)
|
|
167
159
|
sys.exit(1)
|
|
168
|
-
else:
|
|
169
|
-
msg = "Menu bar error, exiting"
|
|
170
|
-
QtWidgets.QMessageBox.warning(self, "Creation Error", msg)
|
|
171
|
-
logger.log.exception(msg)
|
|
172
|
-
sys.exit(1)
|
|
173
160
|
|
|
174
|
-
if menu_bar is not None:
|
|
175
161
|
list_menu = menu_bar.addMenu("&List")
|
|
176
162
|
if list_menu is not None:
|
|
177
163
|
list_menu.addAction(list_add)
|
|
@@ -180,80 +166,50 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
180
166
|
list_menu.addAction(list_switch)
|
|
181
167
|
else:
|
|
182
168
|
msg = "Could not populate list menu, exiting"
|
|
183
|
-
|
|
169
|
+
QMessageBox.warning(self, "Creation Error", msg)
|
|
184
170
|
logger.log.exception(msg)
|
|
185
171
|
sys.exit(1)
|
|
186
|
-
else:
|
|
187
|
-
msg = "Menu bar error, exiting"
|
|
188
|
-
QtWidgets.QMessageBox.warning(self, "Creation Error", msg)
|
|
189
|
-
logger.log.exception(msg)
|
|
190
|
-
sys.exit(1)
|
|
191
172
|
|
|
192
|
-
if menu_bar is not None:
|
|
193
173
|
sync_menu = menu_bar.addMenu("&Sync")
|
|
194
174
|
if sync_menu is not None:
|
|
195
175
|
sync_menu.addAction(sync_pull)
|
|
196
176
|
sync_menu.addAction(sync_push)
|
|
197
177
|
else:
|
|
198
178
|
msg = "Could not populate sync menu, exiting"
|
|
199
|
-
|
|
200
|
-
logger.log.exception(msg)
|
|
201
|
-
sys.exit(1)
|
|
202
|
-
else:
|
|
203
|
-
msg = "Menu bar error, exiting"
|
|
204
|
-
QtWidgets.QMessageBox.warning(self, "Creation Error", msg)
|
|
205
|
-
logger.log.exception(msg)
|
|
206
|
-
sys.exit(1)
|
|
207
|
-
|
|
208
|
-
if menu_bar is not None:
|
|
209
|
-
server_menu = menu_bar.addMenu("&Server")
|
|
210
|
-
if server_menu is not None:
|
|
211
|
-
server_menu.addAction(start_server)
|
|
212
|
-
server_menu.addAction(stop_server)
|
|
213
|
-
server_menu.addAction(change_port)
|
|
214
|
-
server_menu.addAction(change_bind_address)
|
|
215
|
-
else:
|
|
216
|
-
msg = "Could not populate server menu, exiting"
|
|
217
|
-
QtWidgets.QMessageBox.warning(self, "Creation Error", msg)
|
|
179
|
+
QMessageBox.warning(self, "Creation Error", msg)
|
|
218
180
|
logger.log.exception(msg)
|
|
219
181
|
sys.exit(1)
|
|
220
|
-
else:
|
|
221
|
-
msg = "Menu bar error, exiting"
|
|
222
|
-
QtWidgets.QMessageBox.warning(self, "Creation Error", msg)
|
|
223
|
-
logger.log.exception(msg)
|
|
224
|
-
sys.exit(1)
|
|
225
182
|
|
|
226
|
-
if menu_bar is not None:
|
|
227
183
|
help_menu = menu_bar.addMenu("&Help")
|
|
228
184
|
if help_menu is not None:
|
|
229
185
|
help_menu.addAction(about)
|
|
230
186
|
help_menu.addAction(about_qt)
|
|
231
187
|
else:
|
|
232
188
|
msg = "Could not populate help menu, exiting"
|
|
233
|
-
|
|
189
|
+
QMessageBox.warning(self, "Creation Error", msg)
|
|
234
190
|
logger.log.exception(msg)
|
|
235
191
|
sys.exit(1)
|
|
236
|
-
else:
|
|
237
|
-
msg = "Menu bar error, exiting"
|
|
238
|
-
QtWidgets.QMessageBox.warning(self, "Creation Error", msg)
|
|
239
|
-
logger.log.exception(msg)
|
|
240
|
-
sys.exit(1)
|
|
241
192
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
193
|
+
# create action toolbar
|
|
194
|
+
toolbar = self.addToolBar("To-Do Actions")
|
|
195
|
+
if toolbar is not None:
|
|
196
|
+
toolbar.addAction(add)
|
|
197
|
+
toolbar.addAction(delete)
|
|
198
|
+
toolbar.addAction(toggle)
|
|
199
|
+
toolbar.addAction(quit)
|
|
200
|
+
else:
|
|
201
|
+
msg = "Could not create toolbar, exiting"
|
|
202
|
+
QMessageBox.warning(self, "Creation Error", msg)
|
|
203
|
+
logger.log.exception(msg)
|
|
204
|
+
sys.exit(1)
|
|
249
205
|
else:
|
|
250
|
-
msg = "Could not create
|
|
251
|
-
|
|
206
|
+
msg = "Could not create menu bar, exiting"
|
|
207
|
+
QMessageBox.warning(self, "Creation Error", msg)
|
|
252
208
|
logger.log.exception(msg)
|
|
253
209
|
sys.exit(1)
|
|
254
210
|
|
|
255
211
|
# create table, set it as central widget
|
|
256
|
-
self.table =
|
|
212
|
+
self.table = QTableWidget(self)
|
|
257
213
|
if self.table is not None:
|
|
258
214
|
self.table.insertColumn(0)
|
|
259
215
|
self.table.insertColumn(1)
|
|
@@ -263,45 +219,50 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
263
219
|
self.setCentralWidget(self.table)
|
|
264
220
|
else:
|
|
265
221
|
msg = "Could not create to-do list table, exiting"
|
|
266
|
-
|
|
222
|
+
QMessageBox.critical(self, "Creation Error", msg)
|
|
267
223
|
logger.log.exception(msg)
|
|
268
224
|
sys.exit(1)
|
|
269
225
|
|
|
270
226
|
# create a status bar
|
|
271
|
-
self.progressBar =
|
|
272
|
-
self.statusBarLabel =
|
|
227
|
+
self.progressBar = QProgressBar()
|
|
228
|
+
self.statusBarLabel = QLabel()
|
|
273
229
|
self.statusBar = self.statusBar()
|
|
274
230
|
if self.statusBar is not None:
|
|
275
231
|
self.statusBar.addPermanentWidget(self.progressBar)
|
|
276
232
|
self.statusBar.addPermanentWidget(self.statusBarLabel, 1)
|
|
277
233
|
else:
|
|
278
234
|
msg = "Could not create status bar, exiting"
|
|
279
|
-
|
|
235
|
+
QMessageBox.critical(self, "Creation Error", msg)
|
|
280
236
|
logger.log.exception(msg)
|
|
281
237
|
sys.exit(1)
|
|
282
238
|
|
|
283
|
-
#
|
|
284
|
-
self.tray_icon =
|
|
285
|
-
|
|
286
|
-
)
|
|
287
|
-
self.tray_icon.activated.connect(self.tray_event)
|
|
239
|
+
# system tray icon
|
|
240
|
+
self.tray_icon = QSystemTrayIcon(self)
|
|
241
|
+
self.tray_icon.setIcon(QIcon("gui/icons/todo.png"))
|
|
288
242
|
|
|
289
|
-
|
|
290
|
-
|
|
243
|
+
# system tray menu actions
|
|
244
|
+
show_action = QAction("Show", self)
|
|
245
|
+
quit_action = QAction("Exit", self)
|
|
246
|
+
hide_action = QAction("Hide", self)
|
|
247
|
+
show_action.triggered.connect(self.show)
|
|
248
|
+
hide_action.triggered.connect(self.hide)
|
|
249
|
+
quit_action.triggered.connect(self.close)
|
|
291
250
|
|
|
292
|
-
tray_menu =
|
|
251
|
+
tray_menu = QMenu("&To-Do", self)
|
|
293
252
|
if tray_menu is not None:
|
|
294
|
-
tray_menu.addAction(
|
|
253
|
+
tray_menu.addAction(show_action)
|
|
254
|
+
tray_menu.addAction(hide_action)
|
|
255
|
+
tray_menu.addAction(quit_action)
|
|
295
256
|
self.tray_icon.setContextMenu(tray_menu)
|
|
296
257
|
self.tray_icon.show()
|
|
297
258
|
else:
|
|
298
259
|
msg = "Could not create status tray menu, exiting"
|
|
299
|
-
|
|
260
|
+
QMessageBox.critical(self, "Creation Error", msg)
|
|
300
261
|
logger.log.exception(msg)
|
|
301
262
|
sys.exit(1)
|
|
302
263
|
|
|
303
|
-
# create a printer
|
|
304
|
-
self.printer =
|
|
264
|
+
# create a printer
|
|
265
|
+
self.printer = QPrinter()
|
|
305
266
|
|
|
306
267
|
# show the window
|
|
307
268
|
self.show()
|
|
@@ -321,7 +282,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
321
282
|
self.update_status_bar("Reading in JSON data")
|
|
322
283
|
result, msg = json_helpers.read_json_data()
|
|
323
284
|
if not result:
|
|
324
|
-
|
|
285
|
+
QMessageBox.warning(self, "Read Error", str(msg))
|
|
325
286
|
self.update_progress_bar()
|
|
326
287
|
self.update_status_bar()
|
|
327
288
|
else:
|
|
@@ -334,7 +295,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
334
295
|
"""Write to-do lists to a JSON file."""
|
|
335
296
|
if len(settings.db.todo_lists.keys()) == 0:
|
|
336
297
|
msg = "No to-do information, aborting write"
|
|
337
|
-
|
|
298
|
+
QMessageBox.warning(self, "Write Error", msg)
|
|
338
299
|
return
|
|
339
300
|
|
|
340
301
|
self.update_progress_bar(0)
|
|
@@ -342,7 +303,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
342
303
|
|
|
343
304
|
result, msg = json_helpers.write_json_data()
|
|
344
305
|
if not result:
|
|
345
|
-
|
|
306
|
+
QMessageBox.warning(self, "Write Error", msg)
|
|
346
307
|
self.update_progress_bar()
|
|
347
308
|
self.update_status_bar()
|
|
348
309
|
|
|
@@ -369,63 +330,55 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
369
330
|
settings.db.active_list = list_name
|
|
370
331
|
result, msg = settings.db.write_config()
|
|
371
332
|
if not result:
|
|
372
|
-
|
|
333
|
+
QMessageBox.critical(self, "Write Error", msg)
|
|
373
334
|
sys.exit(1)
|
|
374
335
|
else:
|
|
375
|
-
|
|
336
|
+
QMessageBox.information(self, "Write Success", msg)
|
|
376
337
|
|
|
377
338
|
@error_on_none_db
|
|
378
339
|
def db_start_server(self, *args, **kwargs):
|
|
379
340
|
"""Start the database server."""
|
|
380
341
|
if settings.db.server_running():
|
|
381
|
-
|
|
342
|
+
QMessageBox.information(
|
|
382
343
|
self, "Info", "The database server is already running."
|
|
383
344
|
)
|
|
384
345
|
else:
|
|
385
346
|
settings.db.start_server()
|
|
386
|
-
|
|
387
|
-
self, "Info", "The database server was started."
|
|
388
|
-
)
|
|
347
|
+
QMessageBox.information(self, "Info", "The database server was started.")
|
|
389
348
|
self.refresh()
|
|
390
349
|
|
|
391
350
|
@error_on_none_db
|
|
392
351
|
def db_stop_server(self, *args, **kwargs):
|
|
393
352
|
"""Stop the database server."""
|
|
394
353
|
if not settings.db.server_running():
|
|
395
|
-
|
|
396
|
-
self, "Info", "The database server is not running."
|
|
397
|
-
)
|
|
354
|
+
QMessageBox.information(self, "Info", "The database server is not running.")
|
|
398
355
|
else:
|
|
399
356
|
settings.db.stop_server()
|
|
400
|
-
|
|
401
|
-
self, "Info", "The database server was stopped."
|
|
402
|
-
)
|
|
357
|
+
QMessageBox.information(self, "Info", "The database server was stopped.")
|
|
403
358
|
self.refresh()
|
|
404
359
|
|
|
405
360
|
@error_on_none_db
|
|
406
361
|
def db_server_port(self, *args, **kwargs):
|
|
407
362
|
"""Change the port the database server listens too."""
|
|
408
|
-
port, ok =
|
|
409
|
-
self, "Change database server port", "Port: "
|
|
410
|
-
)
|
|
363
|
+
port, ok = QInputDialog.getInt(self, "Change database server port", "Port: ")
|
|
411
364
|
if not ok:
|
|
412
365
|
return
|
|
413
366
|
|
|
414
367
|
if settings.options["port"] == port:
|
|
415
|
-
|
|
368
|
+
QMessageBox.information(
|
|
416
369
|
self, "Info", f"Server is already using port {port}"
|
|
417
370
|
)
|
|
418
371
|
else:
|
|
419
372
|
settings.options["port"] = port
|
|
420
373
|
if settings.db.server_running():
|
|
421
|
-
reply =
|
|
374
|
+
reply = QMessageBox.question(
|
|
422
375
|
self,
|
|
423
376
|
"Restart Database Server?",
|
|
424
377
|
"The server needs to be restarted for changes to take effect, would you like to do that now?",
|
|
425
|
-
|
|
426
|
-
|
|
378
|
+
QMessageBox.StandardButton.Yes,
|
|
379
|
+
QMessageBox.StandardButton.No,
|
|
427
380
|
)
|
|
428
|
-
if reply ==
|
|
381
|
+
if reply == QMessageBox.StandardButton.Yes:
|
|
429
382
|
settings.db.restart_server()
|
|
430
383
|
settings.db.write_config()
|
|
431
384
|
self.refresh()
|
|
@@ -433,27 +386,27 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
433
386
|
@error_on_none_db
|
|
434
387
|
def db_server_bind_address(self, *args, **kwargs):
|
|
435
388
|
"""Bind database server to an ip address."""
|
|
436
|
-
address, ok =
|
|
389
|
+
address, ok = QInputDialog.getText(
|
|
437
390
|
self, "Change server ip address", "IP Address: "
|
|
438
391
|
)
|
|
439
392
|
if not ok:
|
|
440
393
|
return
|
|
441
394
|
|
|
442
395
|
if settings.options["address"] == address:
|
|
443
|
-
|
|
396
|
+
QMessageBox.information(
|
|
444
397
|
self, "Info", f"Server is already bound to {address}"
|
|
445
398
|
)
|
|
446
399
|
else:
|
|
447
400
|
settings.options["address"] = address
|
|
448
401
|
if settings.db.server_running():
|
|
449
|
-
reply =
|
|
402
|
+
reply = QMessageBox.question(
|
|
450
403
|
self,
|
|
451
404
|
"Restart Database Server?",
|
|
452
405
|
"The server needs to be restarted for changes to take effect, would you like to do that now?",
|
|
453
|
-
|
|
454
|
-
|
|
406
|
+
QMessageBox.StandardButton.Yes,
|
|
407
|
+
QMessageBox.StandardButton.No,
|
|
455
408
|
)
|
|
456
|
-
if reply ==
|
|
409
|
+
if reply == QMessageBox.StandardButton.Yes:
|
|
457
410
|
settings.db.restart_server()
|
|
458
411
|
settings.db.write_config()
|
|
459
412
|
self.refresh()
|
|
@@ -464,7 +417,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
464
417
|
self.update_progress_bar(0)
|
|
465
418
|
self.update_status_bar("Waiting for input")
|
|
466
419
|
|
|
467
|
-
list_name, ok =
|
|
420
|
+
list_name, ok = QInputDialog.getText(
|
|
468
421
|
self, "Add New List", "Enter a name for the new list: "
|
|
469
422
|
)
|
|
470
423
|
if ok:
|
|
@@ -480,7 +433,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
480
433
|
settings.db.write_config()
|
|
481
434
|
self.write_todo_data()
|
|
482
435
|
else:
|
|
483
|
-
|
|
436
|
+
QMessageBox.warning(
|
|
484
437
|
self,
|
|
485
438
|
"Duplicate List",
|
|
486
439
|
f'A list named "{list_name}" already exists.',
|
|
@@ -495,7 +448,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
495
448
|
|
|
496
449
|
# if there is more than one list, ask user which one to delete
|
|
497
450
|
if len(settings.db.todo_lists.keys()) > 1:
|
|
498
|
-
list_entry, ok =
|
|
451
|
+
list_entry, ok = QInputDialog.getItem(
|
|
499
452
|
self,
|
|
500
453
|
"Select List",
|
|
501
454
|
"To-Do Lists: ",
|
|
@@ -517,14 +470,14 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
517
470
|
self.write_todo_data()
|
|
518
471
|
break
|
|
519
472
|
else:
|
|
520
|
-
reply =
|
|
473
|
+
reply = QMessageBox.question(
|
|
521
474
|
self,
|
|
522
475
|
"Confirm deletion",
|
|
523
476
|
f'Really delete list "{settings.db.active_list}"?',
|
|
524
|
-
|
|
525
|
-
|
|
477
|
+
QMessageBox.StandardButton.Yes,
|
|
478
|
+
QMessageBox.StandardButton.No,
|
|
526
479
|
)
|
|
527
|
-
if reply ==
|
|
480
|
+
if reply == QMessageBox.StandardButton.No:
|
|
528
481
|
self.update_progress_bar()
|
|
529
482
|
return
|
|
530
483
|
|
|
@@ -547,19 +500,19 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
547
500
|
"""Rename the active list"""
|
|
548
501
|
self.update_progress_bar(0)
|
|
549
502
|
|
|
550
|
-
list_name, ok =
|
|
503
|
+
list_name, ok = QInputDialog.getText(
|
|
551
504
|
self, "Rename to-do list", "Enter new name:"
|
|
552
505
|
)
|
|
553
506
|
if ok:
|
|
554
|
-
reply =
|
|
507
|
+
reply = QMessageBox.question(
|
|
555
508
|
self,
|
|
556
509
|
"Confirm rename",
|
|
557
510
|
f"Are you sure you want to rename list {settings.db.active_list} to {list_name}",
|
|
558
|
-
|
|
559
|
-
|
|
511
|
+
QMessageBox.StandardButton.Yes,
|
|
512
|
+
QMessageBox.StandardButton.No,
|
|
560
513
|
)
|
|
561
514
|
|
|
562
|
-
if reply ==
|
|
515
|
+
if reply == QMessageBox.StandardButton.No:
|
|
563
516
|
return
|
|
564
517
|
|
|
565
518
|
settings.db.todo_lists[list_name] = settings.db.todo_lists[
|
|
@@ -583,7 +536,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
583
536
|
if len(settings.db.todo_lists.keys()) == 0:
|
|
584
537
|
return
|
|
585
538
|
|
|
586
|
-
list_entry, ok =
|
|
539
|
+
list_entry, ok = QInputDialog.getItem(
|
|
587
540
|
self, "Select List", "To-Do Lists: ", list(settings.db.todo_lists.keys())
|
|
588
541
|
)
|
|
589
542
|
if ok:
|
|
@@ -603,7 +556,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
603
556
|
if fn is None:
|
|
604
557
|
# prompt user for fn
|
|
605
558
|
self.update_status_bar("Waiting for input")
|
|
606
|
-
fn, ok =
|
|
559
|
+
fn, ok = QInputDialog.getText(
|
|
607
560
|
self,
|
|
608
561
|
"Save list to text file",
|
|
609
562
|
"Enter name of file to write as text:",
|
|
@@ -616,7 +569,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
616
569
|
self.update_status_bar(f"finished exporting to {fn}.")
|
|
617
570
|
self.update_progress_bar()
|
|
618
571
|
|
|
619
|
-
def
|
|
572
|
+
def printlist(self):
|
|
620
573
|
"""Print the active list."""
|
|
621
574
|
self.update_progress_bar(0)
|
|
622
575
|
|
|
@@ -627,7 +580,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
627
580
|
|
|
628
581
|
tmp_fn = ".todo_printer.tmp"
|
|
629
582
|
|
|
630
|
-
accept =
|
|
583
|
+
accept = QPrintDialog(self.printer).exec()
|
|
631
584
|
if accept:
|
|
632
585
|
self.update_status_bar("Printing")
|
|
633
586
|
|
|
@@ -646,8 +599,8 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
646
599
|
os.remove(tmp_fn)
|
|
647
600
|
|
|
648
601
|
# Open string as a QTextDocument and then print it
|
|
649
|
-
doc =
|
|
650
|
-
doc.
|
|
602
|
+
doc = QTextDocument(string)
|
|
603
|
+
doc.print(self.printer)
|
|
651
604
|
|
|
652
605
|
self.update_progress_bar()
|
|
653
606
|
self.update_status_bar("finished printing")
|
|
@@ -659,7 +612,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
659
612
|
|
|
660
613
|
if not settings.db.active_list:
|
|
661
614
|
if settings.db.list_count == 0:
|
|
662
|
-
|
|
615
|
+
QMessageBox.information(
|
|
663
616
|
self,
|
|
664
617
|
"No list",
|
|
665
618
|
"You need to create a list before you add a reminder",
|
|
@@ -670,17 +623,17 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
670
623
|
else:
|
|
671
624
|
# ask the user if they would like to switch to an existing list
|
|
672
625
|
self.update_status_bar("Waiting for input")
|
|
673
|
-
reply =
|
|
626
|
+
reply = QMessageBox.question(
|
|
674
627
|
self,
|
|
675
628
|
"Set an active list",
|
|
676
629
|
"There is currently no active list set, but lists do exist,"
|
|
677
630
|
"would you like to switch to one of them?",
|
|
678
|
-
|
|
679
|
-
|
|
631
|
+
QMessageBox.StandardButton.Yes,
|
|
632
|
+
QMessageBox.StandardButton.No,
|
|
680
633
|
)
|
|
681
634
|
|
|
682
635
|
# check the user response
|
|
683
|
-
if reply ==
|
|
636
|
+
if reply == QMessageBox.StandardButton.Yes:
|
|
684
637
|
self.switch_list()
|
|
685
638
|
else:
|
|
686
639
|
return
|
|
@@ -697,13 +650,13 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
697
650
|
|
|
698
651
|
if self.table is None:
|
|
699
652
|
msg = "To-Do List Table is invalid, exiting"
|
|
700
|
-
|
|
653
|
+
QMessageBox.critical(self, "To-Do List Error", msg)
|
|
701
654
|
logger.log.exception(msg)
|
|
702
655
|
sys.exit(1)
|
|
703
656
|
else:
|
|
704
657
|
if self.table.selectionModel().hasSelection():
|
|
705
658
|
indices = [
|
|
706
|
-
|
|
659
|
+
QPersistentModelIndex(index)
|
|
707
660
|
for index in self.table.selectionModel().selectedIndexes()
|
|
708
661
|
]
|
|
709
662
|
for index in indices:
|
|
@@ -717,9 +670,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
717
670
|
self.table.removeRow(index.row())
|
|
718
671
|
self.refresh()
|
|
719
672
|
else:
|
|
720
|
-
|
|
721
|
-
self, "Delete To-Do", "No reminders selected."
|
|
722
|
-
)
|
|
673
|
+
QMessageBox.warning(self, "Delete To-Do", "No reminders selected.")
|
|
723
674
|
|
|
724
675
|
@error_on_none_db
|
|
725
676
|
def toggle_todo(self, *args, **kwargs):
|
|
@@ -779,16 +730,16 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
779
730
|
<br><br>License: <a href="http://www.fsf.org/licenses/gpl.html">GPLv3</a>
|
|
780
731
|
<br><br><b>Copyright (C) 2024 Michael Berry</b>
|
|
781
732
|
"""
|
|
782
|
-
|
|
733
|
+
QMessageBox.about(self, "About To-Do", text)
|
|
783
734
|
|
|
784
735
|
def about_qt(self):
|
|
785
736
|
"""Display information about Qt."""
|
|
786
|
-
|
|
737
|
+
QMessageBox.aboutQt(self, "About Qt")
|
|
787
738
|
|
|
788
739
|
def center(self):
|
|
789
740
|
"""Place the main window in the center of the screen."""
|
|
790
741
|
qt_rectangle = self.frameGeometry()
|
|
791
|
-
center_point =
|
|
742
|
+
center_point = self.screen().availableGeometry().center()
|
|
792
743
|
qt_rectangle.moveCenter(center_point)
|
|
793
744
|
self.move(qt_rectangle.topLeft())
|
|
794
745
|
|
|
@@ -857,7 +808,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
857
808
|
|
|
858
809
|
for todo in settings.db.todo_lists[settings.db.active_list]:
|
|
859
810
|
# create priority table item
|
|
860
|
-
item_p =
|
|
811
|
+
item_p = QComboBox(self)
|
|
861
812
|
item_p.addItems(["Low", "Normal", "High"])
|
|
862
813
|
item_p.currentIndexChanged.connect(self.change_priority)
|
|
863
814
|
if todo["priority"] == 1:
|
|
@@ -868,7 +819,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
868
819
|
item_p.setCurrentIndex(0)
|
|
869
820
|
|
|
870
821
|
# create reminder table item
|
|
871
|
-
item_r =
|
|
822
|
+
item_r = QLineEdit(todo["reminder"])
|
|
872
823
|
item_r.returnPressed.connect(self.edit_reminder)
|
|
873
824
|
|
|
874
825
|
# set the font
|
|
@@ -893,9 +844,9 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
893
844
|
self.update_progress_bar()
|
|
894
845
|
self.update_status_bar()
|
|
895
846
|
|
|
896
|
-
def tray_event(self, reason=
|
|
847
|
+
def tray_event(self, reason=QSystemTrayIcon.activated, *args, **kwargs):
|
|
897
848
|
"""Hide the main window when the system tray icon is clicked."""
|
|
898
|
-
if reason ==
|
|
849
|
+
if reason == QSystemTrayIcon.activated:
|
|
899
850
|
if self.isVisible():
|
|
900
851
|
self.hide()
|
|
901
852
|
else:
|
|
@@ -907,7 +858,7 @@ class CreateMainWindow(QtWidgets.QMainWindow):
|
|
|
907
858
|
# save configuration
|
|
908
859
|
result, msg = settings.db.write_config()
|
|
909
860
|
if not result:
|
|
910
|
-
|
|
861
|
+
QMessageBox.warning(self, "Write Error", msg)
|
|
911
862
|
|
|
912
863
|
# save todo lists
|
|
913
864
|
self.write_todo_data()
|
|
@@ -3,19 +3,25 @@
|
|
|
3
3
|
Simple dialog to collect information needed to perform a sync operation.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
from PyQt6.QtWidgets import (
|
|
7
|
+
QDialog,
|
|
8
|
+
QLabel,
|
|
9
|
+
QLineEdit,
|
|
10
|
+
QPushButton,
|
|
11
|
+
QVBoxLayout,
|
|
12
|
+
QMessageBox,
|
|
13
|
+
)
|
|
14
|
+
from PyQt6.QtGui import QIntValidator
|
|
7
15
|
|
|
8
|
-
from
|
|
9
|
-
|
|
10
|
-
from
|
|
11
|
-
from todo.core.Logger import Logger
|
|
12
|
-
from todo.net.sync_operations import sync_operations
|
|
16
|
+
from ..core import error_on_none_db, settings
|
|
17
|
+
from ..core.Logger import Logger
|
|
18
|
+
from ..net.sync_operations import sync_operations
|
|
13
19
|
|
|
14
20
|
|
|
15
21
|
logger = Logger(__name__)
|
|
16
22
|
|
|
17
23
|
|
|
18
|
-
class SyncDialog(
|
|
24
|
+
class SyncDialog(QDialog):
|
|
19
25
|
"""Synchronize lists with remotes."""
|
|
20
26
|
|
|
21
27
|
def __init__(self, operation=None):
|
|
@@ -30,21 +36,21 @@ class SyncDialog(QtWidgets.QDialog):
|
|
|
30
36
|
self.operation = operation
|
|
31
37
|
|
|
32
38
|
# address
|
|
33
|
-
address_label =
|
|
34
|
-
self.address_field =
|
|
39
|
+
address_label = QLabel("Host Address", self)
|
|
40
|
+
self.address_field = QLineEdit(self)
|
|
35
41
|
|
|
36
42
|
# port
|
|
37
|
-
port_label =
|
|
38
|
-
self.port_field =
|
|
43
|
+
port_label = QLabel("Port", self)
|
|
44
|
+
self.port_field = QLineEdit(self)
|
|
39
45
|
self.port_field.setText(str(settings.options["port"]))
|
|
40
|
-
self.port_field.setValidator(
|
|
46
|
+
self.port_field.setValidator(QIntValidator())
|
|
41
47
|
|
|
42
48
|
# add button
|
|
43
|
-
self.get_button =
|
|
49
|
+
self.get_button = QPushButton("Synchronize", self)
|
|
44
50
|
self.get_button.clicked.connect(self.get_host)
|
|
45
51
|
|
|
46
52
|
# create a vertical box layout
|
|
47
|
-
v_box =
|
|
53
|
+
v_box = QVBoxLayout()
|
|
48
54
|
v_box.addWidget(address_label)
|
|
49
55
|
v_box.addWidget(self.address_field)
|
|
50
56
|
v_box.addWidget(port_label)
|
|
@@ -63,17 +69,13 @@ class SyncDialog(QtWidgets.QDialog):
|
|
|
63
69
|
"""Get host information."""
|
|
64
70
|
address = self.address_field.text()
|
|
65
71
|
if address == "":
|
|
66
|
-
|
|
67
|
-
self, "Empty address", "Address cannot be empty"
|
|
68
|
-
)
|
|
72
|
+
QMessageBox.information(self, "Empty address", "Address cannot be empty")
|
|
69
73
|
return
|
|
70
74
|
|
|
71
75
|
# get remote port
|
|
72
76
|
port = self.port_field.text()
|
|
73
77
|
if port == "":
|
|
74
|
-
|
|
75
|
-
self, "Empty port", "Port cannot be empty"
|
|
76
|
-
)
|
|
78
|
+
QMessageBox.information(self, "Empty port", "Port cannot be empty")
|
|
77
79
|
return
|
|
78
80
|
|
|
79
81
|
port = int(port)
|
|
@@ -82,7 +84,7 @@ class SyncDialog(QtWidgets.QDialog):
|
|
|
82
84
|
if self.operation == sync_operations["PULL_REQUEST"].name:
|
|
83
85
|
# try the pull, inform user of the results
|
|
84
86
|
result, msg = settings.db.sync_pull((address, port))
|
|
85
|
-
|
|
87
|
+
QMessageBox.information(self, "Sync Pull", msg)
|
|
86
88
|
if not result:
|
|
87
89
|
return
|
|
88
90
|
elif self.operation == sync_operations["PUSH_REQUEST"].name:
|
|
@@ -93,7 +95,7 @@ class SyncDialog(QtWidgets.QDialog):
|
|
|
93
95
|
|
|
94
96
|
# try the push, inform user of results
|
|
95
97
|
result, msg = settings.db.sync_push((address, port))
|
|
96
|
-
|
|
98
|
+
QMessageBox.information(self, "Sync Push", msg)
|
|
97
99
|
if not pull_ok:
|
|
98
100
|
settings.options["pull"] = False
|
|
99
101
|
|
|
@@ -8,12 +8,11 @@ import os
|
|
|
8
8
|
import socket
|
|
9
9
|
import time
|
|
10
10
|
|
|
11
|
-
from
|
|
12
|
-
from
|
|
13
|
-
from
|
|
14
|
-
from
|
|
15
|
-
|
|
16
|
-
from . import recv_all
|
|
11
|
+
from ..core import settings, json_helpers
|
|
12
|
+
from ..core.Logger import Logger
|
|
13
|
+
from ..crypto.AESCipher import AESCipher
|
|
14
|
+
from ..net import recv_all
|
|
15
|
+
from ..net.sync_operations import sync_operations
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
logger = Logger(__name__)
|
|
@@ -9,11 +9,12 @@ import socketserver
|
|
|
9
9
|
import sys
|
|
10
10
|
import time
|
|
11
11
|
|
|
12
|
-
from
|
|
13
|
-
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
12
|
+
from PyQt6.QtWidgets import QMessageBox
|
|
13
|
+
|
|
14
|
+
from ..core import error_on_none_db, settings
|
|
15
|
+
from ..core.Logger import Logger
|
|
16
|
+
from ..crypto.AESCipher import AESCipher
|
|
17
|
+
from ..net.sync_operations import sync_operations
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
logger = Logger(__name__)
|
|
@@ -115,7 +116,7 @@ class TCPRequestHandler(socketserver.StreamRequestHandler):
|
|
|
115
116
|
sync_operations["REJECT"].name
|
|
116
117
|
)
|
|
117
118
|
self.request.send(self.encrypted_reply)
|
|
118
|
-
|
|
119
|
+
QMessageBox.warning(None, "Push Sync", msg)
|
|
119
120
|
logger.log.warning(msg)
|
|
120
121
|
return
|
|
121
122
|
|
|
@@ -127,7 +128,7 @@ class TCPRequestHandler(socketserver.StreamRequestHandler):
|
|
|
127
128
|
self.host = (self.peer_name[0], settings.options["port"])
|
|
128
129
|
else:
|
|
129
130
|
msg = "Not performing push sync, no host peer"
|
|
130
|
-
|
|
131
|
+
QMessageBox.warning(None, "Push Sync", msg)
|
|
131
132
|
logger.log.warning(msg)
|
|
132
133
|
return
|
|
133
134
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|