This repository has been archived by the owner on Apr 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
config.py
65 lines (54 loc) · 2.74 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from calibre.utils.config import JSONConfig
from PyQt5.Qt import QWidget, QLabel, QLineEdit, QGridLayout
prefs = JSONConfig("plugins/remarkable_device_plugin")
# Set defaults
prefs.defaults["ip"] = "10.11.99.1"
prefs.defaults["books_path"] = "/"
prefs.defaults["metadata_path"] = "/home/root/"
prefs.defaults["password"] = ""
prefs.defaults["storage"] = "/dev/mmcblk1p7"
class ConfigWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
self.layout = QGridLayout()
self.layout.setSpacing(10)
self.ip_label = QLabel("Remarkable IP:")
self.layout.addWidget(self.ip_label, 1, 0)
self.ip_label_msg = QLineEdit(self)
self.ip_label_msg.setText(prefs["ip"])
self.layout.addWidget(self.ip_label_msg, 1, 1)
self.ip_label.setBuddy(self.ip_label_msg)
self.books_path_label = QLabel("Books Path:")
self.layout.addWidget(self.books_path_label, 2, 0)
self.books_path_label_msg = QLineEdit(self)
self.books_path_label_msg.setText(prefs["books_path"])
self.layout.addWidget(self.books_path_label_msg, 2, 1)
self.books_path_label.setBuddy(self.books_path_label_msg)
self.metadata_path_label = QLabel("Config Path:")
self.layout.addWidget(self.metadata_path_label, 3, 0)
self.metadata_path_label_msg = QLineEdit(self)
self.metadata_path_label_msg.setText(prefs["metadata_path"])
self.layout.addWidget(self.metadata_path_label_msg, 3, 1)
self.metadata_path_label.setBuddy(self.metadata_path_label_msg)
self.password_label = QLabel("Password ( If not using Key ):")
self.layout.addWidget(self.password_label, 4, 0)
self.password_label_msg = QLineEdit(self)
self.password_label_msg.setText(prefs["password"])
self.layout.addWidget(self.password_label_msg, 4, 1)
self.password_label.setBuddy(self.password_label_msg)
self.storage_label = QLabel("Storage ( like '/dev/mmcblk1p7' ):")
self.layout.addWidget(self.storage_label, 5, 0)
self.storage_label_msg = QLineEdit(self)
self.storage_label_msg.setText(prefs["storage"])
self.layout.addWidget(self.storage_label_msg, 5, 1)
self.storage_label.setBuddy(self.storage_label_msg)
self.setLayout(self.layout)
self.setGeometry(150, 150, 150, 150)
self.setWindowTitle("Remarkable Config")
def save_settings(self):
prefs["ip"] = self.ip_label_msg.text()
# append an extra '/' in case it was forgotten
prefs["books_path"] = self.books_path_label_msg.text() + "/"
prefs["metadata_path"] = self.metadata_path_label_msg.text() + "/"
prefs["password"] = self.password_label_msg.text()
prefs["storage"] = self.storage_label_msg.text()