Esempio n. 1
0
 def closer(self, choose):
     """
     托盘界面设置
     :param choose:
     :return:
     """
     if choose == True:
         QApplication.instance().quit()
     elif choose == False:
         self.window().hide()
         self.tray = QSystemTrayIcon(self)
         if os.path.exists(ICON_NORM):
             self.icon = QIcon(ICON_NORM)
         else:
             self.icon = QIcon((os.path.split(__file__)[0] +
                                "\\beautifyUi\\").replace('\\', '/') +
                               ICON_NORM)
         self.tray.setIcon(self.icon)
         self.tray.activated.connect(self.TuoPanEvent)
         self.tray.setToolTip(self.icon_name)
         self.tray_menu = QMenu(QApplication.desktop())
         self.RestoreAction = QAction(u'还原',
                                      self,
                                      triggered=self.window().show)
         self.QuitAction = QAction(u'退出',
                                   self,
                                   triggered=QApplication.instance().quit)
         self.tray_menu.addAction(self.RestoreAction)
         self.tray_menu.addAction(self.QuitAction)
         self.tray.setContextMenu(self.tray_menu)
         self.tray.show()
         self.tray.showMessage(self.icon_name, '托盘在这!', icon=1)
     else:
         QMessageBox.warning(self, "警告", "系统出现问题,\n请稍后再试")
Esempio n. 2
0
 def __init__(self, app):
     QDialog.__init__(self)
     self.app = app
     self.app_path = os.getenv("APPDATA") + "\\" + qApp.applicationName()
     self.registrySettings = QSettings("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", QSettings.NativeFormat)
     self.table_path = self.app_path + "\\tables"
     self.engine = Engine()
     self.minimize_action = QAction("Minimize", self)
     self.maximize_action = QAction("Maximize", self)
     self.settings_action = QAction("Settings", self)
     self.about_action = QAction("About", self)
     self.quit_action = QAction("Quit", self)
     self.tray_icon_menu = QMenu(self)
     self.tray_icon = QSystemTrayIcon(self)
     self.setupUi(self)
     self.icon = QIcon(QPixmap(":icon/off_logo"))
     self.construct_tray_icon()
     self.signal_connectors()
     self.database = DatabaseManager()
     self.shortcut_key = self.database.get_shortcut_key()
     self.populate_modifier_cbox()
     if self.database.get_current_state() == "True":
         self.engine.conv_state = False
     else:
         self.engine.conv_state = True
     self.icon_activated(QSystemTrayIcon.Trigger)
     self.file_path_tview.setEnabled(False)
     self.check_app_path()
     self.update_table(True)
     self.init_combobox()
     if self.registrySettings.contains(qApp.applicationName()):
         self.start_windows_check.setChecked(True)
     else:
         self.start_windows_check.setChecked(False)
Esempio n. 3
0
 def create_system_tray_icon(self, parent=None, title=None, category=None):
     if self.has_status_notifier:
         from calibre.gui2.dbus_export.tray import StatusNotifierItem
         ans = StatusNotifierItem(parent=parent, title=title, app_id=self.app_id, category=category)
         self.register_status_notifier(ans)
         self.prune_dead_refs()
         self.status_notifiers.append(weakref.ref(ans))
         return ans
     if iswindows or isosx:
         return QSystemTrayIcon(parent)
Esempio n. 4
0
# -*- coding: utf-8 -*-

__author__ = 'ipetrash'

from PyQt5.Qt import QApplication, QSystemTrayIcon, QStyle, QMenu, QMessageBox, QWidget

app = QApplication([])
# app.setQuitOnLastWindowClosed(False)

mw = QWidget()
mw.show()

icon = app.style().standardIcon(QStyle.SP_DirOpenIcon)
# icon = QIcon('favicon.ico')

tray = QSystemTrayIcon(icon)

menu = QMenu()
action_settings = menu.addAction("About Qt")
action_settings.triggered.connect(lambda: QMessageBox.aboutQt(None))

action_quit = menu.addAction("Quit")
action_quit.triggered.connect(app.quit)

tray.setContextMenu(menu)
tray.activated.connect(lambda x: menu.exec(tray.geometry().center()))

tray.show()

