Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PyQt5.QtGui import QIcon
- from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog, QInputDialog, QLineEdit, QSystemTrayIcon, QAction, QMenu
- import resources.Interface
- import resources.ConfiGUI
- import modules.ui
- from classes.Config import Config
- from classes.Logger import Logger
- log = Config()
- config = Logger()
- class MainGUI(QMainWindow, resources.Interface.Ui_Interface):
- exitForReal = False
- def __init__(self, parent=None):
- super(MainGUI, self).__init__(parent)
- log.debug("ui initialised")
- self.setupUi(self)
- self.setWindowIcon(QIcon('resources/icon.ico'))
- log.debug("setup ui")
- self.Overview_Button_Retest.clicked.connect(lambda: self.Retest())
- self.Overview_Combo_Retesttype.currentTextChanged.connect(
- lambda: self.Overview_Button_Retest.setText(self.Overview_Combo_Retesttype.currentText()))
- self.General_TreeView.currentItemChanged.connect(
- lambda: self.UpdateDetails(self.General_TreeView.selectedIndexes()))
- self.Server_Button_Configure.clicked.connect(lambda: self.ShowConfigWindow())
- self.General_Button_AddServer.clicked.connect(lambda: self.AddServer())
- log.debug("connected buttons")
- self.tray_icon = QSystemTrayIcon(self)
- self.showhide_action = QAction("Hide", self)
- quit_action = QAction("Exit", self)
- self.showhide_action.triggered.connect(lambda: self.ShowHideTrigger())
- quit_action.triggered.connect(lambda: self.RealExit())
- tray_menu = QMenu()
- tray_menu.addAction(self.showhide_action)
- tray_menu.addAction(quit_action)
- self.tray_icon.setIcon(QIcon('resources/icon.ico'))
- self.tray_icon.setContextMenu(tray_menu)
- self.tray_icon.show()
- log.info("ui ready")
- self.show()
- def ShowConfigWindow(self):
- log.info("open config window")
- self.dialog = resources.ConfiGUI.ConfiGUI(self)
- self.dialog.show()
- def Retest(self):
- pass
- def AddGroup(self):
- log.info("add group pressed")
- text, okPressed = QInputDialog.getText(self, "Add Group", "Name of the Group:", QLineEdit.Normal, "")
- if okPressed and text != '':
- log.debug("received groupname \"{}\"".format(text))
- def AddServer(self):
- log.info("add server pressed")
- text, okPressed = QInputDialog.getText(self, "Add Server", "Serveradress to be contacted:", QLineEdit.Normal, "")
- if okPressed and text != '':
- log.debug("received serveraddress \"{}\"".format(text))
- def UpdateDetails(self, index):
- if len(index) == 0:
- return
- item = self.General_TreeView.itemFromIndex(index[0])
- log.info("show details of \"{}\"".format(str(item.text(0))))
- def RealExit(self):
- self.exitForReal = True
- self.close()
- def ShowHideTrigger(self):
- if self.isHidden():
- self.showhide_action.setText("Hide")
- self.show()
- else:
- self.showhide_action.setText("Show")
- self.hide()
- def closeEvent(self, event):
- log.info("close")
- if not self.exitForReal:
- log.debug("caught")
- event.ignore()
- self.hide()
- self.showhide_action.setText("Show")
- if config.getboolean("Interaction", "NotifyClose"):
- modules.ui.SendNotification(self, "TSar Background Notification",
- "TSar has been minimised to the tray, "
- "right-click the icon for more options.")
- def show():
- app = QApplication(sys.argv)
- window = MainGUI()
- sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment