diff options
| author | Méven Car <[email protected]> | 2019-03-17 17:24:30 +0100 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2019-03-17 19:29:53 +0100 |
| commit | 1ff74854ecb4e5c9a2099759b71c378225c9e988 (patch) | |
| tree | 82e1ec73364f1b1f5b26ca2b3aeced0d70fbacce /src/panels/information/informationpanel.cpp | |
| parent | 508dc815c75c9db8abaec26ae664ae41bf7f89b5 (diff) | |
Fix a todo: InformationPanelContent::configureSettings code is moved to InformationPanel::contextMenuEvent
Summary:
Fix a TODO : InformationPanelContent::configureSettings code is moved to InformationPanel::contextMenuEvent
Adding necessary accessors and changing visibility of one slot.
Test Plan:
1 compile
2 in dolphin right on the information panel
3 toggle preview
4 from the same context menu, click configure, metadadata settings appears
5 toggle "condensed date" if available
Reviewers: elvisangelaccio, #dolphin
Reviewed By: elvisangelaccio, #dolphin
Subscribers: kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D19832
Diffstat (limited to 'src/panels/information/informationpanel.cpp')
| -rw-r--r-- | src/panels/information/informationpanel.cpp | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp index a0aeaaa37..a864cb005 100644 --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -25,11 +25,18 @@ #include <KIO/JobUiDelegate> #include <KJobWidgets> #include <KDirNotify> +#include <KLocalizedString> + +#include <Baloo/FileMetaDataWidget> #include <QApplication> #include <QShowEvent> #include <QVBoxLayout> #include <QTimer> +#include <QMenu> + +#include "dolphin_informationpanelsettings.h" +#include "filemetadataconfigurationdialog.h" InformationPanel::InformationPanel(QWidget* parent) : Panel(parent), @@ -157,11 +164,59 @@ void InformationPanel::resizeEvent(QResizeEvent* event) void InformationPanel::contextMenuEvent(QContextMenuEvent* event) { - // TODO: Move code from InformationPanelContent::configureSettings() here - m_content->configureSettings(customContextMenuActions(), event->globalPos()); + showContextMenu(event->globalPos()); Panel::contextMenuEvent(event); } +void InformationPanel::showContextMenu(const QPoint &pos) { + QMenu popup(this); + + QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); + previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); + previewAction->setCheckable(true); + previewAction->setChecked(InformationPanelSettings::previewsShown()); + + QAction* configureAction = popup.addAction(i18nc("@action:inmenu", "Configure...")); + configureAction->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); + + QAction* dateformatAction = popup.addAction(i18nc("@action:inmenu", "Condensed Date")); + dateformatAction->setIcon(QIcon::fromTheme(QStringLiteral("change-date-symbolic"))); + dateformatAction->setCheckable(true); + dateformatAction->setChecked(InformationPanelSettings::dateFormat() == static_cast<int>(Baloo::DateFormats::ShortFormat)); + + popup.addSeparator(); + foreach (QAction* action, customContextMenuActions()) { + popup.addAction(action); + } + + // Open the popup and adjust the settings for the + // selected action. + QAction* action = popup.exec(pos); + if (!action) { + return; + } + + const bool isChecked = action->isChecked(); + if (action == previewAction) { + m_content->setPreviewVisible(isChecked); + InformationPanelSettings::setPreviewsShown(isChecked); + } else if (action == configureAction) { + FileMetaDataConfigurationDialog* dialog = new FileMetaDataConfigurationDialog(this); + dialog->setDescription(i18nc("@label::textbox", + "Select which data should be shown in the information panel:")); + dialog->setItems(m_content->items()); + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->show(); + connect(dialog, &FileMetaDataConfigurationDialog::destroyed, m_content, &InformationPanelContent::refreshMetaData); + } + if (action == dateformatAction) { + int dateFormat = static_cast<int>(isChecked ? Baloo::DateFormats::ShortFormat : Baloo::DateFormats::LongFormat); + + InformationPanelSettings::setDateFormat(dateFormat); + m_content->refreshMetaData(); + } +} + void InformationPanel::showItemInfo() { if (!isVisible()) { |
