]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/viewpropertiesdialog.cpp
Fix the problem "the scrollbar remains if it was shown on the
[dolphin.git] / src / viewpropertiesdialog.cpp
index 61fd38476967b2c084e9330fd21a4fd5c4bca60a..5d7fbc59f631ce65cbd2367d0cd6b01e1d9de5f7 100644 (file)
 #include <kstandarddirs.h>
 #include <kurl.h>
 
+#include <QAction>
 #include <QButtonGroup>
 #include <QCheckBox>
 #include <QComboBox>
 #include <QGridLayout>
 #include <QGroupBox>
 #include <QLabel>
+#include <QMenu>
+#include <QPushButton>
 #include <QRadioButton>
-#include <QVBoxLayout>
+#include <QBoxLayout>
 
 ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
-        KDialog(dolphinView),
-        m_isDirty(false),
-        m_dolphinView(dolphinView),
-        m_viewProps(0),
-        m_viewMode(0),
-        m_sorting(0),
-        m_sortOrder(0),
-        m_categorizedSorting(0),
-        m_additionalInfo(0),
-        m_showPreview(0),
-        m_showHiddenFiles(0),
-        m_applyToCurrentFolder(0),
-        m_applyToSubFolders(0),
-        m_useAsDefault(0)
+    KDialog(dolphinView),
+    m_isDirty(false),
+    m_dolphinView(dolphinView),
+    m_viewProps(0),
+    m_viewMode(0),
+    m_sortOrder(0),
+    m_sorting(0),
+    m_additionalInfo(0),
+    m_showPreview(0),
+    m_showInGroups(0),
+    m_showHiddenFiles(0),
+    m_applyToCurrentFolder(0),
+    m_applyToSubFolders(0),
+    m_useAsDefault(0)
 {
     Q_ASSERT(dolphinView != 0);
     const bool useGlobalViewProps = DolphinSettings::instance().generalSettings()->globalViewProps();
@@ -80,11 +83,12 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
 
     QLabel* viewModeLabel = new QLabel(i18n("View mode:"), propsBox);
     m_viewMode = new QComboBox(propsBox);
-    m_viewMode->addItem(KIcon("view-icon"), i18n("Icons"));
-    m_viewMode->addItem(KIcon("fileview-text"), i18n("Details"));
-    m_viewMode->addItem(KIcon("view-tree"), i18n("Column"));
+    m_viewMode->addItem(KIcon("fileview-icon"), i18n("Icons"));
+    m_viewMode->addItem(KIcon("fileview-detailed"), i18n("Details"));
+    m_viewMode->addItem(KIcon("fileview-column"), i18n("Column"));
     const int index = static_cast<int>(m_viewProps->viewMode());
     m_viewMode->setCurrentIndex(index);
+    const bool iconsViewEnabled = (index == DolphinView::IconsView);
 
     QLabel* sortingLabel = new QLabel(i18n("Sorting:"), propsBox);
     QWidget* sortingBox = new QWidget(propsBox);
@@ -92,28 +96,23 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     m_sortOrder = new QComboBox(sortingBox);
     m_sortOrder->addItem(i18n("Ascending"));
     m_sortOrder->addItem(i18n("Descending"));
-    const int sortOrderIdx = (m_viewProps->sortOrder() == Qt::AscendingOrder) ? 0 : 1;
-    m_sortOrder->setCurrentIndex(sortOrderIdx);
-
-    m_categorizedSorting = new QComboBox(sortingBox);
-    m_categorizedSorting->addItem(i18n("Uncategorized"));
-    m_categorizedSorting->addItem(i18n("Categorized"));
-    m_categorizedSorting->setCurrentIndex(m_viewProps->categorizedSorting() ? 1 : 0);
+    const int sortOrderIndex = (m_viewProps->sortOrder() == Qt::AscendingOrder) ? 0 : 1;
+    m_sortOrder->setCurrentIndex(sortOrderIndex);
 
     m_sorting = new QComboBox(sortingBox);
-    m_sorting->addItem("By Name");
-    m_sorting->addItem("By Size");
-    m_sorting->addItem("By Date");
-    m_sorting->addItem("By Permissions");
-    m_sorting->addItem("By Owner");
-    m_sorting->addItem("By Group");
+    m_sorting->addItem(i18n("By Name"));
+    m_sorting->addItem(i18n("By Size"));
+    m_sorting->addItem(i18n("By Date"));
+    m_sorting->addItem(i18n("By Permissions"));
+    m_sorting->addItem(i18n("By Owner"));
+    m_sorting->addItem(i18n("By Group"));
+    m_sorting->addItem(i18n("By Type"));
     m_sorting->setCurrentIndex(m_viewProps->sorting());
 
     QHBoxLayout* sortingLayout = new QHBoxLayout();
     sortingLayout->setMargin(0);
     sortingLayout->addWidget(m_sortOrder);
     sortingLayout->addWidget(m_sorting);
-    sortingLayout->addWidget(m_categorizedSorting);
     sortingBox->setLayout(sortingLayout);
 
     QLabel* additionalInfoLabel = new QLabel(i18n("Additional information:"), propsBox);
@@ -124,11 +123,14 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     m_additionalInfo->addItem(i18n("Date"), KFileItemDelegate::ModificationTime);
     const int addInfoIndex = m_additionalInfo->findData(m_viewProps->additionalInfo());
     m_additionalInfo->setCurrentIndex(addInfoIndex);
-    m_additionalInfo->setEnabled(m_viewProps->viewMode() == DolphinView::IconsView);
+    m_additionalInfo->setEnabled(iconsViewEnabled);
 
     m_showPreview = new QCheckBox(i18n("Show preview"), propsBox);
     m_showPreview->setChecked(m_viewProps->showPreview());
 
+    m_showInGroups = new QCheckBox(i18n("Show in Groups"), propsBox);
+    m_showInGroups->setChecked(m_viewProps->categorizedSorting());
+
     m_showHiddenFiles = new QCheckBox(i18n("Show hidden files"), propsBox);
     m_showHiddenFiles->setChecked(m_viewProps->showHiddenFiles());
 
@@ -140,7 +142,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     propsBoxLayout->addWidget(additionalInfoLabel, 2, 0);
     propsBoxLayout->addWidget(m_additionalInfo, 2, 1);
     propsBoxLayout->addWidget(m_showPreview, 3, 0);
-    propsBoxLayout->addWidget(m_showHiddenFiles, 4, 0);
+    propsBoxLayout->addWidget(m_showInGroups, 4, 0);
+    propsBoxLayout->addWidget(m_showHiddenFiles, 5, 0);
 
     topLayout->addWidget(propsBox);
 
@@ -150,12 +153,12 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
             this, SLOT(slotSortingChanged(int)));
     connect(m_sortOrder, SIGNAL(activated(int)),
             this, SLOT(slotSortOrderChanged(int)));
