Customize minimize/close buttons
This commit is contained in:
parent
e401667e13
commit
39e77ee3c2
2 changed files with 61 additions and 5 deletions
24
menus.py
24
menus.py
|
@ -621,7 +621,7 @@ class PesterOptions(QtGui.QDialog):
|
||||||
self.tabs = QtGui.QButtonGroup(self)
|
self.tabs = QtGui.QButtonGroup(self)
|
||||||
self.connect(self.tabs, QtCore.SIGNAL('buttonClicked(int)'),
|
self.connect(self.tabs, QtCore.SIGNAL('buttonClicked(int)'),
|
||||||
self, QtCore.SLOT('changePage(int)'))
|
self, QtCore.SLOT('changePage(int)'))
|
||||||
tabNames = ["Chum List", "Conversations", "Sound", "Logging", "Idle", "Theme"]
|
tabNames = ["Chum List", "Conversations", "Interface", "Sound", "Logging", "Idle", "Theme"]
|
||||||
for t in tabNames:
|
for t in tabNames:
|
||||||
button = QtGui.QPushButton(t)
|
button = QtGui.QPushButton(t)
|
||||||
self.tabs.addButton(button)
|
self.tabs.addButton(button)
|
||||||
|
@ -710,6 +710,20 @@ class PesterOptions(QtGui.QDialog):
|
||||||
if t == theme.name:
|
if t == theme.name:
|
||||||
self.themeBox.setCurrentIndex(i)
|
self.themeBox.setCurrentIndex(i)
|
||||||
|
|
||||||
|
self.buttonOptions = ["Minimize to Taskbar", "Minimize to Tray", "Quit"]
|
||||||
|
self.miniBox = QtGui.QComboBox(self)
|
||||||
|
self.miniBox.addItems(self.buttonOptions)
|
||||||
|
self.miniBox.setCurrentIndex(self.config.minimizeAction())
|
||||||
|
self.closeBox = QtGui.QComboBox(self)
|
||||||
|
self.closeBox.addItems(self.buttonOptions)
|
||||||
|
self.closeBox.setCurrentIndex(self.config.closeAction())
|
||||||
|
layout_mini = QtGui.QHBoxLayout()
|
||||||
|
layout_mini.addWidget(QtGui.QLabel("Minimize"))
|
||||||
|
layout_mini.addWidget(self.miniBox)
|
||||||
|
layout_close = QtGui.QHBoxLayout()
|
||||||
|
layout_close.addWidget(QtGui.QLabel("Close"))
|
||||||
|
layout_close.addWidget(self.closeBox)
|
||||||
|
|
||||||
self.ok = QtGui.QPushButton("OK", self)
|
self.ok = QtGui.QPushButton("OK", self)
|
||||||
self.ok.setDefault(True)
|
self.ok.setDefault(True)
|
||||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||||
|
@ -747,6 +761,14 @@ class PesterOptions(QtGui.QDialog):
|
||||||
#layout_chat.addWidget(self.userlinkscheck)
|
#layout_chat.addWidget(self.userlinkscheck)
|
||||||
self.pages.addWidget(widget)
|
self.pages.addWidget(widget)
|
||||||
|
|
||||||
|
# Interface
|
||||||
|
widget = QtGui.QWidget()
|
||||||
|
layout_interface = QtGui.QVBoxLayout(widget)
|
||||||
|
layout_interface.setAlignment(QtCore.Qt.AlignTop)
|
||||||
|
layout_interface.addLayout(layout_mini)
|
||||||
|
layout_interface.addLayout(layout_close)
|
||||||
|
self.pages.addWidget(widget)
|
||||||
|
|
||||||
# Sound
|
# Sound
|
||||||
widget = QtGui.QWidget()
|
widget = QtGui.QWidget()
|
||||||
layout_sound = QtGui.QVBoxLayout(widget)
|
layout_sound = QtGui.QVBoxLayout(widget)
|
||||||
|
|
|
@ -342,6 +342,10 @@ class userConfig(object):
|
||||||
return not self.config.get('userLinks', True)
|
return not self.config.get('userLinks', True)
|
||||||
def idleTime(self):
|
def idleTime(self):
|
||||||
return self.config.get('idleTime', 10)
|
return self.config.get('idleTime', 10)
|
||||||
|
def minimizeAction(self):
|
||||||
|
return self.config.get('miniAction', 0)
|
||||||
|
def closeAction(self):
|
||||||
|
return self.config.get('closeAction', 1)
|
||||||
def addChum(self, chum):
|
def addChum(self, chum):
|
||||||
if chum.handle not in self.chums():
|
if chum.handle not in self.chums():
|
||||||
fp = open(self.filename) # what if we have two clients open??
|
fp = open(self.filename) # what if we have two clients open??
|
||||||
|
@ -1398,11 +1402,9 @@ class PesterWindow(MovingWindow):
|
||||||
self.helpmenu.addAction(self.aboutAction)
|
self.helpmenu.addAction(self.aboutAction)
|
||||||
|
|
||||||
self.closeButton = WMButton(PesterIcon(self.theme["main/close/image"]), self)
|
self.closeButton = WMButton(PesterIcon(self.theme["main/close/image"]), self)
|
||||||
self.connect(self.closeButton, QtCore.SIGNAL('clicked()'),
|
self.setButtonAction(self.closeButton, self.config.closeAction(), -1)
|
||||||
self, QtCore.SLOT('closeToTray()'))
|
|
||||||
self.miniButton = WMButton(PesterIcon(self.theme["main/minimize/image"]), self)
|
self.miniButton = WMButton(PesterIcon(self.theme["main/minimize/image"]), self)
|
||||||
self.connect(self.miniButton, QtCore.SIGNAL('clicked()'),
|
self.setButtonAction(self.miniButton, self.config.minimizeAction(), -1)
|
||||||
self, QtCore.SLOT('showMinimized()'))
|
|
||||||
|
|
||||||
self.namesdb = CaseInsensitiveDict()
|
self.namesdb = CaseInsensitiveDict()
|
||||||
self.chumdb = PesterProfileDB()
|
self.chumdb = PesterProfileDB()
|
||||||
|
@ -2327,8 +2329,40 @@ class PesterWindow(MovingWindow):
|
||||||
self.idlethreshold = 60*idlesetting
|
self.idlethreshold = 60*idlesetting
|
||||||
# theme
|
# theme
|
||||||
self.themeSelected()
|
self.themeSelected()
|
||||||
|
# button actions
|
||||||
|
minisetting = self.optionmenu.miniBox.currentIndex()
|
||||||
|
curmini = self.config.minimizeAction()
|
||||||
|
if minisetting != curmini:
|
||||||
|
self.config.set('miniAction', minisetting)
|
||||||
|
self.setButtonAction(self.miniButton, minisetting, curmini)
|
||||||
|
closesetting = self.optionmenu.closeBox.currentIndex()
|
||||||
|
curclose = self.config.closeAction()
|
||||||
|
if closesetting != curclose:
|
||||||
|
self.config.set('closeAction', closesetting)
|
||||||
|
self.setButtonAction(self.closeButton, closesetting, curclose)
|
||||||
self.optionmenu = None
|
self.optionmenu = None
|
||||||
|
|
||||||
|
def setButtonAction(self, button, setting, old):
|
||||||
|
if old == 0: # minimize to taskbar
|
||||||
|
self.disconnect(button, QtCore.SIGNAL('clicked()'),
|
||||||
|
self, QtCore.SLOT('showMinimized()'));
|
||||||
|
elif old == 1: # minimize to tray
|
||||||
|
self.disconnect(button, QtCore.SIGNAL('clicked()'),
|
||||||
|
self, QtCore.SLOT('closeToTray()'));
|
||||||
|
elif old == 2: # quit
|
||||||
|
self.disconnect(button, QtCore.SIGNAL('clicked()'),
|
||||||
|
self, QtCore.SLOT('close()'));
|
||||||
|
|
||||||
|
if setting == 0: # minimize to taskbar
|
||||||
|
self.connect(button, QtCore.SIGNAL('clicked()'),
|
||||||
|
self, QtCore.SLOT('showMinimized()'));
|
||||||
|
elif setting == 1: # minimize to tray
|
||||||
|
self.connect(button, QtCore.SIGNAL('clicked()'),
|
||||||
|
self, QtCore.SLOT('closeToTray()'));
|
||||||
|
elif setting == 2: # quit
|
||||||
|
self.connect(button, QtCore.SIGNAL('clicked()'),
|
||||||
|
self, QtCore.SLOT('close()'));
|
||||||
|
|
||||||
@QtCore.pyqtSlot()
|
@QtCore.pyqtSlot()
|
||||||
def themeSelected(self):
|
def themeSelected(self):
|
||||||
themename = unicode(self.optionmenu.themeBox.currentText())
|
themename = unicode(self.optionmenu.themeBox.currentText())
|
||||||
|
|
Loading…
Reference in a new issue