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


Python QSystemTrayIcon.hide方法代码示例

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


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

示例1: Tray

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import hide [as 别名]
class Tray():

    def __init__(self, parent):
        
        icon = AppIcon.getAppIcon()
        if icon:
            self.tray = QSystemTrayIcon(icon)
        else:
            self.tray = QSystemTrayIcon()
        self.parent = parent
        
        self.tray.setToolTip("Droid Navi")
        
        # Menu
        self.menu = QMenu()
        self.menu.addAction("Show Connected List", partial(self.maximize))
        self.menu.addAction("Options", partial(self.parent.openSettings))
        self.menu.addAction("Exit", partial(self.parent.close))
        self.tray.setContextMenu(self.menu)
        
        # Connect handlers
        self.tray.activated.connect(self.activated)
    
    def getTray(self):
        return self.tray
     
    def display(self, show):
        ''' Toggle showing the tray '''
        
        if show:
            self.tray.show()
        else:
            self.tray.hide()
    
    @pyqtSlot()
    def maximize(self):
        ''' Show the main window and hide tray icon '''
        
        self.display(False)
        self.parent.maximizeFromTray()
    
    @pyqtSlot()
    def activated(self, reason):
        if reason == QSystemTrayIcon.DoubleClick:
            self.maximize()
开发者ID:Kenishi,项目名称:DroidNavi,代码行数:47,代码来源:tray.py

示例2: sysBaloon

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import hide [as 别名]
class sysBaloon(QMainWindow):
    def baloon(self, t, m, tm=50000):
        self.trayicon = QSystemTrayIcon(self)
        if self.trayicon.supportsMessages():
            icona = QIcon('py.ico')
            self.trayicon.setIcon(icona)
            self.trayicon.show()
            self.trayicon.showMessage(t, m, msecs=tm)
            time.sleep(10)
            self.trayicon.hide()
        else:
            print "This Function isn't supported."
            choose = raw_input("Would you enable it? Y/N \n --> ")
            if choose == "Y":
                shell = os.popen('enable_baloon.reg')
                print "Run again this program"
            elif choose == "N":
                print "You don't use this program without baloon enabled."
            else:
                print "You have insert wrong char."
开发者ID:Mirio,项目名称:pywin_baloon,代码行数:22,代码来源:pywin_baloon.py

示例3: GlobalSysTray

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import hide [as 别名]

#.........这里部分代码省略.........
        ##elif TrayEngine == "AppIndicator":
            ##for child in menu_widget.get_submenu().get_children():
                ##menu_widget.get_submenu().remove(child)
        ##else:
        #if (1):
            #menu_widget.clear()
        #list_of_submenus = [menu_name_id]
        #for x in range(0, 10): # 10x level deep, should cover all cases...
            #for this_menu_name_id, menu_widget, parent_menu_id in self.menu_indexes:
                #if parent_menu_id in list_of_submenus and this_menu_name_id not in list_of_submenus:
                    #list_of_submenus.append(this_menu_name_id)
        #for this_menu_name_id in list_of_submenus:
            #self.remove_actions_by_menu_name_id(this_menu_name_id)
            #self.remove_separators_by_menu_name_id(this_menu_name_id)
            #self.remove_submenus_by_menu_name_id(this_menu_name_id)

    # -------------------------------------------------------------------------------------------

    def getTrayEngine(self):
        return TrayEngine

    def isTrayAvailable(self):
        if TrayEngine in ("KDE", "Qt"):
            return QSystemTrayIcon.isSystemTrayAvailable()
        elif TrayEngine == "AppIndicator":
            # Ubuntu/Unity always has a systray
            return True
        else:
            return False

    def handleQtCloseEvent(self, event):
        if self.isTrayAvailable() and self._parent.isVisible():
            event.accept()
            self.__hideShowCall()
            return

        self.close()
        QMainWindow.closeEvent(self._parent, event)

    # -------------------------------------------------------------------------------------------

    def show(self):
        if not self._quit_added:
            self._quit_added = True

            if TrayEngine != "KDE":
                self.addSeparator("_quit")
                self.addAction("show", self._parent.tr("Minimize"))
                self.addAction("quit", self._parent.tr("Quit"))
                self.setActionIcon("quit", "application-exit")
                self.connect("show", self.__hideShowCall)
                self.connect("quit", self.__quitCall)

        if TrayEngine == "KDE":
            self.tray.setStatus(KStatusNotifierItem.Active)
        elif TrayEngine == "AppIndicator":
            self.tray.set_status(AppIndicator.IndicatorStatus.ACTIVE)
        elif TrayEngine == "Qt":
            self.tray.show()

    def hide(self):
        if TrayEngine == "KDE":
            self.tray.setStatus(KStatusNotifierItem.Passive)
        elif TrayEngine == "AppIndicator":
            self.tray.set_status(AppIndicator.IndicatorStatus.PASSIVE)
        elif TrayEngine == "Qt":
开发者ID:ViktorNova,项目名称:Cadence,代码行数:70,代码来源:systray.py

示例4: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import hide [as 别名]
class MainWindow(base_class, ui_class):
    implements(IObserver)

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.saved_account_state = None

        notification_center = NotificationCenter()
        notification_center.add_observer(self, name='SIPApplicationWillStart')
        notification_center.add_observer(self, name='SIPApplicationDidStart')
        notification_center.add_observer(self, name='SIPAccountGotMessageSummary')
        notification_center.add_observer(self, name='SIPAccountGotPendingWatcher')
        notification_center.add_observer(self, name='BlinkSessionNewOutgoing')
        notification_center.add_observer(self, name='BlinkSessionDidReinitializeForOutgoing')
        notification_center.add_observer(self, name='FileTransferNewIncoming')
        notification_center.add_observer(self, name='FileTransferNewOutgoing')
        notification_center.add_observer(self, sender=AccountManager())

        icon_manager = IconManager()

        self.pending_watcher_dialogs = []

        self.mwi_icons = [QIcon(Resources.get('icons/mwi-%d.png' % i)) for i in xrange(0, 11)]
        self.mwi_icons.append(QIcon(Resources.get('icons/mwi-many.png')))

        with Resources.directory:
            self.setupUi()

        self.setWindowTitle('Blink')
        self.setWindowIconText('Blink')

        geometry = QSettings().value("main_window/geometry")
        if geometry:
            self.restoreGeometry(geometry)

        self.default_icon_path = Resources.get('icons/default-avatar.png')
        self.default_icon = QIcon(self.default_icon_path)
        self.last_icon_directory = Path('~').normalized
        self.set_user_icon(icon_manager.get('avatar'))

        self.active_sessions_label.hide()
        self.enable_call_buttons(False)
        self.conference_button.setEnabled(False)
        self.hangup_all_button.setEnabled(False)
        self.sip_server_settings_action.setEnabled(False)
        self.search_for_people_action.setEnabled(False)
        self.history_on_server_action.setEnabled(False)
        self.main_view.setCurrentWidget(self.contacts_panel)
        self.contacts_view.setCurrentWidget(self.contact_list_panel)
        self.search_view.setCurrentWidget(self.search_list_panel)

        # System tray
        if QSystemTrayIcon.isSystemTrayAvailable() and not os.getenv('XDG_CURRENT_DESKTOP', '').lower().startswith('unity'):
            self.system_tray_icon = QSystemTrayIcon(QIcon(Resources.get('icons/blink.png')), self)
            self.system_tray_icon.activated.connect(self._SH_SystemTrayIconActivated)
            menu = QMenu(self)
            menu.addAction(QAction("Show", self, triggered=self._AH_SystemTrayShowWindow))
            menu.addAction(QAction(QIcon(Resources.get('icons/application-exit.png')), "Quit", self, triggered=self._AH_QuitActionTriggered))
            self.system_tray_icon.setContextMenu(menu)
            self.system_tray_icon.show()
        else:
            self.system_tray_icon = None

        # Accounts
        self.account_model = AccountModel(self)
        self.enabled_account_model = ActiveAccountModel(self.account_model, self)
        self.server_tools_account_model = ServerToolsAccountModel(self.account_model, self)
        self.identity.setModel(self.enabled_account_model)

        # Contacts
        self.contact_model = ContactModel(self)
        self.contact_search_model = ContactSearchModel(self.contact_model, self)
        self.contact_list.setModel(self.contact_model)
        self.search_list.setModel(self.contact_search_model)

        # Sessions (audio)
        self.session_model = AudioSessionModel(self)
        self.session_list.setModel(self.session_model)
        self.session_list.selectionModel().selectionChanged.connect(self._SH_SessionListSelectionChanged)

        # History
        self.history_manager = HistoryManager()

        # Windows, dialogs and panels
        self.about_panel = AboutPanel(self)
        self.conference_dialog = ConferenceDialog(self)
        self.contact_editor_dialog = ContactEditorDialog(self)
        self.google_contacts_dialog = GoogleContactsDialog(self)
        self.filetransfer_window = FileTransferWindow()
        self.preferences_window = PreferencesWindow(self.account_model, None)
        self.server_tools_window = ServerToolsWindow(self.server_tools_account_model, None)

        # Signals
        self.account_state.stateChanged.connect(self._SH_AccountStateChanged)
        self.account_state.clicked.connect(self._SH_AccountStateClicked)
        self.activity_note.editingFinished.connect(self._SH_ActivityNoteEditingFinished)
        self.add_contact_button.clicked.connect(self._SH_AddContactButtonClicked)
        self.add_search_contact_button.clicked.connect(self._SH_AddContactButtonClicked)
        self.audio_call_button.clicked.connect(self._SH_AudioCallButtonClicked)
        self.video_call_button.clicked.connect(self._SH_VideoCallButtonClicked)
