[plasmate/terietor/tools] plasmoidviewer: Make plasmoidviewer have non-persistent applet config files.
Shaun Reich
shaun.reich at kdemail.net
Thu Aug 16 18:41:51 UTC 2012
Git commit 17d192ac9354d9d2aa227ee95d152b237340a45f by Shaun Reich.
Committed on 03/01/2012 at 04:04.
Pushed by tsiapaliwkas into branch 'terietor/tools'.
Make plasmoidviewer have non-persistent applet config files.
Non-persistence is on by default, since this is a debugging application
(I've run into a few times already where my applet was loading config
file entries, and they were overriding the less-heavy default settings.
iow: I was getting repeticious undesired behavior.
Enable config persistence by passing --persistent-config
(we could also make the option behave inversely, if that's more
intelligent. seemed like this would be the most desired behavior for a
debugging application).
CCMAIL:plasma-devel at kde.org
M +5 -4 plasmoidviewer/fullview.cpp
M +4 -1 plasmoidviewer/fullview.h
M +10 -1 plasmoidviewer/main.cpp
http://commits.kde.org/plasmate/17d192ac9354d9d2aa227ee95d152b237340a45f
diff --git a/plasmoidviewer/fullview.cpp b/plasmoidviewer/fullview.cpp
index a30d9d1..c6a7ce0 100644
--- a/plasmoidviewer/fullview.cpp
+++ b/plasmoidviewer/fullview.cpp
@@ -45,13 +45,14 @@
using namespace Plasma;
-FullView::FullView(const QString &ff, const QString &loc, QWidget *parent)
+FullView::FullView(const QString &ff, const QString &loc, bool persistent, QWidget *parent)
: QGraphicsView(parent),
m_formfactor(Plasma::Planar),
m_location(Plasma::Floating),
m_containment(0),
m_applet(0),
- m_appletShotTimer(0)
+ m_appletShotTimer(0),
+ m_persistentConfig(persistent)
{
setFrameStyle(QFrame::NoFrame);
QString formfactor = ff.toLower();
@@ -157,7 +158,7 @@ void FullView::addApplet(const QString &name, const QString &containment,
return;
}
- if (hasStorageGroupFor(m_applet)) {
+ if (hasStorageGroupFor(m_applet) && m_persistentConfig) {
KConfigGroup cg = m_applet->config();
KConfigGroup storage = storageGroup(m_applet);
cg.deleteGroup();
@@ -371,7 +372,7 @@ KConfigGroup FullView::storageGroup(Plasma::Applet *applet) const
void FullView::storeCurrentApplet()
{
- if (m_applet) {
+ if (m_applet && m_persistentConfig) {
KConfigGroup cg;
m_applet->save(cg);
cg = m_applet->config();
diff --git a/plasmoidviewer/fullview.h b/plasmoidviewer/fullview.h
index b998a41..eed247f 100644
--- a/plasmoidviewer/fullview.h
+++ b/plasmoidviewer/fullview.h
@@ -44,7 +44,7 @@ class FullView : public QGraphicsView
Q_OBJECT
public:
- explicit FullView(const QString &formfactor = "planar", const QString &location = "floating", QWidget *parent = 0);
+ explicit FullView(const QString &formfactor = "planar", const QString &location = "floating", bool persistentConfig = false, QWidget *parent = 0);
~FullView();
void addApplet(const QString &name, const QString& containment,
@@ -77,6 +77,9 @@ private:
Plasma::Applet *m_applet;
QStringList m_appletsToShoot;
QTimer *m_appletShotTimer;
+ // passed through cli by default, config files
+ // are non-persistent in plasmoidviewer.
+ bool m_persistentConfig;
};
#endif
diff --git a/plasmoidviewer/main.cpp b/plasmoidviewer/main.cpp
index ec7ab42..e589cdd 100644
--- a/plasmoidviewer/main.cpp
+++ b/plasmoidviewer/main.cpp
@@ -139,6 +139,8 @@ int main(int argc, char **argv)
options.add("location <name>", ki18nc("Do not translate floating, desktop, fullscreen, top, bottom, left nor right", "The location constraint to start the Containment with (floating, desktop, fullscreen, top, bottom, left, right)"), "floating");
options.add("p");
options.add("pixmapcache <size>", ki18n("The size in kB to set the pixmap cache to"));
+ options.add("pr");
+ options.add("persistent-config", ki18n("By default the config file of applets run from plasmoidviewer is NOT PERSISTENT. This makes the applets loaded able to save config files"));
options.add("s");
options.add("screenshot", ki18n("Takes a screenshot of the widget and saves it the working directory as <pluginname>.png"));
options.add("sa");
@@ -212,7 +214,14 @@ int main(int argc, char **argv)
kDebug() << "setting auth policy";
Plasma::AuthorizationManager::self()->setAuthorizationPolicy(Plasma::AuthorizationManager::PinPairing);
- FullView view(formfactor, location);
+ bool persistentConfig = args->isSet("persistent-config");
+ if (persistentConfig) {
+ kDebug() << "persistent-config flag set. Config file will now be saved in plasmoidviewer-appletsrc";
+ } else {
+ kWarning() << "!!! WARNING: PERSISTENT CONFIG flag was NOT SET. APPLET CONFIGURATION WILL NOT BE SAVED BETWEEN RUNS!!!";
+ }
+
+ FullView view(formfactor, location, persistentConfig);
if (args->isSet("list-remote")) {
kDebug() << "list remote...";
More information about the Plasma-devel
mailing list