[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/applets/quicklaunch
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2009-05-13 3:21:13
Message-ID: 1242184873.186899.14766.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 967258 by aseigo:

save state immediately when adding/removing icons so if things go wrong on exit the \
widget keeps its config BUG:191432


 M  +26 -18    quicklaunchApplet.cpp  
 M  +1 -7      quicklaunchApplet.h  


--- trunk/KDE/kdebase/workspace/plasma/applets/quicklaunch/quicklaunchApplet.cpp \
#967257:967258 @@ -128,10 +128,13 @@
                 }
             }
         }
-        kDebug() << desktopFiles;
+        //kDebug() << desktopFiles;
     }
 
-    loadPrograms(desktopFiles);
+    foreach (const QString &desktopFile, desktopFiles) {
+        addProgram(-1, desktopFile);
+    }
+
     performUiRefactor();
 }
 
@@ -162,15 +165,15 @@
 
 void QuicklaunchApplet::refactorUi()
 {
-     static int my_counter = 0;
-     kDebug() << "refactorUi count = " << my_counter++;
+     //static int my_counter = 0;
+     //kDebug() << "refactorUi count = " << my_counter++;
      m_timer->start(100);
 }
 
 void QuicklaunchApplet::performUiRefactor()
 {
-    static int my_perforcount = 0;
-    kDebug() << "performUiRefactor count = " << my_perforcount++;
+    //static int my_perforcount = 0;
+    //kDebug() << "performUiRefactor count = " << my_perforcount++;
     clearLayout(m_innerLayout);
 
     m_iconSize = qMin(qMax(m_iconSize, s_defaultIconSize), \
(int)(contentsRect().height() - 2 * s_defaultSpacing));//Don't accept values under 16 \
nor anything over applet's height @@ -234,7 +237,6 @@
     }
 
     //resize(sizeHint(Qt::PreferredSize));
-    kDebug() << "Bar see";
     update();
 }
 
@@ -456,13 +458,16 @@
     dropApp(static_cast<QGraphicsSceneDragDropEvent*>(event),false);
 }
 
-void QuicklaunchApplet::addProgram(int index, const QString &url)
+void QuicklaunchApplet::addProgram(int index, const QString &url, bool isNewIcon)
 {
     if (index < 0 || index > m_icons.size()) {
         index = m_icons.size();
     }
-    if( url.isEmpty() )
+
+    if (url.isEmpty()) {
         return;
+    }
+
     KUrl appUrl = KUrl(url);
     KIcon icon;
     QString text;
@@ -490,12 +495,11 @@
     QuicklaunchIcon *container = new QuicklaunchIcon(appUrl, text, icon, \
genericName, this);  container->installEventFilter(this);
     m_icons.insert(index, container);
-}
 
-void QuicklaunchApplet::loadPrograms(const QStringList &desktopFiles)
-{
-    foreach (const QString &desktopFile, desktopFiles) {
-        addProgram(-1, desktopFile);
+    if (isNewIcon) {
+        KConfigGroup cg = config();
+        saveState(cg);
+        emit configNeedsSaving();
     }
 }
 
@@ -512,6 +516,10 @@
     m_rightClickedIcon->hide();
     m_rightClickedIcon->deleteLater();
     performUiRefactor();
+
+    KConfigGroup cg = config();
+    saveState(cg);
+    emit configNeedsSaving();
 }
 
 bool QuicklaunchApplet::dropHandler(const int pos, const QMimeData *mimedata)
@@ -522,7 +530,7 @@
 
     KUrl::List urls = KUrl::List::fromMimeData(mimedata);
 
-    if (!urls.count()) {
+    if (urls.isEmpty()) {
         return false;
     }
 
@@ -532,8 +540,8 @@
     }
 
     foreach (const KUrl &url, urls) {
-        if(KDesktopFile::isDesktopFile(url.toLocalFile())) {
-            addProgram(pos, url.toLocalFile());
+        if (KDesktopFile::isDesktopFile(url.toLocalFile())) {
+            addProgram(pos, url.toLocalFile(), true);
         }
     }
     return true;
@@ -557,7 +565,7 @@
 void QuicklaunchApplet::addAccepted()
 {
     int insertplace = m_rightClickedIcon ? m_icons.indexOf(m_rightClickedIcon) : \
                m_icons.size();
-    addProgram(insertplace, addUi.urlIcon->url().url());
+    addProgram(insertplace, addUi.urlIcon->url().url(), true);
     performUiRefactor();
 }
 
--- trunk/KDE/kdebase/workspace/plasma/applets/quicklaunch/quicklaunchApplet.h \
#967257:967258 @@ -131,15 +131,9 @@
          * @param index The position to insert the icon into
          * @param desktopFile The Url to read
          */
-        void addProgram(int index, const QString &desktopFile);
+        void addProgram(int index, const QString &desktopFile, bool isNewIcon = \
false);  
         /**
-         * Read all Urls from a list, and insert into icon list
-         * @param desktopFiles List with Urls
-         */
-        void loadPrograms(const QStringList &desktopFiles);
-
-        /**
          * Removes all items from a BoxLayout
          * @param layout Layout to clear
          */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic