diff options
Diffstat (limited to 'src/panels')
| -rw-r--r-- | src/panels/folders/folderspanel.cpp | 1 | ||||
| -rw-r--r-- | src/panels/information/dolphin_informationpanelsettings.kcfg | 8 | ||||
| -rw-r--r-- | src/panels/information/informationpanelcontent.cpp | 99 | ||||
| -rw-r--r-- | src/panels/information/informationpanelcontent.h | 8 | ||||
| -rw-r--r-- | src/panels/places/placesitemmodel.cpp | 5 | ||||
| -rw-r--r-- | src/panels/places/placespanel.cpp | 2 |
6 files changed, 61 insertions, 62 deletions
diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index 61417dc5e..7a0b4b6b2 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -105,7 +105,6 @@ void FoldersPanel::rename(const KFileItem& item) m_controller->view()->editRole(index, "text"); } else { RenameDialog* dialog = new RenameDialog(this, KFileItemList() << item); - dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); dialog->raise(); dialog->activateWindow(); diff --git a/src/panels/information/dolphin_informationpanelsettings.kcfg b/src/panels/information/dolphin_informationpanelsettings.kcfg index 53c756d24..dbc1ab6d2 100644 --- a/src/panels/information/dolphin_informationpanelsettings.kcfg +++ b/src/panels/information/dolphin_informationpanelsettings.kcfg @@ -10,5 +10,13 @@ <label>Previews shown</label> <default>true</default> </entry> + <entry name="dateFormat" type="Enum"> + <label>Date display format</label> + <choices> + <choice name="LongFormat" /> + <choice name="ShortFormat" /> + </choices> + <default>0</default> + </entry> </group> </kcfg> diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index f44a3feb7..0cba0cdf0 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -112,12 +112,13 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) : this, &InformationPanelContent::urlActivated); #else m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); + m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, this, &InformationPanelContent::urlActivated); #endif m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); - + // Encapsulate the MetaDataWidget inside a container that has a dummy widget // at the bottom. This prevents that the meta data widget gets vertically stretched // in the case where the height of m_metaDataArea > m_metaDataWidget. @@ -160,41 +161,42 @@ void InformationPanelContent::showItem(const KFileItem& item) const QUrl itemUrl = item.url(); const bool isSearchUrl = itemUrl.scheme().contains(QStringLiteral("search")) && item.localPath().isEmpty(); - if (!applyPlace(itemUrl)) { - 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(); - } + 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... - m_previewJob = new KIO::PreviewJob(KFileItemList() << item, QSize(m_preview->width(), m_preview->height())); - m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); - m_previewJob->setIgnoreMaximumSize(item.isLocalFile()); - if (m_previewJob->uiDelegate()) { - KJobWidgets::setWindow(m_previewJob, this); - } + // 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(); + } - connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, - this, &InformationPanelContent::showPreview); - connect(m_previewJob.data(), &KIO::PreviewJob::failed, - this, &InformationPanelContent::showIcon); + m_previewJob = new KIO::PreviewJob(KFileItemList() << item, QSize(m_preview->width(), m_preview->height())); + m_previewJob->setScaleType(KIO::PreviewJob::Unscaled); + m_previewJob->setIgnoreMaximumSize(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); } if (m_metaDataWidget) { +#ifdef HAVE_BALOO + m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); +#endif m_metaDataWidget->show(); m_metaDataWidget->setItems(KFileItemList() << item); } @@ -283,6 +285,12 @@ void InformationPanelContent::configureSettings(const QList<QAction*>& customCon QAction* configureAction = popup.addAction(i18nc("@action:inmenu", "Configure...")); configureAction->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); +#ifdef HAVE_BALOO + 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)); +#endif popup.addSeparator(); foreach (QAction* action, customContextMenuActions) { popup.addAction(action); @@ -308,16 +316,22 @@ void InformationPanelContent::configureSettings(const QList<QAction*>& customCon dialog->show(); connect(dialog, &FileMetaDataConfigurationDialog::destroyed, this, &InformationPanelContent::refreshMetaData); } +#ifdef HAVE_BALOO + if (action == dateformatAction) { + int dateFormat = static_cast<int>(isChecked ? Baloo::DateFormats::ShortFormat : Baloo::DateFormats::LongFormat); + + InformationPanelSettings::setDateFormat(dateFormat); + refreshMetaData(); + } +#endif } void InformationPanelContent::showIcon(const KFileItem& item) { m_outdatedPreviewTimer->stop(); - if (!applyPlace(item.targetUrl())) { - QPixmap pixmap = QIcon::fromTheme(item.iconName()).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous); - KIconLoader::global()->drawOverlays(item.overlays(), pixmap, KIconLoader::Desktop); - m_preview->setPixmap(pixmap); - } + QPixmap pixmap = QIcon::fromTheme(item.iconName()).pixmap(KIconLoader::SizeEnormous, KIconLoader::SizeEnormous); + KIconLoader::global()->drawOverlays(item.overlays(), pixmap, KIconLoader::Desktop); + m_preview->setPixmap(pixmap); } void InformationPanelContent::showPreview(const KFileItem& item, @@ -352,21 +366,6 @@ void InformationPanelContent::refreshMetaData() } } -bool InformationPanelContent::applyPlace(const QUrl& url) -{ - const int count = m_placesItemModel->count(); - for (int i = 0; i < count; ++i) { - const PlacesItem* item = m_placesItemModel->placesItem(i); - if (item->url().matches(url, QUrl::StripTrailingSlash)) { - setNameLabelText(item->text()); - m_preview->setPixmap(QIcon::fromTheme(item->icon()).pixmap(128, 128)); - return true; - } - } - - return false; -} - void InformationPanelContent::setNameLabelText(const QString& text) { QTextOption textOption; diff --git a/src/panels/information/informationpanelcontent.h b/src/panels/information/informationpanelcontent.h index 80f3c8e22..9223fcc5a 100644 --- a/src/panels/information/informationpanelcontent.h +++ b/src/panels/information/informationpanelcontent.h @@ -116,14 +116,6 @@ private slots: private: /** - * Checks whether the an URL is repesented by a place. If yes, - * then the place icon and name are shown instead of a preview. - * @return True, if the URL represents exactly a place. - * @param url The url to check. - */ - bool applyPlace(const QUrl& url); - - /** * Sets the text for the label \a m_nameLabel and assures that the * text is split in a way that it can be wrapped within the * label width (QLabel::setWordWrap() does not work if the diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index 3641b3e42..7e313482d 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -453,7 +453,7 @@ void PlacesItemModel::initializeDefaultViewProperties() const } else if (path == QLatin1String("/images")) { props.setViewMode(DolphinView::IconsView); props.setPreviewsShown(true); - props.setVisibleRoles({"text", "imageSize"}); + props.setVisibleRoles({"text", "height", "width"}); } else if (path == QLatin1String("/audio")) { props.setViewMode(DolphinView::DetailsView); props.setPreviewsShown(false); @@ -597,7 +597,8 @@ void PlacesItemModel::onSourceModelDataChanged(const QModelIndex &topLeft, const void PlacesItemModel::onSourceModelGroupHiddenChanged(KFilePlacesModel::GroupType group, bool hidden) { - for(const QModelIndex &sourceIndex : m_sourceModel->groupIndexes(group)) { + const auto groupIndexes = m_sourceModel->groupIndexes(group); + for (const QModelIndex &sourceIndex : groupIndexes) { PlacesItem *item = placesItem(mapFromSource(sourceIndex)); if (item) { item->setGroupHidden(hidden); diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index 1f81a1eaa..00d8735c3 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -291,7 +291,7 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos) {KIconLoader::SizeLarge, I18N_NOOP2_NOSTRIP("Huge icon size", "Huge (%1x%2)")} }; - QMap<QAction*, int> iconSizeActionMap; + QHash<QAction*, int> iconSizeActionMap; QActionGroup* iconSizeGroup = new QActionGroup(iconSizeSubMenu); for (int i = 0; i < iconSizeCount; ++i) { |
