X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/25349096ae7fe344613d35e5548cac1a91b60fd1..c8072005fada01d772595ec64adca449134f421e:/src/viewpropertiesdialog.cpp diff --git a/src/viewpropertiesdialog.cpp b/src/viewpropertiesdialog.cpp index 76a45061e..040e9f6be 100644 --- a/src/viewpropertiesdialog.cpp +++ b/src/viewpropertiesdialog.cpp @@ -26,7 +26,10 @@ #include "dolphin_generalsettings.h" #include "viewproperties.h" -#include +#include +#ifdef HAVE_NEPOMUK +#include +#endif #include #include @@ -36,14 +39,17 @@ #include #include +#include #include #include #include #include #include #include +#include +#include #include -#include +#include ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : KDialog(dolphinView), @@ -51,19 +57,20 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : m_dolphinView(dolphinView), m_viewProps(0), m_viewMode(0), - m_sorting(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) { - assert(dolphinView != 0); + Q_ASSERT(dolphinView != 0); const bool useGlobalViewProps = DolphinSettings::instance().generalSettings()->globalViewProps(); - setCaption(i18n("View Properties")); + setCaption(i18nc("@title:window", "View Properties")); setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply); const KUrl& url = dolphinView->url(); @@ -76,59 +83,81 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : // create 'Properties' group containing view mode, sorting, sort order and show hidden files QWidget* propsBox = main; if (!useGlobalViewProps) { - propsBox = new QGroupBox(i18n("Properties"), main); + propsBox = new QGroupBox(i18nc("@title:group", "Properties"), main); } - QLabel* viewModeLabel = new QLabel(i18n("View mode:"), propsBox); + QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsBox); m_viewMode = new QComboBox(propsBox); - m_viewMode->addItem(SmallIcon("view-icon"), i18n("Icons")); - m_viewMode->addItem(SmallIcon("fileview-text"), i18n("Details")); + 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")); const int index = static_cast(m_viewProps->viewMode()); m_viewMode->setCurrentIndex(index); - - QLabel* sortingLabel = new QLabel(i18n("Sorting:"), propsBox); - m_sorting = new QComboBox(propsBox); - 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"); + const bool iconsViewEnabled = (index == DolphinView::IconsView); + + QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsBox); + QWidget* sortingBox = new QWidget(propsBox); + + m_sortOrder = new QComboBox(sortingBox); + m_sortOrder->addItem(i18nc("@item:inlistbox", "Ascending")); + m_sortOrder->addItem(i18nc("@item:inlistbox", "Descending")); + const int sortOrderIndex = (m_viewProps->sortOrder() == Qt::AscendingOrder) ? 0 : 1; + m_sortOrder->setCurrentIndex(sortOrderIndex); + + m_sorting = new QComboBox(sortingBox); + m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Name")); + m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Size")); + m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Date")); + m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Permissions")); + m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Owner")); + m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Group")); + m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Type")); +#ifdef HAVE_NEPOMUK + if (!Nepomuk::ResourceManager::instance()->init()) { + m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Rating")); + m_sorting->addItem(i18nc("@item:inlistbox Sort", "By Tags")); + } +#endif m_sorting->setCurrentIndex(m_viewProps->sorting()); - QLabel* sortOrderLabel = new QLabel(i18n("Sort order:"), propsBox); - m_sortOrder = new QComboBox(propsBox); - m_sortOrder->addItem(i18n("Ascending")); - m_sortOrder->addItem(i18n("Descending")); - const int sortOrderIdx = (m_viewProps->sortOrder() == Qt::Ascending) ? 0 : 1; - m_sortOrder->setCurrentIndex(sortOrderIdx); + QHBoxLayout* sortingLayout = new QHBoxLayout(); + sortingLayout->setMargin(0); + sortingLayout->addWidget(m_sortOrder); + sortingLayout->addWidget(m_sorting); + sortingBox->setLayout(sortingLayout); - QLabel* additionalInfoLabel = new QLabel(i18n("Additional information:"), propsBox); + QLabel* additionalInfoLabel = new QLabel(i18nc("@label:listbox", "Additional information:"), propsBox); m_additionalInfo = new QComboBox(propsBox); - m_additionalInfo->addItem(i18n("No Information"), KFileItemDelegate::NoInformation); - m_additionalInfo->addItem(i18n("MIME Type"), KFileItemDelegate::FriendlyMimeType); - m_additionalInfo->addItem(i18n("Size"), KFileItemDelegate::Size); - m_additionalInfo->addItem(i18n("Date"), KFileItemDelegate::ModificationTime); + m_additionalInfo->addItem(i18nc("@item:inlistbox Additional info", "No Information"), + KFileItemDelegate::NoInformation); + m_additionalInfo->addItem(i18nc("@item:inlistbox Additional info", "Type"), + KFileItemDelegate::FriendlyMimeType); + m_additionalInfo->addItem(i18nc("@item:inlistbox Additional info", "Size"), + KFileItemDelegate::Size); + m_additionalInfo->addItem(i18nc("@item:inlistbox Additional info", "Date"), + KFileItemDelegate::ModificationTime); const int addInfoIndex = m_additionalInfo->findData(m_viewProps->additionalInfo()); m_additionalInfo->setCurrentIndex(addInfoIndex); + m_additionalInfo->setEnabled(iconsViewEnabled); - m_showPreview = new QCheckBox(i18n("Show preview"), propsBox); + m_showPreview = new QCheckBox(i18nc("@option:check", "Show preview"), propsBox); m_showPreview->setChecked(m_viewProps->showPreview()); - m_showHiddenFiles = new QCheckBox(i18n("Show hidden files"), propsBox); + m_showInGroups = new QCheckBox(i18nc("@option:check", "Show in Groups"), propsBox); + m_showInGroups->setChecked(m_viewProps->categorizedSorting()); + + m_showHiddenFiles = new QCheckBox(i18nc("@option:check", "Show hidden files"), propsBox); m_showHiddenFiles->setChecked(m_viewProps->showHiddenFiles()); QGridLayout* propsBoxLayout = new QGridLayout(propsBox); propsBoxLayout->addWidget(viewModeLabel, 0, 0); propsBoxLayout->addWidget(m_viewMode, 0, 1); - propsBoxLayout->addWidget(m_sorting, 1, 1); propsBoxLayout->addWidget(sortingLabel, 1, 0); - propsBoxLayout->addWidget(m_sorting, 1, 1); - propsBoxLayout->addWidget(sortOrderLabel, 2, 0); - propsBoxLayout->addWidget(m_sortOrder, 2, 1); - propsBoxLayout->addWidget(additionalInfoLabel, 3, 0); - propsBoxLayout->addWidget(m_additionalInfo, 3, 1); - propsBoxLayout->addWidget(m_showPreview, 4, 0); + propsBoxLayout->addWidget(sortingBox, 1, 1); + propsBoxLayout->addWidget(additionalInfoLabel, 2, 0); + propsBoxLayout->addWidget(m_additionalInfo, 2, 1); + propsBoxLayout->addWidget(m_showPreview, 3, 0); + propsBoxLayout->addWidget(m_showInGroups, 4, 0); propsBoxLayout->addWidget(m_showHiddenFiles, 5, 0); topLayout->addWidget(propsBox); @@ -143,6 +172,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : 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())); @@ -152,13 +183,16 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : // Only show the following settings if the view properties are remembered // for each directory: if (!useGlobalViewProps) { - // create 'Apply view properties to:' group - QGroupBox* applyBox = new QGroupBox(i18n("Apply view properties to:"), main); + // create 'Apply View Properties To' group + QGroupBox* applyBox = new QGroupBox(i18nc("@title:group", "Apply View Properties To"), main); - m_applyToCurrentFolder = new QRadioButton(i18n("Current folder"), applyBox); + m_applyToCurrentFolder = new QRadioButton(i18nc("@option:radio Apply View Properties To", + "Current folder"), applyBox); m_applyToCurrentFolder->setChecked(true); - m_applyToSubFolders = new QRadioButton(i18n("Current folder including all sub folders"), applyBox); - m_applyToAllFolders = new QRadioButton(i18n("All folders"),applyBox); + m_applyToSubFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", + "Current folder including all sub folders"), applyBox); + m_applyToAllFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", + "All folders"), applyBox); QButtonGroup* applyGroup = new QButtonGroup(this); applyGroup->addButton(m_applyToCurrentFolder); @@ -170,7 +204,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : applyBoxLayout->addWidget(m_applyToSubFolders); applyBoxLayout->addWidget(m_applyToAllFolders); - m_useAsDefault = new QCheckBox(i18n("Use as default for new folders"), main); + m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use as default for new folders"), main); topLayout->addWidget(applyBox); topLayout->addWidget(m_useAsDefault); @@ -187,6 +221,10 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : main->setLayout(topLayout); setMainWidget(main); + + const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), + "ViewPropertiesDialog"); + restoreDialogSize(dialogConfig); } ViewPropertiesDialog::~ViewPropertiesDialog() @@ -194,6 +232,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() @@ -209,9 +251,12 @@ void ViewPropertiesDialog::slotApply() void ViewPropertiesDialog::slotViewModeChanged(int index) { - assert((index >= 0) && (index <= 2)); m_viewProps->setViewMode(static_cast(index)); m_isDirty = true; + + const bool iconsViewEnabled = (m_viewProps->viewMode() == DolphinView::IconsView); + m_showInGroups->setEnabled(iconsViewEnabled); + m_additionalInfo->setEnabled(iconsViewEnabled); } void ViewPropertiesDialog::slotSortingChanged(int index) @@ -223,19 +268,25 @@ void ViewPropertiesDialog::slotSortingChanged(int index) void ViewPropertiesDialog::slotSortOrderChanged(int index) { - Qt::SortOrder sortOrder = (index == 0) ? Qt::Ascending : Qt::Descending; + const Qt::SortOrder sortOrder = (index == 0) ? Qt::AscendingOrder : Qt::DescendingOrder; m_viewProps->setSortOrder(sortOrder); m_isDirty = true; } +void ViewPropertiesDialog::slotCategorizedSortingChanged() +{ + m_viewProps->setCategorizedSorting(m_showInGroups->isChecked()); + m_isDirty = true; +} + void ViewPropertiesDialog::slotAdditionalInfoChanged(int index) { KFileItemDelegate::AdditionalInformation info = KFileItemDelegate::NoInformation; switch (index) { - case 1: info = KFileItemDelegate::FriendlyMimeType; break; - case 2: info = KFileItemDelegate::Size; break; - case 3: info = KFileItemDelegate::ModificationTime; break; - default: break; + case 1: info = KFileItemDelegate::FriendlyMimeType; break; + case 2: info = KFileItemDelegate::Size; break; + case 3: info = KFileItemDelegate::ModificationTime; break; + default: break; } m_viewProps->setAdditionalInfo(info); m_isDirty = true; @@ -266,14 +317,14 @@ void ViewPropertiesDialog::applyViewProperties() (m_applyToSubFolders != 0) && m_applyToSubFolders->isChecked(); if (applyToSubFolders) { - const QString text(i18n("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; } ViewPropsProgressInfo* info = new ViewPropsProgressInfo(m_dolphinView, - m_dolphinView->url(), - *m_viewProps); + m_dolphinView->url(), + *m_viewProps); info->setWindowModality(Qt::NonModal); info->show(); } @@ -282,7 +333,7 @@ void ViewPropertiesDialog::applyViewProperties() (m_applyToAllFolders != 0) && m_applyToAllFolders->isChecked(); if (applyToAllFolders) { - const QString text(i18n("The view properties of all folders will be changed. Do you want to continue?")); + 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) { return; } @@ -302,6 +353,8 @@ void ViewPropertiesDialog::applyViewProperties() m_dolphinView->setMode(m_viewProps->viewMode()); m_dolphinView->setSorting(m_viewProps->sorting()); m_dolphinView->setSortOrder(m_viewProps->sortOrder()); + m_dolphinView->setCategorizedSorting(m_viewProps->categorizedSorting()); + m_dolphinView->setAdditionalInfo(m_viewProps->additionalInfo()); m_dolphinView->setShowPreview(m_viewProps->showPreview()); m_dolphinView->setShowHiddenFiles(m_viewProps->showHiddenFiles()); @@ -312,7 +365,7 @@ void ViewPropertiesDialog::applyViewProperties() // 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(); - assert(!settings->globalViewProps()); + Q_ASSERT(!settings->globalViewProps()); settings->setGlobalViewProps(true); ViewProperties defaultProps(m_dolphinView->url());