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

List:       kde-usability
Subject:    RMB in-place editing in the K-Menu
From:       Daniel Molkentin <molkentin () kde ! org>
Date:       2002-06-19 0:36:28
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Moin!

Today I toyed around with adding RMB support for kickers applnk section. I
added a QPopup-derived class that gets the entry KSycocaEntry. For now, this
class mostly contains stubs and all possible options are shown, no matther
they make sense at this point or not. Patch attached.

For the hidden files stuff, I added a entry "show hidden" which should also
show all hidden entries if any. The other thing not yet taken into account is
the moving of files into other directories, although that should be trivial
(just accepting drops and then offer a menu on wether to move or copy the
entry).
On this basis, it could be merged with the codebase of KMenuEditor. is there
any smart way to do that?

Cheers,

</daniel>

- -- 
Daniel Molkentin <molkentin@kde.org> | The K Desktop Environment
KDE - Konqueror your Desktop!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9D9IMu1Wkf8kBwz4RAowlAKDA45674OlN/ndaO58Q/FjXYmcQdwCfYjyv
s/sNIJEAkF+VDy1USkaKTHA=
=rJ9v
-----END PGP SIGNATURE-----

[" " (text/x-diff)]

Index: service_mnu.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/ui/service_mnu.cpp,v
retrieving revision 1.46
diff -u -3 -p -r1.46 service_mnu.cpp
--- service_mnu.cpp	2002/05/21 15:23:30	1.46
+++ service_mnu.cpp	2002/06/19 00:32:31
@@ -25,6 +25,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE 
 #include <qpixmap.h>
 #include <qimage.h>
 #include <qregexp.h>
+#include <qcursor.h>
 
 #include <kapplication.h>
 #include <kstandarddirs.h>
@@ -39,6 +40,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE 
 #include <ksycoca.h>
 #include <ksycocaentry.h>
 #include <kservice.h>
+#include <kstringhandler.h>
 
 #include "kicker.h"
 #include "recentapps.h"
@@ -50,6 +52,33 @@ const int kRecentMenusOffset = 1000;
 // static object that stores "recent" history
 static RecentlyLaunchedApps s_RecentApps;
 
+/**********************************************/
+
+RMBActionMenu::RMBActionMenu(QWidget* parent, KSycocaEntry *entry, const char * name)
+	: QPopupMenu(parent, name)
+{
+	entry_ = entry;
+	insertItem(i18n("New Submenu"), this, SLOT(slotNewSubmenu()) );
+	insertSeparator();
+	insertItem(i18n("Edit"), this, SLOT(slotDelete()) );
+	insertItem(i18n("Delete"), this, SLOT(slotDelete()) );
+	insertItem(i18n("Copy"), this, SLOT(slotCopy()) );
+	insertItem(i18n("Cut"), this, SLOT(slotCut()) );
+	insertSeparator();
+	insertItem(i18n("Show hidden"), this, SLOT(slotShowHidden()) );
+	insertSeparator();
+	insertItem(i18n("Cancel"), this, SLOT(close()));
+}
+
+void RMBActionMenu::slotCopy() {};
+void RMBActionMenu::slotCut() {};
+void RMBActionMenu::slotDelete() {};
+void RMBActionMenu::slotEdit() {};
+void RMBActionMenu::slotNewSubmenu() {};
+void RMBActionMenu::slotShowHidden() {};
+
+/**********************************************/
+
 PanelServiceMenu::PanelServiceMenu(const QString & label, const QString & relPath, QWidget * parent,
                                    const char * name, bool addmenumode)
     : KPanelMenu(label, parent, name), relPath_(relPath), clearOnClose_(false),addmenumode_(addmenumode)
@@ -61,6 +90,7 @@ PanelServiceMenu::PanelServiceMenu(const
     subMenus.setAutoDelete(true);
 
     excludeNoDisplay_=true;
+	actionMenu_=0L;
 
     connect(KSycoca::self(),  SIGNAL(databaseChanged()),  SLOT(slotClearOnClose()));
     connect(Kicker::kicker(), SIGNAL(configurationChanged()), this, SLOT(configChanged()) );
@@ -277,6 +307,7 @@ void PanelServiceMenu::configChanged()
 void PanelServiceMenu::insertMenuItem(KService::Ptr & s, int nId, int nIndex/*= -1*/)
 {
     QString serviceName = s->name();
+	 QString comment = s->comment();
 
     // add comment
     if ( detailed_ ) {
@@ -290,10 +321,7 @@ void PanelServiceMenu::insertMenuItem(KS
     }
 
     // restrict menu entries to a sane length
-    if ( serviceName.length() > 60 ) {
-      serviceName.truncate( 57 );
-      serviceName += "...";
-    }
+	KStringHandler::rsqueeze(serviceName, 60);
 
     // check for NoDisplay
     if (s->noDisplay())
@@ -328,6 +356,8 @@ void PanelServiceMenu::insertMenuItem(KS
     iconset.setPixmap(active, QIconSet::Small, QIconSet::Active);
 
     int newId = insertItem(iconset, serviceName, nId, nIndex);
+    setWhatsThis(newId, "<b>" + serviceName + "</b>: " + comment);
+
     entryMap_.insert(newId, static_cast<KSharedPtr<KSycocaEntry> >(s));
 }
 
@@ -349,6 +379,8 @@ void PanelServiceMenu::slotExec(int id)
 
 void PanelServiceMenu::mousePressEvent(QMouseEvent * ev)
 {
+	if (ev->button() == RightButton)
+		showRMBMenu();
     startPos_ = ev->pos();
     KPanelMenu::mousePressEvent(ev);
 }
@@ -416,6 +448,15 @@ void PanelServiceMenu::mouseMoveEvent(QM
     // when we use drag and click to select items. A drag is only initiated when
     // you click to open the menu, and then press and drag an item.
     startPos_ = QPoint(-1,-1);
+}
+
+void PanelServiceMenu::showRMBMenu()
+{
+	delete actionMenu_;
+	int id = idAt(mapFromGlobal(QCursor::pos()));
+	kdDebug() << "ID: " << id << endl;
+	actionMenu_ = new RMBActionMenu(this, entryMap_[id], "rmbactionmenu");
+	actionMenu_->popup(QCursor::pos());
 }
 
 PanelServiceMenu *PanelServiceMenu::newSubMenu(const QString & label, const QString & relPath,
Index: service_mnu.h
===================================================================
RCS file: /home/kde/kdebase/kicker/ui/service_mnu.h,v
retrieving revision 1.18
diff -u -3 -p -r1.18 service_mnu.h
--- service_mnu.h	2002/05/21 15:23:30	1.18
+++ service_mnu.h	2002/06/19 00:32:31
@@ -30,6 +30,27 @@ CONNECTION WITH THE SOFTWARE OR THE USE 
 #include <kservice.h>
 #include <kpanelmenu.h>
 
+class RMBActionMenu : public QPopupMenu
+{
+Q_OBJECT
+public:
+	RMBActionMenu(QWidget *parent, KSycocaEntry *entry, const char * name = 0);
+	~RMBActionMenu() {};
+
+public slots:
+	void slotEdit();
+	void slotCopy();
+	void slotCut();
+	void slotDelete();
+	void slotNewSubmenu();
+	void slotShowHidden();
+	
+protected:
+	KSycocaEntry *entry_;
+	
+};
+
+
 /**
  * PanelServiceMenu is filled with KDE services and service groups. The sycoca
  * database is queried and the hierarchical structure built by creating child
@@ -76,6 +97,8 @@ protected:
     virtual PanelServiceMenu * newSubMenu(const QString & label, const QString & relPath,
 					  QWidget * parent, const char * name);
 
+	virtual void showRMBMenu();
+	
     virtual void mousePressEvent(QMouseEvent *);
     virtual void mouseMoveEvent(QMouseEvent *);
     virtual void closeEvent(QCloseEvent *);
@@ -90,7 +113,8 @@ protected:
     bool loaded_;
     bool excludeNoDisplay_;
 
-    QPopupMenu * opPopup_;
+//    QPopupMenu * opPopup_;
+	RMBActionMenu* actionMenu_;
     bool clearOnClose_;
     bool addmenumode_;
     QPoint startPos_;

_______________________________________________
kde-usability mailing list
kde-usability@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-usability

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

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