Esempio n. 1
0
    def init(self):
        self.setStyleSheet(
            read_text_file(Resources.getResourcesPackagesPath('menu')))

        pros = self.app.strings.properties
        self.editServersAction.setText(pros["editServers"])
        self.importServerFromUrlAction.setText(pros["importServerFromUrl"])
        self.copySelectedServerUrlAction.setText(
            pros["copySelectedServerUrlAction"])
        self.showServerQRCodeAction.setText(pros["showServerQRCode"])

        if len(self.app.guiConfig.guiConfig['serverList']) > 0:
            if self.app.guiConfig.guiConfig['settings']['selectedServerIndex'] > \
                    (len(self.app.guiConfig.guiConfig['serverList']) - 1):
                self.app.guiConfig.guiConfig['settings'][
                    'selectedServerIndex'] = 0
                self.app.guiConfig.write()
                self.app.systemTrayIconContextMenu.disconnectServer()
                self.app.systemTrayIcon.showMessage(pros["reset"],
                                                    pros['resetSelectedIndex'])
                self.setServer(self.app.guiConfig.guiConfig['settings']
                               ['selectedServerIndex'])
                self.app.systemTrayIconContextMenu.connectServer()
            self.serverActions[self.app.guiConfig.guiConfig['settings']['selectedServerIndex']] \
                .setIcon(Resources.getIconByFilename('baseline_check_black_18dp.png'))

        self.editServersAction.setIcon(
            Resources.getIconByFilename('none_black_18dp.png'))

        self.showServerQRCodeAction.triggered.connect(self.showServerQRCode)
        self.editServersAction.triggered.connect(self.editServers)
        self.importServerFromUrlAction.triggered.connect(
            self.importServerFromUrl)
        self.copySelectedServerUrlAction.triggered.connect(
            self.copySelectedServerUrl)
Esempio n. 2
0
 def setStartBoot(self):
     startBoot = self.guiConfig.guiConfig['settings']['startBoot']
     if startBoot:
         self.startBootAction.setIcon(
             Resources.getIconByFilename('baseline_check_black_18dp.png'))
     else:
         self.startBootAction.setIcon(Resources.getIconByFilename('hzj'))
Esempio n. 3
0
 def setDisabledProxy(self):
     if self.guiConfig.guiConfig['systemProxy'][
             'proxyMode'] not in "Disable":
         self.disableAction.setIcon(
             Resources.getIconByFilename('baseline_check_black_18dp.png'))
         self.PACAction.setIcon(Resources.getIconByFilename('hzj'))
         self.globalAction.setIcon(Resources.getIconByFilename('hzj'))
         sysproxy.off()
Esempio n. 4
0
 def setConnectAutomatically(self):
     connectAutomatically = self.guiConfig.guiConfig['settings'][
         'connectAutomatically']
     if connectAutomatically:
         self.connectAutomaticallyAction.setIcon(
             Resources.getIconByFilename('baseline_check_black_18dp.png'))
     else:
         self.connectAutomaticallyAction.setIcon(
             Resources.getIconByFilename('hzj'))
Esempio n. 5
0
 def setSystemTrayIconAndToolTip(self):
     if self.guiConfig.guiConfig['settings']['isConnected']:
         self.app.systemTrayIcon.setIcon(
             Resources.getIconByFilename('baseline_public_black_18dp.png'))
         self.app.systemTrayIcon.setToolTip("Connected -Rocket X")
     else:
         self.app.systemTrayIcon.setIcon(
             Resources.getIconByFilename(
                 'baseline_public_off_black_18dp.png'))
         self.app.systemTrayIcon.setToolTip("Not connect -Rocket X")
Esempio n. 6
0
    def setAllowOtherDevicesToConnect(self):
        allowOtherDevicesToConnect = self.guiConfig.guiConfig['settings'][
            'allowOtherDevicesToConnect']

        if allowOtherDevicesToConnect:
            self.allowOtherDevicesToConnectAction.setIcon(
                Resources.getIconByFilename('baseline_check_black_18dp.png'))
        else:
            self.allowOtherDevicesToConnectAction.setIcon(
                Resources.getIconByFilename('hzj'))
Esempio n. 7
0
 def setServer(self, index):
     self.serverActions[self.app.guiConfig.guiConfig['settings']['selectedServerIndex']] \
         .setIcon(Resources.getIconByFilename(''))
     self.app.guiConfig.guiConfig['settings']['selectedServerIndex'] = index
     self.serverActions[self.app.guiConfig.guiConfig['settings']['selectedServerIndex']] \
         .setIcon(Resources.getIconByFilename('baseline_check_black_18dp.png'))
     self.app.guiConfig.write()
     self.app.guiConfig.guiConfig['forwardServer']['outbounds'][
         0] = self.getOutbound()
     self.app.guiConfig.write()
     self.app.guiConfig.writeNewJsonFile('forwardServer', 'config.json')
     if self.app.systemTrayIconContextMenu.isConnected:
         self.app.systemTrayIconContextMenu.disconnectServer()
         self.app.systemTrayIconContextMenu.connectServer()
