[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [plasmate/terietor/tools] plasmoidviewer: IMPROVEMENTS: * store the config for individual applets;
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2012-08-16 18:41:51
Message-ID: 20120816184151.4DC95A60C6 () git ! kde ! org
[Download RAW message or body]
Git commit 9dbb017f28615c4aa57272e4f92408d48297312c by Aaron J. Seigo.
Committed on 25/08/2010 at 21:31.
Pushed by tsiapaliwkas into branch 'terietor/tools'.
IMPROVEMENTS: * store the config for individual applets; prevents applets clobbering \
each other's configs as they used to, and works with trunk libplasma properly * close \
the app if the user removes the applet manually
svn path=/trunk/KDE/kdebase/workspace/; revision=1167957
M +55 -4 plasmoidviewer/fullview.cpp
M +5 -1 plasmoidviewer/fullview.h
http://commits.kde.org/plasmate/9dbb017f28615c4aa57272e4f92408d48297312c
diff --git a/plasmoidviewer/fullview.cpp b/plasmoidviewer/fullview.cpp
index 631ad39..4f8d507 100644
--- a/plasmoidviewer/fullview.cpp
+++ b/plasmoidviewer/fullview.cpp
@@ -88,11 +88,17 @@ FullView::FullView(const QString &ff, const QString &loc, QWidget \
*parent) setAlignment(Qt::AlignLeft | Qt::AlignTop);
}
+FullView::~FullView()
+{
+ storeCurrentApplet();
+}
+
void FullView::addApplet(const QString &name, const QString &containment,
const QString& wallpaper, const QVariantList &args)
{
kDebug() << "adding applet" << name << "in" << containment;
- if (!m_containment) {
+ if (!m_containment || m_containment->pluginName() != containment) {
+ delete m_containment;
m_containment = m_corona.addContainment(containment);
connect(m_containment, SIGNAL(appletRemoved(Plasma::Applet*)), this, \
SLOT(appletRemoved(Plasma::Applet*))); }
@@ -114,6 +120,13 @@ void FullView::addApplet(const QString &name, const QString \
&containment, return;
}
+ if (m_applet) {
+ // we already have an applet!
+ storeCurrentApplet();
+ disconnect(m_applet);
+ m_applet->destroy();
+ }
+
QFileInfo info(name);
if (!info.isAbsolute()) {
info = QFileInfo(QDir::currentPath() + "/" + name);
@@ -133,7 +146,15 @@ void FullView::addApplet(const QString &name, const QString \
&containment,
if (!m_applet) {
return;
- }
+ }
+
+ if (hasStorageGroupFor(m_applet)) {
+ KConfigGroup cg = m_applet->config();
+ KConfigGroup storage = storageGroup(m_applet);
+ cg.deleteGroup();
+ storage.copyTo(&cg);
+ m_applet->configChanged();
+ }
setSceneRect(m_applet->sceneBoundingRect());
m_applet->setFlag(QGraphicsItem::ItemIsMovable, false);
@@ -141,11 +162,13 @@ void FullView::addApplet(const QString &name, const QString \
&containment, setWindowIcon(SmallIcon(m_applet->icon()));
resize(m_applet->size().toSize());
connect(m_applet, SIGNAL(appletTransformedItself()), this, \
SLOT(appletTransformedItself())); + kDebug() << "connecting ----------------";
+ connect(m_applet, SIGNAL(appletDestroyed(Plasma::Applet*)), this, \
SLOT(appletDestroyed(Plasma::Applet*)));
checkShotTimer();
}
-void FullView::checkShotTimer()
+bool FullView::checkShotTimer()
{
KCmdLineArgs *cliArgs = KCmdLineArgs::parsedArgs();
if (cliArgs->isSet("screenshot") || cliArgs->isSet("screenshot-all")) {
@@ -157,7 +180,10 @@ void FullView::checkShotTimer()
}
m_appletShotTimer->start();
+ return true;
}
+
+ return false;
}
void FullView::screenshotAll()
@@ -241,7 +267,9 @@ void FullView::appletRemoved(Plasma::Applet *applet)
{
if (m_applet == applet) {
m_applet = 0;
- checkShotTimer();
+ if (!checkShotTimer()) {
+ close();
+ }
}
}
@@ -314,5 +342,28 @@ void FullView::sceneRectChanged(const QRectF &rect)
}
}
+bool FullView::hasStorageGroupFor(Plasma::Applet *applet) const
+{
+ KConfigGroup stored = KConfigGroup(KGlobal::config(), "StoredApplets");
+ return stored.groupList().contains(applet->pluginName());
+}
+
+KConfigGroup FullView::storageGroup(Plasma::Applet *applet) const
+{
+ KConfigGroup stored = KConfigGroup(KGlobal::config(), "StoredApplets");
+ return KConfigGroup(&stored, applet->pluginName());
+}
+
+void FullView::storeCurrentApplet()
+{
+ if (m_applet) {
+ KConfigGroup cg = m_applet->config();
+ KConfigGroup storage = storageGroup(m_applet);
+ storage.deleteGroup();
+ cg.copyTo(&storage);
+ KGlobal::config()->sync();
+ }
+}
+
#include "fullview.moc"
diff --git a/plasmoidviewer/fullview.h b/plasmoidviewer/fullview.h
index 2f35634..3ee6e3d 100644
--- a/plasmoidviewer/fullview.h
+++ b/plasmoidviewer/fullview.h
@@ -45,6 +45,7 @@ class FullView : public QGraphicsView
public:
explicit FullView(const QString &formfactor = "planar", const QString &location \
= "floating", QWidget *parent = 0); + ~FullView();
void addApplet(const QString &name, const QString& containment,
const QString& wallpaper, const QVariantList &args = \
QVariantList()); @@ -61,7 +62,10 @@ private Q_SLOTS:
private:
void shootNextPlasmoid();
- void checkShotTimer();
+ bool checkShotTimer();
+ KConfigGroup storageGroup(Plasma::Applet *applet) const;
+ bool hasStorageGroupFor(Plasma::Applet *applet) const;
+ void storeCurrentApplet();
Plasma::Corona m_corona;
Plasma::FormFactor m_formfactor;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic