config now works properly
This commit is contained in:
@@ -5,8 +5,10 @@ sys.path.append('gui')
|
||||
|
||||
try:
|
||||
from gui import Ui_MainWindow
|
||||
from functions import *
|
||||
except ImportError:
|
||||
from gui.gui import Ui_MainWindow
|
||||
from gui.functions import *
|
||||
|
||||
settings = Settings.get_settings()
|
||||
|
||||
@@ -15,17 +17,10 @@ MainWindow = QtWidgets.QMainWindow()
|
||||
ui = Ui_MainWindow()
|
||||
ui.setupUi(MainWindow)
|
||||
|
||||
|
||||
def fill_settings() -> None:
|
||||
ui.chooseAnimationBox.setCurrentText(settings["animation"])
|
||||
ui.pusher_app_id_edit.setText(settings["app_id"])
|
||||
ui.pusher_key_edit.setText(settings["key"])
|
||||
ui.pusher_secret_edit.setText(settings["secret"])
|
||||
ui.pusher_cluster_edit.setText(settings["cluster"])
|
||||
ui.imgurClientId.setText(settings["client_id"])
|
||||
try:
|
||||
fill_settings()
|
||||
except KeyError:
|
||||
fill_settings(ui)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
Settings.fix()
|
||||
|
||||
MainWindow.show()
|
||||
@@ -67,5 +62,6 @@ def handleMenuClick(text: str) -> None:
|
||||
|
||||
|
||||
ui.leftMenu.itemClicked.connect(lambda: handleMenuClick(ui.leftMenu.currentItem().text()))
|
||||
ui.saveSettingsButton.clicked.connect(lambda: update_settings(ui))
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
from data.settings import Settings
|
||||
|
||||
|
||||
def fill_settings(ui) -> None:
|
||||
settings = Settings.get_settings()
|
||||
ui.chooseAnimationBox.setCurrentText(settings.get("animation"))
|
||||
ui.pusher_app_id_edit.setText(settings.get("app_id"))
|
||||
ui.pusher_key_edit.setText(settings.get("key"))
|
||||
ui.pusher_secret_edit.setText(settings.get("secret"))
|
||||
ui.pusher_cluster_edit.setText(settings.get("cluster"))
|
||||
ui.imgurClientId.setText(settings.get("client_id"))
|
||||
|
||||
|
||||
def update_settings(ui) -> None:
|
||||
get_text = lambda text: text if text != "" else None
|
||||
|
||||
settings = {
|
||||
"animation": get_text(ui.chooseAnimationBox.currentText()),
|
||||
"app_id": get_text(ui.pusher_app_id_edit.text().strip()),
|
||||
"key": get_text(ui.pusher_key_edit.text().strip()),
|
||||
"secret": get_text(ui.pusher_secret_edit.text().strip()),
|
||||
"cluster": get_text(ui.pusher_cluster_edit.text().strip()),
|
||||
"client_id": get_text(ui.imgurClientId.text().strip())
|
||||
}
|
||||
list(map((lambda x: Settings.update(x, settings[x])), settings))
|
||||
|
||||
@@ -414,6 +414,10 @@ class Ui_MainWindow(object):
|
||||
self.pingButton.setMinimumSize(QtCore.QSize(0, 30))
|
||||
self.pingButton.setObjectName("pingButton")
|
||||
self.devicesButtonsLayout.addWidget(self.pingButton)
|
||||
self.reconRefreshButton = QtWidgets.QPushButton(self.devicesPage)
|
||||
self.reconRefreshButton.setMinimumSize(QtCore.QSize(0, 30))
|
||||
self.reconRefreshButton.setObjectName("reconRefreshButton")
|
||||
self.devicesButtonsLayout.addWidget(self.reconRefreshButton)
|
||||
self.devicesButtonLayout.addLayout(self.devicesButtonsLayout)
|
||||
self.pagesWidget.addWidget(self.devicesPage)
|
||||
self.screenshotPage = QtWidgets.QWidget()
|
||||
@@ -659,7 +663,7 @@ class Ui_MainWindow(object):
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
self.leftMenu.setCurrentRow(-1)
|
||||
self.pagesWidget.setCurrentIndex(0)
|
||||
self.pagesWidget.setCurrentIndex(1)
|
||||
self.settingsTabWidget.setCurrentIndex(0)
|
||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||
|
||||
@@ -686,9 +690,10 @@ class Ui_MainWindow(object):
|
||||
item.setText(_translate("MainWindow", "Settings"))
|
||||
self.leftMenu.setSortingEnabled(__sortingEnabled)
|
||||
self.dLogo.setText(_translate("MainWindow", "D"))
|
||||
self.choosePanelLabel.setText(_translate("MainWindow", "Choose panel in right side"))
|
||||
self.choosePanelLabel.setText(_translate("MainWindow", "Choose panel in right side, scroll menu to see more"))
|
||||
self.connectButton.setText(_translate("MainWindow", "Connect"))
|
||||
self.pingButton.setText(_translate("MainWindow", "Ping"))
|
||||
self.reconRefreshButton.setText(_translate("MainWindow", "Reconnect and refresh"))
|
||||
self.takeScreenshotButton.setText(_translate("MainWindow", "Take screenshot"))
|
||||
self.wallpaperUrlBox.setPlaceholderText(_translate("MainWindow", "Local or web link to wallpaper"))
|
||||
self.setWallpaperButton.setText(_translate("MainWindow", "Set wallpaper"))
|
||||
|
||||
@@ -481,7 +481,7 @@ QListWidget:item:selected {
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="startPage">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
@@ -517,7 +517,7 @@ color: rgb(40, 40, 40);</string>
|
||||
<string notr="true">color: rgb(70, 70, 70);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose panel in right side</string>
|
||||
<string>Choose panel in right side, scroll menu to see more</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -563,6 +563,19 @@ color: rgb(40, 40, 40);</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="reconRefreshButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reconnect and refresh</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user