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

List:       kde-commits
Subject:    KDE/kdebase/apps/dolphin/src
From:       Peter Penz <peter.penz19 () gmail ! com>
Date:       2010-12-31 10:59:47
Message-ID: 20101231105947.1284BAC8AE () svn ! kde ! org
[Download RAW message or body]

SVN commit 1210424 by ppenz:

Lock panels per default and allow to unlock them like in Amarok.

BUG: 229811
FIXED-IN: 4.7.0


 M  +1 -0      CMakeLists.txt  
 A             dolphindockwidget.cpp   [License: GPL (v2+)]
 A             dolphindockwidget.h   [License: GPL (v2+)]
 M  +51 -12    dolphinmainwindow.cpp  
 M  +5 -0      dolphinmainwindow.h  
 M  +13 -0     panels/filter/filterpanel.cpp  
 M  +3 -0      panels/filter/filterpanel.h  
 M  +4 -0      panels/folders/treeviewcontextmenu.cpp  
 M  +2 -1      panels/information/informationpanel.cpp  
 M  +6 -1      panels/information/informationpanelcontent.cpp  
 M  +3 -1      panels/information/informationpanelcontent.h  
 M  +12 -1     panels/panel.cpp  
 M  +12 -0     panels/panel.h  
 M  +4 -0      settings/dolphin_generalsettings.kcfg  


--- trunk/KDE/kdebase/apps/dolphin/src/CMakeLists.txt #1210423:1210424
@@ -96,6 +96,7 @@
 
 set(dolphin_SRCS
     dolphinapplication.cpp
+    dolphindockwidget.cpp
     dolphinmainwindow.cpp
     dolphinnewfilemenu.cpp
     dolphinviewcontainer.cpp
--- trunk/KDE/kdebase/apps/dolphin/src/dolphinmainwindow.cpp #1210423:1210424
@@ -24,6 +24,7 @@
 #include <config-nepomuk.h>
 
 #include "dolphinapplication.h"
+#include "dolphindockwidget.h"
 #include "dolphincontextmenu.h"
 #include "dolphinnewfilemenu.h"
 #include "dolphinviewcontainer.h"
@@ -56,6 +57,7 @@
 #include <kconfig.h>
 #include <kdesktopfile.h>
 #include <kdeversion.h>
+#include <kdualaction.h>
 #include <kfiledialog.h>
 #include <kfileplacesmodel.h>
 #include <kglobal.h>
@@ -89,7 +91,6 @@
 #include <QKeyEvent>
 #include <QClipboard>
 #include <QSplitter>
-#include <QDockWidget>
 #include <kacceleratormanager.h>
 
 /*
@@ -866,6 +867,21 @@
     lineEdit->setSelection(0, text.length());
 }
 
+void DolphinMainWindow::togglePanelLockState()
+{
+    GeneralSettings* generalSettings = \
DolphinSettings::instance().generalSettings(); +
+    const bool newLockState = !generalSettings->lockPanels();
+    foreach (QObject* child, children()) {
+        DolphinDockWidget* dock = qobject_cast<DolphinDockWidget*>(child);
+        if (dock != 0) {
+            dock->setLocked(newLockState);
+        }
+    }
+
+    generalSettings->setLockPanels(newLockState);
+}
+
 void DolphinMainWindow::goBack()
 {
     clearStatusBar();
@@ -1580,11 +1596,23 @@
 
 void DolphinMainWindow::setupDockWidgets()
 {
-    // setup "Information"
-    QDockWidget* infoDock = new QDockWidget(i18nc("@title:window", "Information"));
+    const bool lock = DolphinSettings::instance().generalSettings()->lockPanels();
+
+    KDualAction* lockLayoutAction = \
actionCollection()->add<KDualAction>("lock_panels"); +    \
lockLayoutAction->setActiveText(i18nc("@action:inmenu Panels", "Unlock Panels")); +   \
lockLayoutAction->setActiveIcon(KIcon("object-unlocked")); +    \
lockLayoutAction->setInactiveText(i18nc("@action:inmenu Panels", "Lock Panels")); +   \
lockLayoutAction->setInactiveIcon(KIcon("object-locked")); +    \
lockLayoutAction->setActive(lock); +    connect(lockLayoutAction, \
SIGNAL(triggered()), this, SLOT(togglePanelLockState())); +
+    // Setup "Information"
+    DolphinDockWidget* infoDock = new DolphinDockWidget(i18nc("@title:window", \
"Information")); +    infoDock->setLocked(lock);
     infoDock->setObjectName("infoDock");
     infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
     Panel* infoPanel = new InformationPanel(infoDock);
+    infoPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
     connect(infoPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
     infoDock->setWidget(infoPanel);
 
@@ -1601,11 +1629,13 @@
     connect(this, SIGNAL(requestItemInfo(KFileItem)),
             infoPanel, SLOT(requestDelayedItemInfo(KFileItem)));
 
-    // setup "Folders"
-    QDockWidget* foldersDock = new QDockWidget(i18nc("@title:window", "Folders"));
+    // Setup "Folders"
+    DolphinDockWidget* foldersDock = new DolphinDockWidget(i18nc("@title:window", \
"Folders")); +    foldersDock->setLocked(lock);
     foldersDock->setObjectName("foldersDock");
     foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
     FoldersPanel* foldersPanel = new FoldersPanel(foldersDock);
+    foldersPanel->setCustomContextMenuActions(QList<QAction*>() << \
lockLayoutAction);  foldersDock->setWidget(foldersPanel);
 
     QAction* foldersAction = foldersDock->toggleViewAction();
@@ -1619,12 +1649,14 @@
     connect(foldersPanel, SIGNAL(changeUrl(KUrl, Qt::MouseButtons)),
             this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons)));
 
-    // setup "Terminal"
+    // Setup "Terminal"
 #ifndef Q_OS_WIN
-    QDockWidget* terminalDock = new QDockWidget(i18nc("@title:window Shell \
terminal", "Terminal")); +    DolphinDockWidget* terminalDock = new \
DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal")); +    \
terminalDock->setLocked(lock);  terminalDock->setObjectName("terminalDock");
     terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
     Panel* terminalPanel = new TerminalPanel(terminalDock);
+    terminalPanel->setCustomContextMenuActions(QList<QAction*>() << \
lockLayoutAction);  terminalDock->setWidget(terminalPanel);
 
     connect(terminalPanel, SIGNAL(hideTerminalPanel()), terminalDock, SLOT(hide()));
@@ -1639,12 +1671,14 @@
             terminalPanel, SLOT(setUrl(KUrl)));
 #endif
 
-    // setup "Filter"
+    // Setup "Filter"
 #ifdef HAVE_NEPOMUK
-    QDockWidget* filterDock = new QDockWidget(i18nc("@title:window", "Filter"));
+    DolphinDockWidget* filterDock = new DolphinDockWidget(i18nc("@title:window", \
"Filter")); +    filterDock->setLocked(lock);
     filterDock->setObjectName("filterDock");
     filterDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
     Panel* filterPanel = new FilterPanel(filterDock);
+    filterPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
     connect(filterPanel, SIGNAL(urlActivated(KUrl)), this, SLOT(handleUrl(KUrl)));
     filterDock->setWidget(filterPanel);
 
@@ -1669,15 +1703,17 @@
 #endif
     }
 
-    // setup "Places"
-    QDockWidget* placesDock = new QDockWidget(i18nc("@title:window", "Places"));
+    // Setup "Places"
+    DolphinDockWidget* placesDock = new DolphinDockWidget(i18nc("@title:window", \
"Places")); +    placesDock->setLocked(lock);
     placesDock->setObjectName("placesDock");
     placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
 
     PlacesPanel* placesPanel = new PlacesPanel(placesDock);
-    placesDock->setWidget(placesPanel);
     placesPanel->setModel(DolphinSettings::instance().placesModel());
     placesPanel->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+    connect(placesPanel, SIGNAL(lockChangeRequested(bool)), this, \
SLOT(slotPanelLockChangeRequested(bool))); +    placesDock->setWidget(placesPanel);
 
     QAction* placesAction = placesDock->toggleViewAction();
     placesAction->setShortcut(Qt::Key_F9);
@@ -1690,6 +1726,7 @@
     connect(this, SIGNAL(urlChanged(KUrl)),
             placesPanel, SLOT(setUrl(KUrl)));
 
+    // Add actions into the "Panels" menu
     KActionMenu* panelsMenu = new KActionMenu(i18nc("@action:inmenu View", \
"Panels"), this);  actionCollection()->addAction("panels", panelsMenu);
     panelsMenu->setDelayed(false);
@@ -1702,6 +1739,8 @@
 #ifdef HAVE_NEPOMUK
     panelsMenu->addAction(filterAction);
 #endif
+    panelsMenu->addSeparator();
+    panelsMenu->addAction(lockLayoutAction);
 }
 
 void DolphinMainWindow::updateEditActions()
--- trunk/KDE/kdebase/apps/dolphin/src/dolphinmainwindow.h #1210423:1210424
@@ -264,6 +264,11 @@
      */
     void replaceLocation();
 
+    /**
+     * Toggles the state of the panels between a locked and unlocked layout.
+     */
+    void togglePanelLockState();
+
     /** Goes back on step of the URL history. */
     void goBack();
 
--- trunk/KDE/kdebase/apps/dolphin/src/panels/filter/filterpanel.cpp #1210423:1210424
@@ -39,6 +39,7 @@
 #include <kfileitem.h>
 #include <kio/jobclasses.h>
 #include <kio/job.h>
+#include <kmenu.h>
 
 #include <QPushButton>
 #include <QShowEvent>
@@ -140,6 +141,18 @@
     Panel::showEvent(event);
 }
 
