当前位置: 首页>>代码示例>>Python>>正文


Python KApplication.isSessionRestored方法代码示例

本文整理汇总了Python中PyKDE4.kdeui.KApplication.isSessionRestored方法的典型用法代码示例。如果您正苦于以下问题:Python KApplication.isSessionRestored方法的具体用法?Python KApplication.isSessionRestored怎么用?Python KApplication.isSessionRestored使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyKDE4.kdeui.KApplication的用法示例。


在下文中一共展示了KApplication.isSessionRestored方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import isSessionRestored [as 别名]
def main():
    global app, aboutData

    import setproctitle
    setproctitle.setproctitle("iosshy")

    from PyQt4.QtCore import QCoreApplication, QTranslator, QLocale, QSettings
    from PyQt4.QtGui import QApplication, QSystemTrayIcon, QImage

    from tunneldialog import TunnelDialog

    try:
        from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs
        from PyKDE4.kdeui import KApplication, KIcon

        aboutData = KAboutData(
            name, #appName
            name, #catalogName
            ki18n(name), #programName
            version,
            ki18n(description), #shortDescription
            KAboutData.License_BSD, #licenseKey
            ki18n("© 2010 Massimiliano Torromeo"), #copyrightStatement
            ki18n(""), #text
            url #homePageAddress
        )
        aboutData.setBugAddress("http://github.com/mtorromeo/iosshy/issues")
        aboutData.addAuthor(
            ki18n("Massimiliano Torromeo"), #name
            ki18n("Main developer"), #task
            "[email protected]" #email
        )
        aboutData.setProgramLogo(QImage(":icons/network-server.png"))

        KCmdLineArgs.init(sys.argv, aboutData)

        app = KApplication()
        app.setWindowIcon(KIcon("network-server"))

        if app.isSessionRestored():
            sys.exit(0)
    except ImportError:
        app = QApplication(sys.argv)
        app.setOrganizationName("MTSoft")
        app.setApplicationName(name)


    if QSystemTrayIcon.isSystemTrayAvailable():
        translator = QTranslator()
        qmFile = "tunneller_%s.qm" % QLocale.system().name()
        if os.path.isfile(qmFile):
            translator.load(qmFile)
        app.installTranslator(translator)

        dialog = TunnelDialog()
        sys.exit(app.exec_())
    else:
        print "System tray not available. Exiting."
        sys.exit(1)
开发者ID:sassman,项目名称:iosshy,代码行数:61,代码来源:application.py

示例2: MainApp

# 需要导入模块: from PyKDE4.kdeui import KApplication [as 别名]
# 或者: from PyKDE4.kdeui.KApplication import isSessionRestored [as 别名]

#.........这里部分代码省略.........
    @method(iface, in_signature='ss', out_signature='o')
    def openUrl(self, url, encoding=None):
        if not isinstance(url, KUrl):
            url = KUrl(url)
        # If no encoding given, set default or check if we can remember it
        if not encoding:
            encoding = self.defaultEncoding
            if self.keepMetaInfo() and not url.isEmpty():
                group = self.stateManager().groupForUrl(url)
                if group:
                    encoding = group.readEntry("encoding", "")
        # If there is only one document open and it is empty, nameless and
        # unmodified, use it.
        if (not url.isEmpty()
            and len(self.documents) == 1
            and not self.documents[0].isModified()
            and self.documents[0].url().isEmpty()):
            d = self.documents[0]
            d.openUrl(url, encoding)
        else:
            d = (not url.isEmpty() and self.findDocument(url)
                 or self.createDocument(url, encoding))
        return d

    @method(iface, in_signature='', out_signature='o')
    def new(self):
        return self.createDocument()

    def run(self, sender=None):
        """
        Last minute setup and enter the KDE event loop.
        At the very last, instantiates one empty doc if nothing loaded yet.
        """
        if self.kapp.isSessionRestored():
            self.mainwin.restore(1, False)
        elif (len(self.documents) == 0
              and not self._sessionStartedFromCommandLine):
            # restore named session?
            action = config("preferences").readEntry("default session", "")
            if action == "lastused":
                self.mainwin.sessionManager().restoreLastSession()
            elif action == "custom":
                session = config("preferences").readEntry("custom session", "")
                if session in self.mainwin.sessionManager().names():
                    self.mainwin.sessionManager().switch(session)
        if len(self.documents) == 0:
            self.createDocument().setActive()
        sys.excepthook = self.handleException
        self.mainwin.show()
        self.kapp.exec_()
        KGlobal.config().sync()
       
    @method(iface, in_signature='s', out_signature='b')
    def isOpen(self, url):
        """Returns true if the specified URL is opened."""
        if not isinstance(url, KUrl):
            url = KUrl(url)
        return bool(self.findDocument(url))
        
    @method(iface, in_signature='', out_signature='o')
    def activeDocument(self):
        """Returns the currently active document."""
        return self.history[-1]

    @method(iface, in_signature='', out_signature='')
    def back(self):
开发者ID:Alwnikrotikz,项目名称:lilykde,代码行数:70,代码来源:app.py


注:本文中的PyKDE4.kdeui.KApplication.isSessionRestored方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。