#.........这里部分代码省略.........
开发者ID:pol51,项目名称:blink-qt,代码行数:103,代码来源:mainwindow.py

示例5: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import hide [as 别名]

#.........这里部分代码省略.........
    def getCryptoKey(self, passphrase=None):
        try:
            return self.config.getPrivateKey(passphrase)
        except ValueError:
            passwordDialog = PasswordDialog()
            retCode = passwordDialog.exec_()
            if retCode == QtGui.QDialog.Accepted:
                return self.getCryptoKey(passwordDialog.getPassword())
            else:
                raise SystemError("Password required")

    def showSettings(self):
        settingsWidget = self.findChild(QWidget, "settings")
        if settingsWidget is None:
            self.settingsWidget = SettingsPage()
            self.settingsWidget.setObjectName("settings")
            self.tabWidget.insertTab(0, self.settingsWidget, QIcon(":/ico/settings.svg"), 'Settings')

        index = self.tabWidget.indexOf(self.settingsWidget)
        self.tabWidget.setCurrentIndex(index)

    def connectHostFromMenu(self, action):
        self.connectHost(unicode(action.text()))

    def connectHostFromTrayMenu(self, action):
        tabPage = self.connectHost(unicode(action.text()))
        if not self.isVisible():
            self.tabWidget.setDetached(True, tabPage)

    def trayActivated(self, reason):
        if reason != QSystemTrayIcon.Trigger:
            return
        if self.isVisible():
            self.hide()
        else:
            self.show()
            self.activateWindow()

    def changeTrayIconVisibility(self):
        if self.tray.isVisible():
            self.tray.hide()
            if not self.isVisible():
                self.show()
        else:
            self.tray.show()

    def refreshGroups(self):
        groupList = self.hosts.getGroupsList()
        for group in groupList:
            if group not in self.groups:
                # add new groups as visible
                self.groups[group] = True

        # remove not existing groups
        keysToDelete = set(self.groups.keys()) - set(groupList)
        for key in keysToDelete:
            self.groups.pop(key)

    def assignGroup(self):
        groups = self.hosts.getGroupsList()
        assignGroupDialog = AssignGroupDialog(groups)
        groupToAssign = assignGroupDialog.assign()
        if groupToAssign is not False:  # None could be used to unassign the group
            groupToAssign = None if groupToAssign.isEmpty() else unicode(groupToAssign)
            for hostName in self.getSelectedHosts():
                self.hosts.assignGroup(hostName, groupToAssign)
开发者ID:szatanszmatan,项目名称:myrdp,代码行数:70,代码来源:mainwindow.py

