Changeset View
Changeset View
Standalone View
Standalone View
src/panels/information/informationpanelcontent.cpp
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Line(s) | 110 | connect(m_metaDataWidget, &KFileMetaDataWidget::urlActivated, | |||
---|---|---|---|---|---|
111 | this, &InformationPanelContent::urlActivated); | 111 | this, &InformationPanelContent::urlActivated); | ||
112 | #else | 112 | #else | ||
113 | m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); | 113 | m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); | ||
114 | connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, | 114 | connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, | ||
115 | this, &InformationPanelContent::urlActivated); | 115 | this, &InformationPanelContent::urlActivated); | ||
116 | #endif | 116 | #endif | ||
117 | m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | 117 | m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); | ||
118 | m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | 118 | m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); | ||
119 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | ||||
119 | 120 | | |||
markg: No c-style cast. | |||||
120 | // Encapsulate the MetaDataWidget inside a container that has a dummy widget | 121 | // Encapsulate the MetaDataWidget inside a container that has a dummy widget | ||
121 | // at the bottom. This prevents that the meta data widget gets vertically stretched | 122 | // at the bottom. This prevents that the meta data widget gets vertically stretched | ||
122 | // in the case where the height of m_metaDataArea > m_metaDataWidget. | 123 | // in the case where the height of m_metaDataArea > m_metaDataWidget. | ||
123 | QWidget* metaDataWidgetContainer = new QWidget(parent); | 124 | QWidget* metaDataWidgetContainer = new QWidget(parent); | ||
124 | QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer); | 125 | QVBoxLayout* containerLayout = new QVBoxLayout(metaDataWidgetContainer); | ||
125 | containerLayout->setContentsMargins(0, 0, 0, 0); | 126 | containerLayout->setContentsMargins(0, 0, 0, 0); | ||
126 | containerLayout->setSpacing(0); | 127 | containerLayout->setSpacing(0); | ||
127 | containerLayout->addWidget(m_metaDataWidget); | 128 | containerLayout->addWidget(m_metaDataWidget); | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 171 | } else { | |||
189 | connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, | 190 | connect(m_previewJob.data(), &KIO::PreviewJob::gotPreview, | ||
190 | this, &InformationPanelContent::showPreview); | 191 | this, &InformationPanelContent::showPreview); | ||
191 | connect(m_previewJob.data(), &KIO::PreviewJob::failed, | 192 | connect(m_previewJob.data(), &KIO::PreviewJob::failed, | ||
192 | this, &InformationPanelContent::showIcon); | 193 | this, &InformationPanelContent::showIcon); | ||
193 | } | 194 | } | ||
194 | } | 195 | } | ||
195 | 196 | | |||
196 | if (m_metaDataWidget) { | 197 | if (m_metaDataWidget) { | ||
198 | m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); | ||||
markg: No c-style cast. | |||||
197 | m_metaDataWidget->show(); | 199 | m_metaDataWidget->show(); | ||
198 | m_metaDataWidget->setItems(KFileItemList() << item); | 200 | m_metaDataWidget->setItems(KFileItemList() << item); | ||
199 | } | 201 | } | ||
200 | 202 | | |||
201 | if (InformationPanelSettings::previewsShown()) { | 203 | if (InformationPanelSettings::previewsShown()) { | ||
202 | const QString mimeType = item.mimetype(); | 204 | const QString mimeType = item.mimetype(); | ||
203 | const bool usePhonon = mimeType.startsWith(QLatin1String("audio/")) || mimeType.startsWith(QLatin1String("video/")); | 205 | const bool usePhonon = mimeType.startsWith(QLatin1String("audio/")) || mimeType.startsWith(QLatin1String("video/")); | ||
204 | if (usePhonon) { | 206 | if (usePhonon) { | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 276 | { | |||
277 | QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); | 279 | QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); | ||
278 | previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); | 280 | previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); | ||
279 | previewAction->setCheckable(true); | 281 | previewAction->setCheckable(true); | ||
280 | previewAction->setChecked(InformationPanelSettings::previewsShown()); | 282 | previewAction->setChecked(InformationPanelSettings::previewsShown()); | ||
281 | 283 | | |||
282 | QAction* configureAction = popup.addAction(i18nc("@action:inmenu", "Configure...")); | 284 | QAction* configureAction = popup.addAction(i18nc("@action:inmenu", "Configure...")); | ||
283 | configureAction->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); | 285 | configureAction->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); | ||
284 | 286 | | |||
287 | QAction* dateformatAction = popup.addAction(i18nc("@action:inmenu", "Condensed Date")); | ||||
288 | dateformatAction->setIcon(QIcon::fromTheme(QStringLiteral("change-date-symbolic"))); | ||||
ngraham: Not sure this is the right icon. How about `change-date-symbolic`? | |||||
289 | dateformatAction->setCheckable(true); | ||||
290 | dateformatAction->setChecked(InformationPanelSettings::dateFormat() == static_cast<int>(Baloo::DateFormats::ShortFormat)); | ||||
markg: No c-style cast. | |||||
285 | popup.addSeparator(); | 291 | popup.addSeparator(); | ||
286 | foreach (QAction* action, customContextMenuActions) { | 292 | foreach (QAction* action, customContextMenuActions) { | ||
287 | popup.addAction(action); | 293 | popup.addAction(action); | ||
288 | } | 294 | } | ||
289 | 295 | | |||
290 | // Open the popup and adjust the settings for the | 296 | // Open the popup and adjust the settings for the | ||
291 | // selected action. | 297 | // selected action. | ||
292 | QAction* action = popup.exec(QCursor::pos()); | 298 | QAction* action = popup.exec(QCursor::pos()); | ||
293 | if (!action) { | 299 | if (!action) { | ||
294 | return; | 300 | return; | ||
295 | } | 301 | } | ||
296 | 302 | | |||
297 | const bool isChecked = action->isChecked(); | 303 | const bool isChecked = action->isChecked(); | ||
298 | if (action == previewAction) { | 304 | if (action == previewAction) { | ||
299 | m_preview->setVisible(isChecked); | 305 | m_preview->setVisible(isChecked); | ||
300 | InformationPanelSettings::setPreviewsShown(isChecked); | 306 | InformationPanelSettings::setPreviewsShown(isChecked); | ||
307 | } else if (action == dateformatAction) { | ||||
308 | int dateFormat = static_cast<int>(isChecked ? Baloo::DateFormats::ShortFormat : Baloo::DateFormats::LongFormat); | ||||
309 | | ||||
310 | InformationPanelSettings::setDateFormat(dateFormat); | ||||
311 | refreshMetaData(); | ||||
Err, auto for int.. No, just int! Don't misuse auto. markg: Err, auto for int.. No, just int! Don't misuse auto.
Also, put this on one line. Nobody formats… | |||||
301 | } else if (action == configureAction) { | 312 | } else if (action == configureAction) { | ||
302 | FileMetaDataConfigurationDialog* dialog = new FileMetaDataConfigurationDialog(this); | 313 | FileMetaDataConfigurationDialog* dialog = new FileMetaDataConfigurationDialog(this); | ||
303 | dialog->setDescription(i18nc("@label::textbox", | 314 | dialog->setDescription(i18nc("@label::textbox", | ||
304 | "Select which data should be shown in the information panel:")); | 315 | "Select which data should be shown in the information panel:")); | ||
305 | dialog->setItems(m_metaDataWidget->items()); | 316 | dialog->setItems(m_metaDataWidget->items()); | ||
306 | dialog->setAttribute(Qt::WA_DeleteOnClose); | 317 | dialog->setAttribute(Qt::WA_DeleteOnClose); | ||
307 | dialog->show(); | 318 | dialog->show(); | ||
308 | connect(dialog, &FileMetaDataConfigurationDialog::destroyed, this, &InformationPanelContent::refreshMetaData); | 319 | connect(dialog, &FileMetaDataConfigurationDialog::destroyed, this, &InformationPanelContent::refreshMetaData); | ||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |
No c-style cast.