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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/applets/kickoff
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2009-04-06 18:49:18
Message-ID: 1239043758.382486.6321.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 950287 by aseigo:

* support "show apps by name", based on a patch by Sujith H
* clean up where read/writing of config values is done and try and minimize save \
disturbances CCMAIL:sujith.h@gmail.com


 M  +31 -13    applet/applet.cpp  
 M  +2 -0      applet/applet.h  
 M  +15 -3     core/applicationmodel.cpp  
 M  +15 -0     core/applicationmodel.h  
 M  +36 -4     ui/launcher.cpp  
 M  +5 -0      ui/launcher.h  


--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/applet/applet.cpp \
#950286:950287 @@ -60,6 +60,7 @@
 
     KIconButton *iconButton;
     QCheckBox *switchOnHoverCheckBox;
+    QCheckBox *appsByNameCheckBox;
     QList<QAction*> actions;
     QAction* switcher;
     LauncherApplet *q;
@@ -75,9 +76,9 @@
     launcher->setAttribute(Qt::WA_NoSystemBackground);
     launcher->setAutoHide(true);
     QObject::connect(launcher, SIGNAL(aboutToHide()), q, SLOT(hidePopup()));
+    QObject::connect(launcher, SIGNAL(configNeedsSaving()), q, \
SIGNAL(configNeedSaving()));  //launcher->resize(launcher->sizeHint());
     //QObject::connect(launcher, SIGNAL(aboutToHide()), icon, SLOT(setUnpressed()));
-    //QObject::connect(launcher, SIGNAL(configNeedsSaving()), q, \
SIGNAL(configNeedsSaving()));  }
 
 void LauncherApplet::Private::initToolTip()
@@ -104,7 +105,7 @@
 
 void LauncherApplet::init()
 {
-    KConfigGroup cg = globalConfig();
+    KConfigGroup cg = config();
     setPopupIcon(cg.readEntry("icon", "start-here-kde"));
 
     if (KService::serviceByStorageId("kde4-kmenuedit.desktop")) {
@@ -155,15 +156,27 @@
     iconLabel->setBuddy(d->iconButton);
     widgetLayout->addWidget(d->iconButton, 0, 1);
 
-    d->switchOnHoverCheckBox = new QCheckBox(i18n("Switch tabs on hover"), widget);
-    widgetLayout->addWidget(d->switchOnHoverCheckBox, 1, 0);
+    QLabel *label = new QLabel(i18n("Switch tabs on hover:"), widget);
+    label->setAlignment(Qt::AlignRight);
+    widgetLayout->addWidget(label, 1, 0);
+    d->switchOnHoverCheckBox = new QCheckBox(widget);
+    label->setBuddy(d->switchOnHoverCheckBox);
+    widgetLayout->addWidget(d->switchOnHoverCheckBox, 1, 1);
 
+    label = new QLabel(i18n("Show applications by name:"), widget);
+    label->setAlignment(Qt::AlignRight);
+    widgetLayout->addWidget(label, 2, 0);
+    d->appsByNameCheckBox = new QCheckBox(widget);
+    label->setBuddy(d->appsByNameCheckBox);
+    widgetLayout->addWidget(d->appsByNameCheckBox, 2, 1);
+
     connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
     connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
     parent->addPage(widget, i18n("General"), icon());
 
     d->createLauncher();
     d->switchOnHoverCheckBox->setChecked(d->launcher->switchTabsOnHover());
+    d->appsByNameCheckBox->setChecked(d->launcher->showAppsByName());
 }
 
 void LauncherApplet::popupEvent(bool show)
@@ -187,23 +200,28 @@
 void LauncherApplet::configAccepted()
 {
     bool switchTabsOnHover = d->switchOnHoverCheckBox->isChecked();
+    bool showAppsByName = d->appsByNameCheckBox->isChecked();
 
     const QString iconname = d->iconButton->icon();
 
     // TODO: should this be moved into Launcher as well? perhaps even the config \
                itself?
-    KConfigGroup cg = globalConfig();
-    cg.writeEntry("SwitchTabsOnHover", switchTabsOnHover);
-    if (!iconname.isEmpty()) {
+    d->createLauncher();
+
+    KConfigGroup cg = config();
+    const QString oldIcon = cg.readEntry("icon", "start-here-kde");
+    if (!iconname.isEmpty() && iconname != oldIcon) {
         cg.writeEntry("icon", iconname);
+
+        if (!iconname.isEmpty()) {
+            setPopupIcon(iconname);
+            d->initToolTip();
+        }
+
+        emit configNeedsSaving();
     }
-    emit configNeedsSaving();
 
-    d->createLauncher();
     d->launcher->setSwitchTabsOnHover(switchTabsOnHover);
-    if (!iconname.isEmpty()) {
-        setPopupIcon(iconname);
-        d->initToolTip();
-    }
+    d->launcher->setShowAppsByName(showAppsByName);
 }
 
 QList<QAction*> LauncherApplet::contextualActions()
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/applet/applet.h #950286:950287
@@ -63,10 +63,12 @@
     //void toggleMenu(bool pressed);
 
 protected:
+
     void createConfigurationInterface(KConfigDialog *parent);
     void popupEvent(bool show);
 
 private:
+    friend class Kickoff::Launcher;
     class Private;
     Private * const d;
 };
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/core/applicationmodel.cpp \
#950286:950287 @@ -259,7 +259,7 @@
 }
 
 ApplicationModel::ApplicationModel(QObject *parent, bool allowSeparators)
