Beispiel #1
0
 def show_msg(self, msg):
     icon = QSystemTrayIcon.MessageIcon(QSystemTrayIcon.Information)
     m = util.js_to_msg(msg)
     self.url = m.content
     self.showMessage(
         _('Notify!'),
         _('A new message from {}.\nClicked this to view detail of:\n{}'. \
         format(m._from, self.url)), icon)
Beispiel #2
0
 def showMessage(self):
     icon = QSystemTrayIcon.MessageIcon(
         self.typeComboBox.itemData(self.typeComboBox.currentIndex()))
     self.trayIcon.showMessage(
         self.titleEdit.text(),
         self.bodyEdit.toPlainText(),
         icon,
         self.durationSpinBox.value() * 1000,
     )
Beispiel #3
0
    def showMessage(self,
                    title: str,
                    body: str,
                    icon: int = 1,
                    limit: int = 5):
        tray = QSystemTrayIcon(_pkg.icon_path("logo.png", True))
        icon_ = tray.MessageIcon(icon)

        tray.showMessage(title, body, icon_, limit * 2000)
        tray.show()
Beispiel #4
0
    def tum_mesajlar_fonk(self):
        self.varolan_mesajlar = self.tum_mesajlar
        self.mesaj_liste.clear()

        duzenli_mesajlar = self.mesajlar_oku_sirala()
        mesajlar = duzenli_mesajlar.keys()
        sirali_mesajlar = list(mesajlar)
        sirali_mesajlar.sort()
        sirali_mesajlar = sirali_mesajlar[::-1]
        if len(sirali_mesajlar) != 0:
            for mesaj in sirali_mesajlar:
                mesaj_ = duzenli_mesajlar[mesaj]
                ozel_widget = listemadddesi.OzelListeMaddesi(self)
                ozel_widget.okuyucu()
                ozel_widget.mesaj_id_ekle(mesaj_[2])
                ozel_widget.mesaj_tipi_ekle(mesaj_[0])
                ozel_widget.mesaj_ekle(mesaj_[1])
                ozel_widget.tarih_ekle(mesaj)
                ozel_widget.gonderen_ekle(mesaj_[3])
                ozel_widget.gonderen_onay_ekle(mesaj_[4])
                if mesaj_[2] in self.okunmus_mesajlar:
                    ozel_widget.okunma_degistir("okundu")
                else:
                    ozel_widget.okunma_degistir("okunmadi")
                ozel_widget_item = QListWidgetItem(self.mesaj_liste)
                ozel_widget_item.setSizeHint(ozel_widget.sizeHint())
                self.mesaj_liste.setItemWidget(ozel_widget_item, ozel_widget)

                if mesaj_[2] not in self.varolan_mesajlar:
                    if mesaj_[0] == "bilgi":
                        icon = 1
                    elif mesaj_[0] == "sistem":
                        icon = 2
                    elif mesaj_[0] == "kritik":
                        icon = 3
                    else:
                        icon = 0
                    self.sistem_cekmecesi.showMessage(
                        mesaj_[0], mesaj_[1],
                        QSystemTrayIcon.MessageIcon(icon), 5000)
                    self.sistem_cekmecesi.setIcon(
                        QIcon("./icons/milis-bildirim-m.png"))
Beispiel #5
0
class BaseTray(object):
    def __init__(self, icon_path):
        self.tray = QSystemTrayIcon()
        self.tray.setIcon(QIcon(icon_path))
        self.tray_menu = QMenu()
        self._set_menu()

    def _set_menu(self):
        pass

    def show_message(self, text):
        icon = self.tray.MessageIcon()
        self.tray.showMessage('message', text, icon, 1000)

    def show(self):
        self.tray.show()

    def quit(self):
        self.tray.hide()
        sys.exit()
Beispiel #6
0
 def showNotifcation(self, title, message):
     icon = QSystemTrayIcon.MessageIcon(
         self.typeComboBox.itemData(self.typeComboBox.currentIndex()))
     self.trayIcon.showMessage(title, message, icon,
                               self.durationSpinBox.value() * 1000)