+void FilterPanel::contextMenuEvent(QContextMenuEvent* event)
+{
+    Panel::contextMenuEvent(event);
+
+    QWeakPointer<KMenu> popup = new KMenu(this);
+    foreach (QAction* action, customContextMenuActions()) {
+        popup.data()->addAction(action);
+    }
+    popup.data()->exec(QCursor::pos());
+    delete popup.data();
+}
+
 void FilterPanel::slotSetUrlStatFinished(KJob* job)
 {
     m_lastSetUrlStatJob = 0;
--- trunk/KDE/kdebase/apps/dolphin/src/panels/filter/filterpanel.h #1210423:1210424
@@ -52,6 +52,9 @@
     /** @see QWidget::showEvent() */
     virtual void showEvent(QShowEvent* event);
 
+    /** @see QWidget::contextMenuEvent() */
+    virtual void contextMenuEvent(QContextMenuEvent* event);
+
 private slots:
     void slotSetUrlStatFinished(KJob*);
     void slotQueryTermChanged(const Nepomuk::Query::Term& term);
--- trunk/KDE/kdebase/apps/dolphin/src/panels/folders/treeviewcontextmenu.cpp \
#1210423:1210424 @@ -128,6 +128,10 @@
     popup->addAction(autoScrollingAction);
     connect(autoScrollingAction, SIGNAL(toggled(bool)), this, \
SLOT(setAutoScrolling(bool)));  
+    popup->addSeparator();
+    foreach (QAction* action, m_parent->customContextMenuActions()) {
+        popup->addAction(action);
+    }
 
     popup->exec(QCursor::pos());
     popup->deleteLater();
--- trunk/KDE/kdebase/apps/dolphin/src/panels/information/informationpanel.cpp \
#1210423:1210424 @@ -167,7 +167,8 @@
 
 void InformationPanel::contextMenuEvent(QContextMenuEvent* event)
 {
-    m_content->configureSettings();
+    // TODO: Move code from InformationPanelContent::configureSettings() here
+    m_content->configureSettings(customContextMenuActions());
     Panel::contextMenuEvent(event);
 }
 
--- trunk/KDE/kdebase/apps/dolphin/src/panels/information/informationpanelcontent.cpp \
#1210423:1210424 @@ -265,7 +265,7 @@
     return QWidget::eventFilter(obj, event);
 }
 
