From aed1525abcc82dc32852d2f875e49fc7e2fe0aac Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Tue, 3 Mar 2009 21:17:35 +0000 Subject: [PATCH] added dialog to configure which meta data should be shown in the Information Panel svn path=/trunk/KDE/kdebase/apps/; revision=934828 --- src/CMakeLists.txt | 1 + src/panels/information/informationpanel.cpp | 22 ++++- src/panels/information/informationpanel.h | 26 ++++-- .../information/informationpaneldialog.cpp | 83 +++++++++++++++++++ .../information/informationpaneldialog.h | 48 +++++++++++ 5 files changed, 170 insertions(+), 10 deletions(-) create mode 100644 src/panels/information/informationpaneldialog.cpp create mode 100644 src/panels/information/informationpaneldialog.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c1daf5e8b9..d6cc3e7550 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,6 +102,7 @@ set(dolphin_SRCS panels/information/commentwidget.cpp panels/information/commenteditwidget.cpp panels/information/informationpanel.cpp + panels/information/informationpaneldialog.cpp panels/information/metadatawidget.cpp panels/information/metatextlabel.cpp panels/information/phononwidget.cpp diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp index c586742cf8..2f395a4c49 100644 --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -58,6 +59,7 @@ #include #include "settings/dolphinsettings.h" +#include "informationpaneldialog.h" #include "metadatawidget.h" #include "metatextlabel.h" #include "phononwidget.h" @@ -78,7 +80,8 @@ InformationPanel::InformationPanel(QWidget* parent) : m_phononWidget(0), m_metaDataWidget(0), m_metaTextArea(0), - m_metaTextLabel(0) + m_metaTextLabel(0), + m_dialog(0) { } @@ -207,6 +210,23 @@ bool InformationPanel::eventFilter(QObject* obj, QEvent* event) return Panel::eventFilter(obj, event); } +void InformationPanel::contextMenuEvent(QContextMenuEvent* event) +{ + Panel::contextMenuEvent(event); + + KMenu popup(this); + popup.addAction(i18nc("@action:inmenu", "Configure...")); + if (popup.exec(QCursor::pos()) != 0) { + if (m_dialog == 0) { + m_dialog = new InformationPanelDialog(this); + m_dialog->setAttribute(Qt::WA_DeleteOnClose); + m_dialog->show(); + } else { + m_dialog->raise(); + } + } +} + void InformationPanel::showItemInfo() { if (!isVisible()) { diff --git a/src/panels/information/informationpanel.h b/src/panels/information/informationpanel.h index 997ba69bf6..bc37f812ae 100644 --- a/src/panels/information/informationpanel.h +++ b/src/panels/information/informationpanel.h @@ -21,27 +21,30 @@ #define INFORMATIONPANEL_H #include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include #include +class InformationPanelDialog; +class PhononWidget; +class PixmapViewer; +class MetaDataWidget; +class MetaTextLabel; class QPixmap; class QString; class KFileItem; class QLabel; class QScrollArea; -class PhononWidget; -class PixmapViewer; -class MetaDataWidget; -class MetaTextLabel; /** * @brief Panel for showing meta information of one ore more selected items. @@ -85,6 +88,9 @@ protected: /** @see QObject::eventFilter() */ virtual bool eventFilter(QObject* obj, QEvent* event); + /** @see QWidget::contextMenuEvent() */ + virtual void contextMenuEvent(QContextMenuEvent* event); + private slots: /** * Shows the information for the item of the URL which has been provided by @@ -196,6 +202,8 @@ private: QScrollArea* m_metaTextArea; MetaTextLabel* m_metaTextLabel; + + QPointer m_dialog; }; #endif // INFORMATIONPANEL_H diff --git a/src/panels/information/informationpaneldialog.cpp b/src/panels/information/informationpaneldialog.cpp new file mode 100644 index 0000000000..0922197aa3 --- /dev/null +++ b/src/panels/information/informationpaneldialog.cpp @@ -0,0 +1,83 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#include "informationpaneldialog.h" + +#include +#include + +#include + +InformationPanelDialog::InformationPanelDialog(QWidget* parent) : + KDialog(parent), + m_isDirty(false) +{ + setCaption(i18nc("@title:window", "Information Panel")); + setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply); + + QWidget* main = new QWidget(); + // ... + Q_UNUSED(main); + QVBoxLayout* topLayout = new QVBoxLayout(); + // ... + Q_UNUSED(topLayout); + + connect(this, SIGNAL(okClicked()), this, SLOT(slotOk())); + connect(this, SIGNAL(applyClicked()), this, SLOT(slotApply())); + + main->setLayout(topLayout); + setMainWidget(main); + + const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), + "InformationPanelDialog"); + restoreDialogSize(dialogConfig); + + loadSettings(); +} + +InformationPanelDialog::~InformationPanelDialog() +{ + KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), + "InformationPanelDialog"); + saveDialogSize(dialogConfig, KConfigBase::Persistent); +} + +void InformationPanelDialog::slotOk() +{ + // ... + accept(); +} + +void InformationPanelDialog::slotApply() +{ + // ... + markAsDirty(false); +} + +void InformationPanelDialog::markAsDirty(bool isDirty) +{ + m_isDirty = isDirty; + enableButtonApply(isDirty); +} + +void InformationPanelDialog::loadSettings() +{ +} + +#include "informationpaneldialog.moc" diff --git a/src/panels/information/informationpaneldialog.h b/src/panels/information/informationpaneldialog.h new file mode 100644 index 0000000000..8ed5327ffd --- /dev/null +++ b/src/panels/information/informationpaneldialog.h @@ -0,0 +1,48 @@ +/*************************************************************************** + * Copyright (C) 2009 by Peter Penz * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + ***************************************************************************/ + +#ifndef INFORMATIONPANELDIALOG_H +#define INFORMATIONPANELDIALOG_H + +#include + +/** + * @brief Dialog for adjusting the Information Panel settings. + */ +class InformationPanelDialog : public KDialog +{ + Q_OBJECT + +public: + explicit InformationPanelDialog(QWidget* parent); + virtual ~InformationPanelDialog(); + +private slots: + void slotOk(); + void slotApply(); + void markAsDirty(bool isDirty); + +private: + void loadSettings(); + +private: + bool m_isDirty; +}; + +#endif