-        : KickoffAbstractModel(parent), d(new ApplicationModelPrivate(this, \
allowSeparators)) +  : KickoffAbstractModel(parent), d(new \
ApplicationModelPrivate(this, \
allowSeparators)),m_displayOrder(ApplicationModel::NameAfterDescription)  {
     QDBusConnection dbus = QDBusConnection::sessionBus();
     (void)new KickoffAdaptor(this);
@@ -283,6 +283,16 @@
     return node->isDir && !node->fetched;
 }
 
+void ApplicationModel::setNameDisplayOrder(DisplayOrder displayOrder) 
+{   
+    m_displayOrder = displayOrder;
+}
+
+ApplicationModel::DisplayOrder ApplicationModel::nameDisplayOrder() const
+{
+   return m_displayOrder;
+}
+
 int ApplicationModel::columnCount(const QModelIndex &parent) const
 {
     Q_UNUSED(parent)
@@ -298,14 +308,16 @@
 
     switch (role) {
     case Qt::DisplayRole:
-        if (!node->genericName.isEmpty()) {
+      if (node->isDir || ((m_displayOrder == NameAfterDescription) && \
(!node->genericName.isEmpty()))) {  return node->genericName;
         } else {
             return node->appName;
         }
         break;
     case Kickoff::SubTitleRole:
-        if (!node->genericName.isEmpty()) {
+      if (!node->isDir && (m_displayOrder == NameBeforeDescription) && \
(!node->genericName.isEmpty())) { +            return node->genericName;
+        } else {
             return node->appName;
         }
         break;
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/core/applicationmodel.h \
#950286:950287 @@ -36,12 +36,23 @@
 class KICKOFF_EXPORT ApplicationModel : public KickoffAbstractModel
 {
     Q_OBJECT
+    Q_ENUMS(DisplayOrder)
 
 public:
     ApplicationModel(QObject *parent = 0, bool allowSeparators = false);
     virtual ~ApplicationModel();
 
     /**
+     * This enum describes the policy for displaying 
+     * Name of Application - Description
+     * Description - Name of Application
+     */
+    enum DisplayOrder {
+         NameAfterDescription,
+         NameBeforeDescription
+    };
+    
+    /**
      * This enum describes the policy for
      * handling duplicate applications (that is,
      * two applications with the same name in the same group)
@@ -80,6 +91,9 @@
         GenericNamePrimary
     };
 
+    void setNameDisplayOrder(DisplayOrder displayOrder);
+    DisplayOrder nameDisplayOrder() const;
+    //DisplayOrder m_displayOrder;
     /**
      * Sets the policy for handling duplicate applications.
      * See DuplicatePolicy
@@ -117,6 +131,7 @@
 private:
     friend class ApplicationModelPrivate;
     ApplicationModelPrivate *const d;
+    DisplayOrder m_displayOrder;
 
     Q_DISABLE_COPY(ApplicationModel)
 };
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/ui/launcher.cpp #950286:950287
@@ -70,6 +70,7 @@
 class Launcher::Private
 {
 public:
+    ApplicationModel  *applicationModel;
     Private(Launcher *launcher)
             : q(launcher)
             , applet(0)
@@ -89,6 +90,7 @@
             , visibleItemCount(10)
             , placement(Plasma::TopPosedLeftAlignedPopup)
             , panelEdge(Plasma::BottomEdge) {
+
     }
 
     ~Private() {
@@ -187,7 +189,7 @@
     }
 
     void setupAllProgramsView() {
-        ApplicationModel *applicationModel = new ApplicationModel(q);
+        applicationModel = new ApplicationModel(q);
         applicationModel->setDuplicatePolicy(ApplicationModel::ShowLatestOnlyPolicy);
  
         applicationView = new FlipScrollView();
@@ -456,6 +458,7 @@
 {
     init();
     setApplet(applet);
+
 }
 
 void Launcher::init()
@@ -588,14 +591,42 @@
 
 void Launcher::setSwitchTabsOnHover(bool switchOnHover)
 {
+    if (d->applet && switchOnHover != d->contentSwitcher->switchTabsOnHover()) {
+        KConfigGroup cg = d->applet->globalConfig();
+        cg.writeEntry("SwitchTabsOnHover", switchOnHover);
+        emit configNeedsSaving();
+    }
+
     d->contentSwitcher->setSwitchTabsOnHover(switchOnHover);
 }
 
+void Launcher::setShowAppsByName(bool showAppsByName)
+{
+    //ApplicationModel *m_applicationModel = applicationModel;
+    const bool wasByName = d->applicationModel->nameDisplayOrder() == \
ApplicationModel::NameBeforeDescription; +    if (d->applet && showAppsByName != \
wasByName) { +        KConfigGroup cg = d->applet->config();
+        cg.writeEntry("ShowAppsByName", showAppsByName);
+        emit configNeedsSaving();
+    }
+
+    if (showAppsByName) {
+        d->applicationModel->setNameDisplayOrder(ApplicationModel::NameBeforeDescription);
 +    } else {
+        d->applicationModel->setNameDisplayOrder(ApplicationModel::NameAfterDescription);
 +    }
+}
+
 bool Launcher::switchTabsOnHover() const
 {
     return d->contentSwitcher->switchTabsOnHover();
 }
 
+bool Launcher::showAppsByName() const
+{
+  return d->applicationModel->nameDisplayOrder() == \
ApplicationModel::NameBeforeDescription; +}
+
 void Launcher::setVisibleItemCount(int count)
 {
     d->visibleItemCount = count;
@@ -608,14 +639,15 @@
 
 void Launcher::setApplet(Plasma::Applet *applet)
 {
-    d->applet = applet;
-    d->contextMenuFactory->setApplet(applet);
-
     KConfigGroup cg = applet->globalConfig();
     setSwitchTabsOnHover(cg.readEntry("SwitchTabsOnHover", switchTabsOnHover()));
 
     cg = applet->config();
+    setShowAppsByName(cg.readEntry("ShowAppsByName", showAppsByName()));
     setVisibleItemCount(cg.readEntry("VisibleItemsCount", visibleItemCount()));
+
+    d->applet = applet;
+    d->contextMenuFactory->setApplet(applet);
 }
 
 void Launcher::reset()
--- trunk/KDE/kdebase/workspace/plasma/applets/kickoff/ui/launcher.h #950286:950287
@@ -49,6 +49,11 @@
     void setAutoHide(bool autoHide);
     bool autoHide() const;
 
+    /** Specifies whether the application names in the launcher should be displayed \
* +        before or after the description                                            \
*/ +    void setShowAppsByName(bool showAppByName);
+    bool showAppsByName() const;
+
     /** Specifies whether hovering switches between tabs or if a click is required \
to switch the tabs. */  void setSwitchTabsOnHover(bool switchOnHover);
     bool switchTabsOnHover() const;


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

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