]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/viewpropertiesdialog.cpp
Sometimes, the penultimate item in the bounds would get deselected when it shouldn...
[dolphin.git] / src / viewpropertiesdialog.cpp
index cd4490aadf386dfc7a547fc0b49d94eaeabd4dac..b71732e5648707bc4647572b865f30115fd09320 100644 (file)
@@ -25,6 +25,7 @@
 #include "dolphinsettings.h"
 #include "dolphinsortfilterproxymodel.h"
 #include "dolphin_generalsettings.h"
+#include "dolphin_iconsmodesettings.h"
 #include "viewproperties.h"
 #include "viewpropsprogressinfo.h"
 
@@ -67,6 +68,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     m_additionalInfo(0),
     m_applyToCurrentFolder(0),
     m_applyToSubFolders(0),
+    m_applyToAllFolders(0),
     m_useAsDefault(0)
 {
     Q_ASSERT(dolphinView != 0);
@@ -88,18 +90,20 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
         propsBox = new QGroupBox(i18nc("@title:group", "Properties"), main);
     }
 
-    QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsBox);
-    m_viewMode = new QComboBox(propsBox);
-    m_viewMode->addItem(KIcon("fileview-icon"), i18nc("@item:inlistbox", "Icons"));
-    m_viewMode->addItem(KIcon("fileview-detailed"), i18nc("@item:inlistbox", "Details"));
-    m_viewMode->addItem(KIcon("fileview-column"), i18nc("@item:inlistbox", "Column"));
+    QWidget* propsGrid = new QWidget();
 
-    QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsBox);
-    QWidget* sortingBox = new QWidget(propsBox);
+    QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsGrid);
+    m_viewMode = new QComboBox(propsGrid);
+    m_viewMode->addItem(KIcon("view-list-icons"), i18nc("@item:inlistbox", "Icons"));
+    m_viewMode->addItem(KIcon("view-list-details"), i18nc("@item:inlistbox", "Details"));
+    m_viewMode->addItem(KIcon("view-file-columns"), i18nc("@item:inlistbox", "Column"));
+
+    QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsGrid);
+    QWidget* sortingBox = new QWidget(propsGrid);
 
     m_sortOrder = new QComboBox(sortingBox);
-    m_sortOrder->addItem(i18nc("@item:inlistbox", "Ascending"));
-    m_sortOrder->addItem(i18nc("@item:inlistbox", "Descending"));
+    m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Ascending"));
+    m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Descending"));
 
     m_sorting = new QComboBox(sortingBox);
     m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Name"));
@@ -118,6 +122,11 @@ 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_additionalInfo = new QPushButton(i18nc("@action:button", "Additional Information"), propsBox);
 
     QHBoxLayout* sortingLayout = new QHBoxLayout();
     sortingLayout->setMargin(0);
@@ -125,23 +134,18 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     sortingLayout->addWidget(m_sorting);
     sortingBox->setLayout(sortingLayout);
 
-    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_additionalInfo = new QPushButton(i18nc("@action:button", "Additional Information"), propsBox);
-    connect(m_additionalInfo, SIGNAL(clicked()),
-            this, SLOT(configureAdditionalInfo()));
+    QGridLayout* propsGridLayout = new QGridLayout(propsGrid);
+    propsGridLayout->addWidget(viewModeLabel, 0, 0, Qt::AlignRight);
+    propsGridLayout->addWidget(m_viewMode, 0, 1);
+    propsGridLayout->addWidget(sortingLabel, 1, 0, Qt::AlignRight);
+    propsGridLayout->addWidget(sortingBox, 1, 1);
 
-    QGridLayout* propsBoxLayout = new QGridLayout(propsBox);
-    propsBoxLayout->addWidget(viewModeLabel, 0, 0);
-    propsBoxLayout->addWidget(m_viewMode, 0, 1);
-    propsBoxLayout->addWidget(sortingLabel, 1, 0);
-    propsBoxLayout->addWidget(sortingBox, 1, 1);
-    propsBoxLayout->addWidget(m_showPreview, 2, 0);
-    propsBoxLayout->addWidget(m_showInGroups, 3, 0);
-    propsBoxLayout->addWidget(m_showHiddenFiles, 4, 0);
-    propsBoxLayout->addWidget(m_additionalInfo, 5, 0);
+    QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox);
+    propsBoxLayout->addWidget(propsGrid);
+    propsBoxLayout->addWidget(m_showPreview);
+    propsBoxLayout->addWidget(m_showInGroups);
+    propsBoxLayout->addWidget(m_showHiddenFiles);
+    propsBoxLayout->addWidget(m_additionalInfo);
 
     topLayout->addWidget(propsBox);
 
