diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2018-03-26 16:56:54 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2018-03-26 16:56:54 +0100 |
commit | 3a582f243a8294ed87f40a7f8e0453a4b0637fcc (patch) | |
tree | 4e52a752c1d01518146a3df4c918a1b1fe0c03d7 /src/frontend/gui | |
parent | e9fd0c598c98db90ffd2a71b0a01c72e0dd52c2a (diff) |
merge mirror settings window into main application
Diffstat (limited to 'src/frontend/gui')
-rwxr-xr-x | src/frontend/gui/sisyphus-gui.py | 61 | ||||
-rwxr-xr-x | src/frontend/gui/sisyphusconfig.py | 44 | ||||
-rw-r--r-- | src/frontend/gui/ui/mirrorcfg.ui (renamed from src/frontend/gui/ui/sisyphus-config.ui) | 4 | ||||
-rw-r--r-- | src/frontend/gui/ui/sisyphus.ui (renamed from src/frontend/gui/ui/sisyphus-gui.ui) | 0 |
4 files changed, 52 insertions, 57 deletions
diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py index 9ef3550..0edc1be 100755 --- a/src/frontend/gui/sisyphus-gui.py +++ b/src/frontend/gui/sisyphus-gui.py @@ -7,13 +7,12 @@ import atexit from collections import OrderedDict from PyQt5 import QtCore, QtGui, QtWidgets, uic from libsisyphus import * -from sisyphusconfig import SisyphusConfig - +# main window class Sisyphus(QtWidgets.QMainWindow): def __init__(self): super(Sisyphus, self).__init__() - uic.loadUi('ui/sisyphus-gui.ui', self) + uic.loadUi('ui/sisyphus.ui', self) self.centerOnScreen() self.show() @@ -45,7 +44,7 @@ class Sisyphus(QtWidgets.QMainWindow): self.inputBox.textEdited.connect(self.searchDatabase) - self.settingsButton.clicked.connect(self.sisyphusSettings) + self.settingsButton.clicked.connect(self.mirrorSettings) self.updateWorker = UpdateWorker() self.updateThread = QtCore.QThread() @@ -301,14 +300,54 @@ class Sisyphus(QtWidgets.QMainWindow): def updateStatusBar(self, workerMessage): self.statusBar().showMessage(workerMessage) - def sisyphusSettings(self): - self.window = SisyphusConfig() + def mirrorSettings(self): + self.window = MirrorCfg() self.window.show() def sisyphusExit(self): self.close() +# mirror config window +class MirrorCfg(QtWidgets.QMainWindow): + def __init__(self): + super(MirrorCfg, self).__init__() + uic.loadUi('ui/mirrorcfg.ui', self) + self.centerOnScreen() + self.MIRRORLIST = getMirrors() + self.updateMirrorList() + self.applyButton.pressed.connect(self.mirrorCfgApply) + self.applyButton.released.connect(self.mirrorCfgExit) + self.mirrorCombo.activated.connect(self.setMirrorList) + def centerOnScreen(self): + resolution = QtWidgets.QDesktopWidget().screenGeometry() + self.move((resolution.width() / 2) - (self.frameSize().width() / 2), + (resolution.height() / 2) - (self.frameSize().height() / 2)) + + def updateMirrorList(self): + model = QtGui.QStandardItemModel() + for row in self.MIRRORLIST: + indx = self.MIRRORLIST.index(row) + item = QtGui.QStandardItem() + item.setText(row['Url']) + model.setItem(indx, item) + if row['isActive'] : + self.ACTIVEMIRRORINDEX = indx + self.mirrorCombo.setModel(model) + self.mirrorCombo.setCurrentIndex(self.ACTIVEMIRRORINDEX) + + def setMirrorList(self): + self.MIRRORLIST[self.ACTIVEMIRRORINDEX]['isActive'] = False + self.ACTIVEMIRRORINDEX = self.mirrorCombo.currentIndex() + self.MIRRORLIST[self.ACTIVEMIRRORINDEX]['isActive'] = True + + def mirrorCfgApply(self): + setActiveMirror(self.MIRRORLIST) + + def mirrorCfgExit(self): + self.close() + +# update worker class UpdateWorker(QtCore.QObject): started = QtCore.pyqtSignal() finished = QtCore.pyqtSignal() @@ -319,7 +358,7 @@ class UpdateWorker(QtCore.QObject): sisyphus_pkg_system_update() self.finished.emit() - +# install worker class InstallWorker(QtCore.QObject): started = QtCore.pyqtSignal() finished = QtCore.pyqtSignal() @@ -340,7 +379,7 @@ class InstallWorker(QtCore.QObject): sync_sisyphus_local_packages_table_csv() self.finished.emit() - +# uninstall worker class UninstallWorker(QtCore.QObject): started = QtCore.pyqtSignal() finished = QtCore.pyqtSignal() @@ -361,7 +400,7 @@ class UninstallWorker(QtCore.QObject): sync_sisyphus_local_packages_table_csv() self.finished.emit() - +# upgrade worker class UpgradeWorker(QtCore.QObject): started = QtCore.pyqtSignal() finished = QtCore.pyqtSignal() @@ -381,7 +420,7 @@ class UpgradeWorker(QtCore.QObject): sync_sisyphus_local_packages_table_csv() self.finished.emit() - +# orphans worker class OrphansWorker(QtCore.QObject): started = QtCore.pyqtSignal() finished = QtCore.pyqtSignal() @@ -401,7 +440,7 @@ class OrphansWorker(QtCore.QObject): sync_sisyphus_local_packages_table_csv() self.finished.emit() - +# launch application if __name__ == '__main__': app = QtWidgets.QApplication(sys.argv) window = Sisyphus() diff --git a/src/frontend/gui/sisyphusconfig.py b/src/frontend/gui/sisyphusconfig.py deleted file mode 100755 index 35e50fe..0000000 --- a/src/frontend/gui/sisyphusconfig.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/python3 -import sys -from PyQt5 import QtCore, QtGui, QtWidgets, uic -from libsisyphus import getMirrors, setActiveMirror - -class SisyphusConfig(QtWidgets.QMainWindow): - def __init__(self): - super(SisyphusConfig, self).__init__() - uic.loadUi('ui/sisyphus-config.ui', self) - self.centerOnScreen() - self.MIRRORLIST = getMirrors() - self.updateMirrorList() - self.show() - self.applyButton.pressed.connect(self.SisyphusConfigApply) - self.applyButton.released.connect(self.SisyphusConfigExit) - self.mirrorCombo.activated.connect(self.setMirrorList) - - def centerOnScreen(self): - resolution = QtWidgets.QDesktopWidget().screenGeometry() - self.move((resolution.width() / 2) - (self.frameSize().width() / 2), - (resolution.height() / 2) - (self.frameSize().height() / 2)) - - def updateMirrorList(self): - model = QtGui.QStandardItemModel() - for row in self.MIRRORLIST: - indx = self.MIRRORLIST.index(row) - item = QtGui.QStandardItem() - item.setText(row['Url']) - model.setItem(indx, item) - if row['isActive'] : - self.ACTIVEMIRRORINDEX = indx - self.mirrorCombo.setModel(model) - self.mirrorCombo.setCurrentIndex(self.ACTIVEMIRRORINDEX) - - def setMirrorList(self): - self.MIRRORLIST[self.ACTIVEMIRRORINDEX]['isActive'] = False - self.ACTIVEMIRRORINDEX = self.mirrorCombo.currentIndex() - self.MIRRORLIST[self.ACTIVEMIRRORINDEX]['isActive'] = True - - def SisyphusConfigApply(self): - setActiveMirror(self.MIRRORLIST) - - def SisyphusConfigExit(self): - self.close() diff --git a/src/frontend/gui/ui/sisyphus-config.ui b/src/frontend/gui/ui/mirrorcfg.ui index ecd7ea6..d196d88 100644 --- a/src/frontend/gui/ui/sisyphus-config.ui +++ b/src/frontend/gui/ui/mirrorcfg.ui @@ -26,7 +26,7 @@ </size> </property> <property name="windowTitle"> - <string>Sisyphus settings</string> + <string>Configure mirrors</string> </property> <property name="windowIcon"> <iconset> @@ -37,7 +37,7 @@ <item> <widget class="QGroupBox" name="mirrorGroupBox"> <property name="title"> - <string>Select Mirror</string> + <string>Select active mirror</string> </property> <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> diff --git a/src/frontend/gui/ui/sisyphus-gui.ui b/src/frontend/gui/ui/sisyphus.ui index fdfb763..fdfb763 100644 --- a/src/frontend/gui/ui/sisyphus-gui.ui +++ b/src/frontend/gui/ui/sisyphus.ui |