summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornatural <natural>2006-12-31 09:54:31 +0000
committernatural <natural>2006-12-31 09:54:31 +0000
commite7ae2a8a5f3bcf1669e1a7514540c451cafbc9b6 (patch)
tree7bec160d7559b4b2f1ddab7dd45f155f59f035c2
parent0aa170e67595b83e49e72d78f41c27a48d3059ad (diff)
downloadkberylsettings-e7ae2a8a5f3bcf1669e1a7514540c451cafbc9b6.tar.gz
kberylsettings-e7ae2a8a5f3bcf1669e1a7514540c451cafbc9b6.tar.bz2
Added setting-editor-widgets-dirty-so-prompt before exit check.
Cleaned up the queryClose handling, too.
-rw-r--r--kberylsettings/contentframe.py21
-rw-r--r--kberylsettings/main.py33
-rw-r--r--kberylsettings/pluginframe.py5
3 files changed, 32 insertions, 27 deletions
diff --git a/kberylsettings/contentframe.py b/kberylsettings/contentframe.py
index 208005f..ed6467b 100644
--- a/kberylsettings/contentframe.py
+++ b/kberylsettings/contentframe.py
@@ -82,12 +82,25 @@ class ContentFrame(WidgetStack):
self.tabPage.setGroups(plugin)
self.raiseWidget(self.tabPageId)
+ def queryClose(self):
+ """ checks for unsaved changes in a setting page
+
+ @return True if no changes, changes discarded, or changes
+ applied; False if canceled
+ """
+ try:
+ w = self.visibleWidget()
+ return w.unsavedCheck(None, None)
+ except (AttributeError, ), exc:
+ return True
+
class SettingPage:
""" SettingPage -> mixin with methods common to both the
SinglePage and the TabPage types.
"""
+ previous = (None, None)
unsavedText = ('There are unsaved changes in the active settings.\n'
'Do you want to apply the changes before changing views '
'or discard the changes?')
@@ -152,12 +165,14 @@ class SettingPage:
if self.unsaved():
res = self.unsavedDialog()
if res == KMessageBox.Cancel:
- self.emit(Signals.selectPrevious, (plugin, arg))
+ self.emit(Signals.selectPrevious, self.previous)
ret = False
elif res == KMessageBox.Yes:
self.settingApply()
else:
self.settingDiscard()
+ if ret:
+ self.previous = (plugin, arg)
return ret
def settingHelp(self):
@@ -236,7 +251,6 @@ class SinglePage(Frame, SettingPage):
"""
def __init__(self, parent):
Frame.__init__(self, parent, marginHint, spacingHint)
- self.previous = (None, None)
self.header = ContentHeader(self)
self.main = MultiSettingFrame(self)
self.footer = ContentFooter(self)
@@ -258,9 +272,8 @@ class SinglePage(Frame, SettingPage):
@param arg setting name or setting section name
@return None
"""
- if not self.unsavedCheck(*self.previous):
+ if not self.unsavedCheck(plugin, arg):
return
- self.previous = (plugin, arg)
self.header.setFromPlugin(plugin, arg)
self.main.setPlugin(plugin, arg)
diff --git a/kberylsettings/main.py b/kberylsettings/main.py
index 2c40fc8..81aaa4c 100644
--- a/kberylsettings/main.py
+++ b/kberylsettings/main.py
@@ -75,7 +75,6 @@ class KBerylSettings(KMainWindow):
@return None
"""
- self.quitFlag = False
self.sysTray = KSystemTray(self)
pixmap = icon(self.iconFile, size=KIcon.SizeSmallMedium)
self.sysTray.setPixmap(pixmap)
@@ -105,8 +104,6 @@ class KBerylSettings(KMainWindow):
connect(self.clearSearch, Signals.clicked, self.onClearSearch)
connect(self.inputSearch, Signals.textChanged, self.onInputSearch)
statusBar = self.statusBar()
- connect(self.sysTray, Signals.quitSelected, self.onQuitSelected)
- connect(self.quitAction, Signals.activated, self.onQuitSelected)
actions = self.actionCollection()
connect(actions, Signals.actionStatusText, self.statusBar(),
Slots.messageText)
@@ -263,16 +260,17 @@ class KBerylSettings(KMainWindow):
@return True
"""
- flag = self.quitFlag
- if flag:
- self.saveMainWindowSettings(self.config())
- self.saveWindowSize(self.config('mainwindow'))
- config = self.config('mainview')
- config.writeEntry('iconsize', self.iconSize)
- config.writeEntry('viewmode', self.viewMode)
- else:
+ if not self.sender():
self.hide()
- return flag
+ return False
+ if not self.contentFrame.queryClose():
+ return False
+ self.saveMainWindowSettings(self.config())
+ self.saveWindowSize(self.config('mainwindow'))
+ config = self.config('mainview')
+ config.writeEntry('iconsize', self.iconSize)
+ config.writeEntry('viewmode', self.viewMode)
+ return True
def onClearSearch(self):
""" clears the search input, emits signal to set view mode
@@ -333,16 +331,7 @@ class KBerylSettings(KMainWindow):
"""
self.context.Profile = self.profileMap[itemId]
self.emit(Signals.berylContextChanged, (self.context, ))
-
- def onQuitSelected(self):
- """ sets quit flag and calls application to quit
-
- @return None
- """
- self.quitFlag = True
- self.queryClose()
- KApplication.kApplication().quit()
-
+
def onSelectPlugins(self):
""" shows dialog to select/deselect active plugins
diff --git a/kberylsettings/pluginframe.py b/kberylsettings/pluginframe.py
index bc48399..5772cca 100644
--- a/kberylsettings/pluginframe.py
+++ b/kberylsettings/pluginframe.py
@@ -193,7 +193,10 @@ class BasicPluginView(BasicListView):
try:
return a.value[0].Name == b[0].Name and a.value[1] == b[1]
except:
- pass
+ try:
+ return a.value[1].Name == b[0].Name and a.value[0] == b[1]
+ except:
+ pass
other = (plugin, setting)
for item in self:
if match(item, other):