Merge remote-tracking branch 'origin/Applications/19.04'

This commit is contained in:
Méven Car 2019-03-17 19:38:31 +01:00
commit bc1a99bd11
4 changed files with 81 additions and 67 deletions

View file

@ -25,11 +25,18 @@
#include <KIO/JobUiDelegate> #include <KIO/JobUiDelegate>
#include <KJobWidgets> #include <KJobWidgets>
#include <KDirNotify> #include <KDirNotify>
#include <KLocalizedString>
#include <Baloo/FileMetaDataWidget>
#include <QApplication> #include <QApplication>
#include <QShowEvent> #include <QShowEvent>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QTimer> #include <QTimer>
#include <QMenu>
#include "dolphin_informationpanelsettings.h"
#include "filemetadataconfigurationdialog.h"
InformationPanel::InformationPanel(QWidget* parent) : InformationPanel::InformationPanel(QWidget* parent) :
Panel(parent), Panel(parent),
@ -157,11 +164,59 @@ void InformationPanel::resizeEvent(QResizeEvent* event)
void InformationPanel::contextMenuEvent(QContextMenuEvent* event) void InformationPanel::contextMenuEvent(QContextMenuEvent* event)
{ {
// TODO: Move code from InformationPanelContent::configureSettings() here showContextMenu(event->globalPos());
m_content->configureSettings(customContextMenuActions(), event->globalPos());
Panel::contextMenuEvent(event); 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() void InformationPanel::showItemInfo()
{ {
if (!isVisible()) { if (!isVisible()) {

View file

@ -128,6 +128,12 @@ private:
*/ */
void markUrlAsInvalid(); void markUrlAsInvalid();
/**
* Opens a menu which allows to configure which meta information
* should be shown.
*/
void showContextMenu(const QPoint &point);
void init(); void init();
private: private:

View file

@ -29,7 +29,6 @@
#include <KStringHandler> #include <KStringHandler>
#include <QIcon> #include <QIcon>
#include <QMenu>
#include <QTextDocument> #include <QTextDocument>
#include <Baloo/FileMetaDataWidget> #include <Baloo/FileMetaDataWidget>
@ -48,7 +47,6 @@
#include <QStyle> #include <QStyle>
#include "dolphin_informationpanelsettings.h" #include "dolphin_informationpanelsettings.h"
#include "filemetadataconfigurationdialog.h"
#include "phononwidget.h" #include "phononwidget.h"
#include "pixmapviewer.h" #include "pixmapviewer.h"
@ -264,56 +262,6 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event)
return QWidget::eventFilter(obj, event); return QWidget::eventFilter(obj, event);
} }
void InformationPanelContent::configureSettings(const QList<QAction*>& customContextMenuActions, const QPointF& 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.toPoint());
if (!action) {
return;
}
const bool isChecked = action->isChecked();
if (action == previewAction) {
m_preview->setVisible(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_metaDataWidget->items());
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
connect(dialog, &FileMetaDataConfigurationDialog::destroyed, this, &InformationPanelContent::refreshMetaData);
}
if (action == dateformatAction) {
int dateFormat = static_cast<int>(isChecked ? Baloo::DateFormats::ShortFormat : Baloo::DateFormats::LongFormat);
InformationPanelSettings::setDateFormat(dateFormat);
refreshMetaData();
}
}
void InformationPanelContent::showIcon(const KFileItem& item) void InformationPanelContent::showIcon(const KFileItem& item)
{ {
m_outdatedPreviewTimer->stop(); m_outdatedPreviewTimer->stop();
@ -342,6 +290,14 @@ void InformationPanelContent::markOutdatedPreview()
m_preview->setPixmap(disabledPixmap); m_preview->setPixmap(disabledPixmap);
} }
void InformationPanelContent::setPreviewVisible(bool visible) {
m_preview->setVisible(visible);
}
KFileItemList InformationPanelContent::items() {
return m_metaDataWidget->items();
}
void InformationPanelContent::slotHasVideoChanged(bool hasVideo) void InformationPanelContent::slotHasVideoChanged(bool hasVideo)
{ {
m_preview->setVisible(!hasVideo); m_preview->setVisible(!hasVideo);

View file

@ -72,17 +72,20 @@ public:
*/ */
void showItems(const KFileItemList& items); void showItems(const KFileItemList& items);
/** void setPreviewVisible(bool visible);
* Opens a menu which allows to configure which meta information
* should be shown. KFileItemList items();
*
* TODO: Move this code to the class InformationPanel
*/
void configureSettings(const QList<QAction*>& customContextMenuActions, const QPointF& pos);
signals: signals:
void urlActivated( const QUrl& url ); void urlActivated( const QUrl& url );
public slots:
/**
* Is invoked after the file meta data configuration dialog has been
* closed and refreshes the visibility of the meta data.
*/
void refreshMetaData();
protected: protected:
/** @see QObject::eventFilter() */ /** @see QObject::eventFilter() */
bool eventFilter(QObject* obj, QEvent* event) override; bool eventFilter(QObject* obj, QEvent* event) override;
@ -108,12 +111,6 @@ private slots:
void slotHasVideoChanged(bool hasVideo); void slotHasVideoChanged(bool hasVideo);
/**
* Is invoked after the file meta data configuration dialog has been
* closed and refreshes the visibility of the meta data.
*/
void refreshMetaData();
private: private:
/** /**
* Sets the text for the label \a m_nameLabel and assures that the * Sets the text for the label \a m_nameLabel and assures that the