Beispiel #7
0
    def __init__(self, ebeveyn=None):
        super(Okuyucu, self).__init__(ebeveyn)
        kutu = QVBoxLayout()
        self.setLayout(kutu)
        kutu.setContentsMargins(0, 0, 0, 0)

        self.sistem_cekmecesi = QSystemTrayIcon(self)
        self.sistem_cekmecesi.setIcon(QIcon("./icons/milis-bildirim.png"))
        self.sistem_cekmecesi.activated.connect(self.sistem_cekmecesi_tiklandi)
        self.sistem_cekmecesi.show()

        self.menu_cekmece = QMenu(self)
        self.mesaj_oku_aksiyon = QAction("Mesaj Oku",
                                         self,
                                         statusTip="MesajOku",
                                         triggered=self.mesaj_oku_fonk)
        self.mesaj_gonder_aksiyon = QAction("Mesaj Gönder",
                                            self,
                                            statusTip="MesajGonder",
                                            triggered=self.mesaj_gonder_fonk)
        self.ayarlar_aksiyon = QAction("Ayarlar",
                                       self,
                                       statusTip="Ayarlar",
                                       triggered=self.ayarlar_fonk)
        self.kapat_aksiyon = QAction("Kapat",
                                     self,
                                     statusTip="Kapat",
                                     triggered=self.kapat_fonk)
        self.menu_cekmece.addAction(self.mesaj_oku_aksiyon)
        self.menu_cekmece.addAction(self.mesaj_gonder_aksiyon)
        self.menu_cekmece.addAction(self.ayarlar_aksiyon)
        self.menu_cekmece.addAction(self.kapat_aksiyon)
        self.sistem_cekmecesi.setContextMenu(self.menu_cekmece)
        self.sistem_cekmecesi.showMessage(
            "Çalıştı", "Milis Bildirim Başarıyla Çalıştırıldı",
            QSystemTrayIcon.MessageIcon(1), 5000)

        self.mesaj_liste = QListWidget()
        self.mesaj_liste.setSelectionMode(QListView.ExtendedSelection)
        kutu.addWidget(self.mesaj_liste)

        self.setFixedWidth(285)
        s = QDesktopWidget().screenGeometry(0)
        self.setFixedHeight(s.height())
        self.setWindowFlags(Qt.Popup)
        self.move(s.width() - 285, 0)

        ################################
        self.settings = QSettings()
        self.okunmus_mesajlar = self.settings.value("liste", [], str) or []
        self.tum_mesajlar = os.listdir(self.MESAJ_DIZINI)
        self.varolan_mesajlar = []
        try:
            self.gecersizleri_goster = int(
                self.settings.value("gecersizleri_goster"))
            self.anonimleri_goster = int(
                self.settings.value("anonimleri_goster"))
        except:
            self.gecersizleri_goster = 1
            self.anonimleri_goster = 1
        ################################
        self.tum_mesajlar_fonk()
        self.dosya_izleyici = QFileSystemWatcher()
        self.dosya_izleyici.addPath(self.MESAJ_DIZINI)
        self.dosya_izleyici.directoryChanged.connect(self.tum_mesajlar_fonk)
        #################################
        # Bildirim çalıştırılıyor       #
        #################################
        zamanlayici = QTimer(self)
        zamanlayici.setInterval(6000)
        zamanlayici.timeout.connect(self.bildirim_calistir)
        zamanlayici.start()
Beispiel #8
0
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.logpath = "sslocal.log"
        logging.getLogger('').handlers = []
        logging.basicConfig(level=logging.INFO,
                            format='%(asctime)s %(levelname)-8s %(message)s',
                            datefmt='%Y-%m-%d %H:%M:%S',
                            filename=self.logpath,
                            filemode="a")
        console = logging.StreamHandler()
        console.setLevel(logging.INFO)
        datefmt = '%Y-%m-%d %H:%M:%S'
        formatter = logging.Formatter(
            '%(asctime)s %(levelname)-8s %(message)s', datefmt=datefmt)
        console.setFormatter(formatter)
        logging.getLogger('').addHandler(console)

    def start(self):
        with open(self.logpath, "w") as file_:
            file_.write("shadowsocks-pyqt is started\n")
        if sys.platform.startswith('win'):
            self.fastopenCheckBox.setEnabled(False)
        self.logwindow = LogWindow(self.logpath)
        config_path = find_config("gui-config.json")
        if config_path == None:
            logging.error("config_path is None")
            raise
        self.gui_config = read_json(config_path)
        configlist = self.configlist
        for x in self.gui_config.get("configs", {}):
            x = check_config(x)
            if x.get("remarks", "") == "":
                item_text = "%s:%s" % (x["server"], x["server_port"])
            else:
                item_text = "%s (%s:%s)" % (x["remarks"], x["server"],
                                            x["server_port"])
            configlist.addItem(item_text)
        index = self.gui_config.get("index", 0)
        configlist.setCurrentRow(index)

    def save_config(self):
        new_config = collections.OrderedDict()
        gui_config = self.gui_config
        new_config["server"] = self.serverAddrEdit.text()
        new_config["server_port"] = self.serverPortSpinBox.value()
        new_config["local_port"] = self.localportSpinBox.value()
        new_config["password"] = self.pwdEdit.text()
        new_config["timeout"] = self.timeoutSpinBox.value()
        new_config["method"] = self.encryptComboBox.currentText()
        new_config["local_address"] = self.localaddressEdit.text()
        new_config["one_time_auth"] = self.otaCheckBox.isChecked()
        new_config["fast_open"] = self.fastopenCheckBox.isChecked()

        config_path = find_config("config.json")
        if config_path == None:
            logging.error("config_path is None")
        save_json(config_path, new_config)
        new_config["remarks"] = self.remarksEdit.text()
        index = self.configlist.currentRow()
        if index < len(gui_config["configs"]):
            gui_config["configs"][index] = new_config
            gui_config["index"] = index
        else:
            gui_config["configs"].append(new_config)

        config_path = find_config("gui-config.json")
        if config_path == None:
            logging.error("config_path is None")
        save_json(config_path, gui_config)
        if new_config.get("remarks", "") == "":
            item_text = "%s:%s" % (new_config["server"],
                                   new_config["server_port"])
        else:
            item_text = "%s (%s:%s)" % (new_config["remarks"],
                                        new_config["server"],
                                        new_config["server_port"])
        self.configlist.currentItem().setText(item_text)

    @pyqtSlot()
    def on_b_yes_clicked(self):
        """
        Slot documentation goes here.
        """
        logging.info("close ss-local...")
        self.sslocal_process.terminate()
        self.sslocal_process.join()
        self.save_config()
        logging.info("restart ss-local")
        sslocal_process = SendeventProcess(target=Shadowsocks_Process,
                                           args=(self.logpath, ),
                                           daemon=True)
        sslocal_process.start()
        self.sslocal_process = sslocal_process
        self.showMessage(u"配置已生效!")
        self.destroy()

    @pyqtSlot()
    def on_b_exit_clicked(self):
        self.destroy()

    def app_quit(self):
        self.sslocal_process.terminate()
        self.sslocal_process.join()
        self.tray.hide()
        sys.exit()

    def closeEvent(self, event):
        self.destroy()
        event.ignore()

    @pyqtSlot()
    def on_del_config_clicked(self):
        index = self.configlist.currentRow()
        self.configlist.takeItem(index)
        if index < len(self.gui_config["configs"]):
            self.gui_config["configs"].pop(index)
        self.update()

    @pyqtSlot()
    def on_add_config_clicked(self):
        new_config = collections.OrderedDict()
        count = self.configlist.count()
        self.configlist.addItem("127.0.0.1")
        new_config["server"] = "127.0.0.1"
        new_config["server_port"] = 1080
        new_config["local_port"] = 1080
        new_config["password"] = "******"
        new_config["timeout"] = 600
        new_config["method"] = "aes-256-cfb"
        new_config["local_address"] = "127.0.0.1"
        new_config["one_time_auth"] = False
        new_config["fast_open"] = False
        new_config["remarks"] = ""

        self.gui_config["configs"].append(new_config)
        self.configlist.setCurrentRow(count)
        self.update()

    def update(self):
        user_json = self.gui_config
        index = self.configlist.currentRow()
        select_config = user_json["configs"][index]
        select_config = check_config(select_config)
        remarks = select_config.get("remarks", "")
        server_addr = select_config["server"]
        server_port = select_config["server_port"]
        password = select_config["password"]
        method = select_config["method"]
        timeout = select_config["timeout"]
        local_address = select_config["local_address"]
        local_port = select_config["local_port"]
        fast_open = select_config["fast_open"]
        one_time_auth = select_config["one_time_auth"]
        self.serverAddrEdit.setText(server_addr)
        self.serverPortSpinBox.setValue(int(server_port))
        self.pwdEdit.setText(password)
        self.encryptComboBox.setCurrentText(method)
        self.timeoutSpinBox.setValue(timeout)
        self.otaCheckBox.setChecked(one_time_auth)
        self.remarksEdit.setText(remarks)
        self.localaddressEdit.setText(local_address)
        self.localportSpinBox.setValue(local_port)
        self.fastopenCheckBox.setChecked(fast_open)

    def Tray_init(self):
        self.tray = QSystemTrayIcon()
        self.icon = self.windowIcon()
        self.tray.setIcon(self.icon)
        self.tray.activated[QSystemTrayIcon.ActivationReason].connect(
            self.TrayEvent)
        self.tray_menu = QtWidgets.QMenu(QtWidgets.QApplication.desktop())
        self.ShowAction = QtWidgets.QAction(u'还原 ',
                                            self,
                                            triggered=self.re_build)
        self.ShowLog = QtWidgets.QAction(u'查看日志 ',
                                         self,
                                         triggered=self.logwindow.showlog)
        self.QuitAction = QtWidgets.QAction(u'退出 ',
                                            self,
                                            triggered=self.app_quit)
        self.tray_menu.addAction(self.ShowLog)
        self.tray_menu.addAction(self.ShowAction)
        self.tray_menu.addAction(self.QuitAction)
        self.tray.setContextMenu(self.tray_menu)  # 设置系统托盘菜单
        self.tray.show()
        self.showMessage(u"shadowsocks-pyqt 已经启动!")

    def re_build(self):
        self.hide()
        self.update()
        self.show()
        self.activateWindow()

    def TrayEvent(self, reason):
        if reason == QSystemTrayIcon.DoubleClick:
            if self.isHidden() or self.destroyed:
                self.re_build()
            else:
                self.hide()

    def showMessage(self, text):
        icon = self.tray.MessageIcon()
        self.tray.showMessage(u'提示', text, icon, 1000)
Beispiel #9
0
class MainWindow(QMainWindow, Ui_MainWindow):
    """
    Class documentation goes here.
    """
    def __init__(self, parent=None):
        """
        Constructor
        
        @param parent reference to the parent widget
        @type QWidget
        """
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)

    def save_config(self):
        new_config = collections.OrderedDict()
        gui_config = self.gui_config
        new_config["server"] = self.serverAddrEdit.text()
        new_config["server_port"] = self.serverPortSpinBox.value()
        new_config["password"] = self.pwdEdit.text()
        new_config["method"] = self.encryptComboBox.currentText()
        new_config["timeout"] = self.timeoutSpinBox.value()
        new_config["one_time_auth"] = self.otaCheckBox.isChecked()
        config_path = find_config("config.json")
        if config_path == None:
            logging.error("config_path is None")
        save_json(config_path, new_config)
        new_config["remarks"] = self.remarksEdit.text()
        index = self.configlist.currentRow()
        if index < len(gui_config["configs"]):
            gui_config["configs"][index] = new_config
            gui_config["index"] = index
        else:
            gui_config["configs"].append(new_config)

        config_path = find_config("gui-config.json")
        if config_path == None:
            logging.error("config_path is None")
        save_json(config_path, gui_config)
        if new_config.get("remarks", "") == "":
            item_text = "%s:%s" % (new_config["server"],
                                   new_config["server_port"])
        else:
            item_text = "%s (%s:%s)" % (new_config["remarks"],
                                        new_config["server"],
                                        new_config["server_port"])
        self.configlist.currentItem().setText(item_text)

    @pyqtSlot()
    def on_b_yes_clicked(self):
        """
        Slot documentation goes here.
        """
        logging.info("close ss-local...")
        self.sslocal_process.terminate()
        self.sslocal_process.join()
        self.save_config()
        logging.info("restart ss-local")
        sslocal_process = SendeventProcess(target=ss_local.main, daemon=True)
        sslocal_process.start()
        self.sslocal_process = sslocal_process
        self.showMessage("配置已生效!")
        self.destroy()

    @pyqtSlot()
    def on_b_exit_clicked(self):
        self.destroy()

    def app_quit(self):
        self.sslocal_process.terminate()
        self.sslocal_process.join()
        sys.exit()

    def closeEvent(self, event):
        self.destroy()
        event.ignore()

    @pyqtSlot()
    def on_del_config_clicked(self):
        index = self.configlist.currentRow()
        self.configlist.takeItem(index)
        if index < len(self.gui_config["configs"]):
            self.gui_config["configs"].pop(index)
        self.update()

    @pyqtSlot()
    def on_add_config_clicked(self):
        new_config = collections.OrderedDict()
        count = self.configlist.count()
        self.configlist.addItem("127.0.0.1")
        new_config["server"] = "127.0.0.1"
        new_config["server_port"] = 1080
        new_config["password"] = "******"
        new_config["method"] = "aes-256-cfb"
        new_config["timeout"] = 600
        new_config["one_time_auth"] = False
        new_config["remarks"] = ""
        self.gui_config["configs"].append(new_config)
        self.configlist.setCurrentRow(count)
        self.update()

    def update(self):
        user_json = self.gui_config
        index = self.configlist.currentRow()
        select_config = user_json["configs"][index]
        remarks = select_config.get("remarks", "")
        server_addr = select_config["server"]
        server_port = select_config["server_port"]
        password = select_config["password"]
        method = select_config["method"]
        timeout = select_config["timeout"]
        one_time_auth = select_config["one_time_auth"]
        self.serverAddrEdit.setText(server_addr)
        self.serverPortSpinBox.setValue(int(server_port))
        self.pwdEdit.setText(password)
        self.encryptComboBox.setCurrentText(method)
        self.timeoutSpinBox.setValue(timeout)
        self.otaCheckBox.setChecked(one_time_auth)
        self.remarksEdit.setText(remarks)

    def Tray_init(self):
        self.tray = QSystemTrayIcon()
        self.icon = self.windowIcon()
        self.tray.setIcon(self.icon)
        self.tray.activated[QSystemTrayIcon.ActivationReason].connect(
            self.TrayEvent)
        self.tray_menu = QtWidgets.QMenu(QtWidgets.QApplication.desktop())
        self.ShowAction = QtWidgets.QAction(u'还原 ',
                                            self,
                                            triggered=self.re_build)
        self.QuitAction = QtWidgets.QAction(u'退出 ',
                                            self,
                                            triggered=self.app_quit)
        self.tray_menu.addAction(self.ShowAction)
        self.tray_menu.addAction(self.QuitAction)
        self.tray.setContextMenu(self.tray_menu)  #设置系统托盘菜单
        self.tray.show()
        self.showMessage("shadowsocks-pyqt 已经启动!")

    def re_build(self):
        self.hide()
        self.update()
        self.show()
        self.activateWindow()

    def TrayEvent(self, reason):
        if reason == QSystemTrayIcon.DoubleClick:
            if self.isHidden() or self.destroyed:
                self.re_build()
            else:
                self.hide()

    def showMessage(self, text):
        icon = self.tray.MessageIcon()
        self.tray.showMessage(u'提示', text, icon, 1000)
Beispiel #10
0
 def showMessage(self, msg):
     self.trayIcon.showMessage("This is Python", msg,
                               QSystemTrayIcon.MessageIcon(0), 15 * 1000)
Beispiel #11
0
 def show_message(tray, title, body):
     icon = QSystemTrayIcon.MessageIcon(QSystemTrayIcon.Information)
     tray.showMessage(title, body, icon)
Beispiel #12
0
 def showNotification(title, body):
     trayIcon = QSystemTrayIcon()
     trayIcon.setIcon(QIcon(getResource("speech.png")))
     trayIcon.show()
     icon = QSystemTrayIcon.MessageIcon(QSystemTrayIcon.Information)
     trayIcon.showMessage(title, body, icon)