コード例 #1
0
ファイル: main.py プロジェクト: sirkonst/plasmoid-brightness
    def init(self):
        self.dbusloop = DBusQtMainLoop()
        self.bus = dbus.SessionBus(mainloop=self.dbusloop)

        self.setHasConfigurationInterface(False)
        self.setAspectRatioMode(Plasma.IgnoreAspectRatio)

        # -- widgets
        slider = BrightnessSlider(self.bus, self.applet)
        icon_incr = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/brightness_incr.png"), "",
            self.applet)
        icon_decr = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/brightness_decr.png"), "",
            self.applet)

        # -- some logic
        icon_incr.clicked.connect(slider.stepUp)
        icon_decr.clicked.connect(slider.stepDown)

        # -- layoyt
        layout = QtGui.QGraphicsLinearLayout(Qt.Vertical, self.applet)
        layout.addItem(icon_incr)
        layout.addItem(slider)
        layout.setAlignment(slider, Qt.AlignCenter)
        layout.addItem(icon_decr)

        self.applet.setLayout(layout)
コード例 #2
0
    def init(self):
        self.setHasConfigurationInterface(False)
        self.setAspectRatioMode(Plasma.IgnoreAspectRatio)

        # -- widgets
        self.icon_laptop = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/mode-laptop.png"), "", self.applet)
        self.icon_stand = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/mode-stand.png"), "", self.applet)
        self.icon_tablet = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/mode-tablet.png"), "", self.applet)
        self.icon_tend = Plasma.IconWidget(
            QtGui.QIcon(self.package().path() +
                        "contents/images/mode-tend.png"), "", self.applet)
        self.target = Plasma.ItemBackground(self.applet)

        # -- some logic
        self.icon_laptop.clicked.connect(self.set_laptop_mode)
        self.icon_stand.clicked.connect(self.set_stand_mode)
        self.icon_tablet.clicked.connect(self.set_tablet_mode)
        self.icon_tend.clicked.connect(self.set_tend_mode)

        # -- layoyt
        layout = QtGui.QGraphicsLinearLayout(Qt.Horizontal, self.applet)
        layout.addItem(self.icon_laptop)
        layout.addItem(self.icon_stand)
        layout.addItem(self.icon_tablet)
        layout.addItem(self.icon_tend)

        self.applet.setLayout(layout)

        self.set_laptop_mode()
コード例 #3
0
    def init(self):
        """ Const method for initializing the applet """

        # Configuration interface support comes with plasma
        self.setHasConfigurationInterface(False)

        # Aspect ratio defined in Plasma
        self.setAspectRatioMode(Plasma.IgnoreAspectRatio)

        # Theme is a const variable holds Applet Theme
        self.theme = Plasma.Svg(self)

        # It gets default plasma theme's background
        self.theme.setImagePath("widgets/background")

        # Resize current theme as applet size
        self.theme.resize(self.size())

        self.layout = QGraphicsLinearLayout(self.applet)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)
        self.layout.setSizePolicy(
            QSizePolicy(QSizePolicy.MinimumExpanding,
                        QSizePolicy.MinimumExpanding))

        self.icon = Plasma.IconWidget()
        self.icon.setIcon("input-keyboard")
        self.icon.setToolTip("Wheel mouse to set keyboard backlight..")
        self.icon.setAcceptDrops(False)
        self.layout.addItem(self.icon)

        self.resize(125, 125)
コード例 #4
0
    def __init__(self, parent=None):
        plasmascript.Applet.__init__(self, parent)

        self.kdehome = unicode(KGlobal.dirs().localkdedir())
        self.iconPath = '/usr/share/kde4/apps/plasma/plasmoids/kde-plasma-spacer/contents/icons/Spacer.png'
        self.icon = Plasma.IconWidget()
        self.icon.setIcon(self.iconPath)
