diff options
| author | Peter Penz <[email protected]> | 2010-12-31 10:59:46 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2010-12-31 10:59:46 +0000 |
| commit | 94815093253e5db99aa100f0834cd6c74c96a91a (patch) | |
| tree | 725cbfd9d8b412198a143153cbadf06f0ee724c9 /src/panels | |
| parent | f7bbe21b5b2d3bc85dcba1d03494879aac9e37c7 (diff) | |
Lock panels per default and allow to unlock them like in Amarok.
BUG: 229811
FIXED-IN: 4.7.0
svn path=/trunk/KDE/kdebase/apps/; revision=1210424
Diffstat (limited to 'src/panels')
| -rw-r--r-- | src/panels/filter/filterpanel.cpp | 13 | ||||
| -rw-r--r-- | src/panels/filter/filterpanel.h | 3 | ||||
| -rw-r--r-- | src/panels/folders/treeviewcontextmenu.cpp | 4 | ||||
| -rw-r--r-- | src/panels/information/informationpanel.cpp | 3 | ||||
| -rw-r--r-- | src/panels/information/informationpanelcontent.cpp | 7 | ||||
| -rw-r--r-- | src/panels/information/informationpanelcontent.h | 4 | ||||
| -rw-r--r-- | src/panels/panel.cpp | 13 | ||||
| -rw-r--r-- | src/panels/panel.h | 12 |
8 files changed, 55 insertions, 4 deletions
diff --git a/src/panels/filter/filterpanel.cpp b/src/panels/filter/filterpanel.cpp index 021a2d3b8..d13d6e520 100644 --- a/src/panels/filter/filterpanel.cpp +++ b/src/panels/filter/filterpanel.cpp @@ -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 @@ void FilterPanel::showEvent(QShowEvent* event) 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; diff --git a/src/panels/filter/filterpanel.h b/src/panels/filter/filterpanel.h index c574d618e..574a9f389 100644 --- a/src/panels/filter/filterpanel.h +++ b/src/panels/filter/filterpanel.h @@ -52,6 +52,9 @@ protected: /** @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); diff --git a/src/panels/folders/treeviewcontextmenu.cpp b/src/panels/folders/treeviewcontextmenu.cpp index de93e096c..5c9151df0 100644 --- a/src/panels/folders/treeviewcontextmenu.cpp +++ b/src/panels/folders/treeviewcontextmenu.cpp @@ -128,6 +128,10 @@ void TreeViewContextMenu::open() 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(); diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp index 0fd67b2b6..6681dc30d 100644 --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -167,7 +167,8 @@ void InformationPanel::resizeEvent(QResizeEvent* event) void InformationPanel::contextMenuEvent(QContextMenuEvent* event) { - m_content->configureSettings(); + // TODO: Move code from InformationPanelContent::configureSettings() here + m_content->configureSettings(customContextMenuActions()); Panel::contextMenuEvent(event); } diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index 371bdaf96..f8a72fb70 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -265,7 +265,7 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event) return QWidget::eventFilter(obj, event); } -void InformationPanelContent::configureSettings() +void InformationPanelContent::configureSettings(const QList<QAction*>& customContextMenuActions) { KMenu popup(this); @@ -277,6 +277,11 @@ void InformationPanelContent::configureSettings() 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()); diff --git a/src/panels/information/informationpanelcontent.h b/src/panels/information/informationpanelcontent.h index f918b8582..c41f4043f 100644 --- a/src/panels/information/informationpanelcontent.h +++ b/src/panels/information/informationpanelcontent.h @@ -61,8 +61,10 @@ public: /** * 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 ); diff --git a/src/panels/panel.cpp b/src/panels/panel.cpp index 6d11422d8..e90970c6e 100644 --- a/src/panels/panel.cpp +++ b/src/panels/panel.cpp @@ -23,7 +23,8 @@ Panel::Panel(QWidget* parent) : QWidget(parent), - m_url(KUrl()) + m_url(), + m_customContextMenuActions() { } @@ -36,6 +37,16 @@ KUrl Panel::url() const 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)) { diff --git a/src/panels/panel.h b/src/panels/panel.h index 11558e2de..83ed3da3b 100644 --- a/src/panels/panel.h +++ b/src/panels/panel.h @@ -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 @@ public: /** 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 @@ protected: private: KUrl m_url; + QList<QAction*> m_customContextMenuActions; }; #endif // PANEL_H |
