From 0b9cb0f7d9b6dc7c8c43a2afafb713f8c28ad0c5 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Sun, 24 Mar 2019 11:55:12 +0100 Subject: [PhononWidget] Fix layout warning `controlsLayout` should not be a direct child of the widget, since it already has `m_topLayout` as layout. This fixes the following warning: QLayout: Attempting to add QLayout "" to PhononWidget "", which already has a layout --- src/panels/information/phononwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/panels/information/phononwidget.cpp b/src/panels/information/phononwidget.cpp index 95f535713..77e066d37 100644 --- a/src/panels/information/phononwidget.cpp +++ b/src/panels/information/phononwidget.cpp @@ -106,7 +106,7 @@ void PhononWidget::showEvent(QShowEvent *event) m_topLayout = new QVBoxLayout(this); m_topLayout->setContentsMargins(0, 0, 0, 0); - QHBoxLayout *controlsLayout = new QHBoxLayout(this); + QHBoxLayout *controlsLayout = new QHBoxLayout(); controlsLayout->setContentsMargins(0, 0, 0, 0); controlsLayout->setSpacing(0); -- cgit v1.3 From 35f1fd5c154c72a63f4f70073e8dc8113c051f4f Mon Sep 17 00:00:00 2001 From: Méven Car Date: Sun, 24 Mar 2019 18:32:25 +0100 Subject: [InformationPanel] Hide the video when the preview is disabled, avoid computing the preview when it is disabled Summary: Bug symptom : {F6698879} Fix the bugs and allow to avoid launching a PreviewJob with all files even when the preview is disabled. Test Plan: # In dolphin with an information panel with preview on # launch the video preview # Disable the preview ->bug 1: the video player control is still visible (this bug fix this) # re-enable preview -> bug 2: the video stays visible and the preview is displayed above (this bug fix this) Reviewers: #dolphin, elvisangelaccio, ngraham Reviewed By: #dolphin, elvisangelaccio, ngraham Subscribers: ngraham, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D19844 --- src/panels/information/informationpanel.cpp | 2 +- src/panels/information/informationpanelcontent.cpp | 120 ++++++++++----------- src/panels/information/informationpanelcontent.h | 11 +- 3 files changed, 66 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp index a864cb005..cd8b6b38d 100644 --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -198,8 +198,8 @@ void InformationPanel::showContextMenu(const QPoint &pos) { const bool isChecked = action->isChecked(); if (action == previewAction) { - m_content->setPreviewVisible(isChecked); InformationPanelSettings::setPreviewsShown(isChecked); + m_content->refreshPreview(); } else if (action == configureAction) { FileMetaDataConfigurationDialog* dialog = new FileMetaDataConfigurationDialog(this); dialog->setDescription(i18nc("@label::textbox", diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index 4b34e55e3..e2b90dcc8 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -141,73 +141,80 @@ InformationPanelContent::~InformationPanelContent() void InformationPanelContent::showItem(const KFileItem& item) { + m_item = item; + + refreshPreview(); + refreshMetaData(); +} + +void InformationPanelContent::refreshPreview() { // If there is a preview job, kill it to prevent that we have jobs for // multiple items running, and thus a race condition (bug 250787). if (m_previewJob) { m_previewJob->kill(); } - const QUrl itemUrl = item.url(); - const bool isSearchUrl = itemUrl.scheme().contains(QStringLiteral("search")) && item.localPath().isEmpty(); - setNameLabelText(item.text()); - if (isSearchUrl) { - // in the case of a search-URL the URL is not readable for humans - // (at least not useful to show in the Information Panel) - m_preview->setPixmap( - QIcon::fromTheme(QStringLiteral("nepomuk")).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous) - ); - } else { - // try to get a preview pixmap from the item... - - // Mark the currently shown preview as outdated. This is done - // with a small delay to prevent a flickering when the next preview - // can be shown within a short timeframe. This timer is not started - // for directories, as directory previews might fail and return the - // same icon. - if (!item.isDir()) { - m_outdatedPreviewTimer->start(); - } + if (InformationPanelSettings::previewsShown()) { + m_preview->show(); + + const QUrl itemUrl = m_item.url(); + const bool isSearchUrl = itemUrl.scheme().contains(QStringLiteral("search")) && m_item.localPath().isEmpty(); + setNameLabelText(m_item.text()); + if (isSearchUrl) { + // in the case of a search-URL the URL is not readable for humans + // (at least not useful to show in the Information Panel) + m_preview->setPixmap( + QIcon::fromTheme(QStringLiteral("nepomuk")).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous) + ); + } else { + // try to get a preview pixmap from the item... + + // Mark the currently shown preview as outdated. This is done + // with a small delay to prevent a flickering when the next preview + // can be shown within a short timeframe. This timer is not started + // for directories, as directory previews might fail and return the + // same icon. + if (!m_item.isDir()) { + m_outdatedPreviewTimer->start(); + } - QStringList plugins = KIO::PreviewJob::availablePlugins(); - m_previewJob = new KIO::PreviewJob(KFileItemList() << item, - QSize(m_preview->width(), m_preview->height()), - &plugins); - m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); - m_previewJob->setIgnoreMaximumSize(item.isLocalFile()); - if (m_previewJob->uiDelegate()) { - KJobWidgets::setWindow(m_previewJob, this); - } + QStringList plugins = KIO::PreviewJob::availablePlugins(); + m_previewJob = new KIO::PreviewJob(KFileItemList() << m_item, + QSize(m_preview->width(), m_preview->height()), + &plugins); + m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); + m_previewJob->setIgnoreMaximumSize(m_item.isLocalFile()); + if (m_previewJob->uiDelegate()) { + KJobWidgets::setWindow(m_previewJob, this); + } - connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, - this, &InformationPanelContent::showPreview); - connect(m_previewJob.data(), &KIO::PreviewJob::failed, - this, &InformationPanelContent::showIcon); - } + connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, + this, &InformationPanelContent::showPreview); + connect(m_previewJob.data(), &KIO::PreviewJob::failed, + this, &InformationPanelContent::showIcon); - if (m_metaDataWidget) { - m_metaDataWidget->setDateFormat(static_cast(InformationPanelSettings::dateFormat())); - m_metaDataWidget->show(); - m_metaDataWidget->setItems(KFileItemList() << item); - } - - if (InformationPanelSettings::previewsShown()) { - const QString mimeType = item.mimetype(); - const bool usePhonon = mimeType.startsWith(QLatin1String("audio/")) || mimeType.startsWith(QLatin1String("video/")); - if (usePhonon) { - m_phononWidget->show(); - m_phononWidget->setUrl(item.targetUrl()); - if (m_preview->isVisible()) { + const QString mimeType = m_item.mimetype(); + const bool usePhonon = mimeType.startsWith(QLatin1String("audio/")) || mimeType.startsWith(QLatin1String("video/")); + if (usePhonon) { + m_phononWidget->show(); + m_phononWidget->setUrl(m_item.targetUrl()); m_phononWidget->setVideoSize(m_preview->size()); + } else { + m_phononWidget->hide(); } - } else { - m_phononWidget->hide(); - m_preview->setVisible(true); } } else { + m_preview->hide(); m_phononWidget->hide(); } +} - m_item = item; +void InformationPanelContent::refreshMetaData() { + if (m_metaDataWidget) { + m_metaDataWidget->setDateFormat(static_cast(InformationPanelSettings::dateFormat())); + m_metaDataWidget->show(); + m_metaDataWidget->setItems(KFileItemList() << m_item); + } } void InformationPanelContent::showItems(const KFileItemList& items) @@ -290,10 +297,6 @@ void InformationPanelContent::markOutdatedPreview() m_preview->setPixmap(disabledPixmap); } -void InformationPanelContent::setPreviewVisible(bool visible) { - m_preview->setVisible(visible); -} - KFileItemList InformationPanelContent::items() { return m_metaDataWidget->items(); } @@ -303,13 +306,6 @@ void InformationPanelContent::slotHasVideoChanged(bool hasVideo) m_preview->setVisible(InformationPanelSettings::previewsShown() && !hasVideo); } -void InformationPanelContent::refreshMetaData() -{ - if (!m_item.isNull()) { - showItem(m_item); - } -} - void InformationPanelContent::setNameLabelText(const QString& text) { QTextOption textOption; diff --git a/src/panels/information/informationpanelcontent.h b/src/panels/information/informationpanelcontent.h index a80775aaa..83fb3d80b 100644 --- a/src/panels/information/informationpanelcontent.h +++ b/src/panels/information/informationpanelcontent.h @@ -68,21 +68,24 @@ public: void showItem(const KFileItem& item); /** - * Shows the meta information for the items \p items. + * Shows the meta information for the items \p items and its preview */ void showItems(const KFileItemList& items); - void setPreviewVisible(bool visible); - KFileItemList items(); + /** + * Refreshes the preview display, hiding it if needed + */ + void refreshPreview(); + signals: 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. + * closed and refreshes the displayed meta data by the panel. */ void refreshMetaData(); -- cgit v1.3 From d7277e47a6b84f20957e829d378b389df668fdc6 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Sun, 24 Mar 2019 18:37:10 +0100 Subject: When hovering over a file on the not-focus view panel, the information panel gets updated Test Plan: - In Dolphin with two views (split view) and with the information panels - Hover over a file on the not selected view - > the information panel show information about this file No other changes in behavior Reviewers: #dolphin, elvisangelaccio, ngraham Reviewed By: #dolphin, ngraham Subscribers: kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D19936 --- src/dolphinmainwindow.cpp | 4 ++++ src/panels/information/informationpanel.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index bcadcdb80..296cb1400 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1045,6 +1045,10 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer) oldViewContainer->disconnect(this); oldViewContainer->view()->disconnect(this); oldViewContainer->urlNavigator()->disconnect(this); + + // except the requestItemInfo so that on hover the information panel can still be updated + connect(oldViewContainer->view(), &DolphinView::requestItemInfo, + this, &DolphinMainWindow::requestItemInfo); } connectViewSignals(viewContainer); diff --git a/src/panels/information/informationpanel.h b/src/panels/information/informationpanel.h index 05947145d..f63af1e53 100644 --- a/src/panels/information/informationpanel.h +++ b/src/panels/information/informationpanel.h @@ -75,7 +75,7 @@ protected: private slots: /** * Shows the information for the item of the URL which has been provided by - * InformationPanel::requestItemInfo() and provides default actions. + * InformationPanel::requestDelayedItemInfo() and provides default actions. */ void showItemInfo(); -- cgit v1.3 From 1eaf5d3e0362f8d39655e973bcd29813ae98652b Mon Sep 17 00:00:00 2001 From: Tigran Gabrielyan Date: Sun, 24 Mar 2019 11:30:27 -0600 Subject: Move Safely Remove down in places context menu Summary: BUG: 405620 Reviewers: #dolphin, ngraham, elvisangelaccio Reviewed By: #dolphin, ngraham, elvisangelaccio Subscribers: elvisangelaccio, ngraham, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D19950 --- src/panels/places/placespanel.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index d0dbcce88..224eb0c64 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -175,6 +175,22 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) const bool isDevice = !item->udi().isEmpty(); const bool isTrash = (item->url().scheme() == QLatin1String("trash")); + if (isTrash) { + emptyTrashAction = menu.addAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash")); + emptyTrashAction->setEnabled(item->icon() == QLatin1String("user-trash-full")); + menu.addSeparator(); + } + + QAction* openInNewWindowAction = menu.addAction(QIcon::fromTheme(QStringLiteral("window-new")), i18nc("@item:inmenu", "Open in New Window")); + QAction* openInNewTabAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@item:inmenu", "Open in New Tab")); + QAction* propertiesAction = nullptr; + if (item->url().isLocalFile()) { + propertiesAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18nc("@action:inmenu", "Properties")); + } + if (!isDevice && !isTrash) { + menu.addSeparator(); + } + if (isDevice) { ejectAction = m_model->ejectAction(index); if (ejectAction) { @@ -205,22 +221,6 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) if (teardownAction || ejectAction || mountAction) { menu.addSeparator(); } - } else { - if (isTrash) { - emptyTrashAction = menu.addAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash")); - emptyTrashAction->setEnabled(item->icon() == QLatin1String("user-trash-full")); - menu.addSeparator(); - } - } - - QAction* openInNewWindowAction = menu.addAction(QIcon::fromTheme(QStringLiteral("window-new")), i18nc("@item:inmenu", "Open in New Window")); - QAction* openInNewTabAction = menu.addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@item:inmenu", "Open in New Tab")); - QAction* propertiesAction = nullptr; - if (item->url().isLocalFile()) { - propertiesAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-properties")), i18nc("@action:inmenu", "Properties")); - } - if (!isDevice && !isTrash) { - menu.addSeparator(); } if (!isDevice) { -- cgit v1.3