summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornatural <natural>2007-01-01 05:36:07 +0000
committernatural <natural>2007-01-01 05:36:07 +0000
commit8100c625e1a8d63b3fc434d08dbffb5652a59e69 (patch)
tree2a35cfbd1051fb10b0d05aba4ed88421701d2cfb
parentdd5381035a8a341b87d3836ea3e454eb999e9223 (diff)
downloadkberylsettings-8100c625e1a8d63b3fc434d08dbffb5652a59e69.tar.gz
kberylsettings-8100c625e1a8d63b3fc434d08dbffb5652a59e69.tar.bz2
Added tip of the day dialog, application key configuration dialog.
Removed basedir references in preference to KStandardDirs configuration. Moved about.py to aboutapp.py. Other small fixes and enhancements.
-rw-r--r--kberylsettings/aboutapp.py (renamed from kberylsettings/about.py)0
-rw-r--r--kberylsettings/aboutpage.py6
-rw-r--r--kberylsettings/beryl.py28
-rw-r--r--kberylsettings/contentframe.py2
-rw-r--r--kberylsettings/lib.py11
-rw-r--r--kberylsettings/main.py70
-rw-r--r--kberylsettings/pluginframe.py5
-rw-r--r--kberylsettings/tips24
8 files changed, 99 insertions, 47 deletions
diff --git a/kberylsettings/about.py b/kberylsettings/aboutapp.py
index 0940395..0940395 100644
--- a/kberylsettings/about.py
+++ b/kberylsettings/aboutapp.py
diff --git a/kberylsettings/aboutpage.py b/kberylsettings/aboutpage.py
index 648700e..1b3e585 100644
--- a/kberylsettings/aboutpage.py
+++ b/kberylsettings/aboutpage.py
@@ -10,7 +10,7 @@ from khtml import KHTMLPart
from pykdeconfig import _pkg_config
from kberylsettings.beryl import Setting
-from kberylsettings.lib import App, Signals, iconLoader
+from kberylsettings.lib import Signals, iconLoader
from kberylsettings.widget import Frame
@@ -96,12 +96,12 @@ class AboutPage(Frame):
@return None
"""
self.context = context
- htmlsrc = open(App.basedir + '/html/main.html').read()
+ htmlsrc = open(locate('templates', 'main.html')).read()
extracssurl = locate('data', 'kdeui/about/kde_infopage.css')
extracssurl = 'file://%s' % extracssurl
kcontrolcssurl = locate('data', 'kcontrol/about/kcontrol.css')
kcontrolcssurl = 'file://%s' % kcontrolcssurl
- logourl = 'file://%s' % App.basedir + '/html/beryl-manager.png'
+ logourl = 'file://%s' % locate('templates', 'beryl-manager.png')
if plugin is None:
title = i18n('KDE Beryl Settings')
shortdesc = i18n('Configure Your Beryl Settings')
diff --git a/kberylsettings/beryl.py b/kberylsettings/beryl.py
index 45ccc26..7268887 100644
--- a/kberylsettings/beryl.py
+++ b/kberylsettings/beryl.py
@@ -5,10 +5,8 @@
"""
import berylsettings
-from os.path import abspath, exists
-
-from kdecore import KIcon
-from kberylsettings.lib import App, Signals, icon, iconLoader
+from kdecore import KIcon, locate
+from kberylsettings.lib import Signals, icon, iconLoader
from qt import QImage, QPixmap, QObject
@@ -84,7 +82,7 @@ class Context(QObject):
@return sequence of active plugin names
"""
act = self.general.Setting(self.activePluginsSettingName).Value
- return act # + [Plugin.generalName, ]
+ return act
def setActive(self, active):
""" sets active plugins
@@ -227,14 +225,12 @@ class Plugin:
@param loader KIconLoader instance
@return icon instance
"""
- if App.debug:
- return loader.loadIcon('empty', KIcon.NoGroup, size)
name = self.plugin.Name
try:
pix = self.iconCache[(name, size)]
except (KeyError, ):
- path = abspath(App.basedir + '/pixmaps/beryl-settings-section-%s.svg' % name)
- if not exists(path):
+ path = locate('icon', 'beryl-settings-section-%s.svg' % name)
+ if not path:
path = 'unknown'
ico = loader.loadIcon(path, KIcon.NoGroup)
img = ico.convertToImage()
@@ -243,9 +239,12 @@ class Plugin:
return pix
def iconPath(self):
+ """ path to icon for this plugin
+
+ @return icon path
+ """
name = self.plugin.Name
- path = abspath(App.basedir + '/pixmaps/beryl-settings-section-%s.png' % name)
- return path
+ return locate('icon', 'beryl-settings-section-%s.png' % name)
altType = {
'Int' : 'Values',
@@ -375,7 +374,7 @@ class Setting:
self.setting.Value = value
def icon(cls, value, size):
- """ icon for this plugin
+ """ icon for setting type
@param value setting type name
@param size KIcon size
@@ -386,6 +385,11 @@ class Setting:
icon = classmethod(icon)
def iconPath(cls, value):
+ """ path to icon for setting type
+
+ @param value setting type name
+ @return icon path
+ """
name = cls.iconNameMap.get(str(value), cls.iconNameMap['Choices'])
ico = iconLoader().iconPath(name, KIcon.NoGroup)
return ico
diff --git a/kberylsettings/contentframe.py b/kberylsettings/contentframe.py
index ed6467b..3c709e7 100644
--- a/kberylsettings/contentframe.py
+++ b/kberylsettings/contentframe.py
@@ -11,7 +11,7 @@ from qt import Qt, QFrame, QHBoxLayout, QLabel, QScrollView, QSize, \
from kberylsettings.aboutpage import AboutPage
from kberylsettings.beryl import Setting
-from kberylsettings.lib import App, Signals, icon, iconLoader, iconSet
+from kberylsettings.lib import Signals, icon, iconLoader, iconSet
from kberylsettings.widget import Frame, SmallPushButton, WidgetStack, guiButton
from kberylsettings.settingwidget import settingWidget
diff --git a/kberylsettings/lib.py b/kberylsettings/lib.py
index c6e0e09..13b50f3 100644
--- a/kberylsettings/lib.py
+++ b/kberylsettings/lib.py
@@ -3,9 +3,6 @@
""" kberylsettings.lib -> library classes, functions, and attributes.
"""
-from os import environ
-from os.path import abspath, dirname
-
from qt import PYSIGNAL, QPixmap, QImage, SIGNAL, SLOT
from kdecore import KGlobal, KIcon, KShortcut, i18n
from kdeui import KAction, KStdAction
@@ -16,14 +13,6 @@ from kdeui import KAction, KStdAction
iconCache = {}
-class App:
- """ class for application-wide settings
-
- """
- debug = environ.get('DEBUG')
- basedir = abspath(dirname(__file__))
-
-
class Signals:
""" class with SIGNAL and PYSIGNAL attributes
diff --git a/kberylsettings/main.py b/kberylsettings/main.py
index 81aaa4c..b43e2e7 100644
--- a/kberylsettings/main.py
+++ b/kberylsettings/main.py
@@ -4,18 +4,19 @@
"""
from os import listdir
-from os.path import expanduser
+from os.path import abspath, dirname, expanduser
from sys import argv
-from kdecore import KApplication, KCmdLineArgs, KIcon, KGlobal, KWin, i18n
-from kdeui import KMainWindow, KStdGuiItem, KLineEdit, KSystemTray
+from kdecore import KApplication, KCmdLineArgs, KIcon, KGlobal, KWin, i18n, locate
+from kdeui import KMainWindow, KStdGuiItem, KLineEdit, KSystemTray, KTipDialog, \
+ KKeyDialog
from kfile import KFileDialog
from qt import Qt, QWidget, QHBoxLayout, QLabel, QImage
-from kberylsettings.about import about
+from kberylsettings.aboutapp import about
from kberylsettings.beryl import Context
from kberylsettings.contentframe import ContentFrame
-from kberylsettings.lib import App, Signals, Slots, action, stdAction, icon
+from kberylsettings.lib import Signals, Slots, action, stdAction, icon
from kberylsettings.plugindialog import PluginDialog
from kberylsettings.pluginframe import PluginFrame
from kberylsettings.widget import Frame, Popup, SmallPushButton, Splitter
@@ -36,7 +37,7 @@ class KBerylSettings(KMainWindow):
self.buildSystray()
self.buildConnections()
self.buildFinal()
-
+
def buildWidgets(self):
""" builds widgets on this instance
@@ -90,7 +91,7 @@ class KBerylSettings(KMainWindow):
@return icon filename
"""
- return App.basedir + '/pixmaps/kberylsettings.svg'
+ return locate('icon', 'kberylsettings.svg')
iconFile = property(iconFile)
def buildConnections(self):
@@ -103,6 +104,7 @@ class KBerylSettings(KMainWindow):
connect(self, Signals.iconSizeChanged, self.onIconSize)
connect(self.clearSearch, Signals.clicked, self.onClearSearch)
connect(self.inputSearch, Signals.textChanged, self.onInputSearch)
+ connect(self.sysTray, Signals.quitSelected, self.close)
statusBar = self.statusBar()
actions = self.actionCollection()
connect(actions, Signals.actionStatusText, self.statusBar(),
@@ -133,9 +135,12 @@ class KBerylSettings(KMainWindow):
(config.readNumEntry('iconsize', self.iconSize), ))
viewMode = config.readNumEntry('viewmode', self.viewMode)
emit(Signals.viewModeChanged, (viewMode, ))
+ actions = self.actionCollection()
+ actions.readShortcutSettings('shortcuts', self.config())
## done after initial emit to prevent spurious context update
connect(self, Signals.berylContextChanged, self.onContextChanged)
-
+ self.tipDialog(force=False)
+
def config(self, group=None):
""" loads the general configuration object
@@ -172,12 +177,17 @@ class KBerylSettings(KMainWindow):
@return KPopupMenu instance
"""
+ actions = self.actionCollection()
pop = KMainWindow.helpMenu(self)
+ self.tipAction = stdAction('tipOfDay', self.tipDialog, actions,
+ 'tipOfDay', None)
self.introAction = action('KDE Beryl Settings Introduction',
- 'intro', 'Ctrl+I', self.onIntro,
- self.actionCollection(), 'intro_action',
+ 'help', 'Ctrl+I', self.onIntro,
+ actions, 'intro_action',
'Show the introduction.', None)
- self.introAction.plug(pop, 3)
+ pop.insertSeparator(2)
+ self.tipAction.plug(pop, 3)
+ self.introAction.plug(pop, 4)
return pop
def profileMenu(self):
@@ -216,14 +226,17 @@ class KBerylSettings(KMainWindow):
@return KPopupMenu instance
"""
+ actions = self.actionCollection()
pop = Popup(self)
+ self.keysAction = stdAction('keyBindings', self.onConfigKeys,
+ actions, 'keyBindings', pop)
self.pluginsAction = action('Select Plugins...', 'configure', 'Ctrl+P',
self.onSelectPlugins,
- self.actionCollection(),
+ actions,
'select_plugins',
'Select Beryl plugins.',
pop)
- return pop
+ return pop
def modeMenu(self):
""" creates a new View Mode menu
@@ -270,6 +283,8 @@ class KBerylSettings(KMainWindow):
config = self.config('mainview')
config.writeEntry('iconsize', self.iconSize)
config.writeEntry('viewmode', self.viewMode)
+ actions = self.actionCollection()
+ actions.writeShortcutSettings('shortcuts', config)
return True
def onClearSearch(self):
@@ -280,6 +295,13 @@ class KBerylSettings(KMainWindow):
self.inputSearch.clear()
self.emit(Signals.viewModeChanged, (self.viewMode, ))
+ def onConfigKeys(self):
+ """ displays the kde shortcut key config dialog for our actions
+
+ @return None
+ """
+ KKeyDialog.configure(self.actionCollection(), self)
+
def onContextChanged(self):
""" writes the beryl context and sends a reload message
@@ -302,7 +324,7 @@ class KBerylSettings(KMainWindow):
"""
self.emit(Signals.searchInput, (value, ))
- self.emit(Signals.viewModeChanged, (2, ))
+ self.emit(Signals.viewModeChanged, (PluginFrame.searchPageId, ))
def onIntro(self):
""" emits signal to show the introduction
@@ -339,8 +361,7 @@ class KBerylSettings(KMainWindow):
"""
self.pluginDialogItems = {}
dialog = PluginDialog(self, self.context, self.pluginDialogItems)
- self.connect(dialog, Signals.okClicked,
- self.onPluginDialogOk)
+ self.connect(dialog, Signals.okClicked, self.onPluginDialogOk)
dialog.exec_loop()
def onMode(self, value):
@@ -379,7 +400,6 @@ class KBerylSettings(KMainWindow):
'Select File to Export Profile')
if filename:
print 'exporting file...', filename
-
def showMessage(self, text):
""" show a message in the status bar
@@ -389,6 +409,15 @@ class KBerylSettings(KMainWindow):
"""
self.statusBar().message(text, 3000)
+ def tipDialog(self, force=True):
+ """ show a KTipDialog
+
+ @keyparam force=True if true, forces dialog display. default
+ is True for easy connection to the menu entry.
+ @return None
+ """
+ KTipDialog.showTip(self, locate('data', 'tips'), force)
+
def iconSizes():
""" creates list of KIcon sizes and their names
@@ -411,9 +440,14 @@ def main():
@return None
"""
aboutdata = about()
- aboutdata.setProgramLogo(QImage(App.basedir + '/pixmaps/kberylsettings.png'))
KCmdLineArgs.init(argv, aboutdata)
app = KApplication()
+ dirs = app.dirs()
+ basedir = abspath(dirname(__file__))
+ dirs.addResourceDir('data', basedir)
+ dirs.addResourceDir('templates', basedir + '/html')
+ dirs.addResourceDir('icon', basedir + '/pixmaps')
+ aboutdata.setProgramLogo(QImage(locate('icon', 'kberylsettings.png')))
obj = KBerylSettings()
obj.show()
app.exec_loop()
diff --git a/kberylsettings/pluginframe.py b/kberylsettings/pluginframe.py
index fbfe3c7..eb64c54 100644
--- a/kberylsettings/pluginframe.py
+++ b/kberylsettings/pluginframe.py
@@ -291,7 +291,8 @@ class IconView(BasicPluginView):
return
if item.plugin and not item.setting:
self.showSettingItems(item.plugin)
- self.emit(Signals.showAbout, (self.context, item.plugin, ))
+ if self.sender() is self or self.isVisible():
+ self.emit(Signals.showAbout, (self.context, item.plugin, ))
elif item == self.firstChild():
self.showPlugins()
else:
@@ -413,7 +414,7 @@ class TreeView(BasicPluginView):
plugin, setting = item.plugin, item.setting
if plugin and setting:
self.emit(Signals.showSettings, (plugin, setting))
- else:
+ elif self.sender() is self or self.isVisible():
self.emit(Signals.showAbout, (self.context, plugin, ))
self.emit(Signals.selectItem, (item, ))
diff --git a/kberylsettings/tips b/kberylsettings/tips
new file mode 100644
index 0000000..9b4ceb2
--- /dev/null
+++ b/kberylsettings/tips
@@ -0,0 +1,24 @@
+
+<tip category="KDE Beryl Settings|General">
+<html>
+<p>Don't tug on Superman's cape.</p>
+</html>
+</tip>
+
+<tip category="KDE Beryl Settings|General">
+<html>
+<p>Don't spit into the wind.</p>
+</html>
+</tip>
+
+<tip category="KDE Beryl Settings|General">
+<html>
+<p>Don't pull the mask off the Lone Ranger.</p>
+</html>
+</tip>
+
+<tip category="KDE Beryl Settings|General">
+<html>
+<p>And don't mess around with <em>Jim</em>!</p>
+</html>
+</tip>