From 38c34eeca315c7be58e65d4d3fb72aaf7b866719 Mon Sep 17 00:00:00 2001 From: Serg Podtynnyi Date: Sat, 4 Feb 2023 00:14:53 +0700 Subject: Add clang-format and format code as in Frameworks --- src/panels/folders/foldersitemlistwidget.cpp | 5 +- src/panels/folders/foldersitemlistwidget.h | 4 +- src/panels/folders/folderspanel.cpp | 61 +++++----- src/panels/folders/folderspanel.h | 31 +++-- src/panels/folders/treeviewcontextmenu.cpp | 51 ++++---- src/panels/folders/treeviewcontextmenu.h | 9 +- src/panels/information/informationpanel.cpp | 94 ++++++++------- src/panels/information/informationpanel.h | 42 +++---- src/panels/information/informationpanelcontent.cpp | 125 ++++++++------------ src/panels/information/informationpanelcontent.h | 52 +++++---- src/panels/information/phononwidget.cpp | 60 +++++----- src/panels/information/phononwidget.h | 128 ++++++++++----------- src/panels/information/pixmapviewer.cpp | 43 +++---- src/panels/information/pixmapviewer.h | 17 ++- src/panels/panel.cpp | 16 ++- src/panels/panel.h | 8 +- src/panels/places/placespanel.cpp | 21 ++-- src/panels/places/placespanel.h | 20 ++-- src/panels/terminal/terminalpanel.cpp | 69 ++++++----- src/panels/terminal/terminalpanel.h | 42 +++---- 20 files changed, 419 insertions(+), 479 deletions(-) (limited to 'src/panels') diff --git a/src/panels/folders/foldersitemlistwidget.cpp b/src/panels/folders/foldersitemlistwidget.cpp index 5d5fcbff6..1a3ba50ef 100644 --- a/src/panels/folders/foldersitemlistwidget.cpp +++ b/src/panels/folders/foldersitemlistwidget.cpp @@ -6,8 +6,8 @@ #include "foldersitemlistwidget.h" -FoldersItemListWidget::FoldersItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) : - KFileItemListWidget(informant, parent) +FoldersItemListWidget::FoldersItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent) + : KFileItemListWidget(informant, parent) { } @@ -19,4 +19,3 @@ QPalette::ColorRole FoldersItemListWidget::normalTextColorRole() const { return QPalette::WindowText; } - diff --git a/src/panels/folders/foldersitemlistwidget.h b/src/panels/folders/foldersitemlistwidget.h index 5e437cd95..7c8eabf44 100644 --- a/src/panels/folders/foldersitemlistwidget.h +++ b/src/panels/folders/foldersitemlistwidget.h @@ -17,7 +17,7 @@ class FoldersItemListWidget : public KFileItemListWidget Q_OBJECT public: - FoldersItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent); + FoldersItemListWidget(KItemListWidgetInformant *informant, QGraphicsItem *parent); ~FoldersItemListWidget() override; protected: @@ -25,5 +25,3 @@ protected: }; #endif - - diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp index d9cc6128c..914692000 100644 --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -19,12 +19,12 @@ #include "treeviewcontextmenu.h" #include "views/draganddrophelper.h" -#include -#include #include #include #include #include +#include +#include #include #include @@ -33,11 +33,11 @@ #include #include -FoldersPanel::FoldersPanel(QWidget* parent) : - Panel(parent), - m_updateCurrentItem(false), - m_controller(nullptr), - m_model(nullptr) +FoldersPanel::FoldersPanel(QWidget *parent) + : Panel(parent) + , m_updateCurrentItem(false) + , m_controller(nullptr) + , m_model(nullptr) { setLayoutDirection(Qt::LeftToRight); } @@ -47,7 +47,7 @@ FoldersPanel::~FoldersPanel() FoldersPanelSettings::self()->save(); if (m_controller) { - KItemListView* view = m_controller->view(); + KItemListView *view = m_controller->view(); m_controller->setView(nullptr); delete view; } @@ -86,13 +86,13 @@ bool FoldersPanel::autoScrolling() const return FoldersPanelSettings::autoScrolling(); } -void FoldersPanel::rename(const KFileItem& item) +void FoldersPanel::rename(const KFileItem &item) { if (GeneralSettings::renameInline()) { const int index = m_model->index(item); m_controller->view()->editRole(index, "text"); } else { - KIO::RenameFileDialog* dialog = new KIO::RenameFileDialog(KFileItemList({item}), this); + KIO::RenameFileDialog *dialog = new KIO::RenameFileDialog(KFileItemList({item}), this); dialog->open(); } } @@ -119,8 +119,7 @@ void FoldersPanel::reloadTree() } } - -void FoldersPanel::showEvent(QShowEvent* event) +void FoldersPanel::showEvent(QShowEvent *event) { if (event->spontaneous()) { Panel::showEvent(event); @@ -131,7 +130,7 @@ void FoldersPanel::showEvent(QShowEvent* event) // Postpone the creating of the controller to the first show event. // This assures that no performance and memory overhead is given when the folders panel is not // used at all and stays invisible. - KFileItemListView* view = new KFileItemListView(); + KFileItemListView *view = new KFileItemListView(); view->setScanDirectories(false); view->setWidgetCreator(new KItemListWidgetCreator()); view->setSupportsItemExpanding(true); @@ -140,8 +139,7 @@ void FoldersPanel::showEvent(QShowEvent* event) // opening the folders panel. view->setOpacity(0); - connect(view, &KFileItemListView::roleEditingFinished, - this, &FoldersPanel::slotRoleEditingFinished); + connect(view, &KFileItemListView::roleEditingFinished, this, &FoldersPanel::slotRoleEditingFinished); m_model = new KFileItemModel(this); m_model->setShowDirectoriesOnly(true); @@ -163,10 +161,10 @@ void FoldersPanel::showEvent(QShowEvent* event) connect(m_controller, &KItemListController::viewContextMenuRequested, this, &FoldersPanel::slotViewContextMenuRequested); connect(m_controller, &KItemListController::itemDropEvent, this, &FoldersPanel::slotItemDropEvent); - KItemListContainer* container = new KItemListContainer(m_controller, this); + KItemListContainer *container = new KItemListContainer(m_controller, this); container->setEnabledFrame(false); - QVBoxLayout* layout = new QVBoxLayout(this); + QVBoxLayout *layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(container); } @@ -175,7 +173,7 @@ void FoldersPanel::showEvent(QShowEvent* event) Panel::showEvent(event); } -void FoldersPanel::keyPressEvent(QKeyEvent* event) +void FoldersPanel::keyPressEvent(QKeyEvent *event) { const int key = event->key(); if ((key == Qt::Key_Enter) || (key == Qt::Key_Return)) { @@ -219,7 +217,7 @@ void FoldersPanel::slotItemMiddleClicked(int index) } } -void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF& pos) +void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF &pos) { const KFileItem fileItem = m_model->fileItem(index); @@ -230,7 +228,7 @@ void FoldersPanel::slotItemContextMenuRequested(int index, const QPointF& pos) } } -void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos) +void FoldersPanel::slotViewContextMenuRequested(const QPointF &pos) { QPointer contextMenu = new TreeViewContextMenu(this, KFileItem()); contextMenu.data()->open(pos.toPoint()); @@ -239,7 +237,7 @@ void FoldersPanel::slotViewContextMenuRequested(const QPointF& pos) } } -void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event) +void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent *event) { if (index >= 0) { KFileItem destItem = m_model->fileItem(index); @@ -247,11 +245,7 @@ void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* eve return; } - QDropEvent dropEvent(event->pos().toPoint(), - event->possibleActions(), - event->mimeData(), - event->buttons(), - event->modifiers()); + QDropEvent dropEvent(event->pos().toPoint(), event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers()); KIO::DropJob *job = DragAndDropHelper::dropUrls(destItem.mostLocalUrl(), &dropEvent, this); if (job) { @@ -264,7 +258,7 @@ void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* eve } } -void FoldersPanel::slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value) +void FoldersPanel::slotRoleEditingFinished(int index, const QByteArray &role, const QVariant &value) { if (role == "text") { const KFileItem item = m_model->fileItem(index); @@ -275,7 +269,7 @@ void FoldersPanel::slotRoleEditingFinished(int index, const QByteArray& role, co QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename); newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName)); - KIO::Job* job = KIO::moveAs(oldUrl, newUrl); + KIO::Job *job = KIO::moveAs(oldUrl, newUrl); KJobWidgets::setWindow(job, this); KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job); job->uiDelegate()->setAutoErrorHandlingEnabled(true); @@ -306,7 +300,7 @@ void FoldersPanel::slotLoadingCompleted() void FoldersPanel::startFadeInAnimation() { - QPropertyAnimation* anim = new QPropertyAnimation(m_controller->view(), "opacity", this); + QPropertyAnimation *anim = new QPropertyAnimation(m_controller->view(), "opacity", this); anim->setStartValue(0); anim->setEndValue(1); anim->setEasingCurve(QEasingCurve::InOutQuad); @@ -314,7 +308,7 @@ void FoldersPanel::startFadeInAnimation() anim->setDuration(200); } -void FoldersPanel::loadTree(const QUrl& url, FoldersPanel::NavigationBehaviour navigationBehaviour) +void FoldersPanel::loadTree(const QUrl &url, FoldersPanel::NavigationBehaviour navigationBehaviour) { Q_ASSERT(m_controller); @@ -327,7 +321,7 @@ void FoldersPanel::loadTree(const QUrl& url, FoldersPanel::NavigationBehaviour n baseUrl = url; baseUrl.setPath(QStringLiteral("/")); } else if (Dolphin::homeUrl().isParentOf(url) || (Dolphin::homeUrl() == url)) { - if (FoldersPanelSettings::limitFoldersPanelToHome() ) { + if (FoldersPanelSettings::limitFoldersPanelToHome()) { baseUrl = Dolphin::homeUrl(); } else { // Use the root directory as base for local URLs (#150941) @@ -348,7 +342,7 @@ void FoldersPanel::loadTree(const QUrl& url, FoldersPanel::NavigationBehaviour n const int index = m_model->index(url); if (jumpHome) { - Q_EMIT folderActivated(baseUrl); + Q_EMIT folderActivated(baseUrl); } else if (index >= 0) { updateCurrentItem(index); } else if (url == baseUrl) { @@ -365,11 +359,10 @@ void FoldersPanel::loadTree(const QUrl& url, FoldersPanel::NavigationBehaviour n void FoldersPanel::updateCurrentItem(int index) { - KItemListSelectionManager* selectionManager = m_controller->selectionManager(); + KItemListSelectionManager *selectionManager = m_controller->selectionManager(); selectionManager->setCurrentItem(index); selectionManager->clearSelection(); selectionManager->setSelected(index); m_controller->view()->scrollToItem(index); } - diff --git a/src/panels/folders/folderspanel.h b/src/panels/folders/folderspanel.h index 3ce7870ff..1a482436a 100644 --- a/src/panels/folders/folderspanel.h +++ b/src/panels/folders/folderspanel.h @@ -27,7 +27,7 @@ class FoldersPanel : public Panel Q_OBJECT public: - explicit FoldersPanel(QWidget* parent = nullptr); + explicit FoldersPanel(QWidget *parent = nullptr); ~FoldersPanel() override; void setShowHiddenFiles(bool show); @@ -38,31 +38,31 @@ public: void setAutoScrolling(bool enable); bool autoScrolling() const; - void rename(const KFileItem& item); + void rename(const KFileItem &item); Q_SIGNALS: - void folderActivated(const QUrl& url); + void folderActivated(const QUrl &url); void folderInNewTab(const QUrl &url); void folderInNewActiveTab(const QUrl &url); - void errorMessage(const QString& error); + void errorMessage(const QString &error); protected: /** @see Panel::urlChanged() */ bool urlChanged() override; /** @see QWidget::showEvent() */ - void showEvent(QShowEvent* event) override; + void showEvent(QShowEvent *event) override; /** @see QWidget::keyPressEvent() */ - void keyPressEvent(QKeyEvent* event) override; + void keyPressEvent(QKeyEvent *event) override; private Q_SLOTS: void slotItemActivated(int index); void slotItemMiddleClicked(int index); - void slotItemContextMenuRequested(int index, const QPointF& pos); - void slotViewContextMenuRequested(const QPointF& pos); - void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event); - void slotRoleEditingFinished(int index, const QByteArray& role, const QVariant& value); + void slotItemContextMenuRequested(int index, const QPointF &pos); + void slotViewContextMenuRequested(const QPointF &pos); + void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent *event); + void slotRoleEditingFinished(int index, const QByteArray &role, const QVariant &value); void slotLoadingCompleted(); @@ -72,14 +72,13 @@ private Q_SLOTS: */ void startFadeInAnimation(); - private: /** * Indicate if it is allowed to leave current location. */ enum NavigationBehaviour { - StayWhereYouAre, ///< Don't leave current location. - AllowJumpHome ///< Go Home only when context menu option got checked. + StayWhereYouAre, ///< Don't leave current location. + AllowJumpHome ///< Go Home only when context menu option got checked. }; /** * Initializes the base URL of the tree and expands all @@ -87,7 +86,7 @@ private: * @param url URL of the leaf directory that should get expanded. * @param navigationBehaviour Navigation behaviour \see NavigationBehaviour */ - void loadTree(const QUrl& url, NavigationBehaviour navigationBehaviour = StayWhereYouAre); + void loadTree(const QUrl &url, NavigationBehaviour navigationBehaviour = StayWhereYouAre); void reloadTree(); @@ -99,8 +98,8 @@ private: private: bool m_updateCurrentItem; - KItemListController* m_controller; - KFileItemModel* m_model; + KItemListController *m_controller; + KFileItemModel *m_model; }; #endif // FOLDERSPANEL_H diff --git a/src/panels/folders/treeviewcontextmenu.cpp b/src/panels/folders/treeviewcontextmenu.cpp index 893a494fb..f6cafcac5 100644 --- a/src/panels/folders/treeviewcontextmenu.cpp +++ b/src/panels/folders/treeviewcontextmenu.cpp @@ -36,11 +36,10 @@ #include #include -TreeViewContextMenu::TreeViewContextMenu(FoldersPanel* parent, - const KFileItem& fileInfo) : - QObject(parent), - m_parent(parent), - m_fileItem(fileInfo) +TreeViewContextMenu::TreeViewContextMenu(FoldersPanel *parent, const KFileItem &fileInfo) + : QObject(parent) + , m_parent(parent) + , m_fileItem(fileInfo) { } @@ -48,25 +47,25 @@ TreeViewContextMenu::~TreeViewContextMenu() { } -void TreeViewContextMenu::open(const QPoint& pos) +void TreeViewContextMenu::open(const QPoint &pos) { - QMenu* popup = new QMenu(m_parent); + QMenu *popup = new QMenu(m_parent); if (!m_fileItem.isNull()) { KFileItemListProperties capabilities(KFileItemList() << m_fileItem); // insert 'Cut', 'Copy' and 'Paste' - QAction* cutAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-cut")), i18nc("@action:inmenu", "Cut"), this); + QAction *cutAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-cut")), i18nc("@action:inmenu", "Cut"), this); cutAction->setEnabled(capabilities.supportsMoving()); connect(cutAction, &QAction::triggered, this, &TreeViewContextMenu::cut); - QAction* copyAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18nc("@action:inmenu", "Copy"), this); + QAction *copyAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-copy")), i18nc("@action:inmenu", "Copy"), this); connect(copyAction, &QAction::triggered, this, &TreeViewContextMenu::copy); const QMimeData *mimeData = QApplication::clipboard()->mimeData(); bool canPaste; const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileItem); - QAction* pasteAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-paste")), text, this); + QAction *pasteAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-paste")), text, this); connect(pasteAction, &QAction::triggered, this, &TreeViewContextMenu::paste); pasteAction->setEnabled(canPaste); @@ -76,7 +75,7 @@ void TreeViewContextMenu::open(const QPoint& pos) popup->addSeparator(); // insert 'Rename' - QAction* renameAction = new QAction(i18nc("@action:inmenu", "Rename..."), this); + QAction *renameAction = new QAction(i18nc("@action:inmenu", "Rename..."), this); renameAction->setEnabled(capabilities.supportsMoving()); renameAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-rename"))); connect(renameAction, &QAction::triggered, this, &TreeViewContextMenu::rename); @@ -89,8 +88,7 @@ void TreeViewContextMenu::open(const QPoint& pos) const QUrl url = m_fileItem.url(); if (url.isLocalFile()) { - QAction* moveToTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("user-trash")), - i18nc("@action:inmenu", "Move to Trash"), this); + QAction *moveToTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("user-trash")), i18nc("@action:inmenu", "Move to Trash"), this); const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); moveToTrashAction->setEnabled(enableMoveToTrash); connect(moveToTrashAction, &QAction::triggered, this, &TreeViewContextMenu::moveToTrash); @@ -100,7 +98,7 @@ void TreeViewContextMenu::open(const QPoint& pos) } if (showDeleteCommand) { - QAction* deleteAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18nc("@action:inmenu", "Delete"), this); + QAction *deleteAction = new QAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18nc("@action:inmenu", "Delete"), this); deleteAction->setEnabled(capabilities.supportsDeleting()); connect(deleteAction, &QAction::triggered, this, &TreeViewContextMenu::deleteItem); popup->addAction(deleteAction); @@ -110,7 +108,7 @@ void TreeViewContextMenu::open(const QPoint& pos) } // insert 'Show Hidden Files' - QAction* showHiddenFilesAction = new QAction(i18nc("@action:inmenu", "Show Hidden Files"), this); + QAction *showHiddenFilesAction = new QAction(i18nc("@action:inmenu", "Show Hidden Files"), this); showHiddenFilesAction->setCheckable(true); showHiddenFilesAction->setChecked(m_parent->showHiddenFiles()); popup->addAction(showHiddenFilesAction); @@ -120,7 +118,7 @@ void TreeViewContextMenu::open(const QPoint& pos) // insert 'Limit to Home Directory' const QUrl url = m_fileItem.url(); const bool enableLimitToHomeDirectory = url.isLocalFile(); - QAction* limitFoldersPanelToHomeAction = new QAction(i18nc("@action:inmenu", "Limit to Home Directory"), this); + QAction *limitFoldersPanelToHomeAction = new QAction(i18nc("@action:inmenu", "Limit to Home Directory"), this); limitFoldersPanelToHomeAction->setCheckable(true); limitFoldersPanelToHomeAction->setEnabled(enableLimitToHomeDirectory); limitFoldersPanelToHomeAction->setChecked(m_parent->limitFoldersPanelToHome()); @@ -129,7 +127,7 @@ void TreeViewContextMenu::open(const QPoint& pos) } // insert 'Automatic Scrolling' - QAction* autoScrollingAction = new QAction(i18nc("@action:inmenu", "Automatic Scrolling"), this); + QAction *autoScrollingAction = new QAction(i18nc("@action:inmenu", "Automatic Scrolling"), this); autoScrollingAction->setCheckable(true); autoScrollingAction->setChecked(m_parent->autoScrolling()); // TODO: Temporary disabled. Horizontal autoscrolling will be implemented later either @@ -139,16 +137,16 @@ void TreeViewContextMenu::open(const QPoint& pos) if (!m_fileItem.isNull()) { // insert 'Properties' entry - QAction* propertiesAction = new QAction(i18nc("@action:inmenu", "Properties"), this); + QAction *propertiesAction = new QAction(i18nc("@action:inmenu", "Properties"), this); propertiesAction->setIcon(QIcon::fromTheme(QStringLiteral("document-properties"))); connect(propertiesAction, &QAction::triggered, this, &TreeViewContextMenu::showProperties); popup->addAction(propertiesAction); } - const QList customActions = m_parent->customContextMenuActions(); + const QList customActions = m_parent->customContextMenuActions(); if (!customActions.isEmpty()) { popup->addSeparator(); - for (QAction* action : customActions) { + for (QAction *action : customActions) { popup->addAction(action); } } @@ -160,7 +158,7 @@ void TreeViewContextMenu::open(const QPoint& pos) } } -void TreeViewContextMenu::populateMimeData(QMimeData* mimeData, bool cut) +void TreeViewContextMenu::populateMimeData(QMimeData *mimeData, bool cut) { QList kdeUrls; kdeUrls.append(m_fileItem.url()); @@ -174,14 +172,14 @@ void TreeViewContextMenu::populateMimeData(QMimeData* mimeData, bool cut) void TreeViewContextMenu::cut() { - QMimeData* mimeData = new QMimeData(); + QMimeData *mimeData = new QMimeData(); populateMimeData(mimeData, true); QApplication::clipboard()->setMimeData(mimeData); } void TreeViewContextMenu::copy() { - QMimeData* mimeData = new QMimeData(); + QMimeData *mimeData = new QMimeData(); populateMimeData(mimeData, false); QApplication::clipboard()->setMimeData(mimeData); } @@ -208,7 +206,7 @@ void TreeViewContextMenu::moveToTrash() KIO::JobUiDelegate uiDelegate; uiDelegate.setWindow(m_parent); if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) { - KIO::Job* job = KIO::trash(list); + KIO::Job *job = KIO::trash(list); KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, QUrl(QStringLiteral("trash:/")), job); KJobWidgets::setWindow(job, m_parent); job->uiDelegate()->setAutoErrorHandlingEnabled(true); @@ -227,7 +225,7 @@ void TreeViewContextMenu::deleteItem() KIO::JobUiDelegate uiDelegate; uiDelegate.setWindow(m_parent); if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) { - KIO::Job* job = KIO::del(list); + KIO::Job *job = KIO::del(list); KJobWidgets::setWindow(job, m_parent); job->uiDelegate()->setAutoErrorHandlingEnabled(true); } @@ -236,7 +234,7 @@ void TreeViewContextMenu::deleteItem() void TreeViewContextMenu::showProperties() { - KPropertiesDialog* dialog = new KPropertiesDialog(m_fileItem.url(), m_parent); + KPropertiesDialog *dialog = new KPropertiesDialog(m_fileItem.url(), m_parent); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); } @@ -255,4 +253,3 @@ void TreeViewContextMenu::setAutoScrolling(bool enable) { m_parent->setAutoScrolling(enable); } - diff --git a/src/panels/folders/treeviewcontextmenu.h b/src/panels/folders/treeviewcontextmenu.h index 35f44e90b..2e9228b00 100644 --- a/src/panels/folders/treeviewcontextmenu.h +++ b/src/panels/folders/treeviewcontextmenu.h @@ -30,13 +30,12 @@ public: * is applied. If 0 is passed, the context menu * is above the viewport. */ - TreeViewContextMenu(FoldersPanel* parent, - const KFileItem& fileInfo); + TreeViewContextMenu(FoldersPanel *parent, const KFileItem &fileInfo); ~TreeViewContextMenu() override; /** Opens the context menu modal. */ - void open(const QPoint& pos); + void open(const QPoint &pos); private Q_SLOTS: /** Cuts the item m_fileItem. */ @@ -79,10 +78,10 @@ private Q_SLOTS: void setAutoScrolling(bool enable); private: - void populateMimeData(QMimeData* mimeData, bool cut); + void populateMimeData(QMimeData *mimeData, bool cut); private: - FoldersPanel* m_parent; + FoldersPanel *m_parent; KFileItem m_fileItem; }; 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 #include +#include #include -#include #include -#include +#include #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(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(job)->statResult(); + const KIO::UDSEntry entry = static_cast(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 #include +#include #include #include #include @@ -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(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(event); + QResizeEvent *resizeEvent = static_cast(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(event)); + gestureEvent(static_cast(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(event->gesture(Qt::TapAndHoldGesture)); + QTapAndHoldGesture *tap = static_cast(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 #include "config-dolphin.h" +#include #include #include @@ -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 m_previewJob; - 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; + 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; 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(event); + const QMouseEvent *mouseEvent = static_cast(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: - - enum MediaKind { - Video, - Audio - }; - - explicit PhononWidget(QWidget *parent = nullptr); - - 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 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); - - public Q_SLOTS: - void play(); - - protected: - void showEvent(QShowEvent *event) override; - void hideEvent(QHideEvent *event) override; - - private Q_SLOTS: - void stateChanged(Phonon::State newstate); - void stop(); - void finished(); - - private: - void applyVideoSize(); - - private: - void togglePlayback(); - - QUrl m_url; - QSize m_videoSize; - - 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; +public: + enum MediaKind { Video, Audio }; + + explicit PhononWidget(QWidget *parent = nullptr); + + 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 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); + +public Q_SLOTS: + void play(); + +protected: + void showEvent(QShowEvent *event) override; + void hideEvent(QHideEvent *event) override; + +private Q_SLOTS: + void stateChanged(Phonon::State newstate); + void stop(); + void finished(); + +private: + void applyVideoSize(); + +private: + void togglePlayback(); + + QUrl m_url; + QSize m_videoSize; + + 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; }; #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 #include -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((m_oldPixmap.width() * (1.0 - value)) + (m_pixmap.width() * value)); + const int scaledWidth = static_cast((m_oldPixmap.width() * (1.0 - value)) + (m_pixmap.width() * value)); const int scaledHeight = static_cast((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 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 m_pendingPixmaps; QTimeLine m_animation; Transition m_transition; @@ -95,5 +93,4 @@ inline QPixmap PixmapViewer::pixmap() const return m_pixmap; } - #endif diff --git a/src/panels/panel.cpp b/src/panels/panel.cpp index 9e62cc8e3..32f293c4c 100644 --- a/src/panels/panel.cpp +++ b/src/panels/panel.cpp @@ -7,10 +7,10 @@ #include "panel.h" -Panel::Panel(QWidget* parent) : - QWidget(parent), - m_url(), - m_customContextMenuActions() +Panel::Panel(QWidget *parent) + : QWidget(parent) + , m_url() + , m_customContextMenuActions() { } @@ -23,12 +23,12 @@ QUrl Panel::url() const return m_url; } -void Panel::setCustomContextMenuActions(const QList& actions) +void Panel::setCustomContextMenuActions(const QList &actions) { m_customContextMenuActions = actions; } -QList Panel::customContextMenuActions() const +QList Panel::customContextMenuActions() const { return m_customContextMenuActions; } @@ -43,7 +43,7 @@ QSize Panel::sizeHint() const return QSize(180, 180); } -void Panel::setUrl(const QUrl& url) +void Panel::setUrl(const QUrl &url) { if (url.matches(m_url, QUrl::StripTrailingSlash)) { return; @@ -58,6 +58,4 @@ void Panel::setUrl(const QUrl& url) void Panel::readSettings() { - } - diff --git a/src/panels/panel.h b/src/panels/panel.h index 5932ae6af..5f1fabb4a 100644 --- a/src/panels/panel.h +++ b/src/panels/panel.h @@ -22,7 +22,7 @@ class Panel : public QWidget Q_OBJECT public: - explicit Panel(QWidget* parent = nullptr); + explicit Panel(QWidget *parent = nullptr); ~Panel() override; /** Returns the current set URL of the active Dolphin view. */ @@ -33,8 +33,8 @@ public: * context menu actions. Allows an application to apply custom actions to * the panel. */ - void setCustomContextMenuActions(const QList& actions); - QList customContextMenuActions() const; + void setCustomContextMenuActions(const QList &actions); + QList customContextMenuActions() const; QSize sizeHint() const override; @@ -62,7 +62,7 @@ protected: private: QUrl m_url; - QList m_customContextMenuActions; + QList m_customContextMenuActions; }; #endif // PANEL_H diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index de7137747..6467f9c23 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -11,12 +11,12 @@ #include "placespanel.h" -#include "dolphinplacesmodelsingleton.h" #include "dolphin_generalsettings.h" #include "dolphin_placespanelsettings.h" +#include "dolphinplacesmodelsingleton.h" #include "global.h" -#include "views/draganddrophelper.h" #include "settings/dolphinsettingsdialog.h" +#include "views/draganddrophelper.h" #include #include @@ -31,12 +31,11 @@ #include -PlacesPanel::PlacesPanel(QWidget* parent) +PlacesPanel::PlacesPanel(QWidget *parent) : KFilePlacesView(parent) { setDropOnPlaceEnabled(true); - connect(this, &PlacesPanel::urlsDropped, - this, &PlacesPanel::slotUrlsDropped); + connect(this, &PlacesPanel::urlsDropped, this, &PlacesPanel::slotUrlsDropped); setAutoResizeItemsEnabled(false); @@ -57,7 +56,7 @@ PlacesPanel::PlacesPanel(QWidget* parent) // Don't store 0 size, let's keep -1 for default/small/automatic iconSize = -1; } - PlacesPanelSettings* settings = PlacesPanelSettings::self(); + PlacesPanelSettings *settings = PlacesPanelSettings::self(); settings->setIconSize(iconSize); settings->save(); }); @@ -73,7 +72,7 @@ void PlacesPanel::setUrl(const QUrl &url) KFilePlacesView::setUrl(url); } -QList PlacesPanel::customContextMenuActions() const +QList PlacesPanel::customContextMenuActions() const { return m_customContextMenuActions; } @@ -105,7 +104,7 @@ void PlacesPanel::readSettings() setIconSize(QSize(iconSize, iconSize)); } -void PlacesPanel::showEvent(QShowEvent* event) +void PlacesPanel::showEvent(QShowEvent *event) { if (!event->spontaneous() && !model()) { readSettings(); @@ -163,13 +162,13 @@ void PlacesPanel::slotConfigureTrash() { const QUrl url = currentIndex().data(KFilePlacesModel::UrlRole).toUrl(); - DolphinSettingsDialog* settingsDialog = new DolphinSettingsDialog(url, this); + DolphinSettingsDialog *settingsDialog = new DolphinSettingsDialog(url, this); settingsDialog->setCurrentPage(settingsDialog->trashSettings); settingsDialog->setAttribute(Qt::WA_DeleteOnClose); settingsDialog->show(); } -void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent) +void PlacesPanel::slotUrlsDropped(const QUrl &dest, QDropEvent *event, QWidget *parent) { KIO::DropJob *job = DragAndDropHelper::dropUrls(dest, event, parent); if (job) { @@ -225,7 +224,7 @@ void PlacesPanel::slotTearDownRequested(const QModelIndex &index) void PlacesPanel::slotTearDownRequestedExternally(const QString &udi) { Q_UNUSED(udi); - auto *storageAccess = static_cast(sender()); + auto *storageAccess = static_cast(sender()); Q_EMIT storageTearDownExternallyRequested(storageAccess->filePath()); } diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index ef213ab30..2eb309483 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -11,8 +11,8 @@ #include "panels/panel.h" -#include #include +#include #include // Solid::ErrorType @@ -30,15 +30,15 @@ class PlacesPanel : public KFilePlacesView Q_OBJECT public: - explicit PlacesPanel(QWidget* parent); + explicit PlacesPanel(QWidget *parent); ~PlacesPanel() override; void setUrl(const QUrl &url); // override // for compatibility with Panel, actions that are shown // on the view's context menu - QList customContextMenuActions() const; - void setCustomContextMenuActions(const QList& actions); + QList customContextMenuActions() const; + void setCustomContextMenuActions(const QList &actions); void requestTearDown(); void proceedWithTearDown(); @@ -47,18 +47,18 @@ public Q_SLOTS: void readSettings(); Q_SIGNALS: - void errorMessage(const QString& error); - void storageTearDownRequested(const QString& mountPath); - void storageTearDownExternallyRequested(const QString& mountPath); + void errorMessage(const QString &error); + void storageTearDownRequested(const QString &mountPath); + void storageTearDownExternallyRequested(const QString &mountPath); void storageTearDownSuccessful(); protected: - void showEvent(QShowEvent* event) override; + void showEvent(QShowEvent *event) override; void dragMoveEvent(QDragMoveEvent *event) override; private Q_SLOTS: void slotConfigureTrash(); - void slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent); + void slotUrlsDropped(const QUrl &dest, QDropEvent *event, QWidget *parent); void slotContextMenuAboutToShow(const QModelIndex &index, QMenu *menu); void slotTearDownRequested(const QModelIndex &index); void slotTearDownRequestedExternally(const QString &udi); @@ -70,7 +70,7 @@ private: void connectDeviceSignals(const QModelIndex &idx); QUrl m_url; // only used for initial setUrl - QList m_customContextMenuActions; + QList m_customContextMenuActions; QPersistentModelIndex m_indexToTearDown; diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index a9c61768b..53464e620 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -28,20 +28,18 @@ #include #include -TerminalPanel::TerminalPanel(QWidget* parent) : - Panel(parent), - m_clearTerminal(true), - m_mostLocalUrlJob(nullptr), - m_layout(nullptr), - m_terminal(nullptr), - m_terminalWidget(nullptr), - m_konsolePartMissingMessage(nullptr), - m_konsolePart(nullptr), - m_konsolePartCurrentDirectory(), - m_sendCdToTerminalHistory(), - m_kiofuseInterface(QStringLiteral("org.kde.KIOFuse"), - QStringLiteral("/org/kde/KIOFuse"), - QDBusConnection::sessionBus()) +TerminalPanel::TerminalPanel(QWidget *parent) + : Panel(parent) + , m_clearTerminal(true) + , m_mostLocalUrlJob(nullptr) + , m_layout(nullptr) + , m_terminal(nullptr) + , m_terminalWidget(nullptr) + , m_konsolePartMissingMessage(nullptr) + , m_konsolePart(nullptr) + , m_konsolePartCurrentDirectory() + , m_sendCdToTerminalHistory() + , m_kiofuseInterface(QStringLiteral("org.kde.KIOFuse"), QStringLiteral("/org/kde/KIOFuse"), QDBusConnection::sessionBus()) { m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(0, 0, 0, 0); @@ -72,8 +70,7 @@ void TerminalPanel::terminalExited() bool TerminalPanel::isHiddenInVisibleWindow() const { - return parentWidget() - && parentWidget()->isHidden(); + return parentWidget() && parentWidget()->isHidden(); } void TerminalPanel::dockVisibilityChanged() @@ -82,8 +79,7 @@ void TerminalPanel::dockVisibilityChanged() // respond when e.g. Dolphin is minimized. if (isHiddenInVisibleWindow() && m_terminal && !hasProgramRunning()) { // Make sure that the following "cd /" command will not affect the view. - disconnect(m_konsolePart, SIGNAL(currentDirectoryChanged(QString)), - this, SLOT(slotKonsolePartCurrentDirectoryChanged(QString))); + disconnect(m_konsolePart, SIGNAL(currentDirectoryChanged(QString)), this, SLOT(slotKonsolePartCurrentDirectoryChanged(QString))); // Make sure this terminal does not prevent unmounting any removable drives changeDir(QUrl::fromLocalFile(QStringLiteral("/"))); @@ -135,7 +131,7 @@ bool TerminalPanel::urlChanged() return true; } -void TerminalPanel::showEvent(QShowEvent* event) +void TerminalPanel::showEvent(QShowEvent *event) { if (event->spontaneous()) { Panel::showEvent(event); @@ -154,7 +150,7 @@ void TerminalPanel::showEvent(QShowEvent* event) if (m_konsolePartMissingMessage) { m_layout->removeWidget(m_konsolePartMissingMessage); } - m_terminal = qobject_cast(m_konsolePart); + m_terminal = qobject_cast(m_konsolePart); // needed to collect the correct KonsolePart actionCollection // namely the one of the single inner terminal and not the outer KonsolePart @@ -174,8 +170,9 @@ void TerminalPanel::showEvent(QShowEvent* event) } else if (!m_konsolePartMissingMessage) { const auto konsoleInstallUrl = QUrl("appstream://org.kde.konsole.desktop"); - const auto konsoleNotInstalledText = i18n("Terminal cannot be shown because Konsole is not installed. " - "Please install it and then reopen the panel."); + const auto konsoleNotInstalledText = i18n( + "Terminal cannot be shown because Konsole is not installed. " + "Please install it and then reopen the panel."); m_konsolePartMissingMessage = new KMessageWidget(konsoleNotInstalledText, this); m_konsolePartMissingMessage->setCloseButtonVisible(false); m_konsolePartMissingMessage->hide(); @@ -195,18 +192,17 @@ void TerminalPanel::showEvent(QShowEvent* event) } if (m_terminal) { m_terminal->showShellInDir(url().toLocalFile()); - if(!hasProgramRunning()) { + if (!hasProgramRunning()) { changeDir(url()); } m_terminalWidget->setFocus(); - connect(m_konsolePart, SIGNAL(currentDirectoryChanged(QString)), - this, SLOT(slotKonsolePartCurrentDirectoryChanged(QString))); + connect(m_konsolePart, SIGNAL(currentDirectoryChanged(QString)), this, SLOT(slotKonsolePartCurrentDirectoryChanged(QString))); } Panel::showEvent(event); } -void TerminalPanel::changeDir(const QUrl& url) +void TerminalPanel::changeDir(const QUrl &url) { delete m_mostLocalUrlJob; m_mostLocalUrlJob = nullptr; @@ -230,9 +226,9 @@ void TerminalPanel::changeDir(const QUrl& url) sendCdToTerminalKIOFuse(url); } -void TerminalPanel::sendCdToTerminal(const QString& dir, HistoryPolicy addToHistory) +void TerminalPanel::sendCdToTerminal(const QString &dir, HistoryPolicy addToHistory) { - if (dir == m_konsolePartCurrentDirectory // We are already there + if (dir == m_konsolePartCurrentDirectory // We are already there && m_sendCdToTerminalHistory.isEmpty() // …and that is not because the terminal couldn't keep up ) { m_clearTerminal = false; @@ -259,13 +255,14 @@ void TerminalPanel::sendCdToTerminal(const QString& dir, HistoryPolicy addToHist } } -void TerminalPanel::sendCdToTerminalKIOFuse(const QUrl &url) { +void TerminalPanel::sendCdToTerminalKIOFuse(const QUrl &url) +{ // URL isn't local, only hope for the terminal to be in sync with the // DolphinView is to mount the remote URL in KIOFuse and point to it. // If we can't do that for any reason, silently fail. auto reply = m_kiofuseInterface.mountUrl(url.toString()); - QDBusPendingCallWatcher * watcher = new QDBusPendingCallWatcher(reply, this); - QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher* watcher) { + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *watcher) { watcher->deleteLater(); if (!reply.isError()) { // Successfully mounted, point to the KIOFuse equivalent path. @@ -274,9 +271,9 @@ void TerminalPanel::sendCdToTerminalKIOFuse(const QUrl &url) { }); } -void TerminalPanel::slotMostLocalUrlResult(KJob* job) +void TerminalPanel::slotMostLocalUrlResult(KJob *job) { - KIO::StatJob* statJob = static_cast(job); + KIO::StatJob *statJob = static_cast(job); const QUrl url = statJob->mostLocalUrl(); if (url.isLocalFile()) { sendCdToTerminal(url.toLocalFile()); @@ -287,7 +284,7 @@ void TerminalPanel::slotMostLocalUrlResult(KJob* job) m_mostLocalUrlJob = nullptr; } -void TerminalPanel::slotKonsolePartCurrentDirectoryChanged(const QString& dir) +void TerminalPanel::slotKonsolePartCurrentDirectoryChanged(const QString &dir) { m_konsolePartCurrentDirectory = QDir(dir).canonicalPath(); @@ -312,8 +309,8 @@ void TerminalPanel::slotKonsolePartCurrentDirectoryChanged(const QString& dir) } auto reply = m_kiofuseInterface.remoteUrl(m_konsolePartCurrentDirectory); - QDBusPendingCallWatcher * watcher = new QDBusPendingCallWatcher(reply, this); - QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [=] (QDBusPendingCallWatcher* watcher) { + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); + QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *watcher) { watcher->deleteLater(); if (reply.isError()) { // KIOFuse errored out... just show the normal URL diff --git a/src/panels/terminal/terminalpanel.h b/src/panels/terminal/terminalpanel.h index 5a2b0bb83..a1b7af03a 100644 --- a/src/panels/terminal/terminalpanel.h +++ b/src/panels/terminal/terminalpanel.h @@ -18,12 +18,14 @@ class KMessageWidget; class QVBoxLayout; class QWidget; -namespace KIO { - class StatJob; +namespace KIO +{ +class StatJob; } -namespace KParts { - class ReadOnlyPart; +namespace KParts +{ +class ReadOnlyPart; } class KJob; /** @@ -35,7 +37,7 @@ class TerminalPanel : public Panel Q_OBJECT public: - explicit TerminalPanel(QWidget* parent = nullptr); + explicit TerminalPanel(QWidget *parent = nullptr); ~TerminalPanel() override; /** @@ -60,35 +62,33 @@ Q_SIGNALS: /** * Is emitted if the an URL change is requested. */ - void changeUrl(const QUrl& url); + void changeUrl(const QUrl &url); protected: bool urlChanged() override; - void showEvent(QShowEvent* event) override; + void showEvent(QShowEvent *event) override; private Q_SLOTS: - void slotMostLocalUrlResult(KJob* job); - void slotKonsolePartCurrentDirectoryChanged(const QString& dir); + void slotMostLocalUrlResult(KJob *job); + void slotKonsolePartCurrentDirectoryChanged(const QString &dir); private: - enum class HistoryPolicy { - AddToHistory, - SkipHistory - }; + enum class HistoryPolicy { AddToHistory, SkipHistory }; - void changeDir(const QUrl& url); - void sendCdToTerminal(const QString& path, HistoryPolicy addToHistory = HistoryPolicy::AddToHistory); + void changeDir(const QUrl &url); + void sendCdToTerminal(const QString &path, HistoryPolicy addToHistory = HistoryPolicy::AddToHistory); void sendCdToTerminalKIOFuse(const QUrl &url); + private: bool m_clearTerminal; - KIO::StatJob* m_mostLocalUrlJob; + KIO::StatJob *m_mostLocalUrlJob; - QVBoxLayout* m_layout; - TerminalInterface* m_terminal; - QWidget* m_terminalWidget; - KMessageWidget* m_konsolePartMissingMessage; - KParts::ReadOnlyPart* m_konsolePart; + QVBoxLayout *m_layout; + TerminalInterface *m_terminal; + QWidget *m_terminalWidget; + KMessageWidget *m_konsolePartMissingMessage; + KParts::ReadOnlyPart *m_konsolePart; QString m_konsolePartCurrentDirectory; QQueue m_sendCdToTerminalHistory; org::kde::KIOFuse::VFS m_kiofuseInterface; -- cgit v1.3