Lukas Appelhans 写道:
Am Freitag 14 August 2009 14:00:40 schrieb 潘卫平(Peter Pan):
Lukas Appelhans 写道:
Am Freitag 14 August 2009 11:10:42 schrieb 潘卫平(Peter Pan):
Hi,all

I think we should give user a hint when he/she adds a application which
already exists in quicklaunch, so I made this patch.


Regards
Hey!

Good thing! But 2 things: I'm not 100% into the code currently, but why
not implementing the loop inside addProgram()?
In the beginning, I want to quit as soon as possible, to save CPU cycles.
But I agree that addProgram() is a more elegant place, but we should pay
attention to initializing and sorting.

And the second one: "Cancel or Continue?" is not needed as words inside
the MessageBox imo, as the buttons are named like it... "\"%1\" is
already in quicklaunch!"  should be enough!
agree with you.
And I modify my patch.
Ok that looks much nicer... :) Now I think we can merge m_isSorting and m_isInitializing to m_isBusy or m_notAdding or sth like this...


done. I use m_isBusy. Thanks a lot.

Lukas
Regards,

Lukas
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Regards
--
潘卫平(Peter Pan)
Red Flag Software Co., Ltd
Index: quicklaunchApplet.h
===================================================================
--- quicklaunchApplet.h	(revision 1011354)
+++ quicklaunchApplet.h	(working copy)
@@ -178,6 +178,7 @@
         Ui::quicklaunchAdd addUi;
         QuicklaunchIcon *m_rightClickedIcon;
         QPointF m_mousePressPos;
+        bool m_isBusy;
 
         QAction* m_addAction;
         QAction* m_removeAction;
Index: quicklaunchApplet.cpp
===================================================================
--- quicklaunchApplet.cpp	(revision 1011354)
+++ quicklaunchApplet.cpp	(working copy)
@@ -21,6 +21,7 @@
 
 #include <KConfigDialog>
 #include <KDesktopFile>
+#include <KMessageBox>
 #include <QGraphicsSceneDragDropEvent>
 #include <QGraphicsWidget>
 #include <QDrag>
@@ -58,6 +59,7 @@
     m_dialogLayout(0),
     m_addDialog(0),
     m_rightClickedIcon(0),
+    m_isBusy(false),
     m_addAction(0),
     m_removeAction(0),
     m_sortappAscending(0),
@@ -97,6 +99,7 @@
 
 void QuicklaunchApplet::init()
 {
+    m_isBusy = true;
     KConfigGroup cg = config();
     m_preferredIconSize = m_iconSize = qMax(s_defaultIconSize, (int)cg.readEntry("iconSize", contentsRect().height() / 2));
     m_visibleIcons = qMax(-1, cg.readEntry("visibleIcons", m_visibleIcons));
@@ -148,6 +151,8 @@
     if (firstStart) {
         resize(sizeHint(Qt::PreferredSize));
     }
+
+    m_isBusy = false;
 }
 
 QSizeF QuicklaunchApplet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
@@ -396,12 +401,16 @@
 
 void QuicklaunchApplet::ascendingSort() 
 {
+    m_isBusy = true;
     sortQuicklaunch(AscendingSort);
+    m_isBusy = false;
 }
 
 void QuicklaunchApplet::descendingSort()
 {
+    m_isBusy = true;
     sortQuicklaunch(DescendingSort);
+    m_isBusy = false;
 }
 
 void QuicklaunchApplet::sortQuicklaunch(SortingOrder sortingorder)
@@ -601,7 +610,29 @@
     KIcon icon;
     QString text;
     QString genericName;
+    bool do_add_program = true;
 
+    if (!m_isBusy) {
+        foreach (QuicklaunchIcon *icon, m_icons) {
+            if (icon->url().url() == appUrl.url()) {
+                if (KMessageBox::warningContinueCancel(
+                        0, 
+                        i18n("\"%1\" is already in quicklaunch!", icon->url().pathOrUrl()), 
+                        i18n("Warning") 
+                    ) == KMessageBox::Cancel) {
+                    do_add_program = false;
+                    break;
+                } else {
+                    break;
+                }
+            }
+        }
+    }
+
+    if (!do_add_program) {
+        return;
+    }
+
     if (appUrl.isLocalFile() && KDesktopFile::isDesktopFile(appUrl.toLocalFile())) {
         KDesktopFile *f = new KDesktopFile(appUrl.toLocalFile());
 
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to