Пример #1
0
    def __init__(self, parent=None):
        QObject.__init__(self, parent)

        self.tray = KStatusNotifierItem("ksni-test-tool", self)
        self.tray.setCategory(KStatusNotifierItem.Communications)
        self.tray.setIconByName(
            QString(
                "/usr/share/icons/oxygen/16x16/categories/applications-internet.png"
            ))
        self.tray.setAttentionIconByName(QString("accessories-text-editor"))
        self.tray.setStatus(KStatusNotifierItem.Active)
        self.tray.setToolTipIconByName(
            QString(
                "/usr/share/icons/oxygen/16x16/categories/applications-internet.png"
            ))

        self.menu = KMenu("KSNI Test Tool")
        self.menu.addAction("Hello", self.onHelloClicked)
        self.menu.addAction("Change Status", self.toggleStatus)
        self.menu.addAction("Hide for some seconds", self.hideForAWhile)
        self.menu.addAction("Switch to pixmap icon", self.usePixmap)
        self.menu.addSeparator()
        self.menu.addAction("Set overlay pixmap", self.setOverlayPixmap)
        self.menu.addAction("Set overlay icon name", self.setOverlayName)
        self.menu.addAction("Remove overlay icon", self.removeOverlay)
        self.tray.setContextMenu(self.menu)

        self.tray.activateRequested.connect(self.onActivated)
        self.tray.scrollRequested.connect(self.onScroll)
Пример #2
0
    def __init__(self):

        app_name = "magneto"
        catalog = ""
        prog_name = ki18n("Magneto")
        version = "1.0"
        description = ki18n("System Update Status")
        lic = KAboutData.License_GPL
        cright = ki18n("(c) 2013 Fabio Erculiani")
        text = ki18n("none")
        home_page = "www.sabayon.org"
        bug_mail = "*****@*****.**"

        self._kabout = KAboutData(app_name, catalog, prog_name, version,
                                  description, lic, cright, text, home_page,
                                  bug_mail)

        argv = [sys.argv[0]]
        KCmdLineArgs.init(argv, self._kabout)
        self._app = KApplication()

        from dbus.mainloop.qt import DBusQtMainLoop
        super(Magneto, self).__init__(main_loop_class=DBusQtMainLoop)

        self._window = KStatusNotifierItem()
        # do not show "Quit" and use quitSelected() signal
        self._window.setStandardActionsEnabled(False)

        icon_name = self.icons.get("okay")
        self._window.setIconByName(icon_name)
        self._window.setStatus(KStatusNotifierItem.Passive)

        self._window.connect(self._window,
                             SIGNAL("activateRequested(bool,QPoint)"),
                             self.applet_activated)
        self._menu = KMenu(_("Magneto Entropy Updates Applet"))
        self._window.setContextMenu(self._menu)

        self._menu_items = {}
        for item in self._menu_item_list:
            if item is None:
                self._menu.addSeparator()
                continue

            myid, _unused, mytxt, myslot_func = item
            name = self.get_menu_image(myid)
            action_icon = KIcon(name)

            w = KAction(action_icon, mytxt, self._menu)
            self._menu_items[myid] = w
            self._window.connect(w, SIGNAL("triggered()"), myslot_func)
            self._menu.addAction(w)

        self._menu.hide()
Пример #3
0
    def init_ui(self):
        grid = QtGui.QGridLayout()
        grid.setSpacing(2)

        for i, control in enumerate(self.controls):
            icon = QtGui.QLabel(self)
            icon.setPixmap(QtGui.QPixmap(asset('%s.png' % control['tag'])))
            icon.setToolTip(control['name'])
            grid.addWidget(icon, i + 1, 0)

            label = QtGui.QLabel(self)
            label.setMinimumWidth(32)
            label.setAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignRight)
            grid.addWidget(label, i + 1, 1)

            sld = QtGui.QSlider(QtCore.Qt.Horizontal, self)

            sld.label = label
            sld.control = control

            value, max_value = self.device.read(control['id'], True)

            sld.setMinimum(0)
            sld.setMaximum(max_value)
            sld.setValue(value)
            self.update_label(sld)

            sld.setMinimumWidth(150)
            sld.setFocusPolicy(QtCore.Qt.NoFocus)
            sld.valueChanged[int].connect(self.change_value)

            control['slider'] = sld  # FIXME circular reference

            grid.addWidget(sld, i + 1, 2)

        self.setLayout(grid)
        self.setGeometry(300, 300, 280, 70)
        self.setWindowTitle('Qt DDC/CI Gui')
        self.show()

        if self.scroll_control:
            self.tray_icon = KStatusNotifierItem("qddccigui", self)
            self.tray_icon.setIconByPixmap(
                QtGui.QIcon(
                    QtGui.QPixmap(asset('%s.png' %
                                        self.scroll_control['tag']))))
            self.tray_icon.scrollRequested[int, QtCore.Qt.Orientation].\
                connect(self.scroll_requested)
Пример #4
0
    def __init__(self, parent, name, icon):
        object.__init__(self)

        self._app = None
        self._parent = parent
        self._gtk_running = False
        self._quit_added = False

        self.act_indexes = []
        self.sep_indexes = []
        self.menu_indexes = []

        if TrayEngine == "KDE":
            self.menu = KMenu(parent)
            self.menu.setTitle(name)
            self.tray = KStatusNotifierItem()
            self.tray.setAssociatedWidget(parent)
            self.tray.setCategory(KStatusNotifierItem.ApplicationStatus)
            self.tray.setContextMenu(self.menu)
            self.tray.setIconByPixmap(getIcon(icon))
            self.tray.setTitle(name)
            self.tray.setToolTipTitle(" ")
            self.tray.setToolTipIconByPixmap(getIcon(icon))
            # Double-click is managed by KDE

        elif TrayEngine == "AppIndicator":
            self.menu = Gtk.Menu()
            self.tray = AppIndicator.Indicator.new(
                name, icon, AppIndicator.IndicatorCategory.APPLICATION_STATUS)
            self.tray.set_menu(self.menu)
            # Double-click is not possible with App-Indicators

        elif TrayEngine == "Qt":
            self.menu = QMenu(parent)
            self.tray = QSystemTrayIcon(getIcon(icon))
            self.tray.setContextMenu(self.menu)
            self.tray.setParent(parent)
            self.tray.connect(
                self.tray,
                SIGNAL("activated(QSystemTrayIcon::ActivationReason)"),
                self.qt_systray_clicked)
Пример #5
0
    def __init__(self, parent, title, icon):
        QObject.__init__(self)

        # Setup contextual menu
        if kde:
            self.menu = KMenu(parent)
            self.tray = KStatusNotifierItem(parent)
            self.tray.setStatus(KStatusNotifierItem.Passive)
            self.tray.setCategory(KStatusNotifierItem.ApplicationStatus)
            self.tray.setAssociatedWidget(parent)
            self.tray.setStandardActionsEnabled(False)
            self.tray.activateRequested.connect(self._activateRequested)
        else:
            self.menu = QMenu()
            self.tray = QSystemTrayIcon()
            self.tray.activated.connect(self._activated)
        self.setIcon(icon)
        self.setTitle(title)
        if not kde:
            self.tray.show()
        self.tray.setContextMenu(self.menu)