app.exec()
Esempio n. 5
0
    def setupUi(self, MainWindow):
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.localProxyEntry = QtWidgets.QPlainTextEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.localProxyEntry.sizePolicy().hasHeightForWidth())
        self.localProxyEntry.setSizePolicy(sizePolicy)
        self.localProxyEntry.setMaximumSize(QtCore.QSize(16777215, 40))
        self.localProxyEntry.setObjectName("localProxyEntry")
        self.gridLayout.addWidget(self.localProxyEntry, 3, 1, 1, 1)
        self.serverAddr = QtWidgets.QLabel(self.centralwidget)
        self.serverAddr.setObjectName("serverAddr")
        self.gridLayout.addWidget(self.serverAddr, 0, 0, 1, 1)
        self.passwd = QtWidgets.QLabel(self.centralwidget)
        self.passwd.setObjectName("passwd")
        self.gridLayout.addWidget(self.passwd, 2, 0, 1, 1)
        self.serverEntry = QtWidgets.QPlainTextEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(100)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.serverEntry.sizePolicy().hasHeightForWidth())
        self.serverEntry.setSizePolicy(sizePolicy)
        self.serverEntry.setMaximumSize(QtCore.QSize(16777215, 40))
        self.serverEntry.setObjectName("serverEntry")
        self.gridLayout.addWidget(self.serverEntry, 0, 1, 1, 1)
        self.localProxyPort = QtWidgets.QLabel(self.centralwidget)
        self.localProxyPort.setObjectName("localProxyPort")
        self.gridLayout.addWidget(self.localProxyPort, 3, 0, 1, 1)
        self.passwdEntry = QtWidgets.QPlainTextEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.passwdEntry.sizePolicy().hasHeightForWidth())
        self.passwdEntry.setSizePolicy(sizePolicy)
        self.passwdEntry.setMaximumSize(QtCore.QSize(16777215, 40))
        self.passwdEntry.setObjectName("passwdEntry")
        self.gridLayout.addWidget(self.passwdEntry, 2, 1, 1, 1)
        self.usrName = QtWidgets.QLabel(self.centralwidget)
        self.usrName.setObjectName("usrName")
        self.gridLayout.addWidget(self.usrName, 1, 0, 1, 1)
        self.userEntry = QtWidgets.QPlainTextEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.userEntry.sizePolicy().hasHeightForWidth())
        self.userEntry.setSizePolicy(sizePolicy)
        self.userEntry.setMaximumSize(QtCore.QSize(16777215, 40))
        self.userEntry.setObjectName("userEntry")
        self.gridLayout.addWidget(self.userEntry, 1, 1, 1, 1)
        self.gridLayout_2 = QtWidgets.QGridLayout()
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.connect = QtWidgets.QPushButton(self.centralwidget)
        self.connect.setObjectName("connect")
        self.gridLayout_2.addWidget(self.connect, 0, 0, 1, 1)
        self.disconnect = QtWidgets.QPushButton(self.centralwidget)
        self.disconnect.setObjectName("disconnect")
        self.gridLayout_2.addWidget(self.disconnect, 0, 1, 1, 1)
        self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
        self.progressBar.setProperty("value", 0)
        self.progressBar.setObjectName("progressBar")
        self.gridLayout_2.addWidget(self.progressBar, 1, 0, 1, 2)
        self.gridLayout.addLayout(self.gridLayout_2, 4, 0, 1, 2)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.menuBar = QtWidgets.QMenuBar(MainWindow)
        self.menuBar.setGeometry(QtCore.QRect(0, 0, 576, 26))
        self.menuBar.setObjectName("menuBar")
        self.menuFile = QtWidgets.QMenu(self.menuBar)
        self.menuFile.setObjectName("menuFile")
        MainWindow.setMenuBar(self.menuBar)
        self.actionOpen_Config = QtWidgets.QAction(MainWindow)
        self.actionOpen_Config.setObjectName("actionOpen_Config")
        self.actionOpen_Config.setShortcut("Ctrl+O")
        self.actionSave_Config = QtWidgets.QAction(MainWindow)
        self.actionSave_Config.setObjectName("actionSave_Config")
        self.actionSave_Config.setShortcut("Ctrl+S")
        self.actionExit = QtWidgets.QAction(MainWindow)
        self.actionExit.setObjectName("actionExit")
        self.menuFile.addAction(self.actionOpen_Config)
        self.menuFile.addAction(self.actionSave_Config)
        self.menuFile.addAction(self.actionExit)
        self.menuBar.addAction(self.menuFile.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        # Connect all buttons with functions
        self.actionExit.triggered.connect(self.exitOnClick)
        self.actionSave_Config.triggered.connect(self.saveConfig)
        self.actionOpen_Config.triggered.connect(self.loadConfig)
        self.connect.clicked.connect(self.connectToNaive)
        self.disconnect.clicked.connect(self.disconnectFromNaive)
        self.CONNECTED = False

        # System tray
        self.trayIcon = QSystemTrayIcon(QIcon('icon.png'), parent=app)
        self.trayIcon.setToolTip("Naive Proxy")
        self.trayIcon.show()
        self.trayIcon.setContextMenu(self.menuFile)

        self.defaultConfig()
Esempio n. 6
0
    def __init__(self):
        super().__init__()

        self.setWindowTitle(WINDOW_TITLE)

        from pathlib import Path
        file_name = str(Path(__file__).resolve().parent / 'favicon.ico')
        icon = QIcon(file_name)

        self.setWindowIcon(icon)

        self.tray = QSystemTrayIcon(icon)
        self.tray.setToolTip(self.windowTitle())
        self.tray.activated.connect(self._on_tray_activated)
        self.tray.show()

        self.logged_dict = dict()

        self.pb_refresh = QPushButton('REFRESH')
        self.pb_refresh.clicked.connect(self.refresh)

        self.cb_show_log = QCheckBox()
        self.cb_show_log.setChecked(True)

        self.log = QPlainTextEdit()
        self.log.setReadOnly(True)
        self.log.setWordWrapMode(QTextOption.NoWrap)
        log_font = self.log.font()
        log_font.setFamily('Courier New')
        self.log.setFont(log_font)

        self.cb_show_log.clicked.connect(self.log.setVisible)
        self.log.setVisible(self.cb_show_log.isChecked())

        header_labels = ['DATE', 'TOTAL LOGGED TIME']
        self.table_logged = QTableWidget()
        self.table_logged.setEditTriggers(QTableWidget.NoEditTriggers)
        self.table_logged.setSelectionBehavior(QTableWidget.SelectRows)
        self.table_logged.setSelectionMode(QTableWidget.SingleSelection)
        self.table_logged.setColumnCount(len(header_labels))
        self.table_logged.setHorizontalHeaderLabels(header_labels)
        self.table_logged.horizontalHeader().setStretchLastSection(True)
        self.table_logged.itemClicked.connect(
            self._on_table_logged_item_clicked)

        header_labels = ['TIME', 'LOGGED', 'JIRA']
        self.table_logged_info = QTableWidget()
        self.table_logged_info.setEditTriggers(QTableWidget.NoEditTriggers)
        self.table_logged_info.setSelectionBehavior(QTableWidget.SelectRows)
        self.table_logged_info.setSelectionMode(QTableWidget.SingleSelection)
        self.table_logged_info.setColumnCount(len(header_labels))
        self.table_logged_info.setHorizontalHeaderLabels(header_labels)
        self.table_logged_info.horizontalHeader().setSectionResizeMode(
            1, QHeaderView.ResizeToContents)
        self.table_logged_info.horizontalHeader().setStretchLastSection(True)
        self.table_logged_info.itemDoubleClicked.connect(
            self._on_table_logged_info_item_double_clicked)

        main_layout = QVBoxLayout()

        central_widget = QWidget()
        central_widget.setLayout(main_layout)

        self.setCentralWidget(central_widget)

        self.pb_refresh.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred))

        h_layout = QHBoxLayout()
        h_layout.addWidget(self.pb_refresh)
        h_layout.addWidget(self.cb_show_log)

        layout_table_widget = QVBoxLayout()
        layout_table_widget.setContentsMargins(0, 0, 0, 0)
        layout_table_widget.addWidget(self.table_logged)
        layout_table_widget.addWidget(self.table_logged_info)

        table_widget = QWidget()
        table_widget.setLayout(layout_table_widget)

        splitter = QSplitter(Qt.Horizontal)
        splitter.addWidget(table_widget)
        splitter.addWidget(self.log)

        main_layout.addLayout(h_layout)
        main_layout.addWidget(splitter)