diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,14 +1,14 @@ cmake_minimum_required(VERSION 3.0) # KDE Application Version, managed by release script -set (KDE_APPLICATIONS_VERSION_MAJOR "18") -set (KDE_APPLICATIONS_VERSION_MINOR "12") -set (KDE_APPLICATIONS_VERSION_MICRO "1") +set (KDE_APPLICATIONS_VERSION_MAJOR "19") +set (KDE_APPLICATIONS_VERSION_MINOR "03") +set (KDE_APPLICATIONS_VERSION_MICRO "70") set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}") project(Dolphin VERSION ${KDE_APPLICATIONS_VERSION}) set(QT_MIN_VERSION "5.8.0") -set(KF5_MIN_VERSION "5.43.0") +set(KF5_MIN_VERSION "5.53.0") # ECM setup find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -201,7 +201,6 @@ filterbar/filterbar.cpp panels/places/placespanel.cpp panels/places/placesitem.cpp - panels/places/placesitemeditdialog.cpp panels/places/placesitemlistgroupheader.cpp panels/places/placesitemlistwidget.cpp panels/places/placesitemmodel.cpp diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -162,7 +162,7 @@ Q_ASSERT(m_context & TrashContext); Q_ASSERT(m_context & ItemContext); - QAction* restoreAction = new QAction(i18nc("@action:inmenu", "Restore"), m_mainWindow); + QAction* restoreAction = new QAction(QIcon::fromTheme("restoration"), i18nc("@action:inmenu", "Restore"), m_mainWindow); addAction(restoreAction); QAction* deleteAction = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)); @@ -307,6 +307,7 @@ } // insert 'Properties...' entry + addSeparator(); QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties")); addAction(propertiesAction); @@ -421,26 +422,24 @@ addAction(collection->action(KStandardAction::name(KStandardAction::RenameFile))); // Insert 'Move to Trash' and/or 'Delete' - if (properties.supportsDeleting()) { - const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || - !properties.isLocal()); - const bool showMoveToTrashAction = (properties.isLocal() && - properties.supportsMoving()); - - if (showDeleteAction && showMoveToTrashAction) { - delete m_removeAction; - m_removeAction = nullptr; - addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash))); - addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile))); - } else if (showDeleteAction && !showMoveToTrashAction) { - addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile))); - } else { - if (!m_removeAction) { - m_removeAction = new DolphinRemoveAction(this, m_mainWindow->actionCollection()); - } - addAction(m_removeAction); - m_removeAction->update(); + const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || + !properties.isLocal()); + const bool showMoveToTrashAction = (properties.isLocal() && + properties.supportsMoving()); + + if (showDeleteAction && showMoveToTrashAction) { + delete m_removeAction; + m_removeAction = nullptr; + addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash))); + addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile))); + } else if (showDeleteAction && !showMoveToTrashAction) { + addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile))); + } else { + if (!m_removeAction) { + m_removeAction = new DolphinRemoveAction(this, m_mainWindow->actionCollection()); } + addAction(m_removeAction); + m_removeAction->update(); } } diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -551,7 +551,7 @@ // URL instead of all items of the view KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator(); - QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); // krazy:exclude=qclasses + QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); const bool selectUrl = urlNavigator->isUrlEditable() && lineEdit->hasFocus(); if (selectUrl) { @@ -621,12 +621,19 @@ void DolphinMainWindow::replaceLocation() { KUrlNavigator* navigator = m_activeViewContainer->urlNavigator(); - navigator->setUrlEditable(true); - navigator->setFocus(); - - // select the whole text of the combo box editor - QLineEdit* lineEdit = navigator->editor()->lineEdit(); // krazy:exclude=qclasses - lineEdit->selectAll(); + QLineEdit* lineEdit = navigator->editor()->lineEdit(); + + // If the text field currently has focus and everything is selected, + // pressing the keyboard shortcut returns the whole thing to breadcrumb mode + if (navigator->isUrlEditable() + && lineEdit->hasFocus() + && lineEdit->selectedText() == lineEdit->text() ) { + navigator->setUrlEditable(false); + } else { + navigator->setUrlEditable(true); + navigator->setFocus(); + lineEdit->selectAll(); + } } void DolphinMainWindow::togglePanelLockState() @@ -965,6 +972,9 @@ void DolphinMainWindow::activeViewChanged(DolphinViewContainer* viewContainer) { + if (m_activeViewContainer == viewContainer) { + return; + } DolphinViewContainer* oldViewContainer = m_activeViewContainer; Q_ASSERT(viewContainer); @@ -1001,7 +1011,10 @@ void DolphinMainWindow::updateWindowTitle() { - setWindowTitle(m_activeViewContainer->caption()); + const QString newTitle = m_activeViewContainer->caption(); + if (windowTitle() != newTitle) { + setWindowTitle(newTitle); + } } void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath) diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -260,7 +260,7 @@ protected: void onGroupedSortingChanged(bool current) override; - void onSortRoleChanged(const QByteArray& current, const QByteArray& previous) override; + void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true) override; void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) override; private slots: @@ -371,7 +371,7 @@ * Sorts the items between \a begin and \a end using the comparison * function lessThan(). */ - void sort(QList::iterator begin, QList::iterator end) const; + void sort(const QList::iterator &begin, const QList::iterator &end) const; /** * Helper method for lessThan() and expandedParentsCountCompare(): Compares @@ -386,7 +386,7 @@ QList > nameRoleGroups() const; QList > sizeRoleGroups() const; - QList > timeRoleGroups(std::function fileTimeCb) const; + QList > timeRoleGroups(const std::function &fileTimeCb) const; QList > permissionRoleGroups() const; QList > ratingRoleGroups() const; QList > genericStringRoleGroups(const QByteArray& typeForRole) const; diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -304,6 +304,9 @@ int count = 0; const RoleInfoMap* map = rolesInfoMap(count); for (int i = 0; i < count; ++i) { + if (!map[i].roleTranslation) { + continue; + } description.insert(map[i].role, i18nc(map[i].roleTranslationContext, map[i].roleTranslation)); } } @@ -786,7 +789,7 @@ m_groups.clear(); } -void KFileItemModel::onSortRoleChanged(const QByteArray& current, const QByteArray& previous) +void KFileItemModel::onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems) { Q_UNUSED(previous); m_sortRole = typeForRole(current); @@ -797,7 +800,9 @@ setRoles(newRoles); } - resortAllItems(); + if (resortItems) { + resortAllItems(); + } } void KFileItemModel::onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) @@ -1712,8 +1717,8 @@ return (sortOrder() == Qt::AscendingOrder) ? result < 0 : result > 0; } -void KFileItemModel::sort(QList::iterator begin, - QList::iterator end) const +void KFileItemModel::sort(const QList::iterator &begin, + const QList::iterator &end) const { auto lambdaLessThan = [&] (const KFileItemModel::ItemData* a, const KFileItemModel::ItemData* b) { @@ -1977,7 +1982,7 @@ return groups; } -QList > KFileItemModel::timeRoleGroups(std::function fileTimeCb) const +QList > KFileItemModel::timeRoleGroups(const std::function &fileTimeCb) const { Q_ASSERT(!m_itemData.isEmpty()); diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -157,7 +157,7 @@ private slots: void slotItemsInserted(const KItemRangeList& itemRanges); void slotItemsRemoved(const KItemRangeList& itemRanges); - void slotItemsMoved(const KItemRange& itemRange, QList movedToIndexes); + void slotItemsMoved(const KItemRange& itemRange, const QList &movedToIndexes); void slotItemsChanged(const KItemRangeList& itemRanges, const QSet& roles); void slotSortRoleChanged(const QByteArray& current, diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -405,7 +405,7 @@ } } -void KFileItemModelRolesUpdater::slotItemsMoved(const KItemRange& itemRange, QList movedToIndexes) +void KFileItemModelRolesUpdater::slotItemsMoved(const KItemRange& itemRange, const QList &movedToIndexes) { Q_UNUSED(itemRange); Q_UNUSED(movedToIndexes); @@ -710,6 +710,8 @@ return; } applyChangedBalooRolesForItem(item); +#else + Q_UNUSED(file); #endif } diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h --- a/src/kitemviews/kitemlistcontroller.h +++ b/src/kitemviews/kitemlistcontroller.h @@ -40,10 +40,8 @@ class QGraphicsSceneMouseEvent; class QGraphicsSceneResizeEvent; class QGraphicsSceneWheelEvent; -class QHideEvent; class QInputMethodEvent; class QKeyEvent; -class QShowEvent; class QTransform; /** @@ -136,24 +134,7 @@ void setSingleClickActivationEnforced(bool singleClick); bool singleClickActivationEnforced() const; - virtual bool showEvent(QShowEvent* event); - virtual bool hideEvent(QHideEvent* event); - virtual bool keyPressEvent(QKeyEvent* event); - virtual bool inputMethodEvent(QInputMethodEvent* event); - virtual bool mousePressEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform); - virtual bool mouseMoveEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform); - virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform); - virtual bool mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform); - virtual bool dragEnterEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform); - virtual bool dragLeaveEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform); - virtual bool dragMoveEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform); - virtual bool dropEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform); - virtual bool hoverEnterEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform); - virtual bool hoverMoveEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform); - virtual bool hoverLeaveEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform); - virtual bool wheelEvent(QGraphicsSceneWheelEvent* event, const QTransform& transform); - virtual bool resizeEvent(QGraphicsSceneResizeEvent* event, const QTransform& transform); - virtual bool processEvent(QEvent* event, const QTransform& transform); + bool processEvent(QEvent* event, const QTransform& transform); signals: /** @@ -307,6 +288,22 @@ */ void updateExtendedSelectionRegion(); + bool keyPressEvent(QKeyEvent* event); + bool inputMethodEvent(QInputMethodEvent* event); + bool mousePressEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform); + bool mouseMoveEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform); + bool mouseReleaseEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform); + bool mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform); + bool dragEnterEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform); + bool dragLeaveEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform); + bool dragMoveEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform); + bool dropEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform); + bool hoverEnterEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform); + bool hoverMoveEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform); + bool hoverLeaveEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform); + bool wheelEvent(QGraphicsSceneWheelEvent* event, const QTransform& transform); + bool resizeEvent(QGraphicsSceneResizeEvent* event, const QTransform& transform); + private: bool m_singleClickActivationEnforced; bool m_selectionTogglePressed; diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -210,18 +210,6 @@ return m_singleClickActivationEnforced; } -bool KItemListController::showEvent(QShowEvent* event) -{ - Q_UNUSED(event); - return false; -} - -bool KItemListController::hideEvent(QHideEvent* event) -{ - Q_UNUSED(event); - return false; -} - bool KItemListController::keyPressEvent(QKeyEvent* event) { int index = m_selectionManager->currentItem(); diff --git a/src/kitemviews/kitemmodelbase.h b/src/kitemviews/kitemmodelbase.h --- a/src/kitemviews/kitemmodelbase.h +++ b/src/kitemviews/kitemmodelbase.h @@ -85,8 +85,9 @@ * Sets the sort-role to \a role. The method KItemModelBase::onSortRoleChanged() will be * called so that model-implementations can react on the sort-role change. Afterwards the * signal sortRoleChanged() will be emitted. + * The implementation should resort only if \a resortItems is true. */ - void setSortRole(const QByteArray& role); + void setSortRole(const QByteArray& role, bool resortItems = true); QByteArray sortRole() const; /** @@ -266,8 +267,9 @@ * Usually the most efficient way is to emit a * itemsRemoved() signal for all items, reorder the items internally and to emit a * itemsInserted() signal afterwards. + * The implementation should resort only if \a resortItems is true. */ - virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous); + virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true); /** * Is invoked if the sort order has been changed by KItemModelBase::setSortOrder(). Allows diff --git a/src/kitemviews/kitemmodelbase.cpp b/src/kitemviews/kitemmodelbase.cpp --- a/src/kitemviews/kitemmodelbase.cpp +++ b/src/kitemviews/kitemmodelbase.cpp @@ -63,12 +63,12 @@ return m_groupedSorting; } -void KItemModelBase::setSortRole(const QByteArray& role) +void KItemModelBase::setSortRole(const QByteArray& role, bool resortItems) { if (role != m_sortRole) { const QByteArray previous = m_sortRole; m_sortRole = role; - onSortRoleChanged(role, previous); + onSortRoleChanged(role, previous, resortItems); emit sortRoleChanged(role, previous); } } @@ -152,10 +152,11 @@ Q_UNUSED(current); } -void KItemModelBase::onSortRoleChanged(const QByteArray& current, const QByteArray& previous) +void KItemModelBase::onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems) { Q_UNUSED(current); Q_UNUSED(previous); + Q_UNUSED(resortItems); } void KItemModelBase::onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) diff --git a/src/kitemviews/private/kitemlistheaderwidget.cpp b/src/kitemviews/private/kitemlistheaderwidget.cpp --- a/src/kitemviews/private/kitemlistheaderwidget.cpp +++ b/src/kitemviews/private/kitemlistheaderwidget.cpp @@ -220,10 +220,11 @@ // Change the sort role and reset to the ascending order const QByteArray previous = m_model->sortRole(); const QByteArray current = m_columns[m_pressedRoleIndex]; - m_model->setSortRole(current); + const bool resetSortOrder = m_model->sortOrder() == Qt::DescendingOrder; + m_model->setSortRole(current, !resetSortOrder); emit sortRoleChanged(current, previous); - if (m_model->sortOrder() == Qt::DescendingOrder) { + if (resetSortOrder) { m_model->setSortOrder(Qt::AscendingOrder); emit sortOrderChanged(Qt::AscendingOrder, Qt::DescendingOrder); } diff --git a/src/org.kde.dolphin.appdata.xml b/src/org.kde.dolphin.appdata.xml --- a/src/org.kde.dolphin.appdata.xml +++ b/src/org.kde.dolphin.appdata.xml @@ -200,7 +200,7 @@
  • Barra de navegación para enderezos URL, que lle permite navegar rapidamente pola xerarquía de ficheiros e cartafoles.
  • Navigációs (vagy webmorzsa) sáv az URL-ekhez, amely lehetővé teszi a fájlok és mappák hierarchiáján keresztüli gyors navigációt.
  • Barra de navigation (o "breadcrumb") pro URLs, que il permitte te navigar rapidemente a transverso del hierarchia de files e dossieres.
  • -
  • Bilah navigasi (atau remah) untuk URL-URL, membolehkanmu secara cepat menavigasi melalui hirerarki file-file dan folder-folder.
  • +
  • Bilah navigasi (atau remah) untuk URL-URL, memungkinkanmu secara cepat menavigasi melalui hirerarki file-file dan folder-folder.
  • La barra di navigazione per gli URL, che ti consente di navigare rapidamente attraverso la struttura di file e cartelle.
  • 파일과 폴더 구조를 빠르게 탐색할 수 있도록 URL 탐색 표시줄을 사용할 수 있습니다.
  • Navigasjonslinje (brødsmulelinje) for URL-er slik at du raskt kan navigere gjennom hierarkiet av filer og mapper.
  • @@ -241,7 +241,7 @@
  • É compatíbel con varios estilos e propiedades de vista distintos, e permítelle configurar a vista como mellor lle pareza.
  • Számos különféle nézetstílus fajtát és tulajdonságot támogat, valamint lehetővé teszi a nézet beállítását pontosan olyanra, ahogy azt látni szeretné.
  • Il supporta multe differente typos de stilos de vista e proprietates e il permitte te configurar le vista exactemente como tu vole.
  • -
  • Mendukung beberapa jenis gaya tampilan dan properti yang berbeda dan membolehkanmu untuk mengonfigurasi tampilan persis seperti yang kamu inginkan.
  • +
  • Mendukung beberapa jenis gaya tampilan dan properti yang berbeda dan memungkinkanmu untuk mengonfigurasi tampilan persis seperti yang kamu inginkan.
  • Supporta diversi stili di visualizzazione e proprietà e ti consente di configurare la vista come desideri.
  • 여러 종류의 보기 형식을 지원하여 원하는 대로 항목을 볼 수 있습니다.
  • Støtter flere forskjellige visningsstiler og kan sette opp visningen akkurat slik du vil ha den.
  • @@ -282,7 +282,7 @@
  • Vista dividida, que lle permite copiar ou mover ficheiros facilmente entre dous lugares.
  • Osztott nézet, amely lehetővé teszi a fájlok könnyű másolását és áthelyezését a helyek között.
  • Scinde vista, il permitte te copiar o mover facilemente files inter locationes.
  • -
  • Tampilan pisah, membolehkanmu untuk menyalin atau memindah file antar lokasi dengan mudah.
  • +
  • Tampilan pisah, memungkinkanmu untuk menyalin atau memindah file antar lokasi dengan mudah.
  • La vista divisa, che ti consente di copiare o spostare i file tra le diverse posizioni in maniera semplice.
  • 화면을 나누어서 서로 다른 위치 간 파일을 쉽게 이동하거나 복사할 수 있도록 합니다.
  • Delt visning, så du lett kan kopiere eller flytte filer mellom steder.
  • @@ -323,7 +323,7 @@
  • Información adicional e atallos dispoñíbeis como paneis acoplábeis que pode colocar en calquera parte e mostrar como prefira.
  • További információk és gyorsbillentyűk érhetők el dokkolható panelekként, lehetővé téve azok szabad mozgatását, illetve pontosan úgy megjelenítve, ahogy szeretné.
  • Information additional e vias breve es disponibile como pannellos de basin (dock-panels), il permitte mover los liberemente e monstrar los exactemente como tu vole.
  • -
  • Informasi tambahan dan pintasan tersedia sebagai panel yang bisa di-dock, membolehkanmu untuk memindahkannya secara bebas dan menampilkan apa yang kamu inginkan.
  • +
  • Informasi tambahan dan pintasan tersedia sebagai panel yang bisa di-dock, memungkinkanmu untuk memindahkannya secara bebas dan menampilkan apa yang kamu inginkan.
  • Informazioni aggiuntive e scorciatoie sono disponibili come pannelli agganciabili, che possono essere spostati liberamente e visualizzare esattamente ciò che desideri.
  • 추가 정보 표시 창과 바로 가기는 도킹 가능한 패널 형태로 사용할 수 있으며, 원하는 곳으로 이동하여 표시할 수 있습니다.
  • Mer informasjon og snarveier er tilgjengelige som dokkbare ruter, som du kan flytte fritt rundt og bruke til å vise akkurat hva du vil.
  • @@ -530,21 +530,26 @@ File management in Dolphin + Xestión de ficheros en Dolphin Gestió de fitxers al Dolphin Gestió de fitxers al Dolphin Dateiverwaltung mit Dolphin + Διαχείριση αρχείων στο Dolphin File management in Dolphin Gestión de archivos en Dolphin Tiedostonhallinta Dolphinissa Gestion de fichiers dans Dophin Xestión de ficheiros en Dolphin + Gerente de file in Dolphin + Pengelolaan file di Dolphin Gestione dei file in Dolphin Bestandsbeheer in Dolphin Filhandsaming i Dolphin Zarządzanie plikami w Dolphinie Gestão de ficheiros no Dolphin Gerenciamento de arquivos no Dolphin Управление файлами + Správa súborov v Dolphin Filhantering i Dolphin Керування файлами у Dolphin xxFile management in Dolphinxx diff --git a/src/panels/folders/folderspanel.cpp b/src/panels/folders/folderspanel.cpp --- a/src/panels/folders/folderspanel.cpp +++ b/src/panels/folders/folderspanel.cpp @@ -105,9 +105,7 @@ m_controller->view()->editRole(index, "text"); } else { RenameDialog* dialog = new RenameDialog(this, KFileItemList() << item); - dialog->show(); - dialog->raise(); - dialog->activateWindow(); + dialog->open(); } } diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -91,7 +91,7 @@ if (item.isNull()) { // The cursor is above the viewport. If files are selected, // show information regarding the selection. - if (m_selection.size() > 0) { + if (!m_selection.isEmpty()) { m_fileItem = KFileItem(); m_infoTimer->start(); } diff --git a/src/panels/information/pixmapviewer.cpp b/src/panels/information/pixmapviewer.cpp --- a/src/panels/information/pixmapviewer.cpp +++ b/src/panels/information/pixmapviewer.cpp @@ -112,7 +112,7 @@ void PixmapViewer::checkPendingPixmaps() { - if (m_pendingPixmaps.count() > 0) { + if (!m_pendingPixmaps.isEmpty()) { QPixmap pixmap = m_pendingPixmaps.dequeue(); m_oldPixmap = m_pixmap.isNull() ? pixmap : m_pixmap; m_pixmap = pixmap; diff --git a/src/panels/places/placesitem.h b/src/panels/places/placesitem.h --- a/src/panels/places/placesitem.h +++ b/src/panels/places/placesitem.h @@ -52,6 +52,9 @@ void setUdi(const QString& udi); QString udi() const; + void setApplicationName(const QString& applicationName); + QString applicationName() const; + void setHidden(bool hidden); bool isHidden() const; diff --git a/src/panels/places/placesitem.cpp b/src/panels/places/placesitem.cpp --- a/src/panels/places/placesitem.cpp +++ b/src/panels/places/placesitem.cpp @@ -1,5 +1,6 @@ /*************************************************************************** * Copyright (C) 2012 by Peter Penz * + * Copyright (C) 2018 by Elvis Angelaccio * * * * Based on KFilePlacesItem from kdelibs: * * Copyright (C) 2007 Kevin Ottens * @@ -80,6 +81,16 @@ return dataValue("udi").toString(); } +void PlacesItem::setApplicationName(const QString &applicationName) +{ + setDataValue("applicationName", applicationName); +} + +QString PlacesItem::applicationName() const +{ + return dataValue("applicationName").toString(); +} + void PlacesItem::setHidden(bool hidden) { setDataValue("isHidden", hidden); @@ -247,6 +258,8 @@ m_bookmark.setUrl(url()); } else if (role == "udi") { m_bookmark.setMetaDataItem(QStringLiteral("UDI"), udi()); + } else if (role == "applicationName") { + m_bookmark.setMetaDataItem(QStringLiteral("OnlyInApp"), applicationName()); } else if (role == "isSystemItem") { m_bookmark.setMetaDataItem(QStringLiteral("isSystemItem"), isSystemItem() ? QStringLiteral("true") : QStringLiteral("false")); } else if (role == "isHidden") { diff --git a/src/panels/places/placesitemeditdialog.h b/src/panels/places/placesitemeditdialog.h deleted file mode 100644 --- a/src/panels/places/placesitemeditdialog.h +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2012 by Peter Penz * - * * - * Based on KFilePlaceEditDialog from kdelibs: * - * Copyright (C) 2001,2002,2003 Carsten Pfeiffer * - * Copyright (C) 2007 Kevin Ottens * * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#ifndef PLACESITEMEDITDIALOG_H -#define PLACESITEMEDITDIALOG_H - -#include -#include - -class KIconButton; -class KUrlRequester; -class QLineEdit; -class QCheckBox; -class QDialogButtonBox; - -class PlacesItemEditDialog: public QDialog -{ - Q_OBJECT - -public: - explicit PlacesItemEditDialog(QWidget* parent = nullptr); - ~PlacesItemEditDialog() override; - - void setIcon(const QString& icon); - QString icon() const; - - void setText(const QString& text); - QString text() const; - - void setUrl(const QUrl& url); - QUrl url() const; - - void setAllowGlobal(bool allow); - bool allowGlobal() const; - -protected: - bool event(QEvent* event) override; - -private slots: - void slotUrlChanged(const QString& text); - -private: - void initialize(); - -private: - QString m_icon; - QString m_text; - QUrl m_url; - bool m_allowGlobal; - - KUrlRequester* m_urlEdit; - QLineEdit* m_textEdit; - KIconButton* m_iconButton; - QCheckBox* m_appLocal; - QDialogButtonBox *m_buttonBox; -}; - -#endif diff --git a/src/panels/places/placesitemeditdialog.cpp b/src/panels/places/placesitemeditdialog.cpp deleted file mode 100644 --- a/src/panels/places/placesitemeditdialog.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2012 by Peter Penz * - * * - * Based on KFilePlaceEditDialog from kdelibs: * - * Copyright (C) 2001,2002,2003 Carsten Pfeiffer * - * Copyright (C) 2007 Kevin Ottens * * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "placesitemeditdialog.h" - -#include "dolphindebug.h" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -PlacesItemEditDialog::PlacesItemEditDialog(QWidget* parent) : - QDialog(parent), - m_icon(), - m_text(), - m_url(), - m_allowGlobal(false), - m_urlEdit(nullptr), - m_textEdit(nullptr), - m_iconButton(nullptr), - m_appLocal(nullptr), - m_buttonBox(nullptr) -{ -} - -void PlacesItemEditDialog::setIcon(const QString& icon) -{ - m_icon = icon; -} - -QString PlacesItemEditDialog::icon() const -{ - return m_iconButton ? m_iconButton->icon() : m_icon; -} - -void PlacesItemEditDialog::setText(const QString& text) -{ - m_text = text; -} - -QString PlacesItemEditDialog::text() const -{ - QString text = m_textEdit->text(); - if (text.isEmpty()) { - const QUrl url = m_urlEdit->url(); - text = url.fileName().isEmpty() ? url.toDisplayString(QUrl::PreferLocalFile) : url.fileName(); - } - return text; -} - -void PlacesItemEditDialog::setUrl(const QUrl& url) -{ - m_url = url; -} - -QUrl PlacesItemEditDialog::url() const -{ - return m_urlEdit->url(); -} - -void PlacesItemEditDialog::setAllowGlobal(bool allow) -{ - m_allowGlobal = allow; -} - -bool PlacesItemEditDialog::allowGlobal() const -{ - return m_allowGlobal; -} - -bool PlacesItemEditDialog::event(QEvent* event) -{ - if (event->type() == QEvent::Polish) { - initialize(); - } - return QWidget::event(event); -} - -void PlacesItemEditDialog::slotUrlChanged(const QString& text) -{ - m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty()); -} - -PlacesItemEditDialog::~PlacesItemEditDialog() -{ -} - -void PlacesItemEditDialog::initialize() -{ - m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this); - connect(m_buttonBox, &QDialogButtonBox::accepted, this, &PlacesItemEditDialog::accept); - connect(m_buttonBox, &QDialogButtonBox::rejected, this, &PlacesItemEditDialog::reject); - setModal(true); - - QVBoxLayout *mainLayout = new QVBoxLayout; - setLayout(mainLayout); - QWidget* mainWidget = new QWidget(this); - mainLayout->addWidget(mainWidget); - mainLayout->addWidget(m_buttonBox); - - QVBoxLayout* vBox = new QVBoxLayout(mainWidget); - - QFormLayout* formLayout = new QFormLayout(); - vBox->addLayout( formLayout ); - - m_textEdit = new QLineEdit(mainWidget); - formLayout->addRow(i18nc("@label", "Label:"), m_textEdit); - m_textEdit->setText(m_text); - m_textEdit->setPlaceholderText(i18n("Enter descriptive label here")); - - m_urlEdit = new KUrlRequester(m_url, mainWidget); - m_urlEdit->setMode(KFile::Directory); - formLayout->addRow(i18nc("@label", "Location:"), m_urlEdit); - // Provide room for at least 40 chars (average char width is half of height) - m_urlEdit->setMinimumWidth(m_urlEdit->fontMetrics().height() * (40 / 2)); - connect(m_urlEdit, &KUrlRequester::textChanged, this, &PlacesItemEditDialog::slotUrlChanged); - - if (m_url.scheme() != QLatin1String("trash")) { - m_iconButton = new KIconButton(mainWidget); - formLayout->addRow(i18nc("@label", "Choose an icon:"), m_iconButton); - m_iconButton->setIconSize(IconSize(KIconLoader::Desktop)); - m_iconButton->setIconType(KIconLoader::NoGroup, KIconLoader::Place); - if (m_icon.isEmpty()) { - QMimeDatabase db; - m_iconButton->setIcon(db.mimeTypeForUrl(m_url).iconName()); - } else { - m_iconButton->setIcon(m_icon); - } - } - - if (m_allowGlobal) { - const QString appName = KAboutData::applicationData().displayName(); - m_appLocal = new QCheckBox( i18n("&Only show when using this application (%1)", appName ), mainWidget ); - m_appLocal->setChecked(false); - vBox->addWidget(m_appLocal); - } - - if (m_text.isEmpty()) { - m_urlEdit->setFocus(); - } else { - m_textEdit->setFocus(); - } - -} - diff --git a/src/panels/places/placesitemmodel.h b/src/panels/places/placesitemmodel.h --- a/src/panels/places/placesitemmodel.h +++ b/src/panels/places/placesitemmodel.h @@ -52,10 +52,8 @@ * @brief Create a new place entry in the bookmark file * and add it to the model */ - void createPlacesItem(const QString& text, - const QUrl& url, - const QString& iconName = QString(), - int after = -1); + void createPlacesItem(const QString& text, const QUrl& url, const QString& iconName = {}, const QString& appName = {}); + void createPlacesItem(const QString& text, const QUrl& url, const QString& iconName, const QString& appName, int after); PlacesItem* placesItem(int index) const; diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -78,12 +78,14 @@ { } -void PlacesItemModel::createPlacesItem(const QString& text, - const QUrl& url, - const QString& iconName, - int after) +void PlacesItemModel::createPlacesItem(const QString &text, const QUrl &url, const QString &iconName, const QString &appName) { - m_sourceModel->addPlace(text, url, iconName, {}, mapToSource(after)); + createPlacesItem(text, url, iconName, appName, -1); +} + +void PlacesItemModel::createPlacesItem(const QString &text, const QUrl &url, const QString &iconName, const QString &appName, int after) +{ + m_sourceModel->addPlace(text, url, iconName, appName, mapToSource(after)); } PlacesItem* PlacesItemModel::placesItem(int index) const @@ -369,7 +371,7 @@ continue; } - createPlacesItem(text, url, KIO::iconNameForUrl(url), qMax(0, index - 1)); + createPlacesItem(text, url, KIO::iconNameForUrl(url), {}, qMax(0, index - 1)); } } // will save bookmark alteration and fix sort if that is broken by the drag/drop operation diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -30,14 +30,14 @@ #include "kitemviews/kitemlistselectionmanager.h" #include "kitemviews/kstandarditem.h" #include "placesitem.h" -#include "placesitemeditdialog.h" #include "placesitemlistgroupheader.h" #include "placesitemlistwidget.h" #include "placesitemmodel.h" #include "placesview.h" #include "trash/dolphintrash.h" #include "views/draganddrophelper.h" +#include #include #include #include @@ -474,32 +474,31 @@ { const int index = m_controller->selectionManager()->currentItem(); const QUrl url = m_model->data(index).value("url").toUrl(); + const QString text = url.fileName().isEmpty() ? url.toDisplayString(QUrl::PreferLocalFile) : url.fileName(); - QPointer dialog = new PlacesItemEditDialog(this); - dialog->setWindowTitle(i18nc("@title:window", "Add Places Entry")); - dialog->setAllowGlobal(true); - dialog->setUrl(url); + QPointer dialog = new KFilePlaceEditDialog(true, url, text, QString(), true, false, KIconLoader::SizeMedium, this); if (dialog->exec() == QDialog::Accepted) { - m_model->createPlacesItem(dialog->text(), dialog->url(), dialog->icon()); + const QString appName = dialog->applicationLocal() ? QCoreApplication::applicationName() : QString(); + m_model->createPlacesItem(dialog->label(), dialog->url(), dialog->icon(), appName); } delete dialog; } void PlacesPanel::editEntry(int index) { QHash data = m_model->data(index); + const QUrl url = data.value("url").toUrl(); + const QString text = data.value("text").toString(); + const bool applicationLocal = !data.value("applicationName").toString().isEmpty(); - QPointer dialog = new PlacesItemEditDialog(this); - dialog->setWindowTitle(i18nc("@title:window", "Edit Places Entry")); - dialog->setIcon(data.value("iconName").toString()); - dialog->setText(data.value("text").toString()); - dialog->setUrl(data.value("url").toUrl()); - dialog->setAllowGlobal(true); + QPointer dialog = new KFilePlaceEditDialog(true, url, text, QString(), true, applicationLocal, KIconLoader::SizeMedium, this); if (dialog->exec() == QDialog::Accepted) { PlacesItem* oldItem = m_model->placesItem(index); if (oldItem) { - oldItem->setText(dialog->text()); + const QString appName = dialog->applicationLocal() ? QCoreApplication::applicationName() : QString(); + oldItem->setApplicationName(appName); + oldItem->setText(dialog->label()); oldItem->setUrl(dialog->url()); oldItem->setIcon(dialog->icon()); m_model->refresh(); diff --git a/src/tests/kitemlistcontrollertest.cpp b/src/tests/kitemlistcontrollertest.cpp --- a/src/tests/kitemlistcontrollertest.cpp +++ b/src/tests/kitemlistcontrollertest.cpp @@ -197,7 +197,7 @@ */ struct ViewState { - ViewState(int current, const KItemSet selection, bool activated = false) : + ViewState(int current, const KItemSet &selection, bool activated = false) : m_current(current), m_selection(selection), m_activated(activated) diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -638,9 +638,7 @@ RenameDialog* dialog = new RenameDialog(this, items); connect(dialog, &RenameDialog::renamingFinished, this, &DolphinView::slotRenameDialogRenamingFinished); - dialog->show(); - dialog->raise(); - dialog->activateWindow(); + dialog->open(); } // Assure that the current index remains visible when KFileItemModel diff --git a/src/views/versioncontrol/versioncontrolobserver.cpp b/src/views/versioncontrol/versioncontrolobserver.cpp --- a/src/views/versioncontrol/versioncontrolobserver.cpp +++ b/src/views/versioncontrol/versioncontrolobserver.cpp @@ -248,7 +248,7 @@ } } - if (items.count() > 0) { + if (!items.isEmpty()) { const QUrl& url = items.first().first.url(); itemStates.insert(url.adjusted(QUrl::RemoveFilename).path(), items); }