コード例 #5
0
ファイル: main.py プロジェクト: triffid/plasmoid
    def init(self):
        #TODO: have a configuration interface to set keybroad shortcut
        #self.setHasConfigurationInterface(True)
        self.setAspectRatioMode(Plasma.ConstrainedSquare)
        self.setBackgroundHints(self.NoBackground)

        self.sessionBus = dbus.SessionBus()
        self.powerdevil = self.sessionBus.get_object(
            'org.freedesktop.PowerManagement', '/modules/powerdevil')

        self.icon = Plasma.IconWidget(KIcon('preferences-desktop-screensaver'),
                                      '', self.applet)
        if KGlobalSettings.singleClick():
            self.connect(self.icon, SIGNAL('clicked()'), self.turn_off_screen)
        else:
            self.connect(self.icon, SIGNAL('doubleClicked()'),
                         self.turn_off_screen)
        self.connect(self, SIGNAL('active()'), self.turn_off_screen)

        self.layout = QGraphicsLinearLayout(self.applet)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)
        self.layout.addItem(self.icon)
        self.setLayout(self.layout)
        self.resize(25, 25)
コード例 #6
0
 def create_expander(self):
     self.expander = Plasma.IconWidget(self.panel)
     self.expander.setZValue(10)
     self.connect(self, SIGNAL("geometryChanged()"), self._resize_widgets)
     self.expander.setSizePolicy(
         QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed))
     self.expander.clicked.connect(self.on_expander_clicked)
     self.expander.setSvg("widgets/arrows", "left-arrow")
コード例 #7
0
 def createMiddle(self):
     self.middle = Plasma.IconWidget()
     self.middle_layout = QGraphicsLinearLayout(Qt.Vertical)
     self.middle_layout.setContentsMargins(0,0,0,0)
     self.middle.setLayout(self.middle_layout)
     self.set_middle_size()
     self.middle.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
     if self.veromix.is_albumart_enabled():
         self.middle.setIcon(KIcon(self.get_pauseIcon()))
コード例 #8
0
ファイル: main.py プロジェクト: AlexNk/hdmi_switcher
    def init(self):
        self.setHasConfigurationInterface(True)

        self.cfg = self.config()
        self.read_config()

        self.setBackgroundHints(Plasma.Applet.TranslucentBackground)
        self.layout = QGraphicsLinearLayout(self.applet)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)
        self.layout.setOrientation(Qt.Horizontal)
        self.icon = Plasma.IconWidget()
        self.layout.addItem(self.icon)
        self.resize(128, 128)
        self.connect(self.icon, SIGNAL("clicked()"), self.on_click)

        self.timer = QTimer()
        self.connect(self.timer, SIGNAL("timeout()"), self.on_timer)
        self.timer.start(timer_delay)
コード例 #9
0
    def __init__(self, parent, name, isdescenabled=True):
        QGraphicsWidget.__init__(self, parent)

        self.animator = Plasma.Animator.self()
        self._name = name
        self._parent = parent

        self.layout = QGraphicsLinearLayout(Qt.Horizontal, self)
        self.service_icon = Plasma.IconWidget(self)
        self.service_icon.setMinimumWidth(20)
        self.layout.addItem(self.service_icon)

        info = link.System.Service[self._name].info()
        self._type, self._desc, self._state = map(lambda x: unicode(x), info)
        self.service_icon.setIcon(state_icons[self._state])

        self.label_layout = QGraphicsLinearLayout(Qt.Vertical)
        self.layout.addItem(self.label_layout)

        self.service_name = Plasma.Label(self)
        self.service_name.setText(name.capitalize().replace('_',' '))
        self.service_name.setStyleSheet("font-weight:bold")
        self.label_layout.addItem(self.service_name)

        if isdescenabled:
            self.service_desc = Plasma.Label(self)
            self.service_desc.setText(self._desc)
            self.label_layout.addItem(self.service_desc)

        self.layout.addStretch()

        self.stateButton = Plasma.PushButton(self)
        self.stateButton.setMinimumWidth(100)
        self.stateButton.setMaximumHeight(120)
        self.layout.addItem(self.stateButton)

        self.connect(self.stateButton, SIGNAL("clicked()"), self.setService)

        QTimer.singleShot(100, self.setButtonStates)
