summaryrefslogtreecommitdiff
path: root/src/frontend/gui/sisyphus-config.py
diff options
context:
space:
mode:
authorGhiunhan Mamut (aka V3n3RiX) <venerix@redcorelinux.org>2018-03-24 21:59:39 +0000
committerGhiunhan Mamut (aka V3n3RiX) <venerix@redcorelinux.org>2018-03-24 21:59:39 +0000
commit698f61bac078d2fbb97e1657d3c8f51fbf8eba95 (patch)
treef1acad77cfd35e275fee849b8a1da94f097ea2c4 /src/frontend/gui/sisyphus-config.py
parent3a9714df4681b5cf022a8c469d0e79fbe9bc677c (diff)
parent9a1341e32e82dd13e7b584e484b169817b4da2c6 (diff)
Merge branch 'add_config_gui' into 'master'
add config gui See merge request redcore/sisyphus!8
Diffstat (limited to 'src/frontend/gui/sisyphus-config.py')
-rwxr-xr-xsrc/frontend/gui/sisyphus-config.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/frontend/gui/sisyphus-config.py b/src/frontend/gui/sisyphus-config.py
new file mode 100755
index 0000000..35afccc
--- /dev/null
+++ b/src/frontend/gui/sisyphus-config.py
@@ -0,0 +1,49 @@
+#!/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.closeButton.clicked.connect(self.SisyphusConfigExit)
+ self.applyButton.clicked.connect(self.SisyphusConfigApply)
+ 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()
+
+if __name__ == '__main__':
+ app = QtWidgets.QApplication(sys.argv)
+ window = SisyphusConfig()
+ sys.exit(app.exec_())