示例6: __init__

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import hide [as 别名]
class Qt4SysTrayIcon:
    def __init__( self ):
        self.snapshots = snapshots.Snapshots()
        self.config = self.snapshots.config
        self.decode = None

        if len( sys.argv ) > 1:
            if not self.config.set_current_profile(sys.argv[1]):
                logger.warning("Failed to change Profile_ID %s"
                               %sys.argv[1], self)

        self.qapp = qt4tools.create_qapplication(self.config.APP_NAME)
        translator = qt4tools.get_translator()
        self.qapp.installTranslator(translator)
        self.qapp.setQuitOnLastWindowClosed(False)

        import icon
        self.icon = icon
        self.qapp.setWindowIcon(icon.BIT_LOGO)

        self.status_icon = QSystemTrayIcon(icon.BIT_LOGO)
        #self.status_icon.actionCollection().clear()
        self.contextMenu = QMenu()

        self.menuProfileName = self.contextMenu.addAction(_('Profile: "%s"') % self.config.get_profile_name())
        qt4tools.set_font_bold(self.menuProfileName)
        self.contextMenu.addSeparator()

        self.menuStatusMessage = self.contextMenu.addAction(_('Done'))
        self.menuProgress = self.contextMenu.addAction('')
        self.menuProgress.setVisible(False)
        self.contextMenu.addSeparator()

        self.btnDecode = self.contextMenu.addAction(icon.VIEW_SNAPSHOT_LOG, _('decode paths'))
        self.btnDecode.setCheckable(True)
        self.btnDecode.setVisible(self.config.get_snapshots_mode() == 'ssh_encfs')
        QObject.connect(self.btnDecode, SIGNAL('toggled(bool)'), self.onBtnDecode)

        self.openLog = self.contextMenu.addAction(icon.VIEW_LAST_LOG, _('View Last Log'))
        QObject.connect(self.openLog, SIGNAL('triggered()'), self.onOpenLog)
        self.startBIT = self.contextMenu.addAction(icon.BIT_LOGO, _('Start BackInTime'))
        QObject.connect(self.startBIT, SIGNAL('triggered()'), self.onStartBIT)
        self.status_icon.setContextMenu(self.contextMenu)

        self.pixmap = icon.BIT_LOGO.pixmap(24)
        self.progressBar = QProgressBar()
        self.progressBar.setMinimum(0)
        self.progressBar.setMaximum(100)
        self.progressBar.setValue(0)
        self.progressBar.setTextVisible(False)
        self.progressBar.resize(24, 6)
        self.progressBar.render(self.pixmap, sourceRegion = QRegion(0, -14, 24, 6), flags = QWidget.RenderFlags(QWidget.DrawChildren))

        self.first_error = self.config.is_notify_enabled()
        self.popup = None
        self.last_message = None

        self.timer = QTimer()
        QObject.connect( self.timer, SIGNAL('timeout()'), self.update_info )

        self.ppid = os.getppid()

    def prepare_exit( self ):
        self.timer.stop()

        if not self.status_icon is None:
            self.status_icon.hide()
            self.status_icon = None

        if not self.popup is None:
            self.popup.deleteLater()
            self.popup = None

        self.qapp.processEvents()

    def run( self ):
        self.status_icon.show()
        self.timer.start( 500 )

        logger.info("[qt4systrayicon] begin loop", self)

        self.qapp.exec_()

        logger.info("[qt4systrayicon] end loop", self)

        self.prepare_exit()

    def update_info( self ):
        if not tools.is_process_alive( self.ppid ):
            self.prepare_exit()
            self.qapp.exit(0)
            return

        message = self.snapshots.get_take_snapshot_message()
        if message is None and self.last_message is None:
            message = ( 0, _('Working...') )

        if not message is None:
            if message != self.last_message:
                self.last_message = message
#.........这里部分代码省略.........
开发者ID:heysion,项目名称:backintime,代码行数:103,代码来源:qt4systrayicon.py