Esempio n. 8
0
 def share(self):
     pros = self.app.strings.properties
     pyperclip.copy(self.url)
     print(f"copy url {self.url}")
     self.app.systemTrayIcon.showMessage(
         pros['appName'], pros['copyUrl'].replace("{0}", ""),
         Resources.getIconByFilename('app.ico'))
Esempio n. 9
0
 def __init__(self, app):
     super(FeedbackWindow, self).__init__()
     self.app = app
     self.ui = Ui_Feedback()
     self.setWindowIcon(Resources.getIconByFilename('app.ico'))
     self.ui.setupUi(self)
     self.setWindowFlags(Qt.WindowCloseButtonHint)
Esempio n. 10
0
    def __init__(self, app):
        super(ImportServerFromURLDialog, self).__init__()
        self.app = app
        self.ui = Ui_ImportServerFromURLDialog()
        self.setWindowIcon(Resources.getIconByFilename('app.ico'))
        self.ui.setupUi(self)

        self.init()
Esempio n. 11
0
 def copySelectedServerUrl(self):
     pros = self.app.strings.properties
     url = self.app.qrcodeMainWindow.serverToUrl(
         self.app.guiConfig.guiConfig['settings']['selectedServerIndex'])
     pyperclip.copy(url)
     print(f"copy url {url}")
     self.app.systemTrayIcon.showMessage(
         pros['appName'], pros['copyUrl'].replace("{0}", ""),
         Resources.getIconByFilename('app.ico'))
Esempio n. 12
0
 def __init__(self, app):
     super(AboutWindow, self).__init__()
     self.app = app
     self.ui = Ui_AboutWindow()
     self.setLayout(QHBoxLayout())
     self.setWindowIcon(Resources.getIconByFilename('app.ico'))
     self.ui.setupUi(self)
     self.setWindowFlags(Qt.WindowCloseButtonHint)
     self.init()
Esempio n. 13
0
 def informationBox(self, title, text):
     informationMessageBox = QMessageBox(self)
     informationMessageBox.setWindowIcon(
         Resources.getIconByFilename('app.ico'))
     informationMessageBox.setWindowTitle(title)
     informationMessageBox.setIcon(QMessageBox.Information)
     informationMessageBox.setText(text)
     informationMessageBox.exec()
     return
Esempio n. 14
0
 def __init__(self, app):
     super(TransportSettingsDialog, self).__init__()
     self.app = app
     self.ui = Ui_TransportSettings()
     # self.setLayout(QHBoxLayout())
     self.setWindowTitle("About")
     self.setWindowIcon(Resources.getIconByFilename('app.ico'))
     self.ui.setupUi(self)
     self.init()
Esempio n. 15
0
 def disconnectServer(self):
     pros = self.app.strings.properties
     server.kill_forward_server()
     self.isConnected = False
     self.connectAndDisconnectAction.setText(pros['connect'])
     self.app.systemTrayIcon.setIcon(
         Resources.getIconByFilename('baseline_public_off_black_18dp.png'))
     self.app.systemTrayIcon.setToolTip(pros['notConnected'].replace(
         '{0}', pros['appName']))
     self.systemProxyMenu.setDisabledProxy()
Esempio n. 16
0
    def init(self):

        self.setStyleSheet(
            read_text_file(Resources.getResourcesPackagesPath('menu')))
        pros = self.app.strings.properties
        self.feedbackAction.setText(pros["feedback"])
        self.aboutAction.setText(pros["about"])

        self.feedbackAction.setIcon(
            Resources.getIconByFilename('none_black_18dp.png'))

        self.aboutAction.triggered.connect(self.aboutActionTriggered)
        self.feedbackAction.triggered.connect(self.feedbackActionTriggered)
Esempio n. 17
0
 def add(self):
     if self.ui.listWidget.count() > 0:
         if not self.save():
             return
     self.clearServer()
     remarks = "New Server"
     item = QListWidgetItem()
     item.setText(remarks)
     item.setIcon(
         Resources.getIconByFilename('baseline_public_black_18dp.png'))
     self.vmessServer = {"protocol": "Vmess", "remarks": remarks}
     self.setServer(self.vmessServer)
     self.ui.listWidget.addItem(item)
     self.ui.listWidget.setCurrentRow(
         len(self.guiConfig.guiConfig['serverList']))
Esempio n. 18
0
 def __init__(self, app):
     super(EditServersWindow, self).__init__()
     self.app = app
     self.guiConfig = self.app.guiConfig
     self.selectedServerIndex = self.guiConfig.guiConfig['settings'][
         'selectedServerIndex']
     self.ui = Ui_EditServerWindow()
     self.vmessServer = {}
     self.vlessServer = {}
     self.shadowscoksServer = {}
     self.trojanServer = {}
     self.shadowscoksServer = {}
     self.setWindowIcon(Resources.getIconByFilename('app.ico'))
     self.ui.setupUi(self)
     self.setWindowFlags(Qt.WindowCloseButtonHint)
     self.url = ""
     self.init()
Esempio n. 19
0
 def setSystemProxyModelIcon(self):
     if self.guiConfig.guiConfig['systemProxy']['proxyMode'] in "Disable":
         self.disableAction.setIcon(
             Resources.getIconByFilename('baseline_check_black_18dp.png'))
         self.PACAction.setIcon(Resources.getIconByFilename('hzj'))
         self.globalAction.setIcon(Resources.getIconByFilename('hzj'))
         sysproxy.off()
     elif self.guiConfig.guiConfig['systemProxy']['proxyMode'] in "PAC":
         self.PACAction.setIcon(
             Resources.getIconByFilename('baseline_check_black_18dp.png'))
         self.globalAction.setIcon(Resources.getIconByFilename('hzj'))
         self.disableAction.setIcon(Resources.getIconByFilename('hzj'))
         sysproxy.setAutoProxyUrl(
             self.guiConfig.guiConfig['systemProxy']['scriptAddress'])
     elif self.guiConfig.guiConfig['systemProxy']['proxyMode'] in "Global":
         self.globalAction.setIcon(
             Resources.getIconByFilename('baseline_check_black_18dp.png'))
         self.PACAction.setIcon(Resources.getIconByFilename('hzj'))
         self.disableAction.setIcon(Resources.getIconByFilename('hzj'))
         sysproxy.setWebProxy(
             f"{self.guiConfig.guiConfig['systemProxy']['proxyAddress']}:"
             f"{self.guiConfig.guiConfig['systemProxy']['proxyPort']}",
             self.guiConfig.guiConfig['systemProxy']['proxyOverride'])
Esempio n. 20
0
    def connectServer(self):
        pros = self.app.strings.properties
        if len(self.app.guiConfig.guiConfig['serverList']) == 0:
            self.informationBox(pros['connect'], pros['connectFailed'])
            return

        server.start_forward_server()
        self.isConnected = True
        self.connectAndDisconnectAction.setText(pros['disconnect'])
        self.app.systemTrayIcon.setIcon(
            Resources.getIconByFilename('baseline_public_black_18dp.png'))
        self.app.systemTrayIcon.setToolTip(pros['connected'].replace(
            '{0}', self.guiConfig.guiConfig["serverList"][
                self.guiConfig.guiConfig['settings']['selectedServerIndex']]
            ['remarks']).replace('{1}', pros['appName']).replace(
                '{2}',
                pros[self.guiConfig.guiConfig['systemProxy']['proxyMode']]))
        self.systemProxyMenu.setEnabledProxy()
Esempio n. 21
0
    def init(self):
        self.setStyleSheet(
            read_text_file(Resources.getResourcesPackagesPath('menu')))

        # 根据配置初始化菜单
        self.disableAction.setIcon(
            Resources.getIconByFilename('baseline_check_black_18dp.png'))

        # 根据属性文件初始化菜单
        pros = self.app.strings.properties
        self.disableAction.setText(pros["disable"])
        self.PACAction.setText(pros["pac"])
        self.globalAction.setText(pros["global"])

        # 绑定信槽
        self.disableAction.triggered.connect(self.disableActionTriggered)
        self.PACAction.triggered.connect(self.PACActionTriggered)
        self.globalAction.triggered.connect(self.globalActionTriggered)
Esempio n. 22
0
    def init(self):

        self.setStyleSheet(
            read_text_file(Resources.getResourcesPackagesPath('window')))
        # 根据配置文件初始化

        if len(self.guiConfig.guiConfig['serverList']) == 0:
            self.add()
        else:
            for serverDetail in self.guiConfig.guiConfig['serverList']:
                print(serverDetail)
                item = QListWidgetItem()
                item.setText(f"{serverDetail['remarks']}")
                item.setIcon(
                    Resources.getIconByFilename(
                        'baseline_public_black_18dp.png'))
                self.ui.listWidget.addItem(item)

            self.ui.listWidget.setCurrentRow(self.selectedServerIndex)
            self.setServer(self.guiConfig.guiConfig['serverList'][0])

        # 绑定信槽
        self.ui.addPushButton.clicked.connect(self.add)
        self.ui.addFromLinkPushButton.clicked.connect(self.addFromLink)
        self.ui.deletePushButton.clicked.connect(self.delete)
        self.ui.showQRCodePushButton.clicked.connect(self.showQRCode)
        self.ui.sharPushButton.clicked.connect(self.share)

        self.ui.listWidget.clicked.connect(self.listWidgetItemClicked)

        self.ui.protocolComboBox.currentIndexChanged.connect(self.setProtocol)
        self.ui.transportSettingsPushButton.clicked.connect(
            self.transportSettings)

        self.ui.savePushButton.clicked.connect(self.save)
        self.ui.cancelPushButton.clicked.connect(self.close)
        self.ui.resetPushButton.clicked.connect(self.reset)
        self.url = self.app.qrcodeMainWindow.serverToUrl(
            self.app.guiConfig.guiConfig['settings']['selectedServerIndex'])
Esempio n. 23
0
 def init(self):
     if len(self.guiConfig.guiConfig['serverList']) == 0:
         self.editServersWindow.show()
     self.systemTrayIcon.setContextMenu(self.systemTrayIconContextMenu)
     self.systemTrayIcon.setIcon(Resources.getIconByFilename('app.ico'))