~morgul/gmusic-player/trunk

« back to all changes in this revision

Viewing changes to classes/main.py

  • Committer: Christopher S. Case
  • Date: 2011-08-11 19:45:27 UTC
  • Revision ID: chris.case@g33xnexus.com-20110811194527-nl7ejt3jvctqq4im
Added window icon, and added behavior to tryicon: when double clicked, it toggles the player window's visibility.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
    def createWidgets(self):
59
59
        logger.debug("Creating widgets")
60
60
 
61
 
        # Setup the player window
62
 
        self.playerWindow = PlayerWindow()
63
 
 
64
61
        # Setup the system tray icon
65
62
        self.resourcedir = os.path.join(
66
63
            QtGui.QApplication.instance().property("AppPath"), "resources")
67
 
        print self.resourcedir
 
64
 
 
65
        # Setup tray icon
68
66
        self.icon = QtGui.QIcon(self.resourcedir + '/gMusic_16.png')
69
67
        self.trayIcon = QtGui.QSystemTrayIcon(self.icon)
70
68
 
 
69
        # Setup the player window
 
70
        self.playerWindow = PlayerWindow()
 
71
 
71
72
        # Setup the tray icon context menu
72
73
        self.trayMenu = QtGui.QMenu()
73
74
        self.openAction = QtGui.QAction(QtGui.QIcon(self.resourcedir + '/open_16.png'),
122
123
        self.remoteListener.start()
123
124
 
124
125
    def connectSignals(self):
 
126
        # Tray Icon Signals
 
127
        self.trayIcon.activated.connect(self.handleTrayActivated)
 
128
 
 
129
        # Player signals
125
130
        self.play.connect(self.playerWindow.handlePlayPause)
126
131
        self.prev.connect(self.playerWindow.handlePrev)
127
132
        self.next.connect(self.playerWindow.handleNext)
158
163
    # Slots
159
164
    #--------------------------------------------------------------------------#
160
165
 
 
166
    def handleTrayActivated(self, reason):
 
167
        if reason == QtGui.QSystemTrayIcon.DoubleClick:
 
168
            if self.playerWindow.isHidden():
 
169
                self.playerWindow.show()
 
170
            else:
 
171
                self.playerWindow.hide()
 
172
 
161
173
    def notify(self, title, message, icon=None):
162
174
        if self.notifier.notifier is not None:
163
175
            self.notifier.notify(title, message, icon)