X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/4157103173b1718262e8c329219461f0d67b2a2a..d3496b12310d9fec0e52e537c341e87fcaa2f8b5:/src/settings/viewpropertiesdialog.cpp diff --git a/src/settings/viewpropertiesdialog.cpp b/src/settings/viewpropertiesdialog.cpp index ba8de4d9c..2a35f7eb8 100644 --- a/src/settings/viewpropertiesdialog.cpp +++ b/src/settings/viewpropertiesdialog.cpp @@ -21,27 +21,25 @@ #include "viewpropertiesdialog.h" #include "additionalinfodialog.h" -#include "dolphinview.h" +#include "views/dolphinview.h" #include "settings/dolphinsettings.h" -#include "dolphinsortfilterproxymodel.h" #include "dolphin_generalsettings.h" #include "dolphin_iconsmodesettings.h" -#include "viewproperties.h" #include "viewpropsprogressinfo.h" #include #ifdef HAVE_NEPOMUK -#include +#include #endif -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -54,6 +52,9 @@ #include #include +#include +#include + ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : KDialog(dolphinView), m_isDirty(false), @@ -62,6 +63,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : m_viewMode(0), m_sortOrder(0), m_sorting(0), + m_sortFoldersFirst(0), m_showPreview(0), m_showInGroups(0), m_showHiddenFiles(0), @@ -71,7 +73,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : m_applyToAllFolders(0), m_useAsDefault(0) { - Q_ASSERT(dolphinView != 0); + Q_ASSERT(dolphinView); const bool useGlobalViewProps = DolphinSettings::instance().generalSettings()->globalViewProps(); setCaption(i18nc("@title:window", "View Properties")); @@ -122,11 +124,12 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : // m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Tags")); // } #endif - m_showPreview = new QCheckBox(i18nc("@option:check", "Show preview"), propsBox); - m_showInGroups = new QCheckBox(i18nc("@option:check", "Show in groups"), propsBox); - m_showHiddenFiles = new QCheckBox(i18nc("@option:check", "Show hidden files"), propsBox); + m_sortFoldersFirst = new QCheckBox(i18nc("@option:check", "Show folders first")); + m_showPreview = new QCheckBox(i18nc("@option:check", "Show preview")); + m_showInGroups = new QCheckBox(i18nc("@option:check", "Show in groups")); + m_showHiddenFiles = new QCheckBox(i18nc("@option:check", "Show hidden files")); - m_additionalInfo = new QPushButton(i18nc("@action:button", "Additional Information"), propsBox); + m_additionalInfo = new QPushButton(i18nc("@action:button", "Additional Information")); QHBoxLayout* sortingLayout = new QHBoxLayout(); sortingLayout->setMargin(0); @@ -142,6 +145,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox); propsBoxLayout->addWidget(propsGrid); + propsBoxLayout->addWidget(m_sortFoldersFirst); propsBoxLayout->addWidget(m_showPreview); propsBoxLayout->addWidget(m_showInGroups); propsBoxLayout->addWidget(m_showHiddenFiles); @@ -157,6 +161,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : this, SLOT(slotSortOrderChanged(int))); connect(m_additionalInfo, SIGNAL(clicked()), this, SLOT(configureAdditionalInfo())); + connect(m_sortFoldersFirst, SIGNAL(clicked()), + this, SLOT(slotSortFoldersFirstChanged())); connect(m_showPreview, SIGNAL(clicked()), this, SLOT(slotShowPreviewChanged())); connect(m_showInGroups, SIGNAL(clicked()), @@ -177,7 +183,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : "Current folder"), applyBox); m_applyToCurrentFolder->setChecked(true); m_applyToSubFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", - "Current folder including all sub folders"), applyBox); + "Current folder including all sub-folders"), applyBox); m_applyToAllFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", "All folders"), applyBox); @@ -191,19 +197,19 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : applyBoxLayout->addWidget(m_applyToSubFolders); applyBoxLayout->addWidget(m_applyToAllFolders); - m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use as default for new folders"), main); + m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use these view properties as default"), main); topLayout->addWidget(applyBox); topLayout->addWidget(m_useAsDefault); - connect(m_applyToCurrentFolder, SIGNAL(clicked()), - this, SLOT(markAsDirty())); - connect(m_applyToSubFolders, SIGNAL(clicked()), - this, SLOT(markAsDirty())); - connect(m_applyToAllFolders, SIGNAL(clicked()), - this, SLOT(markAsDirty())); - connect(m_useAsDefault, SIGNAL(clicked()), - this, SLOT(markAsDirty())); + connect(m_applyToCurrentFolder, SIGNAL(clicked(bool)), + this, SLOT(markAsDirty(bool))); + connect(m_applyToSubFolders, SIGNAL(clicked(bool)), + this, SLOT(markAsDirty(bool))); + connect(m_applyToAllFolders, SIGNAL(clicked(bool)), + this, SLOT(markAsDirty(bool))); + connect(m_useAsDefault, SIGNAL(clicked(bool)), + this, SLOT(markAsDirty(bool))); } main->setLayout(topLayout); @@ -236,12 +242,13 @@ void ViewPropertiesDialog::slotOk() void ViewPropertiesDialog::slotApply() { applyViewProperties(); + markAsDirty(false); } void ViewPropertiesDialog::slotViewModeChanged(int index) { m_viewProps->setViewMode(static_cast(index)); - m_isDirty = true; + markAsDirty(true); const DolphinView::Mode mode = m_viewProps->viewMode(); m_showInGroups->setEnabled(mode == DolphinView::IconsView); @@ -252,39 +259,47 @@ void ViewPropertiesDialog::slotSortingChanged(int index) { const DolphinView::Sorting sorting = DolphinSortFilterProxyModel::sortingForColumn(index); m_viewProps->setSorting(sorting); - m_isDirty = true; + markAsDirty(true); } void ViewPropertiesDialog::slotSortOrderChanged(int index) { const Qt::SortOrder sortOrder = (index == 0) ? Qt::AscendingOrder : Qt::DescendingOrder; m_viewProps->setSortOrder(sortOrder); - m_isDirty = true; + markAsDirty(true); } void ViewPropertiesDialog::slotCategorizedSortingChanged() { m_viewProps->setCategorizedSorting(m_showInGroups->isChecked()); - m_isDirty = true; + markAsDirty(true); +} + +void ViewPropertiesDialog::slotSortFoldersFirstChanged() +{ + const bool foldersFirst = m_sortFoldersFirst->isChecked(); + m_viewProps->setSortFoldersFirst(foldersFirst); + markAsDirty(true); } void ViewPropertiesDialog::slotShowPreviewChanged() { const bool show = m_showPreview->isChecked(); m_viewProps->setShowPreview(show); - m_isDirty = true; + markAsDirty(true); } void ViewPropertiesDialog::slotShowHiddenFilesChanged() { const bool show = m_showHiddenFiles->isChecked(); m_viewProps->setShowHiddenFiles(show); - m_isDirty = true; + markAsDirty(true); } -void ViewPropertiesDialog::markAsDirty() +void ViewPropertiesDialog::markAsDirty(bool isDirty) { - m_isDirty = true; + m_isDirty = isDirty; + enableButtonApply(isDirty); } void ViewPropertiesDialog::configureAdditionalInfo() @@ -302,11 +317,12 @@ void ViewPropertiesDialog::configureAdditionalInfo() m_viewProps->setAdditionalInfo(info); } - AdditionalInfoDialog dialog(this, info); - if (dialog.exec() == QDialog::Accepted) { - m_viewProps->setAdditionalInfo(dialog.additionalInfo()); - m_isDirty = true; + QPointer dialog = new AdditionalInfoDialog(this, info); + if (dialog->exec() == QDialog::Accepted) { + m_viewProps->setAdditionalInfo(dialog->informationList()); + markAsDirty(true); } + delete dialog; } void ViewPropertiesDialog::applyViewProperties() @@ -316,10 +332,9 @@ void ViewPropertiesDialog::applyViewProperties() return; } - const bool applyToSubFolders = (m_applyToSubFolders != 0) && - m_applyToSubFolders->isChecked(); + 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?")); + 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) { return; } @@ -332,13 +347,11 @@ void ViewPropertiesDialog::applyViewProperties() info->show(); } - const bool applyToAllFolders = (m_applyToAllFolders != 0) && - m_applyToAllFolders->isChecked(); + const bool applyToAllFolders = m_applyToAllFolders && m_applyToAllFolders->isChecked(); // If the user selected 'Apply To All Folders' the view properties implicitely // are also used as default for new folders. - const bool useAsDefault = applyToAllFolders || - ((m_useAsDefault != 0) && m_useAsDefault->isChecked()); + const bool useAsDefault = applyToAllFolders || (m_useAsDefault && m_useAsDefault->isChecked()); if (useAsDefault) { // For directories where no .directory file is available, the .directory // file stored for the global view properties is used as fallback. To update @@ -368,6 +381,7 @@ void ViewPropertiesDialog::applyViewProperties() m_dolphinView->setMode(m_viewProps->viewMode()); m_dolphinView->setSorting(m_viewProps->sorting()); m_dolphinView->setSortOrder(m_viewProps->sortOrder()); + m_dolphinView->setSortFoldersFirst(m_viewProps->sortFoldersFirst()); m_dolphinView->setCategorizedSorting(m_viewProps->categorizedSorting()); m_dolphinView->setAdditionalInfo(m_viewProps->additionalInfo()); m_dolphinView->setShowPreview(m_viewProps->showPreview()); @@ -375,7 +389,7 @@ void ViewPropertiesDialog::applyViewProperties() m_viewProps->save(); - m_isDirty = false; + markAsDirty(false); } void ViewPropertiesDialog::loadSettings() @@ -393,6 +407,7 @@ void ViewPropertiesDialog::loadSettings() (index == DolphinView::IconsView); m_additionalInfo->setEnabled(enabled); + m_sortFoldersFirst->setChecked(m_viewProps->sortFoldersFirst()); // load show preview, show in groups and show hidden files settings m_showPreview->setChecked(m_viewProps->showPreview()); @@ -400,6 +415,7 @@ void ViewPropertiesDialog::loadSettings() m_showInGroups->setEnabled(index == DolphinView::IconsView); // only the icons view supports categorized sorting m_showHiddenFiles->setChecked(m_viewProps->showHiddenFiles()); + markAsDirty(false); } #include "viewpropertiesdialog.moc"