summaryrefslogtreecommitdiff
path: root/kberylsettings/contentframe.py
diff options
context:
space:
mode:
authornatural <natural>2006-12-24 10:20:10 +0000
committernatural <natural>2006-12-24 10:20:10 +0000
commitefa1df0939d879cf18e0cf9fa342aaf86d3e9ea1 (patch)
tree486d072a630c5720689ccb13f48a76485e346e6c /kberylsettings/contentframe.py
parent5dbd7720a4e446d8f12c1456584e354a3facdd7c (diff)
downloadkberylsettings-efa1df0939d879cf18e0cf9fa342aaf86d3e9ea1.tar.gz
kberylsettings-efa1df0939d879cf18e0cf9fa342aaf86d3e9ea1.tar.bz2
Updates for most recent berylsettings.pyx.
Added setting widget for strings with fewer than 5 restrictions; uses radio buttons instead of a list box. Added profile menus to main.py (not yet functional). Changed color setting widgets; they now work! Other minor fixes and changes. Enabled "Defaults" and "Reset" buttons.
Diffstat (limited to 'kberylsettings/contentframe.py')
-rw-r--r--kberylsettings/contentframe.py62
1 files changed, 49 insertions, 13 deletions
diff --git a/kberylsettings/contentframe.py b/kberylsettings/contentframe.py
index bcea158..68e8582 100644
--- a/kberylsettings/contentframe.py
+++ b/kberylsettings/contentframe.py
@@ -3,11 +3,11 @@
""" kberylsettings.contentframe -> defines the right side about/setting views.
"""
-from kdecore import KIcon
+from kdecore import KIcon, i18n
from kdeui import KMessageBox, KPassivePopup, KPushButton, \
KSeparator, KStdGuiItem
from qt import Qt, QFrame, QHBoxLayout, QLabel, QScrollView, QSize, \
- QSizePolicy, QStringList, QVBoxLayout
+ QSizePolicy, QStringList, QToolTip, QVBoxLayout
from kberylsettings.lib import App, Signals, buildPart, icon, iconLoader, iconSet
from kberylsettings.widget import Frame, SmallPushButton, WidgetStack
@@ -90,7 +90,7 @@ class ContentFrame(WidgetStack):
root = self.topLevelWidget()
connect(self, Signals.berylSettingChanged, root.onContextChanged)
connect(self, Signals.statusMessage, root.showMessage)
- connect(self.settingsMain, Signals.somethingChanged,
+ connect(self.settingsMain, Signals.someChange,
self.onSomethingChanged)
def onSomethingChanged(self):
@@ -117,7 +117,11 @@ class ContentFrame(WidgetStack):
self.infoHtml.end()
self.raiseWidget(self.aboutPageId)
-
+ unsavedText = """There are unsaved changes in the active settings.
+
+ Do you want to apply the changes before changing views or discard the changes?
+ """
+
def showSettings(self, plugin, arg):
""" displays the settings page with individual setting frames
@@ -125,7 +129,15 @@ class ContentFrame(WidgetStack):
@param arg setting name or setting section name
@return None
"""
- p = self.parent()
+ if self.applyButton.isEnabled():
+ msg = KMessageBox.warningYesNoCancel
+ res = msg(self, self.unsavedText, i18n('Unsaved Changes'),
+ KStdGuiItem.apply(), KStdGuiItem.discard())
+ if res == KMessageBox.Cancel:
+ return
+ elif res == KMessageBox.Yes:
+ self.settingApply()
+ #else it's no/discard so fall thru
ico = plugin.icon(KIcon.SizeLarge, self.loader)
self.pluginIconLabel.setPixmap(ico)
if arg in plugin.settings:
@@ -146,13 +158,27 @@ class ContentFrame(WidgetStack):
"""
def settingDefaults(self):
- """ not implemented
+ """ set each setting to its default value
+ @return None
"""
+ frame = self.settingsPage
+ widgets = frame.queryList('SettingFrame')
+ for widget in widgets:
+ try:
+ widget.setDefault()
+ except (Exception, ), exc:
+ print 'reset exception:', exc
+ self.applyButton.setEnabled(True)
+ self.resetButton.setEnabled(True)
def settingsReset(self):
+ """ set each setting to its previous value
+
+ @return None
+ """
frame = self.settingsPage
- widgets = frame.queryList('SettingWidgetBase')
+ widgets = frame.queryList('SettingWidget')
for widget in widgets:
try:
widget.reset()
@@ -166,7 +192,7 @@ class ContentFrame(WidgetStack):
"""
excs = []
- for w in self.settingsPage.queryList('SettingWidgetBase'):
+ for w in self.settingsPage.queryList('SettingWidget'):
try:
v = w.value()
w.setting.set(v)
@@ -195,7 +221,7 @@ class SettingsContainer(QFrame):
def addSettings(self, plugin, settings):
self.clearFrames()
layout = self.layout()
- changed = Signals.somethingChanged
+ changed = Signals.someChange
for setting in settings:
frame = SettingFrame(self, plugin, setting)
self.settingFrames.append(frame)
@@ -225,7 +251,9 @@ class SettingFrame(QFrame):
self.infoCaption = setting.ShortDesc
self.infoText = setting.LongDesc
self.infoButton = info = SmallPushButton(iconSet('help'), '', self)
- self.resetButton = reset = SmallPushButton(iconSet('reload'), '', self)
+ self.resetButton = reset = \
+ SmallPushButton(iconSet('locationbar_erase'), '', self)
+ QToolTip.add(reset, i18n('Reset to default value'))
self.settingWidget = widget = settingWidget(self, plugin, setting)
if isinstance(widget.layout(), QHBoxLayout):
align = Qt.AlignLeft | Qt.AlignVCenter
@@ -238,8 +266,16 @@ class SettingFrame(QFrame):
connect = self.connect
connect(info, Signals.clicked, self.showInfo)
- connect(widget, Signals.somethingChanged,
- self, Signals.somethingChanged)
+ connect(reset, Signals.clicked, self.setDefault)
+ connect(widget, Signals.someChange,
+ self, Signals.someChange)
+
+ def setDefault(self):
+ w = self.settingWidget
+ curv = w.value()
+ newv = w.initial = w.setting.ResetToDefault()
+ w.setting.set(curv) # because it's not applied yet
+ w.reset()
def showInfo(self):
""" show a balloon tip with the setting description
@@ -266,5 +302,5 @@ class ContentScroll(QScrollView):
def __init__(self, parent, child):
QScrollView.__init__(self, parent)
self.setResizePolicy(QScrollView.AutoOneFit)
- self.setFrameShape(self.Box)
+ self.setFrameShape(self.NoFrame)
self.addChild(child)