-void InformationPanelContent::configureSettings()
+void InformationPanelContent::configureSettings(const QList<QAction*>& \
customContextMenuActions)  {
     KMenu popup(this);
 
@@ -277,6 +277,11 @@
     QAction* configureAction = popup.addAction(i18nc("@action:inmenu", \
"Configure..."));  configureAction->setIcon(KIcon("configure"));
 
+    popup.addSeparator();
+    foreach (QAction* action, customContextMenuActions) {
+        popup.addAction(action);
+    }
+
     // Open the popup and adjust the settings for the
     // selected action.
     QAction* action = popup.exec(QCursor::pos());
--- trunk/KDE/kdebase/apps/dolphin/src/panels/information/informationpanelcontent.h \
#1210423:1210424 @@ -61,8 +61,10 @@
     /**
      * Opens a menu which allows to configure which meta information
      * should be shown.
+     *
+     * TODO: Move this code to the class InformationPanel
      */
-    void configureSettings();
+    void configureSettings(const QList<QAction*>& customContextMenuActions);
 
 signals:
     void urlActivated( const KUrl& url );
--- trunk/KDE/kdebase/apps/dolphin/src/panels/panel.cpp #1210423:1210424
@@ -23,7 +23,8 @@
 
 Panel::Panel(QWidget* parent) :
     QWidget(parent),
-    m_url(KUrl())
+    m_url(),
+    m_customContextMenuActions()
 {
 }
 
@@ -36,6 +37,16 @@
     return m_url;
 }
 
+void Panel::setCustomContextMenuActions(const QList<QAction*>& actions)
+{
+    m_customContextMenuActions = actions;
+}
+
+QList<QAction*> Panel::customContextMenuActions() const
+{
+    return m_customContextMenuActions;
+}
+
 void Panel::setUrl(const KUrl& url)
 {
     if (url.equals(m_url, KUrl::CompareWithoutTrailingSlash)) {
--- trunk/KDE/kdebase/apps/dolphin/src/panels/panel.h #1210423:1210424
@@ -27,6 +27,9 @@
 
 /**
  * @brief Base widget for all panels that can be docked on the window borders.
+ *
+ * Derived panels should provide a context menu that at least offers the
+ * actions from Panel::customContextMenuActions().
  */
 class Panel : public QWidget
 {
@@ -39,6 +42,14 @@
     /** Returns the current set URL of the active Dolphin view. */
     KUrl url() const;
 
+    /**
+     * Sets custom context menu actions that are added to the panel specific
+     * context menu actions. Allows an application to apply custom actions to
+     * the panel.
+     */
+    void setCustomContextMenuActions(const QList<QAction*>& actions);
+    QList<QAction*> customContextMenuActions() const;
+
 public slots:
     /**
      * This is invoked every time the folder being displayed in the
@@ -58,6 +69,7 @@
 
 private:
     KUrl m_url;
+    QList<QAction*> m_customContextMenuActions;
 };
 
 #endif // PANEL_H
--- trunk/KDE/kdebase/apps/dolphin/src/settings/dolphin_generalsettings.kcfg \
#1210423:1210424 @@ -83,5 +83,9 @@
             <label>Show the space information in the statusbar</label>
             <default>false</default>
         </entry>
+        <entry name="LockPanels" type="Bool">
+            <label>Lock the layout of the panels</label>
+            <default>true</default>
+        </entry>
     </group>
 </kcfg>


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

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