diff options
| author | Serg Podtynnyi <[email protected]> | 2023-02-04 00:14:53 +0700 |
|---|---|---|
| committer | Serg Podtynnyi <[email protected]> | 2023-02-05 12:45:38 +0700 |
| commit | 38c34eeca315c7be58e65d4d3fb72aaf7b866719 (patch) | |
| tree | 886e53f20c9c43edc3eb7fe04789716a9bc98ebe /src/panels/information | |
| parent | ffff8af851e3a386c44438337779d0ce7ca98a61 (diff) | |
Add clang-format and format code as in Frameworks
Diffstat (limited to 'src/panels/information')
| -rw-r--r-- | src/panels/information/informationpanel.cpp | 94 | ||||
| -rw-r--r-- | src/panels/information/informationpanel.h | 42 | ||||
| -rw-r--r-- | src/panels/information/informationpanelcontent.cpp | 125 | ||||
| -rw-r--r-- | src/panels/information/informationpanelcontent.h | 50 | ||||
| -rw-r--r-- | src/panels/information/phononwidget.cpp | 60 | ||||
| -rw-r--r-- | src/panels/information/phononwidget.h | 102 | ||||
| -rw-r--r-- | src/panels/information/pixmapviewer.cpp | 43 | ||||
| -rw-r--r-- | src/panels/information/pixmapviewer.h | 17 |
8 files changed, 247 insertions, 286 deletions
diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp index 31617bb5e..a0dff0d5e 100644 --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -16,26 +16,26 @@ #include <Baloo/FileMetaDataWidget> #include <QApplication> +#include <QMenu> #include <QShowEvent> -#include <QVBoxLayout> #include <QTimer> -#include <QMenu> +#include <QVBoxLayout> #include "dolphin_informationpanelsettings.h" -InformationPanel::InformationPanel(QWidget* parent) : - Panel(parent), - m_initialized(false), - m_infoTimer(nullptr), - m_urlChangedTimer(nullptr), - m_resetUrlTimer(nullptr), - m_shownUrl(), - m_urlCandidate(), - m_invalidUrlCandidate(), - m_hoveredItem(), - m_selection(), - m_folderStatJob(nullptr), - m_content(nullptr) +InformationPanel::InformationPanel(QWidget *parent) + : Panel(parent) + , m_initialized(false) + , m_infoTimer(nullptr) + , m_urlChangedTimer(nullptr) + , m_resetUrlTimer(nullptr) + , m_shownUrl() + , m_urlCandidate() + , m_invalidUrlCandidate() + , m_hoveredItem() + , m_selection() + , m_folderStatJob(nullptr) + , m_content(nullptr) { } @@ -43,7 +43,7 @@ InformationPanel::~InformationPanel() { } -void InformationPanel::setSelection(const KFileItemList& selection) +void InformationPanel::setSelection(const KFileItemList &selection) { m_selection = selection; @@ -66,7 +66,7 @@ void InformationPanel::setSelection(const KFileItemList& selection) } } -void InformationPanel::requestDelayedItemInfo(const KFileItem& item) +void InformationPanel::requestDelayedItemInfo(const KFileItem &item) { if (!isVisible()) { return; @@ -115,7 +115,7 @@ bool InformationPanel::urlChanged() return true; } -void InformationPanel::showEvent(QShowEvent* event) +void InformationPanel::showEvent(QShowEvent *event) { Panel::showEvent(event); if (!event->spontaneous()) { @@ -131,7 +131,7 @@ void InformationPanel::showEvent(QShowEvent* event) } } -void InformationPanel::resizeEvent(QResizeEvent* event) +void InformationPanel::resizeEvent(QResizeEvent *event) { if (isVisible()) { m_urlCandidate = m_shownUrl; @@ -140,7 +140,7 @@ void InformationPanel::resizeEvent(QResizeEvent* event) Panel::resizeEvent(event); } -void InformationPanel::contextMenuEvent(QContextMenuEvent* event) +void InformationPanel::contextMenuEvent(QContextMenuEvent *event) { showContextMenu(event->globalPos()); Panel::contextMenuEvent(event); @@ -150,23 +150,23 @@ void InformationPanel::showContextMenu(const QPoint &pos) { QMenu popup(this); - QAction* previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); + QAction *previewAction = popup.addAction(i18nc("@action:inmenu", "Preview")); previewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-preview"))); previewAction->setCheckable(true); previewAction->setChecked(InformationPanelSettings::previewsShown()); - QAction* previewAutoPlayAction = popup.addAction(i18nc("@action:inmenu", "Auto-Play media files")); + QAction *previewAutoPlayAction = popup.addAction(i18nc("@action:inmenu", "Auto-Play media files")); previewAutoPlayAction->setIcon(QIcon::fromTheme(QStringLiteral("media-playback-start"))); previewAutoPlayAction->setCheckable(true); previewAutoPlayAction->setChecked(InformationPanelSettings::previewsAutoPlay()); - QAction* configureAction = popup.addAction(i18nc("@action:inmenu", "Configure...")); + QAction *configureAction = popup.addAction(i18nc("@action:inmenu", "Configure...")); configureAction->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); if (m_inConfigurationMode) { configureAction->setEnabled(false); } - QAction* dateformatAction = popup.addAction(i18nc("@action:inmenu", "Condensed Date")); + 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)); @@ -179,7 +179,7 @@ void InformationPanel::showContextMenu(const QPoint &pos) // Open the popup and adjust the settings for the // selected action. - QAction* action = popup.exec(pos); + QAction *action = popup.exec(pos); if (!action) { return; } @@ -238,15 +238,14 @@ void InformationPanel::showItemInfo() if (m_folderStatJob->uiDelegate()) { KJobWidgets::setWindow(m_folderStatJob, this); } - connect(m_folderStatJob, &KIO::Job::result, - this, &InformationPanel::slotFolderStatFinished); + connect(m_folderStatJob, &KIO::Job::result, this, &InformationPanel::slotFolderStatFinished); } } -void InformationPanel::slotFolderStatFinished(KJob* job) +void InformationPanel::slotFolderStatFinished(KJob *job) { m_folderStatJob = nullptr; - const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult(); + const KIO::UDSEntry entry = static_cast<KIO::StatJob *>(job)->statResult(); m_content->showItem(KFileItem(entry, m_shownUrl)); } @@ -270,7 +269,7 @@ void InformationPanel::reset() } } -void InformationPanel::slotFileRenamed(const QString& source, const QString& dest) +void InformationPanel::slotFileRenamed(const QString &source, const QString &dest) { auto sourceUrl = QUrl::fromUserInput(source); if (m_shownUrl == sourceUrl) { @@ -290,7 +289,7 @@ void InformationPanel::slotFileRenamed(const QString& source, const QString& des } } -void InformationPanel::slotFilesAdded(const QString& directory) +void InformationPanel::slotFilesAdded(const QString &directory) { if (m_shownUrl == QUrl::fromUserInput(directory)) { // If the 'trash' icon changes because the trash has been emptied or got filled, @@ -307,9 +306,9 @@ void InformationPanel::slotFilesItemChanged(const KFileItemList &changedFileItem } } -void InformationPanel::slotFilesChanged(const QStringList& files) +void InformationPanel::slotFilesChanged(const QStringList &files) { - for (const QString& fileName : files) { + for (const QString &fileName : files) { if (m_shownUrl == QUrl::fromUserInput(fileName)) { showItemInfo(); break; @@ -317,9 +316,9 @@ void InformationPanel::slotFilesChanged(const QStringList& files) } } -void InformationPanel::slotFilesRemoved(const QStringList& files) +void InformationPanel::slotFilesRemoved(const QStringList &files) { - for (const QString& fileName : files) { + for (const QString &fileName : files) { if (m_shownUrl == QUrl::fromUserInput(fileName)) { // the currently shown item has been removed, show // the parent directory as fallback @@ -329,12 +328,12 @@ void InformationPanel::slotFilesRemoved(const QStringList& files) } } -void InformationPanel::slotEnteredDirectory(const QString& directory) +void InformationPanel::slotEnteredDirectory(const QString &directory) { Q_UNUSED(directory) } -void InformationPanel::slotLeftDirectory(const QString& directory) +void InformationPanel::slotLeftDirectory(const QString &directory) { if (m_shownUrl == QUrl::fromUserInput(directory)) { // The signal 'leftDirectory' is also emitted when a media @@ -360,7 +359,7 @@ void InformationPanel::cancelRequest() m_urlCandidate.clear(); } -bool InformationPanel::isEqualToShownUrl(const QUrl& url) const +bool InformationPanel::isEqualToShownUrl(const QUrl &url) const { return m_shownUrl.matches(url, QUrl::StripTrailingSlash); } @@ -376,26 +375,22 @@ void InformationPanel::init() m_infoTimer = new QTimer(this); m_infoTimer->setInterval(300); m_infoTimer->setSingleShot(true); - connect(m_infoTimer, &QTimer::timeout, - this, &InformationPanel::slotInfoTimeout); + connect(m_infoTimer, &QTimer::timeout, this, &InformationPanel::slotInfoTimeout); m_urlChangedTimer = new QTimer(this); m_urlChangedTimer->setInterval(200); m_urlChangedTimer->setSingleShot(true); - connect(m_urlChangedTimer, &QTimer::timeout, - this, &InformationPanel::showItemInfo); + connect(m_urlChangedTimer, &QTimer::timeout, this, &InformationPanel::showItemInfo); m_resetUrlTimer = new QTimer(this); m_resetUrlTimer->setInterval(1000); m_resetUrlTimer->setSingleShot(true); - connect(m_resetUrlTimer, &QTimer::timeout, - this, &InformationPanel::reset); + connect(m_resetUrlTimer, &QTimer::timeout, this, &InformationPanel::reset); Q_ASSERT(m_urlChangedTimer->interval() < m_infoTimer->interval()); Q_ASSERT(m_urlChangedTimer->interval() < m_resetUrlTimer->interval()); - org::kde::KDirNotify* dirNotify = new org::kde::KDirNotify(QString(), QString(), - QDBusConnection::sessionBus(), this); + org::kde::KDirNotify *dirNotify = new org::kde::KDirNotify(QString(), QString(), QDBusConnection::sessionBus(), this); connect(dirNotify, &OrgKdeKDirNotifyInterface::FileRenamed, this, &InformationPanel::slotFileRenamed); connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesAdded, this, &InformationPanel::slotFilesAdded); connect(dirNotify, &OrgKdeKDirNotifyInterface::FilesChanged, this, &InformationPanel::slotFilesChanged); @@ -405,13 +400,14 @@ void InformationPanel::init() m_content = new InformationPanelContent(this); connect(m_content, &InformationPanelContent::urlActivated, this, &InformationPanel::urlActivated); - connect(m_content, &InformationPanelContent::configurationFinished, this, [this]() { m_inConfigurationMode = false; }); + connect(m_content, &InformationPanelContent::configurationFinished, this, [this]() { + m_inConfigurationMode = false; + }); connect(m_content, &InformationPanelContent::contextMenuRequested, this, &InformationPanel::showContextMenu); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_content); m_initialized = true; } - diff --git a/src/panels/information/informationpanel.h b/src/panels/information/informationpanel.h index b150948ca..ee405cb39 100644 --- a/src/panels/information/informationpanel.h +++ b/src/panels/information/informationpanel.h @@ -14,7 +14,7 @@ class InformationPanelContent; namespace KIO { - class Job; +class Job; } /** @@ -25,18 +25,18 @@ class InformationPanel : public Panel Q_OBJECT public: - explicit InformationPanel(QWidget* parent = nullptr); + explicit InformationPanel(QWidget *parent = nullptr); ~InformationPanel() override; Q_SIGNALS: - void urlActivated(const QUrl& url); + void urlActivated(const QUrl &url); public Q_SLOTS: /** * This is invoked to inform the panel that the user has selected a new * set of items. */ - void setSelection(const KFileItemList& selection); + void setSelection(const KFileItemList &selection); /** * Does a delayed request of information for the item \a item. @@ -44,7 +44,7 @@ public Q_SLOTS: * are invoked, then the request will be skipped. Requesting a delayed item information * makes sense when hovering items. */ - void requestDelayedItemInfo(const KFileItem& item); + void requestDelayedItemInfo(const KFileItem &item); void slotFilesItemChanged(const KFileItemList &changedFileItems); @@ -53,13 +53,13 @@ protected: bool urlChanged() override; /** @see QWidget::showEvent() */ - void showEvent(QShowEvent* event) override; + void showEvent(QShowEvent *event) override; /** @see QWidget::resizeEvent() */ - void resizeEvent(QResizeEvent* event) override; + void resizeEvent(QResizeEvent *event) override; /** @see QWidget::contextMenuEvent() */ - void contextMenuEvent(QContextMenuEvent* event) override; + void contextMenuEvent(QContextMenuEvent *event) override; private Q_SLOTS: /** @@ -72,7 +72,7 @@ private Q_SLOTS: * Shows the information for the currently displayed folder as a result from * a stat job issued in showItemInfo(). */ - void slotFolderStatFinished(KJob* job); + void slotFolderStatFinished(KJob *job); /** * Triggered if the request for item information has timed out. @@ -87,12 +87,12 @@ private Q_SLOTS: */ void reset(); - void slotFileRenamed(const QString& source, const QString& dest); - void slotFilesAdded(const QString& directory); - void slotFilesChanged(const QStringList& files); - void slotFilesRemoved(const QStringList& files); - void slotEnteredDirectory(const QString& directory); - void slotLeftDirectory(const QString& directory); + void slotFileRenamed(const QString &source, const QString &dest); + void slotFilesAdded(const QString &directory); + void slotFilesChanged(const QStringList &files); + void slotFilesRemoved(const QStringList &files); + void slotEnteredDirectory(const QString &directory); + void slotLeftDirectory(const QString &directory); private: /** Assures that any pending item information request is cancelled. */ @@ -101,7 +101,7 @@ private: /** * Returns true, if \a url is equal to the shown URL m_shownUrl. */ - bool isEqualToShownUrl(const QUrl& url) const; + bool isEqualToShownUrl(const QUrl &url) const; /** * Marks the URL as invalid and will reset the Information Panel @@ -121,9 +121,9 @@ private: private: bool m_initialized; - QTimer* m_infoTimer; - QTimer* m_urlChangedTimer; - QTimer* m_resetUrlTimer; + QTimer *m_infoTimer; + QTimer *m_urlChangedTimer; + QTimer *m_resetUrlTimer; // URL that is currently shown in the Information Panel. QUrl m_shownUrl; @@ -141,9 +141,9 @@ private: KFileItem m_hoveredItem; KFileItemList m_selection; - KIO::Job* m_folderStatJob; + KIO::Job *m_folderStatJob; - InformationPanelContent* m_content; + InformationPanelContent *m_content; bool m_inConfigurationMode = false; }; diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index f1379f961..725ef785b 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -6,8 +6,8 @@ #include "informationpanelcontent.h" -#include <KIO/PreviewJob> #include <KConfigGroup> +#include <KIO/PreviewJob> #include <KIconEffect> #include <KIconLoader> #include <KJobWidgets> @@ -45,17 +45,17 @@ const int PLAY_ARROW_SIZE = 24; const int PLAY_ARROW_BORDER_SIZE = 2; -InformationPanelContent::InformationPanelContent(QWidget* parent) : - QWidget(parent), - m_item(), - m_previewJob(nullptr), - m_outdatedPreviewTimer(nullptr), - m_preview(nullptr), - m_phononWidget(nullptr), - m_nameLabel(nullptr), - m_metaDataWidget(nullptr), - m_metaDataArea(nullptr), - m_isVideo(false) +InformationPanelContent::InformationPanelContent(QWidget *parent) + : QWidget(parent) + , m_item() + , m_previewJob(nullptr) + , m_outdatedPreviewTimer(nullptr) + , m_preview(nullptr) + , m_phononWidget(nullptr) + , m_nameLabel(nullptr) + , m_metaDataWidget(nullptr) + , m_metaDataArea(nullptr) + , m_isVideo(false) { parent->installEventFilter(this); @@ -65,10 +65,9 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) : m_outdatedPreviewTimer = new QTimer(this); m_outdatedPreviewTimer->setInterval(100); m_outdatedPreviewTimer->setSingleShot(true); - connect(m_outdatedPreviewTimer, &QTimer::timeout, - this, &InformationPanelContent::markOutdatedPreview); + connect(m_outdatedPreviewTimer, &QTimer::timeout, this, &InformationPanelContent::markOutdatedPreview); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); // preview const int minPreviewWidth = KIconLoader::SizeEnormous + KIconLoader::SizeMedium; @@ -81,8 +80,7 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) : m_phononWidget->hide(); m_phononWidget->setMinimumWidth(minPreviewWidth); m_phononWidget->setAutoPlay(InformationPanelSettings::previewsAutoPlay()); - connect(m_phononWidget, &PhononWidget::hasVideoChanged, - this, &InformationPanelContent::slotHasVideoChanged); + connect(m_phononWidget, &PhononWidget::hasVideoChanged, this, &InformationPanelContent::slotHasVideoChanged); // name m_nameLabel = new QLabel(parent); @@ -99,40 +97,36 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) : m_metaDataWidget = new Baloo::FileMetaDataWidget(parent); m_metaDataWidget->setDateFormat(static_cast<Baloo::DateFormats>(InformationPanelSettings::dateFormat())); - connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, - this, &InformationPanelContent::urlActivated); + connect(m_metaDataWidget, &Baloo::FileMetaDataWidget::urlActivated, this, &InformationPanelContent::urlActivated); m_metaDataWidget->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); m_metaDataWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); // Configuration - m_configureLabel = new QLabel(i18nc("@label::textbox", - "Select which data should be shown:"), this); + m_configureLabel = new QLabel(i18nc("@label::textbox", "Select which data should be shown:"), this); m_configureLabel->setWordWrap(true); m_configureLabel->setVisible(false); m_configureButtons = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel); m_configureButtons->setVisible(false); connect(m_configureButtons, &QDialogButtonBox::accepted, this, [this]() { - m_metaDataWidget->setConfigurationMode(Baloo::ConfigurationMode::Accept); - m_configureButtons->setVisible(false); - m_configureLabel->setVisible(false); - Q_EMIT configurationFinished(); - } - ); + m_metaDataWidget->setConfigurationMode(Baloo::ConfigurationMode::Accept); + m_configureButtons->setVisible(false); + m_configureLabel->setVisible(false); + Q_EMIT configurationFinished(); + }); connect(m_configureButtons, &QDialogButtonBox::rejected, this, [this]() { - m_metaDataWidget->setConfigurationMode(Baloo::ConfigurationMode::Cancel); - m_configureButtons->setVisible(false); - m_configureLabel->setVisible(false); - Q_EMIT configurationFinished(); - } - ); + m_metaDataWidget->setConfigurationMode(Baloo::ConfigurationMode::Cancel); + m_configureButtons->setVisible(false); + m_configureLabel->setVisible(false); + Q_EMIT configurationFinished(); + }); m_metaDataArea = new QScrollArea(parent); m_metaDataArea->setWidget(m_metaDataWidget); m_metaDataArea->setWidgetResizable(true); m_metaDataArea->setFrameShape(QFrame::NoFrame); - QWidget* viewport = m_metaDataArea->viewport(); + QWidget *viewport = m_metaDataArea->viewport(); QScroller::grabGesture(viewport, QScroller::TouchGesture); viewport->installEventFilter(this); @@ -152,7 +146,7 @@ InformationPanelContent::~InformationPanelContent() InformationPanelSettings::self()->save(); } -void InformationPanelContent::showItem(const KFileItem& item) +void InformationPanelContent::showItem(const KFileItem &item) { // compares item entries, comparing items only compares urls if (m_item.entry() != item.entry()) { @@ -181,19 +175,15 @@ void InformationPanelContent::refreshPixmapView() const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings"); const QStringList plugins = globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins()); - m_previewJob = new KIO::PreviewJob(KFileItemList() << m_item, - QSize(m_preview->width(), m_preview->height()), - &plugins); + 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() && !m_item.isSlow()); 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); } void InformationPanelContent::refreshPreview() @@ -207,7 +197,6 @@ void InformationPanelContent::refreshPreview() m_preview->setCursor(Qt::ArrowCursor); setNameLabelText(m_item.text()); if (InformationPanelSettings::previewsShown()) { - const QUrl itemUrl = m_item.url(); const bool isSearchUrl = itemUrl.scheme().contains(QLatin1String("search")) && m_item.localPath().isEmpty(); if (isSearchUrl) { @@ -216,11 +205,8 @@ void InformationPanelContent::refreshPreview() // 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("baloo")).pixmap(m_preview->height(), m_preview->width()) - ); + m_preview->setPixmap(QIcon::fromTheme(QStringLiteral("baloo")).pixmap(m_preview->height(), m_preview->width())); } else { - refreshPixmapView(); const QString mimeType = m_item.mimetype(); @@ -238,12 +224,9 @@ void InformationPanelContent::refreshPreview() // we don't need to update the preview/phonon widget states // unless the previewed file has changed, // or the setting previewshown has changed - if ((m_phononWidget->state() != Phonon::State::PlayingState && - m_phononWidget->state() != Phonon::State::PausedState && - m_phononWidget->state() != Phonon::State::StoppedState) || - m_item.targetUrl() != m_phononWidget->url() || - (!m_preview->isVisible() &&! m_phononWidget->isVisible())) { - + if ((m_phononWidget->state() != Phonon::State::PlayingState && m_phononWidget->state() != Phonon::State::PausedState + && m_phononWidget->state() != Phonon::State::StoppedState) + || m_item.targetUrl() != m_phononWidget->url() || (!m_preview->isVisible() && !m_phononWidget->isVisible())) { if (InformationPanelSettings::previewsAutoPlay() && m_isVideo) { // hides the preview now to avoid flickering when the autoplay video starts m_preview->hide(); @@ -287,7 +270,7 @@ void InformationPanelContent::refreshMetaData() m_metaDataWidget->setItems(KFileItemList() << m_item); } -void InformationPanelContent::showItems(const KFileItemList& items) +void InformationPanelContent::showItems(const KFileItemList &items) { // 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). @@ -297,9 +280,7 @@ void InformationPanelContent::showItems(const KFileItemList& items) m_preview->stopAnimatedImage(); - m_preview->setPixmap( - QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(m_preview->height(), m_preview->width()) - ); + m_preview->setPixmap(QIcon::fromTheme(QStringLiteral("dialog-information")).pixmap(m_preview->height(), m_preview->width())); setNameLabelText(i18ncp("@label", "%1 item selected", "%1 items selected", items.count())); m_metaDataWidget->setItems(items); @@ -309,11 +290,11 @@ void InformationPanelContent::showItems(const KFileItemList& items) m_item = KFileItem(); } -bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event) +bool InformationPanelContent::eventFilter(QObject *obj, QEvent *event) { switch (event->type()) { case QEvent::Resize: { - QResizeEvent* resizeEvent = static_cast<QResizeEvent*>(event); + QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event); if (obj == m_metaDataArea->viewport()) { // The size of the meta text area has changed. Adjust the fixed // width in a way that no horizontal scrollbar needs to be shown. @@ -339,22 +320,22 @@ bool InformationPanelContent::eventFilter(QObject* obj, QEvent* event) return QWidget::eventFilter(obj, event); } -bool InformationPanelContent::event(QEvent* event) +bool InformationPanelContent::event(QEvent *event) { if (event->type() == QEvent::Gesture) { - gestureEvent(static_cast<QGestureEvent*>(event)); + gestureEvent(static_cast<QGestureEvent *>(event)); return true; } return QWidget::event(event); } -bool InformationPanelContent::gestureEvent(QGestureEvent* event) +bool InformationPanelContent::gestureEvent(QGestureEvent *event) { if (!underMouse()) { return false; } - QTapAndHoldGesture* tap = static_cast<QTapAndHoldGesture*>(event->gesture(Qt::TapAndHoldGesture)); + QTapAndHoldGesture *tap = static_cast<QTapAndHoldGesture *>(event->gesture(Qt::TapAndHoldGesture)); if (tap) { if (tap->state() == Qt::GestureFinished) { @@ -366,7 +347,7 @@ bool InformationPanelContent::gestureEvent(QGestureEvent* event) return false; } -void InformationPanelContent::showIcon(const KFileItem& item) +void InformationPanelContent::showIcon(const KFileItem &item) { m_outdatedPreviewTimer->stop(); QPixmap pixmap = QIcon::fromTheme(item.iconName()).pixmap(m_preview->height(), m_preview->width()); @@ -374,8 +355,7 @@ void InformationPanelContent::showIcon(const KFileItem& item) m_preview->setPixmap(pixmap); } -void InformationPanelContent::showPreview(const KFileItem& item, - const QPixmap& pixmap) +void InformationPanelContent::showPreview(const KFileItem &item, const QPixmap &pixmap) { m_outdatedPreviewTimer->stop(); @@ -400,8 +380,7 @@ void InformationPanelContent::showPreview(const KFileItem& item, QPainterPath path; path.addPolygon(arrow); - QLinearGradient gradient(QPointF(zeroX, zeroY + arrowSize / 2), - QPointF(zeroX + arrowSize, zeroY + arrowSize / 2)); + QLinearGradient gradient(QPointF(zeroX, zeroY + arrowSize / 2), QPointF(zeroX + arrowSize, zeroY + arrowSize / 2)); QColor whiteColor = Qt::white; QColor blackColor = Qt::black; @@ -432,9 +411,7 @@ void InformationPanelContent::markOutdatedPreview() showIcon(m_item); } else { KIconEffect *iconEffect = KIconLoader::global()->iconEffect(); - QPixmap disabledPixmap = iconEffect->apply(m_preview->pixmap(), - KIconLoader::Desktop, - KIconLoader::DisabledState); + QPixmap disabledPixmap = iconEffect->apply(m_preview->pixmap(), KIconLoader::Desktop, KIconLoader::DisabledState); m_preview->setPixmap(disabledPixmap); } } @@ -454,11 +431,12 @@ void InformationPanelContent::slotHasVideoChanged(bool hasVideo) } } -void InformationPanelContent::setPreviewAutoPlay(bool autoPlay) { +void InformationPanelContent::setPreviewAutoPlay(bool autoPlay) +{ m_phononWidget->setAutoPlay(autoPlay); } -void InformationPanelContent::setNameLabelText(const QString& text) +void InformationPanelContent::setNameLabelText(const QString &text) { QTextOption textOption; textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); @@ -511,4 +489,3 @@ void InformationPanelContent::adjustWidgetSizes(int width) m_phononWidget->setVideoSize(QSize(maxWidth, maxWidth)); } } - diff --git a/src/panels/information/informationpanelcontent.h b/src/panels/information/informationpanelcontent.h index b2007b0aa..0ea05d990 100644 --- a/src/panels/information/informationpanelcontent.h +++ b/src/panels/information/informationpanelcontent.h @@ -7,8 +7,8 @@ #ifndef INFORMATIONPANELCONTENT_H #define INFORMATIONPANELCONTENT_H -#include <KFileItem> #include "config-dolphin.h" +#include <KFileItem> #include <QPointer> #include <QUrl> @@ -24,12 +24,14 @@ class QLabel; class QScrollArea; class QGestureEvent; -namespace KIO { - class PreviewJob; +namespace KIO +{ +class PreviewJob; } -namespace Baloo { - class FileMetaDataWidget; +namespace Baloo +{ +class FileMetaDataWidget; } /** @@ -41,7 +43,7 @@ class InformationPanelContent : public QWidget Q_OBJECT public: - explicit InformationPanelContent(QWidget* parent = nullptr); + explicit InformationPanelContent(QWidget *parent = nullptr); ~InformationPanelContent() override; /** @@ -49,12 +51,12 @@ public: * The preview of the item is generated asynchronously, * the other meta information are fetched synchronously. */ - void showItem(const KFileItem& item); + void showItem(const KFileItem &item); /** * Shows the meta information for the items \p items and its preview */ - void showItems(const KFileItemList& items); + void showItems(const KFileItemList &items); KFileItemList items(); @@ -76,9 +78,9 @@ public: void setPreviewAutoPlay(bool autoPlay); Q_SIGNALS: - void urlActivated( const QUrl& url ); + void urlActivated(const QUrl &url); void configurationFinished(); - void contextMenuRequested(const QPoint& pos); + void contextMenuRequested(const QPoint &pos); public Q_SLOTS: /** @@ -89,22 +91,22 @@ public Q_SLOTS: protected: /** @see QObject::eventFilter() */ - bool eventFilter(QObject* obj, QEvent* event) override; + bool eventFilter(QObject *obj, QEvent *event) override; - bool event(QEvent * event) override; + bool event(QEvent *event) override; private Q_SLOTS: /** * Is invoked if no preview is available for the item. In this * case the icon will be shown. */ - void showIcon(const KFileItem& item); + void showIcon(const KFileItem &item); /** * Is invoked if a preview is available for the item. The preview * \a pixmap is shown inside the info page. */ - void showPreview(const KFileItem& item, const QPixmap& pixmap); + void showPreview(const KFileItem &item, const QPixmap &pixmap); /** * Marks the currently shown preview as outdated @@ -121,7 +123,7 @@ private: * label width (QLabel::setWordWrap() does not work if the * text represents one extremely long word). */ - void setNameLabelText(const QString& text); + void setNameLabelText(const QString &text); /** * Adjusts the sizes of the widgets dependent on the available @@ -134,21 +136,21 @@ private: */ void refreshPixmapView(); - bool gestureEvent(QGestureEvent* event); + bool gestureEvent(QGestureEvent *event); private: KFileItem m_item; QPointer<KIO::PreviewJob> m_previewJob; - QTimer* m_outdatedPreviewTimer; + QTimer *m_outdatedPreviewTimer; - PixmapViewer* m_preview; - PhononWidget* m_phononWidget; - QLabel* m_nameLabel; - Baloo::FileMetaDataWidget* m_metaDataWidget; - QScrollArea* m_metaDataArea; - QLabel* m_configureLabel; - QDialogButtonBox* m_configureButtons; + PixmapViewer *m_preview; + PhononWidget *m_phononWidget; + QLabel *m_nameLabel; + Baloo::FileMetaDataWidget *m_metaDataWidget; + QScrollArea *m_metaDataArea; + QLabel *m_configureLabel; + QDialogButtonBox *m_configureButtons; bool m_isVideo; }; diff --git a/src/panels/information/phononwidget.cpp b/src/panels/information/phononwidget.cpp index c9ccaa86c..2993e826e 100644 --- a/src/panels/information/phononwidget.cpp +++ b/src/panels/information/phononwidget.cpp @@ -21,37 +21,37 @@ class EmbeddedVideoPlayer : public Phonon::VideoWidget { Q_OBJECT - public: - EmbeddedVideoPlayer(QWidget *parent = nullptr) : - Phonon::VideoWidget(parent) - { - } +public: + EmbeddedVideoPlayer(QWidget *parent = nullptr) + : Phonon::VideoWidget(parent) + { + } - void setSizeHint(const QSize& size) - { - m_sizeHint = size; - updateGeometry(); - } + void setSizeHint(const QSize &size) + { + m_sizeHint = size; + updateGeometry(); + } - QSize sizeHint() const override - { - return m_sizeHint.isValid() ? m_sizeHint : Phonon::VideoWidget::sizeHint(); - } + QSize sizeHint() const override + { + return m_sizeHint.isValid() ? m_sizeHint : Phonon::VideoWidget::sizeHint(); + } - private: - QSize m_sizeHint; +private: + QSize m_sizeHint; }; PhononWidget::PhononWidget(QWidget *parent) - : QWidget(parent), - m_url(), - m_playButton(nullptr), - m_pauseButton(nullptr), - m_topLayout(nullptr), - m_media(nullptr), - m_seekSlider(nullptr), - m_audioOutput(nullptr), - m_videoPlayer(nullptr) + : QWidget(parent) + , m_url() + , m_playButton(nullptr) + , m_pauseButton(nullptr) + , m_topLayout(nullptr) + , m_media(nullptr) + , m_seekSlider(nullptr) + , m_audioOutput(nullptr) + , m_videoPlayer(nullptr) { } @@ -99,7 +99,7 @@ bool PhononWidget::eventFilter(QObject *object, QEvent *event) { Q_UNUSED(object) if (event->type() == QEvent::MouseButtonPress) { - const QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); + const QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); if (mouseEvent->button() == Qt::LeftButton) { // toggle playback togglePlayback(); @@ -109,7 +109,7 @@ bool PhononWidget::eventFilter(QObject *object, QEvent *event) return false; } -void PhononWidget::setVideoSize(const QSize& size) +void PhononWidget::setVideoSize(const QSize &size) { if (m_videoSize != size) { m_videoSize = size; @@ -201,10 +201,8 @@ void PhononWidget::play() { if (!m_media) { m_media = new Phonon::MediaObject(this); - connect(m_media, &Phonon::MediaObject::stateChanged, - this, &PhononWidget::stateChanged); - connect(m_media, &Phonon::MediaObject::finished, - this, &PhononWidget::finished); + connect(m_media, &Phonon::MediaObject::stateChanged, this, &PhononWidget::stateChanged); + connect(m_media, &Phonon::MediaObject::finished, this, &PhononWidget::finished); m_seekSlider->setMediaObject(m_media); } diff --git a/src/panels/information/phononwidget.h b/src/panels/information/phononwidget.h index 5510b0544..4662e47af 100644 --- a/src/panels/information/phononwidget.h +++ b/src/panels/information/phononwidget.h @@ -15,10 +15,10 @@ namespace Phonon { - class AudioOutput; - class MediaObject; - class SeekSlider; - class VideoPlayer; +class AudioOutput; +class MediaObject; +class SeekSlider; +class VideoPlayer; } // namespace Phonon class EmbeddedVideoPlayer; @@ -28,68 +28,64 @@ class QVBoxLayout; class PhononWidget : public QWidget { Q_OBJECT - public: +public: + enum MediaKind { Video, Audio }; - enum MediaKind { - Video, - Audio - }; + explicit PhononWidget(QWidget *parent = nullptr); - explicit PhononWidget(QWidget *parent = nullptr); + void setUrl(const QUrl &url, MediaKind kind); + QUrl url() const; + void clearUrl(); - void setUrl(const QUrl &url, MediaKind kind); - QUrl url() const; - void clearUrl(); + void setVideoSize(const QSize &size); + QSize videoSize() const; + Phonon::State state() const; - void setVideoSize(const QSize& size); - QSize videoSize() const; - Phonon::State state() const; + void setAutoPlay(bool autoPlay); + bool eventFilter(QObject *object, QEvent *event) override; - void setAutoPlay(bool autoPlay); - bool eventFilter(QObject *object, QEvent *event) override; +Q_SIGNALS: + /** + * Is emitted whenever the video-state + * has changed: If true is returned, a video + * including control-buttons will be shown. + * If false is returned, no video is shown + * and the control-buttons are available for + * audio only. + */ + void hasVideoChanged(bool hasVideo); - Q_SIGNALS: - /** - * Is emitted whenever the video-state - * has changed: If true is returned, a video - * including control-buttons will be shown. - * If false is returned, no video is shown - * and the control-buttons are available for - * audio only. - */ - void hasVideoChanged(bool hasVideo); +public Q_SLOTS: + void play(); - public Q_SLOTS: - void play(); +protected: + void showEvent(QShowEvent *event) override; + void hideEvent(QHideEvent *event) override; - protected: - void showEvent(QShowEvent *event) override; - void hideEvent(QHideEvent *event) override; +private Q_SLOTS: + void stateChanged(Phonon::State newstate); + void stop(); + void finished(); - private Q_SLOTS: - void stateChanged(Phonon::State newstate); - void stop(); - void finished(); +private: + void applyVideoSize(); - private: - void applyVideoSize(); +private: + void togglePlayback(); - private: - void togglePlayback(); + QUrl m_url; + QSize m_videoSize; - QUrl m_url; - QSize m_videoSize; + QToolButton *m_playButton; + QToolButton *m_pauseButton; - QToolButton *m_playButton; - QToolButton *m_pauseButton; - - QVBoxLayout *m_topLayout; - Phonon::MediaObject *m_media; - Phonon::SeekSlider *m_seekSlider; - Phonon::AudioOutput *m_audioOutput; - EmbeddedVideoPlayer *m_videoPlayer; - bool m_autoPlay; - bool m_isVideo; + QVBoxLayout *m_topLayout; + Phonon::MediaObject *m_media; + Phonon::SeekSlider *m_seekSlider; + Phonon::AudioOutput *m_audioOutput; + EmbeddedVideoPlayer *m_videoPlayer; + bool m_autoPlay; + bool m_isVideo; }; #endif // PHONONWIDGET_H diff --git a/src/panels/information/pixmapviewer.cpp b/src/panels/information/pixmapviewer.cpp index 1f072641e..7eca876c8 100644 --- a/src/panels/information/pixmapviewer.cpp +++ b/src/panels/information/pixmapviewer.cpp @@ -13,13 +13,13 @@ #include <QPainter> #include <QStyle> -PixmapViewer::PixmapViewer(QWidget* parent, Transition transition) : - QWidget(parent), - m_animatedImage(nullptr), - m_transition(transition), - m_animationStep(0), - m_sizeHint(), - m_hasAnimatedImage(false) +PixmapViewer::PixmapViewer(QWidget *parent, Transition transition) + : QWidget(parent) + , m_animatedImage(nullptr) + , m_transition(transition) + , m_animationStep(0) + , m_sizeHint() + , m_hasAnimatedImage(false) { setMinimumWidth(KIconLoader::SizeEnormous); setMinimumHeight(KIconLoader::SizeEnormous); @@ -37,7 +37,7 @@ PixmapViewer::~PixmapViewer() { } -void PixmapViewer::setPixmap(const QPixmap& pixmap) +void PixmapViewer::setPixmap(const QPixmap &pixmap) { if (pixmap.isNull()) { return; @@ -61,8 +61,7 @@ void PixmapViewer::setPixmap(const QPixmap& pixmap) m_pixmap = pixmap; update(); - const bool animateTransition = (m_transition != NoTransition) && - (m_pixmap.size() != m_oldPixmap.size()); + const bool animateTransition = (m_transition != NoTransition) && (m_pixmap.size() != m_oldPixmap.size()); if (animateTransition) { m_animation.start(); } else if (m_hasAnimatedImage) { @@ -75,7 +74,7 @@ void PixmapViewer::setPixmap(const QPixmap& pixmap) } } -void PixmapViewer::setSizeHint(const QSize& size) +void PixmapViewer::setSizeHint(const QSize &size) { if (m_animatedImage && size != m_sizeHint) { m_animatedImage->stop(); @@ -105,7 +104,6 @@ void PixmapViewer::setAnimatedImageFileName(const QString &fileName) m_hasAnimatedImage = m_animatedImage->isValid() && (m_animatedImage->frameCount() > 1); } - QString PixmapViewer::animatedImageFileName() const { if (!m_hasAnimatedImage) { @@ -114,7 +112,7 @@ QString PixmapViewer::animatedImageFileName() const return m_animatedImage->fileName(); } -void PixmapViewer::paintEvent(QPaintEvent* event) +void PixmapViewer::paintEvent(QPaintEvent *event) { QWidget::paintEvent(event); @@ -122,17 +120,13 @@ void PixmapViewer::paintEvent(QPaintEvent* event) if (m_transition != NoTransition || (m_hasAnimatedImage && m_animatedImage->state() != QMovie::Running)) { const float value = m_animation.currentValue(); - const int scaledWidth = static_cast<int>((m_oldPixmap.width() * (1.0 - value)) + (m_pixmap.width() * value)); + const int scaledWidth = static_cast<int>((m_oldPixmap.width() * (1.0 - value)) + (m_pixmap.width() * value)); const int scaledHeight = static_cast<int>((m_oldPixmap.height() * (1.0 - value)) + (m_pixmap.height() * value)); - const bool useOldPixmap = (m_transition == SizeTransition) && - (m_oldPixmap.width() > m_pixmap.width()); - const QPixmap& largePixmap = useOldPixmap ? m_oldPixmap : m_pixmap; + const bool useOldPixmap = (m_transition == SizeTransition) && (m_oldPixmap.width() > m_pixmap.width()); + const QPixmap &largePixmap = useOldPixmap ? m_oldPixmap : m_pixmap; if (!largePixmap.isNull()) { - const QPixmap scaledPixmap = largePixmap.scaled(scaledWidth, - scaledHeight, - Qt::IgnoreAspectRatio, - Qt::FastTransformation); + const QPixmap scaledPixmap = largePixmap.scaled(scaledWidth, scaledHeight, Qt::IgnoreAspectRatio, Qt::FastTransformation); style()->drawItemPixmap(&painter, rect(), Qt::AlignCenter, scaledPixmap); } @@ -159,7 +153,7 @@ void PixmapViewer::checkPendingPixmaps() void PixmapViewer::updateAnimatedImageFrame() { - Q_ASSERT (m_animatedImage); + Q_ASSERT(m_animatedImage); m_pixmap = m_animatedImage->currentPixmap(); update(); @@ -176,6 +170,7 @@ void PixmapViewer::stopAnimatedImage() bool PixmapViewer::isAnimatedMimeType(const QString &mimeType) { const QList<QByteArray> imageFormats = QImageReader::imageFormatsForMimeType(mimeType.toUtf8()); - return std::any_of(imageFormats.begin(), imageFormats.end(), - [](const QByteArray &format){ return QMovie::supportedFormats().contains(format); }); + return std::any_of(imageFormats.begin(), imageFormats.end(), [](const QByteArray &format) { + return QMovie::supportedFormats().contains(format); + }); } diff --git a/src/panels/information/pixmapviewer.h b/src/panels/information/pixmapviewer.h index 6e0fa3e67..32c06fe15 100644 --- a/src/panels/information/pixmapviewer.h +++ b/src/panels/information/pixmapviewer.h @@ -26,8 +26,7 @@ class PixmapViewer : public QWidget Q_OBJECT public: - enum Transition - { + enum Transition { /** No transition is done when the pixmap is changed. */ NoTransition, @@ -47,21 +46,20 @@ public: SizeTransition }; - explicit PixmapViewer(QWidget* parent, - Transition transition = DefaultTransition); + explicit PixmapViewer(QWidget *parent, Transition transition = DefaultTransition); ~PixmapViewer() override; - void setPixmap(const QPixmap& pixmap); + void setPixmap(const QPixmap &pixmap); QPixmap pixmap() const; /** * Sets the size hint to \a size and triggers a relayout * of the parent widget. Per default no size hint is given. */ - void setSizeHint(const QSize& size); + void setSizeHint(const QSize &size); QSize sizeHint() const override; - void setAnimatedImageFileName(const QString& fileName); + void setAnimatedImageFileName(const QString &fileName); QString animatedImageFileName() const; void stopAnimatedImage(); @@ -72,7 +70,7 @@ public: static bool isAnimatedMimeType(const QString &mimeType); protected: - void paintEvent(QPaintEvent* event) override; + void paintEvent(QPaintEvent *event) override; private Q_SLOTS: void checkPendingPixmaps(); @@ -81,7 +79,7 @@ private Q_SLOTS: private: QPixmap m_pixmap; QPixmap m_oldPixmap; - QMovie* m_animatedImage; + QMovie *m_animatedImage; QQueue<QPixmap> m_pendingPixmaps; QTimeLine m_animation; Transition m_transition; @@ -95,5 +93,4 @@ inline QPixmap PixmapViewer::pixmap() const return m_pixmap; } - #endif |
