X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/0c44dfe2b1c143fae323b9ff4bd415cdd69c1086..a35af3a0d2022a23c5a1cc30d693141a13673b8f:/src/settings/viewpropertiesdialog.cpp diff --git a/src/settings/viewpropertiesdialog.cpp b/src/settings/viewpropertiesdialog.cpp index 6659d79b6..37c3d539b 100644 --- a/src/settings/viewpropertiesdialog.cpp +++ b/src/settings/viewpropertiesdialog.cpp @@ -8,7 +8,6 @@ #include "viewpropertiesdialog.h" #include "dolphin_generalsettings.h" -#include "dolphin_iconsmodesettings.h" #include "global.h" #include "kitemviews/kfileitemmodel.h" #include "viewpropsprogressinfo.h" @@ -19,8 +18,10 @@ #include #include -#ifdef HAVE_BALOO - #include +#include + +#if HAVE_BALOO +#include #endif #include @@ -35,30 +36,30 @@ #include -ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : - QDialog(dolphinView), - m_isDirty(false), - m_dolphinView(dolphinView), - m_viewProps(nullptr), - m_viewMode(nullptr), - m_sortOrder(nullptr), - m_sorting(nullptr), - m_sortFoldersFirst(nullptr), - m_sortHiddenLast(nullptr), - m_previewsShown(nullptr), - m_showInGroups(nullptr), - m_showHiddenFiles(nullptr), - m_applyToCurrentFolder(nullptr), - m_applyToSubFolders(nullptr), - m_applyToAllFolders(nullptr), - m_useAsDefault(nullptr) +ViewPropertiesDialog::ViewPropertiesDialog(DolphinView *dolphinView) + : QDialog(dolphinView) + , m_isDirty(false) + , m_dolphinView(dolphinView) + , m_viewProps(nullptr) + , m_viewMode(nullptr) + , m_sortOrder(nullptr) + , m_sorting(nullptr) + , m_sortFoldersFirst(nullptr) + , m_sortHiddenLast(nullptr) + , m_previewsShown(nullptr) + , m_showInGroups(nullptr) + , m_showHiddenFiles(nullptr) + , m_applyToCurrentFolder(nullptr) + , m_applyToSubFolders(nullptr) + , m_applyToAllFolders(nullptr) + , m_useAsDefault(nullptr) { Q_ASSERT(dolphinView); const bool useGlobalViewProps = GeneralSettings::globalViewProps(); setWindowTitle(i18nc("@title:window", "View Display Style")); - const QUrl& url = dolphinView->url(); + const QUrl &url = dolphinView->url(); m_viewProps = new ViewProperties(url); m_viewProps->setAutoSaveEnabled(false); @@ -78,7 +79,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : m_sorting = new QComboBox(); const QList rolesInfo = KFileItemModel::rolesInformation(); - for (const KFileItemModel::RoleInfo& info : rolesInfo) { + for (const KFileItemModel::RoleInfo &info : rolesInfo) { m_sorting->addItem(info.translation, info.role); } @@ -108,7 +109,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : // Add checkboxes bool indexingEnabled = false; -#ifdef HAVE_BALOO +#if HAVE_BALOO Baloo::IndexerConfig config; indexingEnabled = config.fileIndexingEnabled(); #endif @@ -117,24 +118,23 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : connect(m_listWidget, &QListWidget::itemChanged, this, &ViewPropertiesDialog::slotItemChanged); m_listWidget->setSelectionMode(QAbstractItemView::NoSelection); const QList rolesInfo = KFileItemModel::rolesInformation(); - for (const KFileItemModel::RoleInfo& info : rolesInfo) { - QListWidgetItem* item = new QListWidgetItem(info.translation, m_listWidget); + for (const KFileItemModel::RoleInfo &info : rolesInfo) { + QListWidgetItem *item = new QListWidgetItem(info.translation, m_listWidget); item->setCheckState(visibleRoles.contains(info.role) ? Qt::Checked : Qt::Unchecked); - const bool enable = ((!info.requiresBaloo && !info.requiresIndexer) || - (info.requiresBaloo) || - (info.requiresIndexer && indexingEnabled)) && info.role != "text"; + const bool enable = + ((!info.requiresBaloo && !info.requiresIndexer) || (info.requiresBaloo) || (info.requiresIndexer && indexingEnabled)) && info.role != "text"; if (!enable) { item->setFlags(item->flags() & ~Qt::ItemIsEnabled); } } - QLabel* additionalViewOptionsLabel = new QLabel(i18n("Choose what to see on each file or folder:")); + QLabel *additionalViewOptionsLabel = new QLabel(i18n("Choose what to see on each file or folder:")); innerLayout->addWidget(additionalViewOptionsLabel); innerLayout->addWidget(m_listWidget); } - QHBoxLayout* sortingLayout = new QHBoxLayout(); + QHBoxLayout *sortingLayout = new QHBoxLayout(); sortingLayout->setContentsMargins(0, 0, 0, 0); sortingLayout->addWidget(m_sortOrder); sortingLayout->addWidget(m_sorting); @@ -150,36 +150,25 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : layout->addRow(QString(), m_showHiddenFiles); layout->addRow(QString(), m_sortHiddenLast); - connect(m_viewMode, QOverload::of(&QComboBox::currentIndexChanged), - this, &ViewPropertiesDialog::slotViewModeChanged); - connect(m_sorting, QOverload::of(&QComboBox::currentIndexChanged), - this, &ViewPropertiesDialog::slotSortingChanged); - connect(m_sortOrder, QOverload::of(&QComboBox::currentIndexChanged), - this, &ViewPropertiesDialog::slotSortOrderChanged); - connect(m_sortFoldersFirst, &QCheckBox::clicked, - this, &ViewPropertiesDialog::slotSortFoldersFirstChanged); - connect(m_sortHiddenLast, &QCheckBox::clicked, - this, &ViewPropertiesDialog::slotSortHiddenLastChanged); - connect(m_previewsShown, &QCheckBox::clicked, - this, &ViewPropertiesDialog::slotShowPreviewChanged); - connect(m_showInGroups, &QCheckBox::clicked, - this, &ViewPropertiesDialog::slotGroupedSortingChanged); - connect(m_showHiddenFiles, &QCheckBox::clicked, - this, &ViewPropertiesDialog::slotShowHiddenFilesChanged); + connect(m_viewMode, &QComboBox::currentIndexChanged, this, &ViewPropertiesDialog::slotViewModeChanged); + connect(m_sorting, &QComboBox::currentIndexChanged, this, &ViewPropertiesDialog::slotSortingChanged); + connect(m_sortOrder, &QComboBox::currentIndexChanged, this, &ViewPropertiesDialog::slotSortOrderChanged); + connect(m_sortFoldersFirst, &QCheckBox::clicked, this, &ViewPropertiesDialog::slotSortFoldersFirstChanged); + connect(m_sortHiddenLast, &QCheckBox::clicked, this, &ViewPropertiesDialog::slotSortHiddenLastChanged); + connect(m_previewsShown, &QCheckBox::clicked, this, &ViewPropertiesDialog::slotShowPreviewChanged); + connect(m_showInGroups, &QCheckBox::clicked, this, &ViewPropertiesDialog::slotGroupedSortingChanged); + connect(m_showHiddenFiles, &QCheckBox::clicked, this, &ViewPropertiesDialog::slotShowHiddenFilesChanged); // Only show the following settings if the view properties are remembered // for each directory: if (!useGlobalViewProps) { // create 'Apply View Properties To' group - m_applyToCurrentFolder = new QRadioButton(i18nc("@option:radio Apply View Properties To", - "Current folder")); + m_applyToCurrentFolder = new QRadioButton(i18nc("@option:radio Apply View Properties To", "Current folder")); m_applyToCurrentFolder->setChecked(true); - m_applyToSubFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", - "Current folder and sub-folders")); - m_applyToAllFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", - "All folders")); + m_applyToSubFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", "Current folder and sub-folders")); + m_applyToAllFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", "All folders")); - QButtonGroup* applyGroup = new QButtonGroup(this); + QButtonGroup *applyGroup = new QButtonGroup(this); applyGroup->addButton(m_applyToCurrentFolder); applyGroup->addButton(m_applyToSubFolders); applyGroup->addButton(m_applyToAllFolders); @@ -194,14 +183,10 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use as default view settings"), this); layout->addRow(QString(), m_useAsDefault); - connect(m_applyToCurrentFolder, &QRadioButton::clicked, - this, &ViewPropertiesDialog::markAsDirty); - connect(m_applyToSubFolders, &QRadioButton::clicked, - this, &ViewPropertiesDialog::markAsDirty); - connect(m_applyToAllFolders, &QRadioButton::clicked, - this, &ViewPropertiesDialog::markAsDirty); - connect(m_useAsDefault, &QCheckBox::clicked, - this, &ViewPropertiesDialog::markAsDirty); + connect(m_applyToCurrentFolder, &QRadioButton::clicked, this, &ViewPropertiesDialog::markAsDirty); + connect(m_applyToSubFolders, &QRadioButton::clicked, this, &ViewPropertiesDialog::markAsDirty); + connect(m_applyToAllFolders, &QRadioButton::clicked, this, &ViewPropertiesDialog::markAsDirty); + connect(m_useAsDefault, &QCheckBox::clicked, this, &ViewPropertiesDialog::markAsDirty); } layout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); @@ -224,7 +209,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : applyButton->setEnabled(isDirty); }); - const KConfigGroup dialogConfig(KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "ViewPropertiesDialog"); + const KConfigGroup dialogConfig(KSharedConfig::openConfig(QStringLiteral("dolphinrc")), QStringLiteral("ViewPropertiesDialog")); KWindowConfig::restoreWindowSize(windowHandle(), dialogConfig); loadSettings(); @@ -236,7 +221,7 @@ ViewPropertiesDialog::~ViewPropertiesDialog() delete m_viewProps; m_viewProps = nullptr; - KConfigGroup dialogConfig(KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "ViewPropertiesDialog"); + KConfigGroup dialogConfig(KSharedConfig::openConfig(QStringLiteral("dolphinrc")), QStringLiteral("ViewPropertiesDialog")); KWindowConfig::saveWindowSize(windowHandle(), dialogConfig); } @@ -334,9 +319,9 @@ void ViewPropertiesDialog::applyViewProperties() QList visibleRoles; int index = 0; const QList rolesInfo = KFileItemModel::rolesInformation(); - for (const KFileItemModel::RoleInfo& info : rolesInfo) { - const QListWidgetItem* item = m_listWidget->item(index); - if (item->checkState() == Qt::Checked) { + for (const KFileItemModel::RoleInfo &info : rolesInfo) { + const QListWidgetItem *item = m_listWidget->item(index); + if (item->checkState() == Qt::Checked) { visibleRoles.append(info.role); } ++index; @@ -348,13 +333,11 @@ void ViewPropertiesDialog::applyViewProperties() const bool applyToSubFolders = m_applyToSubFolders && m_applyToSubFolders->isChecked(); if (applyToSubFolders) { const QString text(i18nc("@info", "The view properties of all sub-folders will be changed. Do you want to continue?")); - if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) { + if (KMessageBox::questionTwoActions(this, text, {}, KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::SecondaryAction) { return; } - ViewPropsProgressInfo* info = new ViewPropsProgressInfo(m_dolphinView, - m_dolphinView->url(), - *m_viewProps); + ViewPropsProgressInfo *info = new ViewPropsProgressInfo(m_dolphinView, m_dolphinView->url(), *m_viewProps); info->setAttribute(Qt::WA_DeleteOnClose); info->setWindowModality(Qt::NonModal); info->show(); @@ -380,18 +363,18 @@ void ViewPropertiesDialog::applyViewProperties() if (applyToAllFolders) { const QString text(i18nc("@info", "The view properties of all folders will be changed. Do you want to continue?")); - if (KMessageBox::questionYesNo(this, text) == KMessageBox::No) { + if (KMessageBox::questionTwoActions(this, text, {}, KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::SecondaryAction) { return; } // Updating the global view properties time stamp in the general settings makes // all existing viewproperties invalid, as they have a smaller time stamp. - GeneralSettings* settings = GeneralSettings::self(); + GeneralSettings *settings = GeneralSettings::self(); settings->setViewPropsTimestamp(QDateTime::currentDateTime()); settings->save(); } - m_dolphinView->setMode(m_viewProps->viewMode()); + m_dolphinView->setViewMode(m_viewProps->viewMode()); m_dolphinView->setSortRole(m_viewProps->sortRole()); m_dolphinView->setSortOrder(m_viewProps->sortOrder()); m_dolphinView->setSortFoldersFirst(m_viewProps->sortFoldersFirst()); @@ -410,10 +393,17 @@ void ViewPropertiesDialog::loadSettings() { // Load view mode switch (m_viewProps->viewMode()) { - case DolphinView::IconsView: m_viewMode->setCurrentIndex(0); break; - case DolphinView::CompactView: m_viewMode->setCurrentIndex(1); break; - case DolphinView::DetailsView: m_viewMode->setCurrentIndex(2); break; - default: break; + case DolphinView::IconsView: + m_viewMode->setCurrentIndex(0); + break; + case DolphinView::CompactView: + m_viewMode->setCurrentIndex(1); + break; + case DolphinView::DetailsView: + m_viewMode->setCurrentIndex(2); + break; + default: + break; } // Load sort order and sorting @@ -440,3 +430,4 @@ void ViewPropertiesDialog::loadSettings() markAsDirty(false); } +#include "moc_viewpropertiesdialog.cpp"