@@ -151,8 +155,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
             this, SLOT(slotSortingChanged(int)));
     connect(m_sortOrder, SIGNAL(activated(int)),
             this, SLOT(slotSortOrderChanged(int)));
-    connect(m_additionalInfo, SIGNAL(activated(int)),
-            this, SLOT(slotAdditionalInfoChanged(int)));
+    connect(m_additionalInfo, SIGNAL(clicked()),
+            this, SLOT(configureAdditionalInfo()));
     connect(m_showPreview, SIGNAL(clicked()),
             this, SLOT(slotShowPreviewChanged()));
     connect(m_showInGroups, SIGNAL(clicked()),
@@ -307,8 +311,12 @@ void ViewPropertiesDialog::configureAdditionalInfo()
 
 void ViewPropertiesDialog::applyViewProperties()
 {
-    const bool applyToSubFolders = m_isDirty &&
-                                   (m_applyToSubFolders != 0) &&
+    // if nothing changed in the dialog, we have nothing to apply
+    if (!m_isDirty) {
+        return;
+    }
+
+    const bool applyToSubFolders = (m_applyToSubFolders != 0) &&
                                    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?"));
@@ -317,15 +325,34 @@ void ViewPropertiesDialog::applyViewProperties()
         }
 
         ViewPropsProgressInfo* info = new ViewPropsProgressInfo(m_dolphinView,
-                                      m_dolphinView->url(),
-                                      *m_viewProps);
+                                                                m_dolphinView->url(),
+                                                                *m_viewProps);
+        info->setAttribute(Qt::WA_DeleteOnClose);
         info->setWindowModality(Qt::NonModal);
         info->show();
     }
 
-    const bool applyToAllFolders = m_isDirty &&
-                                   (m_applyToAllFolders != 0) &&
+    const bool applyToAllFolders = (m_applyToAllFolders != 0) &&
                                    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());
+    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
+        // this file we temporary turn on the global view properties mode.
+        GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+        Q_ASSERT(!settings->globalViewProps());
+
+        settings->setGlobalViewProps(true);
+        ViewProperties defaultProps(m_dolphinView->url());
+        defaultProps.setDirProperties(*m_viewProps);
+        defaultProps.save();
+        settings->setGlobalViewProps(false);
+    }
+
     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) {
@@ -336,14 +363,8 @@ void ViewPropertiesDialog::applyViewProperties()
         // all existing viewproperties invalid, as they have a smaller time stamp.
         GeneralSettings* settings = DolphinSettings::instance().generalSettings();
         settings->setViewPropsTimestamp(QDateTime::currentDateTime());
-
-        // This is also a good chance to make a cleanup of all mirrored view properties:
-        const KUrl mirroredDir = ViewProperties::mirroredDirectory();
-        KIO::NetAccess::del(mirroredDir, this);
     }
 
-    m_viewProps->save();
-
     m_dolphinView->setMode(m_viewProps->viewMode());
     m_dolphinView->setSorting(m_viewProps->sorting());
     m_dolphinView->setSortOrder(m_viewProps->sortOrder());
@@ -352,21 +373,9 @@ void ViewPropertiesDialog::applyViewProperties()
     m_dolphinView->setShowPreview(m_viewProps->showPreview());
     m_dolphinView->setShowHiddenFiles(m_viewProps->showHiddenFiles());
 
-    m_isDirty = false;
-
-    if (m_useAsDefault && m_useAsDefault->isChecked()) {
-        // For directories where no .directory file is available, the .directory
-        // file stored for the global view properties is used as fallback. To update
-        // this file we temporary turn on the global view properties mode.
-        GeneralSettings* settings = DolphinSettings::instance().generalSettings();
-        Q_ASSERT(!settings->globalViewProps());
+    m_viewProps->save();
 
-        settings->setGlobalViewProps(true);
-        ViewProperties defaultProps(m_dolphinView->url());
-        defaultProps.setDirProperties(*m_viewProps);
-        defaultProps.save();
-        settings->setGlobalViewProps(false);
-    }
+    m_isDirty = false;
 }
 
 void ViewPropertiesDialog::loadSettings()
@@ -380,7 +389,9 @@ void ViewPropertiesDialog::loadSettings()
     m_sortOrder->setCurrentIndex(sortOrderIndex);
     m_sorting->setCurrentIndex(m_viewProps->sorting());
 
-    m_additionalInfo->setEnabled(index != DolphinView::ColumnView);
+    const bool enabled = (index == DolphinView::DetailsView) ||
+                         (index == DolphinView::IconsView);
+    m_additionalInfo->setEnabled(enabled);
 
     // load show preview, show in groups and show hidden files settings
     m_showPreview->setChecked(m_viewProps->showPreview());