コード例 #10
0
ファイル: main.py プロジェクト: pars-linux/uludag
    def init(self):
        """init method for the plasmoid. GUI stuff is located here."""

        self.moduller = self.link.Network.Firewall[dbus.String(
            "iptables")].listModules()

        self.setHasConfigurationInterface(True)
        self.setAspectRatioMode(Plasma.Square)
        self.resize(450, 250)

        self.theme = Plasma.Svg(self)
        self.theme.setImagePath("widgets/background")
        self.setBackgroundHints(Plasma.Applet.DefaultBackground)
        self.layout = QGraphicsGridLayout(self.applet)

        label = Plasma.Label(self.applet)
        label.setText("<h1>Firewall Plasmoid</h1>")
        self.kilit = Plasma.IconWidget(self.applet)
        self.bilgi_label = Plasma.Label(self.applet)

        self.baslat_pb = Plasma.PushButton(self.applet)
        self.baslat_pb.setText("Start")
        self.durdur_pb = Plasma.PushButton(self.applet)
        self.durdur_pb.setText("Stop")
        print "osman"
        if self.link.Network.Firewall[dbus.String(
                "iptables")].getState() == dbus.String(u"on"):
            self.bilgi_label.setText(
                "<p style='color:green'>Firewall is working now.</p>")
            self.kilit.setIcon("object-locked")
            self.kilit.setMaximumSize(32, 32)
            self.kilit.setMinimumSize(32, 32)
            self.baslat_pb.setEnabled(False)

        else:
            self.bilgi_label.setText(
                "<p style='color:red'>Firewall is stopped now.</p>")
            self.kilit.setMaximumSize(32, 32)
            self.kilit.setMinimumSize(32, 32)
            self.kilit.setIcon("object-unlocked")
            self.durdur_pb.setEnabled(False)

        self.bilgilendirme_baslik = Plasma.Label(self.applet)
        self.bilgilendirme_baslik.setText("Latest news:")

        self.bilgilendirme = Plasma.Label(self.applet)
        self.bilgilendirme.setText("Firewall Plasmoid has been started.")

        gelen_simge = Plasma.IconWidget(self.applet)
        gelen_simge.setIcon("application-x-smb-workgroup")
        paylasim_simge = Plasma.IconWidget(self.applet)
        paylasim_simge.setIcon("application-x-smb-server")
        giden_simge = Plasma.IconWidget(self.applet)
        giden_simge.setIcon("security-medium")

        self.kutular = []
        sayi = 0
        for i in self.moduller:
            self.kutular.append(Plasma.CheckBox(self.applet))
            self.kutular[sayi].setText(self.link.Network.Firewall[dbus.String(
                "iptables")].moduleInfo(i)[0])
            sayi += 1

        self.layout.addItem(label, 0, 0, 1, 4)
        self.layout.addItem(self.kilit, 1, 0)
        self.layout.addItem(self.bilgi_label, 1, 1)
        self.layout.addItem(self.baslat_pb, 1, 2)
        self.layout.addItem(self.durdur_pb, 1, 3)
        self.layout.addItem(gelen_simge, 2, 0, 1, 1)
        self.layout.addItem(paylasim_simge, 3, 0, 1, 1)
        self.layout.addItem(giden_simge, 4, 0, 1, 1)
        self.layout.addItem(self.bilgilendirme_baslik, 5, 0, 1, 1)
        self.layout.addItem(self.bilgilendirme, 5, 1, 1, 4)
        m = 0
        for i in range(0, len(self.moduller)):
            self.layout.addItem(self.kutular[m], m + 2, 1, 1, 4)
            m += 1
        self.applet.setLayout(self.layout)

        QObject.connect(self.baslat_pb, SIGNAL("clicked()"), self.baslat)
        QObject.connect(self.durdur_pb, SIGNAL("clicked()"), self.durdur)

        fonksiyonlar = [self.blockGelen, self.paylasim, self.blockGiden]
        for i in range(0, len(self.moduller)):
            QObject.connect(self.kutular[i], SIGNAL("toggled(bool)"),
                            fonksiyonlar[i])

        self.bilgilendirme_iletileri = [
            "Incoming connections was blocked successfully.",
            "Sharing internet is successful.",
            "Outgoing connections was blocked successfully."
        ]

        self.link.listenSignals("Network.Firewall", self.handler)
コード例 #11
0
 def create_prev_panel(self):
     self.prev_panel = Plasma.IconWidget()
     self.prev_panel_layout = QGraphicsLinearLayout(Qt.Vertical)
     self.prev_panel_layout.setContentsMargins(0,0,0,0)
     self.prev_panel.setLayout(self.prev_panel_layout)
     self.prev_panel.setSizePolicy(QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum))