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

List:       kde-usability
Subject:    Re: kmenu concept
From:       "Aaron J. Seigo" <aseigo () olympusproject ! org>
Date:       2002-06-07 5:28:39
[Download RAW message or body]

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

On June 6, 2002 08:06 pm, Eric Ellsworth wrote:
> The RMB's are excellent - I like how they show the title of the menu you're
> working on.  I still like the idea of having a menu item (not just RMB) for
> changing programs, because as many have pointed out, new users just won't
> see that RMB.

yes, i was going to add those as well but ran out of time ... attached is 
another revision, based on your revision =)

there is a "Configure Task Groups" item, which i envision bringin up a dialog 
that would allow the user to add / remove / edit task groups (submenus) .. 
i'd also like to see these submenus appear as .desktop files somewhere in the 
kicker hierarchy so that various collections of them can be provided (e.g. 
Development, Visual Arts, System Administration, Gaming.....) and they can 
easily be shown/hidden.. much like the special menus are shown/hidden.

> I've made a few modifications to pass on - mostly just filled out some
> menus. I thought we could evaluate just putting documents on the Recent
> Items menu - this is more "document-centric" for what that's worth

ok.. i've moved the Recently Used Applications menu to the Tasks area near the 
More Applications entry ...

> (Cdn$.00001 :)  ).  I also notice when I tried to fill out the Music and
> Movies - Multimedia seems like a vague term to me that there's lots of
> disparate actions here
...
> Seeing as we're not likely to get all those applications to be condensed
> any time soon, perhaps we better think about a slightly modified way of
> addressing this menu....

and that won't be a unique situation either.. i'm thinking the solution might 
be "bite the bullet" and keep the task groups small by default ...

> > this is very preliminary and by no means complete, but i thought i'd toss
> > some code out there for discussion...
>
> Excellent way to get the party started.  Great work!

if there is indeed interest in pursuing this as a kmenu option, i'll merge it 
into kicker as a kmenuext (since that's the easiest to package up) so we can 
play with it with icons and as a part of the panel and commit it kdenonbeta 
so others can access it and hack on it with ease.

/me looks over at kspread, knowing what this means =(

- -- 
Aaron J. Seigo
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

"Everything should be made as simple as possible, but not simpler" 
    - Albert Einstein
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9AESH1rcusafx20MRAjOzAJ44vouI2fEIwN7aby9x2b7JjtIqUACfQSFY
vRkeh7EtYDuxD4ndKlwG47E=
=G7zk
-----END PGP SIGNATURE-----

["kmenu_playing.cc" (text/x-c++src)]

#include <qcursor.h>
#include <kaboutdata.h>
#include <kpopupmenu.h>
#include <kcmdlineargs.h>
#include <kmainwindow.h>
#include <kmenubar.h>
#include <qmenubar.h>
#include <kapplication.h>
#include <kstdaction.h>
#include <iostream>

class rmbPopup : public KPopupMenu
{
    Q_OBJECT

    public:
        rmbPopup(QWidget* parent = 0, const char* name = 0)
            : KPopupMenu(parent, name),
              m_ctxMenu(0),
              continueCtxMenuShow(true)
        {
            installEventFilter(this);
        }

        ~rmbPopup() 
        {
            delete m_ctxMenu;

            if (s_contextedMenu == this)
            {
                s_contextedMenu = 0;
                s_highlightedItem = -1;
            }
        }

        KPopupMenu* contextMenu()
        {
            if (!m_ctxMenu)
            {
                m_ctxMenu = new KPopupMenu(this);
                connect(m_ctxMenu, SIGNAL(aboutToHide()), this, \
SLOT(ctxMenuHiding()));  }

            return m_ctxMenu;
        }

        void cancelContextMenuShow()
        {
            continueCtxMenuShow = false;
        }

        static int contextMenuFocusItem()
        {
            return s_highlightedItem;
        }

        static QPopupMenu* contextMenuFocus()
        {
            return s_contextedMenu;
        }

    signals:
        void aboutToShowContextMenu(rmbPopup* menu, int menuItem, \
KPopupMenu* ctxMenu);

    protected slots:
        void itemHighlighted(int whichItem)
        {
            if (!m_ctxMenu ||  !m_ctxMenu->isVisible())
            {
                return;
            }

            m_ctxMenu->hide();
            showCtxMenu(mapFromGlobal(QCursor::pos()));
        }

        void showCtxMenu(QPoint pos)
        {
            s_highlightedItem = idAt(pos);

            if (s_highlightedItem == -1)
            {
                    s_contextedMenu = 0;
                    return;
            }

            emit aboutToShowContextMenu(this, s_highlightedItem, \
m_ctxMenu);

            if (!continueCtxMenuShow)
            {
                continueCtxMenuShow = true;
                return;
            }

            s_contextedMenu = this;
            m_ctxMenu->popup(this->mapToGlobal(pos));
            connect(this, SIGNAL(highlighted(int)), this, \
SLOT(itemHighlighted(int)));  }

        void ctxMenuHiding()
        {
            disconnect(this, SIGNAL(highlighted(int)), this, \
SLOT(itemHighlighted(int)));  }

    protected:
        bool eventFilter(QObject* obj, QEvent* event)
        {
            if (m_ctxMenu && obj == this)
            {
                if (event->type() == QEvent::MouseButtonRelease)
                {
                    if (m_ctxMenu->isVisible())
                    {
                        return true;
                    }
                }
                else if (event->type() ==  QEvent::ContextMenu )
                {
                    showCtxMenu(mapFromGlobal(QCursor::pos()));
                    return true;
                }
            }

            return QWidget::eventFilter(obj, event);
        }

        void hideEvent(QHideEvent*)
        {
            if (m_ctxMenu)
            {
                m_ctxMenu->hide();
            }
        }

    private:
        KPopupMenu* m_ctxMenu;
        bool continueCtxMenuShow;
        static int s_highlightedItem;
        static KPopupMenu* s_contextedMenu;
};

int rmbPopup::s_highlightedItem = -1;
KPopupMenu* rmbPopup::s_contextedMenu = 0;

const static int configureMenuID = 1000;

class ctxMenuDriver : public QObject
{
    Q_OBJECT

    public:
        ctxMenuDriver()
        {
        }

        ~ctxMenuDriver()
        {
        }

    public slots:
        void contextualize(rmbPopup* menu, int menuItem, KPopupMenu* \
ctxMenu)  {
            if (menuItem == configureMenuID)
            {
                menu->cancelContextMenuShow();
                return;
            }
            
            QString shortcutText("Create a button on the panel for this \
item");  QString editText("Edit this item");
            QString deleteText("Delete this item");
            QString insertText("Insert a new item");
            
            ctxMenu->clear();
            ctxMenu->insertTitle(QString(menu->name()).append(": " + \
menu->text(menuItem)));  ctxMenu->insertItem(shortcutText);
            ctxMenu->insertItem(editText);
            ctxMenu->insertItem(deleteText, this, SLOT(removeAppItem()));
            ctxMenu->insertItem(insertText);
        }

        void removeAppItem()
        {
            rmbPopup::contextMenuFocus()->removeItem(rmbPopup::contextMenuFocusItem());
  }
};

#include "kmenu_playing.moc.cc"
#include <iostream>
int main(int argc, char* argv[])
{
    KAboutData about("menuExtTest", "menuExtTest", "0.1", "Testing \
KPopupMenu Extensions");  KCmdLineArgs::init(argc, argv, &about);
    KApplication foo;
    KMainWindow* testWindow = new KMainWindow(0);
    foo.setMainWidget(testWindow);
    ctxMenuDriver* driver = new ctxMenuDriver();
    
    rmbPopup* kMenu = new rmbPopup(testWindow, "File Menu");
    kMenu->setKeyboardShortcutsEnabled(true);
    kMenu->insertTitle("Recently Used Documents");
    rmbPopup* recentDocs = new rmbPopup(testWindow, "recentDocs");
    kMenu->insertItem("kmenu_playing.cc");
    //recentDocs->insertItem("kmenu_playing.cc");
    //kMenu->insertItem("Applications", recentApps);
    
    kMenu->insertTitle("Tasks");
    
    rmbPopup* apps = new rmbPopup(testWindow, "Internet");
    apps->setKeyboardShortcutsEnabled(true);
    apps->insertItem("Browse the Web (Konqueror)");
    apps->insertItem("Email (Kmail)");
    apps->insertItem("Instant Messenging (Kopete)");
    apps->insertItem("VNC (Keystone)");
    apps->insertItem("FTP (KBear)");
    apps->insertSeparator();
    apps->insertItem("Configure This Task Group", configureMenuID);
    KPopupMenu* rmbMenu = apps->contextMenu();
    rmbMenu->insertTitle("Internet Menu Editor");
    QObject::connect(apps, SIGNAL(aboutToShowContextMenu(rmbPopup*, int, \
                KPopupMenu*)),
                     driver, SLOT(contextualize(rmbPopup*, int, \
KPopupMenu*)));  kMenu->insertItem("Internet", apps);
    
    apps = new rmbPopup(testWindow, "Office Work");
    apps->setKeyboardShortcutsEnabled(true);
    apps->insertItem("Word Processing (OpenOffice.org)");
    apps->insertItem("Spreadsheets (Gnumeric)");
    apps->insertItem("Presentations (KPresenter)");
    apps->insertItem("Drawing (The GIMP)");
    apps->insertSeparator();
    apps->insertItem("Configure This Task Group", configureMenuID);
    rmbMenu = apps->contextMenu();
    rmbMenu->insertTitle("Office Work Menu Editor");
    QObject::connect(apps, SIGNAL(aboutToShowContextMenu(rmbPopup*, int, \
                KPopupMenu*)),
                     driver, SLOT(contextualize(rmbPopup*, int, \
KPopupMenu*)));  kMenu->insertItem("Office Work", apps);
    
    apps = new rmbPopup(testWindow, "Multimedia");
    apps->setKeyboardShortcutsEnabled(true);
    apps->insertItem("Play music (XMMS)");
    apps->insertItem("Watch movies (aKtion)");
    apps->insertItem("Download Music (KNapster)");
    apps->insertItem("Record CD onto my computer");
    apps->insertSeparator();
    apps->insertItem("Configure This Task Group", configureMenuID);
    rmbMenu = apps->contextMenu();
    rmbMenu->insertTitle("Multimedia Menu Editor");
    QObject::connect(apps, SIGNAL(aboutToShowContextMenu(rmbPopup*, int, \
                KPopupMenu*)),
                     driver, SLOT(contextualize(rmbPopup*, int, \
KPopupMenu*)));  kMenu->insertItem("Music, Movies and Media", apps);
    kMenu->insertItem("Configure the Task Groups");
    
    kMenu->insertSeparator();
    rmbPopup* recentApps = new rmbPopup(testWindow, "recentApps");
    recentApps->setKeyboardShortcutsEnabled(true);
    recentApps->insertItem("Lt. Skat");
    recentApps->insertItem("Konsole");
    recentApps->insertSeparator();
    recentApps->insertItem("Configure This Menu", configureMenuID);
    kMenu->insertItem("Recently Used Applications", recentApps);
    
    apps = new rmbPopup(testWindow, "More Applications");
    apps->insertSeparator();
    apps->insertItem("Configure This Menu", configureMenuID);
    kMenu->insertItem("More Applications", apps);
    kMenu->insertItem("Run A Command...");
    
 
    kMenu->insertTitle("Special Menus");
    rmbPopup* specialMenu = new rmbPopup(testWindow, "KPrint");
    kMenu->insertItem("Printing", specialMenu);

    kMenu->insertTitle("Destinations");
    kMenu->insertItem("Help");
    kMenu->insertItem("Control Center");
    kMenu->insertItem("Find Files");
    kMenu->insertItem("Home (Personal Files)");
    kMenu->insertSeparator();
    kMenu->insertItem("Lock Screen");
    kMenu->insertItem("Logout (username)");
    kMenu->insertTearOffHandle();

    KStdAction::quit(kapp, SLOT(quit()), testWindow->actionCollection());
    testWindow->menuBar()->insertItem("KMenu", kMenu);
    testWindow->show();
    int rc = kapp->exec();
 
    
    delete driver;
    return rc;
}

/*
 /usr/lib/qt3/bin/moc kmenu_playing.cc -o kmenu_playing.moc.cc
 g++ -o kmenu_playing kmenu_playing.cc -L/usr/lib/qt3/lib -L/opt/kde3/lib \
                -lqt-mt -lkdeui -lkdecore -I/usr/lib/qt3/include \
                -I/opt/kde3/include
 ./kmenu_playing
 */


_______________________________________________
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