示例7: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import hide [as 别名]
class MainWindow(QMainWindow,Ui_MainWindow):

    def __init__(self,parent=None):
        QMainWindow.__init__(self,parent)         
        self.setupUi(self)
        self.textshorturl.setEnabled(False)
        self.convertprogress.hide()        
        self.trayIcon = QSystemTrayIcon()
        self.trayIcon.setIcon(QIcon("/usr/share/pixmaps/nixiconsvg.svg"))
        trayIconMenu = QMenu()
        self.appabout = trayIconMenu.addAction("About")
        self.appexit = trayIconMenu.addAction("Exit")
        self.trayIcon.setContextMenu(trayIconMenu)       
        self.connect(self.trayIcon,SIGNAL("activated(QSystemTrayIcon::ActivationReason)"),self.iconActivated)
        self.connect(self.buttonurlconvert,SIGNAL('clicked()'),self.converturl)
        self.connect(self.appexit,SIGNAL('triggered()'),self.close)
        self.connect(self.appabout,SIGNAL('triggered()'),self.showabout)
        self.connect(self.actionAbout,SIGNAL('triggered()'),self.showabout)
        self.connect(self.buttonreset,SIGNAL('clicked()'),self.resetall)
        self.connect(self.actionNew,SIGNAL('triggered()'),self.resetall)
        
    
    def iconActivated(self,dovod):
        if dovod == QSystemTrayIcon.Trigger:
            if self.isVisible():
                self.hide()
            else:
                self.show()
                 
    def resetall(self):
        self.texturl.setText("")
        self.textshorturl.setText("")
        self.textshorturl.setEnabled(False)
        self.buttonurlconvert.setEnabled(True)
        self.comboservice.setCurrentIndex(0)
        self.convertprogress.hide()
        
    def converturl(self):
        url=str(self.texturl.text())
        url=url.strip()
        if url=="":
            QMessageBox.warning(self,"Error","Please Enter the valid URL")
        else:
            self.convertprogress.show()
            self.convertprogress.setValue(10)
            self.textshorturl.setEnabled(True)
            self.convertprogress.setValue(30)
            self.currentservice=self.comboservice.currentText()
            self.convertprogress.setValue(50)
            self.buttonurlconvert.setEnabled(False)
            if self.currentservice == "TinyURL":
                try:
                    self.textshorturl.setText(str(tinyurl.create_one(url)))
                    self.convertprogress.setValue(100)
                    self.buttonurlconvert.setEnabled(True)
                except:
                    QMessageBox.warning(self,"Error","Host can not be resolved")
                            
            elif self.currentservice == "google":
                try:
                    self.textshorturl.setText(str(google.shorten(url)))
                    self.convertprogress.setValue(100)
                    self.buttonurlconvert.setEnabled(True)
                    self.textshorturl.copy()
                except:
                    QMessageBox.warning(self,"Error","Host can not be resolved")
                    
            elif self.currentservice == "bit.ly":
                try:
                    a=bitly.Api()
                    self.textshorturl.setText(str(a.shorten(url)))
                    self.convertprogress.setValue(100)
                    self.buttonurlconvert.setEnabled(True)
                except:
                    QMessageBox.warning(self,"Error","Host can not be resolved")
    
    def showEvent(self,event):
        self.show()
        self.trayIcon.hide()
        event.ignore()
     
    def closeEvent(self,event):
        reply = QMessageBox.question(self, 'Message',"Are you sure to quit?", QMessageBox.Yes | QMessageBox.No,QMessageBox.No)
        if reply == QMessageBox.Yes:
            self.trayIcon.hide()
            event.accept()
        else:
            self.hide()
            self.trayIcon.show()
            event.ignore()  

    def showabout(self):
        ab=About()
        ab.exec_()
开发者ID:arjunjain,项目名称:nixurl,代码行数:96,代码来源:main.py

示例8: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import hide [as 别名]
class MainWindow(QMainWindow):
	def __init__(self):
		QMainWindow.__init__(self)
		
		self.setWindowTitle('%s %s' % (QApplication.applicationName(), QApplication.applicationVersion()));

		self.config = ConfigHandler(os.path.join(os.path.expanduser('~'), '.pywv/pywv.cfg'), self)

		self.setStyle(QStyleFactory.create(self.config.loadStyle()))
		if self.config.loadStyleSheet():
			self.setStyleSheet(self.config.loadStyleSheet())
		else:
			self.setStyleSheet("* {}") # without any stylesheet, windowstyles won't apply


		self.setDockOptions(QMainWindow.AnimatedDocks | QMainWindow.AllowNestedDocks | QMainWindow.AllowTabbedDocks | QMainWindow.VerticalTabs);

#		self.dummy = QWidget(self)
		self.setCentralWidget(QWidget(self))

		self.pBar = QProgressBar(self)
		self.pBar.setRange(0, self.config.loadReloadInterval())
		self.pBar.setFormat("%v Sekunden")
		if not self.config.loadAutoload():
			self.pBar.hide()

		self.statusBar = QStatusBar(self)
		self.setStatusBar(self.statusBar)
		self.statusBar.addWidget(self.pBar)

		self.reloadTimer = QTimer(self);
		self.reloadTimer.setInterval(self.config.loadReloadInterval() * 1000)
		self.connect(self.reloadTimer, SIGNAL('timeout()'), self.reload_)
		if self.config.loadAutoload():
			self.reloadTimer.start()

		self.autoloadStatusTimer = QTimer(self)
		self.autoloadStatusTimer.setInterval(1000) # 1 sec
		self.connect(self.autoloadStatusTimer, SIGNAL('timeout()'), self.onAutoloadStatus)
		self.autoloadStatusTimer.start()

		self.mAction = self.menuBar().addMenu(self.tr("&Action"))
		self.mAction.addAction(self.tr("&update"), self.reload_, QKeySequence('F5'))
		self.mAction.addAction(self.tr("e&xit"), self.onExit, 'Ctrl+Q')

		self.mStyle = QMenu(self.tr("&Style"), self)
		for s in list(QStyleFactory.keys()):#       // fill in all available Styles
			self.mStyle.addAction(s)
		self.connect(self.mStyle, SIGNAL('triggered(QAction*)'), self.onStyleMenu)

		self.mOption = self.menuBar().addMenu(self.tr("&Options"))
		self.mOption.addAction(self.tr("reloadinterval") , self.onReloadTime , 'F8')
		self.mOption.addAction(self.tr("manage links")   , self.onNewLink    , 'F6')
		self.mOption.addSeparator()

		self.ontopAction       = QAction(self.tr("always on &top")  , self)
		self.showTrayAction    = QAction(self.tr("show tray &icon") , self)
		self.closeToTrayAction = QAction(self.tr("close to &tray")  , self)
		self.autoloadAction    = QAction(self.tr("auto&load")       , self)

		self.ontopAction.setCheckable(True)
		self.showTrayAction.setCheckable(True)
		self.closeToTrayAction.setCheckable(True)
		self.autoloadAction.setCheckable(True)

		self.showTrayAction.setChecked   (self.config.loadShowTray()   )
		self.ontopAction.setChecked      (self.config.loadOntop()      )
		self.closeToTrayAction.setChecked(self.config.loadCloseToTray())
		self.autoloadAction.setChecked   (self.config.loadAutoload()   )

		self.connect(self.ontopAction       , SIGNAL('toggled(bool)') , self.onOntopAction)
		self.connect(self.showTrayAction    , SIGNAL('toggled(bool)') , self.onShowTrayAction)
		self.connect(self.closeToTrayAction , SIGNAL('toggled(bool)') , self.onCloseToTrayAction)
		self.connect(self.autoloadAction    , SIGNAL('toggled(bool)') , self.onAutoloadAction)

		self.mOption.addAction(self.ontopAction)
		self.mOption.addAction(self.showTrayAction)
		self.mOption.addAction(self.closeToTrayAction)
		self.mOption.addAction(self.autoloadAction)
		self.mOption.addSeparator()
		self.mOption.addMenu(self.mStyle)

		self.trayIcon = QSystemTrayIcon(QIcon(':/appicon'), self);
		self.trayMgr = TrayManager(self.config, self.trayIcon)
		self.connect(self.trayIcon, SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), self.onTrayIcon)
		if self.config.loadShowTray(): self.trayIcon.show()

		self.trayIconMenu = QMenu()
		self.trayIconMenu.addAction(self.tr("e&xit"), self.onExit)
		self.trayIcon.setContextMenu(self.trayIconMenu)

		self.mAbout = self.menuBar().addMenu(self.tr("&about"))
		self.mAbout.addAction(QApplication.applicationName(), self.onAboutAppAction)
		self.mAbout.addAction("Qt", self.onAboutQtAction)

		self.createWidgets()

		self.resize(self.config.loadWindowSize())
		self.restoreState(self.config.loadWindowState())

#.........这里部分代码省略.........
开发者ID:ThePsyjo,项目名称:PyWv,代码行数:103,代码来源:window.py

示例9: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import hide [as 别名]
class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        PyQt4.uic.loadUi('ui/pyrex.ui', self)

        # Icon:
        self.setWindowIcon(QIcon("res/rex_18.png"))

        # Tray Icon:
        self.trayIcon = QSystemTrayIcon(QIcon("res/rex_18.png"), self)
        trayMenu = QMenu()
        self.actionQuit = QAction("Quitter", trayMenu)
        self.actionQuit.triggered.connect(self.close)
        trayMenu.addAction(self.actionQuit)
        self.trayIcon.setContextMenu(trayMenu)
        #self.trayIcon.show()

        QObject.connect(self.trayIcon, SIGNAL("activated(QSystemTrayIcon::ActivationReason)"), self.icon_activated)
 
        # Tabs:
        self.tabs = QTabWidget()
        QObject.connect(self.tabs, SIGNAL('currentChanged(int)'), self.change_tab)

        self.downloads = TabDownloads(self.tabs)
        self.search = TabSearch(None, self.downloads, self.tabs)
        self.adv_search = TabAdvSearch(self.search, self.tabs)
        self.peers = TabPeers(self.search, self.downloads, self.tabs)
        self.options = TabOptions(self.tabs)
        self.shares = TabShares(self.tabs)
        self.informations = TabInformations(self.tabs)

        self.tabs.insertTab(0, self.search, u"Recherches")
        self.tabs.insertTab(1, self.adv_search, u"Recherche avancée")
        self.tabs.insertTab(2, self.downloads, u"Téléchargements")
        self.tabs.insertTab(3, self.peers, u"Utilisateurs")
        self.tabs.insertTab(4, self.options, u'Options')
        self.tabs.insertTab(5, self.shares, u'Mes partages')
        self.tabs.insertTab(6, self.informations, u'Informations')
        
        self.setCentralWidget(self.tabs)

    def change_tab(self, tab):
        if tab == 3:
            self.peers.update_peers()
        elif tab == 4:
            self.options.update_conf()
        elif tab == 5:
            self.shares.update_sharedirs()
        elif tab == 6:
            self.informations.update_informations()

    def closeEvent(self, event):
        if not self.trayIcon.isVisible() and Configuration.icon:
            self.trayIcon.show()
            self.hide()
            event.ignore()
        else:
            termine = True
            # On vérifie que tous les téléchargements soient finis
            for download in self.downloads.instance.downloads:
                if download.state == 3:
                    termine = False
            # Si il y a un download en cours on affiche la fenêtre
            if not termine and not Configuration.close_window:
                # Un petit messageBox avec bouton clickable :)
                msgBox = QMessageBox(QMessageBox.Question, u"Voulez-vous vraiment quitter?", u"Un ou plusieurs téléchargements sont en cours, et pyRex ne gère pas encore la reprise des téléchargements. Si vous quittez maintenant, toute progression sera perdue!")
                checkBox = QCheckBox(u"Ne plus afficher ce message", msgBox)
                checkBox.blockSignals(True)
                msgBox.addButton(checkBox, QMessageBox.ActionRole)
                msgBox.addButton("Annuler", QMessageBox.NoRole)
                yesButton = msgBox.addButton("Valider", QMessageBox.YesRole)
                msgBox.exec_()
                
                if msgBox.clickedButton() == yesButton:
                    # On save l'état du bouton à cliquer
                    if checkBox.checkState() == Qt.Checked:
                        Configuration.close_window = True
                        Configuration.write_config()
                    event.accept()
                else:
                    event.ignore()
            else:
                event.accept()
   
    def changeEvent(self, event):
        if event.type() == QEvent.WindowStateChange:
            if self.isMinimized():
                self.trayIcon.show()
                self.hide()
 
    def icon_activated(self, reason):
        if reason == QSystemTrayIcon.Trigger:
            if self.isVisible():
                self.hide()
            else:
                self.setWindowState(self.windowState() & ~Qt.WindowMinimized | Qt.WindowActive)
                self.activateWindow()
                self.show()
                self.trayIcon.hide()
开发者ID:MaximeCheramy,项目名称:pyrex,代码行数:102,代码来源:MainWindow.py

示例10: MainWindow

# 需要导入模块: from PyQt4.QtGui import QSystemTrayIcon [as 别名]
# 或者: from PyQt4.QtGui.QSystemTrayIcon import hide [as 别名]
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)
        self.setupUi(self)
        self._init_menu()
        self._init_actions()
        self._init_models()
        self.lt = ListenThread(self.add_new_device)
        self._install_akmods = False
        self._main_pko = PackageKitQt()

        # right frame
        self.comboBoxModules.currentIndexChanged.connect(self._handle_select_module)
        self.buttonBoxDetails.clicked.connect(self._handle_rbb)

        self.__debug_mode__ = True

        self.trayIcon = QSystemTrayIcon(self)
        self.trayIcon.setIcon(QIcon(":/img/gears"))
        self.trayIcon.activated.connect(self._handle_tray_icon_activate)
        self.hide()

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

    def _init_menu(self):
        self.actionFileExit.triggered.connect(self._handle_exit)

        self.listView.setContextMenuPolicy(Qt.ActionsContextMenu)
        self.listViewActions.setContextMenuPolicy(Qt.ActionsContextMenu)

        # context menu for listView
        for act in self.menuDevices.actions():
            self.listView.addAction(act)
        # context menu for listViewActions
        for act in self.menuActions.actions():
            self.listViewActions.addAction(act)

    def _init_actions(self):
        self.actionDevicesDisable.triggered.connect(self._handle_disable_device)
        self.actionDevicesDisableAll.triggered.connect(self._handle_disable_all)
        self.actionActionsDelete.triggered.connect(self._handle_remove_current_action)
        self.actionActionsClear.triggered.connect(self._handle_clean_actions)
        self.actionActionsApply.triggered.connect(self._handle_apply_actions)

    def _init_models(self):
        self.model = DevicesListModel(self)
        self.listView.setModel(self.model)
        self.listView.selectionModel().currentChanged.connect(self._handle_select_item)

        self.act_model = ActionsModel(self)
        self.listViewActions.setModel(self.act_model)
        self.listViewActions.selectionModel().currentChanged.connect(self._handle_action_select_item)

        self.act_model.actionDeleted.connect(self.model.reset_changes)
        self.model.dataChanged.connect(self._handle_data_changed_in_model)

    def _init_pk(self):
        if self._main_pko is None:
            self._main_pko = PackageKitQt()

    def add_new_device(self, dev):
        self.model.add_new_device(dev)
        self.show_notification()

    def disen_device_notif(self, device_id, disable=False):
        if disable:
            self.lt.disable_device_notif(device_id)
        else:
            self.lt.enable_device_notif(device_id)

    def show_notification(self):
        # if self.isHidden():
        #    self.show()
        self.trayIcon.setVisible(True)

    def start_listen(self):
        self.lt.start()

    def _right_frame_apply(self, idx):
        d = self.model.device_by_index(idx)
        sel_cb_idx = self.comboBoxModules.currentIndex()
        sel_module = str(self.comboBoxModules.itemData(sel_cb_idx).toString())
        if sel_module == d.current_driver():
            return

        self.act_model.remove_actions_by_devid(d.device_id(), sel_module)
        pkgsi = d.packages_to_install(sel_module)
        pkgsr = d.packages_to_remove(sel_module)
        if len(pkgsi) > 0:
            self.act_model.add_new_action(d.device_id(), sel_module, pkgsi, 0)
        if len(pkgsr) > 0:
            rem_mds = str(", ").join(d.device_modules(sel_module))
            self.act_model.add_new_action(d.device_id(), rem_mds, pkgsr, 1)
        d.set_selected_driver(sel_module)
        self.set_right_frame(idx)

    def _current_device(self, idx=None):
        cur_idx = idx
#.........这里部分代码省略.........
开发者ID:elemc,项目名称:scod,代码行数:103,代码来源:MainWindow.py


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