Пример #1
0
    def init(self):
        plasmascript.Applet.init(self)
        KGlobal.locale().insertCatalog("veromix")
        if "usr/share/kde4" not in os.path.realpath(__file__):
            out = commands.getstatusoutput(
                "xdg-icon-resource install --size 128 " +
                unicode(self.package().path()) +
                "contents/icons/veromix-plasmoid-128.png veromix-plasmoid")
            if out[0] == 0:
                print "veromix icon installed"
            else:
                print "Error installing veromix icon:", out

        LADSPAPresetLoader().install_ladspa_presets_if_needed()
        if self.is_ladspa_enabled():
            # force singleton initialisation
            LADSPAPresetLoader().presets()
            LADSPAEffects().effects()

        createDbusServiceDescription(
            self.package().path() + "/dbus-service/veromix-service-qt.py",
            True)

        KGlobal.locale().insertCatalog("veromix")

        self.setHasConfigurationInterface(True)
        self.setAspectRatioMode(Plasma.IgnoreAspectRatio)
        self.theme = Plasma.Svg(self)

        self.widget = VeroMix(self)
        self.widget.init()

        defaultSize = QVariant(QSize(0, 0))
        size = self.config().readEntry("size", defaultSize).toSize()
        if self.formFactor() == Plasma.Planar:
            self.widget.setMinimumSize(275, 125)
        elif (size != defaultSize):
            self.widget.setPreferredSize(size.width(), size.height())
        else:
            self.widget.setPreferredSize(470, 145)

        self.connect(self.widget, SIGNAL("resized()"), self.dialogResized)
        #try:
        self.setGraphicsWidget(self.widget)
        self.applet.setPassivePopup(True)
        ## FIXME: see fixPopupcion
        self.setPopupIcon(KIcon("audio-volume-high"))
        #self.setPopupIcon("audio-volume-muted")
        # dont know why but adding it a second time helps (otherwise it
        # wont popup when you add it directly to the panel)
        self.setGraphicsWidget(self.widget)
        self.connect(self.applet, SIGNAL("appletDestroyed(Plasma::Applet*)"),
                     self.doExit)
        self.setBackgroundHints(Plasma.Applet.StandardBackground)
        self.applyConfig()
        #except AttributeError , e:
        #print e
        #updateMetadataDesktop(self)

        self.initTooltip()
        self.initShortcuts()
        QTimer.singleShot(1000, self.fixPopupIcon)