From 405503df01e3300304939517994dfb94677858ed Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 25 Mar 2018 12:47:26 +0100 Subject: connect sisyphus-config to main application --- src/frontend/gui/icon/settings.png | Bin 0 -> 14015 bytes src/frontend/gui/sisyphus-config.py | 49 --------------- src/frontend/gui/sisyphus-gui.py | 7 +++ src/frontend/gui/sisyphusconfig.py | 44 ++++++++++++++ src/frontend/gui/ui/sisyphus-config.ui | 7 ++- src/frontend/gui/ui/sisyphus-gui.ui | 107 ++++++++++++++++++++------------- 6 files changed, 120 insertions(+), 94 deletions(-) create mode 100644 src/frontend/gui/icon/settings.png delete mode 100755 src/frontend/gui/sisyphus-config.py create mode 100755 src/frontend/gui/sisyphusconfig.py diff --git a/src/frontend/gui/icon/settings.png b/src/frontend/gui/icon/settings.png new file mode 100644 index 0000000..f9857f0 Binary files /dev/null and b/src/frontend/gui/icon/settings.png differ diff --git a/src/frontend/gui/sisyphus-config.py b/src/frontend/gui/sisyphus-config.py deleted file mode 100755 index 67e6ae8..0000000 --- a/src/frontend/gui/sisyphus-config.py +++ /dev/null @@ -1,49 +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() - -if __name__ == '__main__': - app = QtWidgets.QApplication(sys.argv) - window = SisyphusConfig() - sys.exit(app.exec_()) diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py index 613c433..9ef3550 100755 --- a/src/frontend/gui/sisyphus-gui.py +++ b/src/frontend/gui/sisyphus-gui.py @@ -7,6 +7,7 @@ import atexit from collections import OrderedDict from PyQt5 import QtCore, QtGui, QtWidgets, uic from libsisyphus import * +from sisyphusconfig import SisyphusConfig class Sisyphus(QtWidgets.QMainWindow): @@ -44,6 +45,8 @@ class Sisyphus(QtWidgets.QMainWindow): self.inputBox.textEdited.connect(self.searchDatabase) + self.settingsButton.clicked.connect(self.sisyphusSettings) + self.updateWorker = UpdateWorker() self.updateThread = QtCore.QThread() self.updateWorker.moveToThread(self.updateThread) @@ -298,6 +301,10 @@ class Sisyphus(QtWidgets.QMainWindow): def updateStatusBar(self, workerMessage): self.statusBar().showMessage(workerMessage) + def sisyphusSettings(self): + self.window = SisyphusConfig() + self.window.show() + def sisyphusExit(self): self.close() diff --git a/src/frontend/gui/sisyphusconfig.py b/src/frontend/gui/sisyphusconfig.py new file mode 100755 index 0000000..35e50fe --- /dev/null +++ b/src/frontend/gui/sisyphusconfig.py @@ -0,0 +1,44 @@ +#!/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/sisyphus-config.ui index 7d74ae4..fe60c56 100644 --- a/src/frontend/gui/ui/sisyphus-config.ui +++ b/src/frontend/gui/ui/sisyphus-config.ui @@ -2,6 +2,9 @@ MainWindow + + Qt::ApplicationModal + 0 @@ -26,8 +29,8 @@ Sisyphus settings - - .. + + ../icon/sisyphus.png../icon/sisyphus.png diff --git a/src/frontend/gui/ui/sisyphus-gui.ui b/src/frontend/gui/ui/sisyphus-gui.ui index 48c0c06..4b502a7 100644 --- a/src/frontend/gui/ui/sisyphus-gui.ui +++ b/src/frontend/gui/ui/sisyphus-gui.ui @@ -3,7 +3,7 @@ Sisyphus - Qt::ApplicationModal + Qt::NonModal @@ -49,6 +49,68 @@ 25 + + + + 25 + + + 25 + + + 25 + + + + + + 25 + 25 + + + + + ../icon/settings.png../icon/settings.png + + + + 16 + 16 + + + + + + + + + + + <html><head/><body><p align="center">Write package name and press Enter</p></body></html> + + + true + + + + + + + + + + + + + 16777215 + 25 + + + + 24 + + + @@ -98,35 +160,6 @@ - - - - 25 - - - 25 - - - 25 - - - - - - - - <html><head/><body><p align="center">Write package name and press Enter</p></body></html> - - - true - - - - - - - - @@ -264,23 +297,11 @@ - - - - - 16777215 - 25 - - - - 24 - - - + settingsButton applicationFilter inputBox databaseFilter -- cgit v1.2.3