Revize f727f55f
Přidáno uživatelem Martin Forejt před téměř 4 roky(ů)
aswi2021vochomurka/app.py | ||
---|---|---|
1 | 1 |
import logging |
2 | 2 |
|
3 |
from PyQt5.QtCore import QSettings, QCoreApplication |
|
3 | 4 |
from PyQt5.QtWidgets import QApplication |
4 | 5 |
|
5 | 6 |
from aswi2021vochomurka.view.main_view import MainView |
... | ... | |
31 | 32 |
|
32 | 33 |
logging.getLogger('apscheduler').setLevel(logging.WARNING) |
33 | 34 |
logging.getLogger('matplotlib').setLevel(logging.WARNING) |
35 |
|
|
36 |
|
|
37 |
def init_settings(): |
|
38 |
QCoreApplication.setOrganizationName('Vochomurka') |
|
39 |
QCoreApplication.setOrganizationDomain('vochomurka.org') |
|
40 |
QCoreApplication.setApplicationName('MQTTClient') |
|
41 |
|
|
42 |
QSettings.setDefaultFormat(QSettings.IniFormat) |
|
43 |
QSettings.setPath(QSettings.IniFormat, QSettings.SystemScope, '.') |
|
44 |
settings = QSettings() |
aswi2021vochomurka/settings.ini | ||
---|---|---|
1 |
[General] |
|
2 |
topics_items=/home/1, /home/2 |
|
3 |
topics_timeout=60 |
|
4 |
connection_host=localhost |
|
5 |
connection_port=1883 |
|
6 |
connection_keepalive=60 |
|
7 |
connection_anonymous=true |
|
8 |
connection_username= |
|
9 |
connection_password= |
aswi2021vochomurka/view/main_view.py | ||
---|---|---|
15 | 15 |
from aswi2021vochomurka.service.subscriber_params import SubscriberParams, ConnectionParams |
16 | 16 |
from aswi2021vochomurka.view.logger_view import LoggerView |
17 | 17 |
from aswi2021vochomurka.view.settings import SettingsDialog, DEFAULT_HOST, DEFAULT_PORT, DEFAULT_KEEPALIVE, \ |
18 |
DEFAULT_ANONYMOUS, DEFAULT_USERNAME, DEFAULT_TIMEOUT, DEFAULT_TOPICS |
|
18 |
DEFAULT_ANONYMOUS, DEFAULT_USERNAME, DEFAULT_TIMEOUT, DEFAULT_TOPICS, get_settings
|
|
19 | 19 |
|
20 | 20 |
|
21 | 21 |
class Worker(QObject, SubscriberCallback): |
... | ... | |
176 | 176 |
self.workerThread.start() |
177 | 177 |
|
178 | 178 |
def getConfigParams(self) -> SubscriberParams: |
179 |
settings = QSettings("Vochomurka", "MQTTClient")
|
|
179 |
settings = get_settings()
|
|
180 | 180 |
|
181 | 181 |
connection = ConnectionParams( |
182 | 182 |
settings.value("connection_host", DEFAULT_HOST, str), |
aswi2021vochomurka/view/settings.py | ||
---|---|---|
13 | 13 |
DEFAULT_TIMEOUT = 60 |
14 | 14 |
|
15 | 15 |
|
16 |
def get_settings(): |
|
17 |
settings = QSettings('settings.ini', QSettings.IniFormat) |
|
18 |
return settings |
|
19 |
|
|
20 |
|
|
16 | 21 |
class SettingsDialog(QDialog): |
17 | 22 |
topics = DEFAULT_TOPICS |
18 | 23 |
|
19 | 24 |
def __init__(self): |
20 | 25 |
super(SettingsDialog, self).__init__(None, |
21 | 26 |
QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint) |
22 |
self.settings = QSettings("Vochomurka", "MQTTClient")
|
|
27 |
self.settings = get_settings()
|
|
23 | 28 |
self.setWindowTitle("Settings") |
24 | 29 |
self.setMinimumSize(QSize(600, 500)) |
25 | 30 |
|
Také k dispozici: Unified diff
Feature/8996 config file location