-    connect(m_categorizedSorting, SIGNAL(activated(int)),
-            this, SLOT(slotCategorizedSortingChanged(int)));
     connect(m_additionalInfo, SIGNAL(activated(int)),
             this, SLOT(slotAdditionalInfoChanged(int)));
     connect(m_showPreview, SIGNAL(clicked()),
             this, SLOT(slotShowPreviewChanged()));
+    connect(m_showInGroups, SIGNAL(clicked()),
+            this, SLOT(slotCategorizedSortingChanged()));
     connect(m_showHiddenFiles, SIGNAL(clicked()),
             this, SLOT(slotShowHiddenFilesChanged()));
 
@@ -200,6 +203,10 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
 
     main->setLayout(topLayout);
     setMainWidget(main);
+
+    const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
+                                    "ViewPropertiesDialog");
+    restoreDialogSize(dialogConfig);
 }
 
 ViewPropertiesDialog::~ViewPropertiesDialog()
@@ -207,6 +214,10 @@ ViewPropertiesDialog::~ViewPropertiesDialog()
     m_isDirty = false;
     delete m_viewProps;
     m_viewProps = 0;
+
+    KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"),
+                              "ViewPropertiesDialog");
+    saveDialogSize(dialogConfig, KConfigFlags::Persistent);
 }
 
 void ViewPropertiesDialog::slotOk()
@@ -226,7 +237,7 @@ void ViewPropertiesDialog::slotViewModeChanged(int index)
     m_isDirty = true;
 
     const bool iconsViewEnabled = (m_viewProps->viewMode() == DolphinView::IconsView);
-    m_categorizedSorting->setEnabled(iconsViewEnabled);
+    m_showInGroups->setEnabled(iconsViewEnabled);
     m_additionalInfo->setEnabled(iconsViewEnabled);
 }
 
@@ -239,14 +250,14 @@ void ViewPropertiesDialog::slotSortingChanged(int index)
 
 void ViewPropertiesDialog::slotSortOrderChanged(int index)
 {
-    Qt::SortOrder sortOrder = (index == 0) ? Qt::AscendingOrder : Qt::DescendingOrder;
+    const Qt::SortOrder sortOrder = (index == 0) ? Qt::AscendingOrder : Qt::DescendingOrder;
     m_viewProps->setSortOrder(sortOrder);
     m_isDirty = true;
 }
 
-void ViewPropertiesDialog::slotCategorizedSortingChanged(int index)
+void ViewPropertiesDialog::slotCategorizedSortingChanged()
 {
-    m_viewProps->setCategorizedSorting(index == 1);
+    m_viewProps->setCategorizedSorting(m_showInGroups->isChecked());
     m_isDirty = true;
 }