┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/settings
diff options
context:
space:
mode:
authorNathaniel Graham <[email protected]>2018-07-14 13:55:04 -0600
committerNathaniel Graham <[email protected]>2018-07-14 13:55:40 -0600
commit9d1a3abd35f71efa005470c1c559f31bbfc10a8e (patch)
treea23f5a04b1a466a123bfbf6e5075e16b450f2e26 /src/settings
parent23c5fce77fd9a4a9589a6ef6f98ec6375039d958 (diff)
Modernize View Properties window
Summary: Like D12571, but for the {nav View Properties} Window. Also did a little bit of re-organization. This allows us to use a `QFormLayout` as the top-level layout and simplify the code a lot, including no longer using the now-unnecessary paradigm of putting a layout inside a `QWidget`, and ending the use of `QGridLayout` to make a fake and more complicated form-style layout. Depends on D13749 Test Plan: Window still resizes properly when the Additional Information content is shown or hidden. Global view properties, additional information hidden: {F6035943} Global view properties, additional information shown: {F6035945} Per-folder view properties, additional information hidden: {F6035869} Per-folder view properties, additional information shown: {F6035870} Reviewers: #dolphin, elvisangelaccio, broulik, #vdg Reviewed By: #dolphin, elvisangelaccio Subscribers: abetts, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D13768
Diffstat (limited to 'src/settings')
-rw-r--r--src/settings/viewpropertiesdialog.cpp78
1 files changed, 32 insertions, 46 deletions
diff --git a/src/settings/viewpropertiesdialog.cpp b/src/settings/viewpropertiesdialog.cpp
index f22287912..9002765b5 100644
--- a/src/settings/viewpropertiesdialog.cpp
+++ b/src/settings/viewpropertiesdialog.cpp
@@ -22,6 +22,7 @@
#include "dolphin_generalsettings.h"
#include "dolphin_iconsmodesettings.h"
+#include "global.h"
#include "kitemviews/kfileitemmodel.h"
#include "viewpropsprogressinfo.h"
#include "views/dolphinview.h"
@@ -38,12 +39,12 @@
#include <QButtonGroup>
#include <QCheckBox>
#include <QComboBox>
-#include <QGridLayout>
-#include <QGroupBox>
+#include <QFormLayout>
#include <QLabel>
#include <QListWidget>
#include <QPushButton>
#include <QRadioButton>
+#include <QSpacerItem>
#include <views/viewproperties.h>
@@ -73,35 +74,22 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
m_viewProps = new ViewProperties(url);
m_viewProps->setAutoSaveEnabled(false);
- auto layout = new QVBoxLayout(this);
+ auto layout = new QFormLayout(this);
// Otherwise the dialog won't resize when we collapse the KCollapsibleGroupBox.
layout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(layout);
- auto propsGrid = new QWidget(this);
- layout->addWidget(propsGrid);
-
// create 'Properties' group containing view mode, sorting, sort order and show hidden files
- QWidget* propsBox = this;
- if (!useGlobalViewProps) {
- propsBox = new QGroupBox(i18nc("@title:group", "Properties"), this);
- layout->addWidget(propsBox);
- }
-
- QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsGrid);
- m_viewMode = new QComboBox(propsGrid);
+ m_viewMode = new QComboBox();
m_viewMode->addItem(QIcon::fromTheme(QStringLiteral("view-list-icons")), i18nc("@item:inlistbox", "Icons"), DolphinView::IconsView);
m_viewMode->addItem(QIcon::fromTheme(QStringLiteral("view-list-details")), i18nc("@item:inlistbox", "Compact"), DolphinView::CompactView);
m_viewMode->addItem(QIcon::fromTheme(QStringLiteral("view-list-tree")), i18nc("@item:inlistbox", "Details"), DolphinView::DetailsView);
- QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsGrid);
- QWidget* sortingBox = new QWidget(propsGrid);
-
- m_sortOrder = new QComboBox(sortingBox);
+ m_sortOrder = new QComboBox();
m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Ascending"));
m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Descending"));
- m_sorting = new QComboBox(sortingBox);
+ m_sorting = new QComboBox();
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
m_sorting->addItem(info.translation, info.role);
@@ -113,7 +101,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
m_showHiddenFiles = new QCheckBox(i18nc("@option:check", "Show hidden files"));
auto additionalInfoBox = new KCollapsibleGroupBox();
- additionalInfoBox->setTitle(i18nc("@title:group", "Additional Information Shown"));
+ additionalInfoBox->setTitle(i18nc("@title:group", "Additional Information"));
auto innerLayout = new QVBoxLayout();
{
@@ -153,6 +141,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
}
}
+ QLabel* additionalViewOptionsLabel = new QLabel(i18n("Choose what to see on each file or folder:"));
+ innerLayout->addWidget(additionalViewOptionsLabel);
innerLayout->addWidget(m_listWidget);
}
@@ -162,21 +152,16 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
sortingLayout->setMargin(0);
sortingLayout->addWidget(m_sortOrder);
sortingLayout->addWidget(m_sorting);
- sortingBox->setLayout(sortingLayout);
- 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);
+ layout->addRow(i18nc("@label:listbox", "View mode:"), m_viewMode);
+ layout->addRow(i18nc("@label:listbox", "Sorting:"), sortingLayout);
- QVBoxLayout* propsBoxLayout = propsBox == this ? layout : new QVBoxLayout(propsBox);
- propsBoxLayout->addWidget(propsGrid);
- propsBoxLayout->addWidget(m_sortFoldersFirst);
- propsBoxLayout->addWidget(m_previewsShown);
- propsBoxLayout->addWidget(m_showInGroups);
- propsBoxLayout->addWidget(m_showHiddenFiles);
- propsBoxLayout->addWidget(additionalInfoBox);
+ layout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed));
+
+ layout->addRow(i18n("View options:"), m_sortFoldersFirst);
+ layout->addRow(QString(), m_previewsShown);
+ layout->addRow(QString(), m_showInGroups);
+ layout->addRow(QString(), m_showHiddenFiles);
connect(m_viewMode, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &ViewPropertiesDialog::slotViewModeChanged);
@@ -197,29 +182,28 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
// for each directory:
if (!useGlobalViewProps) {
// create 'Apply View Properties To' group
- QGroupBox* applyBox = new QGroupBox(i18nc("@title:group", "Apply View Properties To"), this);
- layout->addWidget(applyBox);
-
m_applyToCurrentFolder = new QRadioButton(i18nc("@option:radio Apply View Properties To",
- "Current folder"), applyBox);
+ "Current folder"));
m_applyToCurrentFolder->setChecked(true);
m_applyToSubFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To",
- "Current folder including all sub-folders"), applyBox);
+ "Current folder and sub-folders"));
m_applyToAllFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To",
- "All folders"), applyBox);
+ "All folders"));
QButtonGroup* applyGroup = new QButtonGroup(this);
applyGroup->addButton(m_applyToCurrentFolder);
applyGroup->addButton(m_applyToSubFolders);
applyGroup->addButton(m_applyToAllFolders);
- QVBoxLayout* applyBoxLayout = new QVBoxLayout(applyBox);
- applyBoxLayout->addWidget(m_applyToCurrentFolder);
- applyBoxLayout->addWidget(m_applyToSubFolders);
- applyBoxLayout->addWidget(m_applyToAllFolders);
+ layout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed));
- m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use these view properties as default"), this);
- layout->addWidget(m_useAsDefault);
+ layout->addRow(i18nc("@title:group", "Apply to:"), m_applyToCurrentFolder);
+ layout->addRow(QString(), m_applyToSubFolders);
+ layout->addRow(QString(), m_applyToAllFolders);
+ layout->addRow(QString(), m_applyToAllFolders);
+
+ 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);
@@ -231,7 +215,9 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
this, &ViewPropertiesDialog::markAsDirty);
}
- layout->addStretch();
+ layout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed));
+
+ layout->addRow(additionalInfoBox);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply, this);
connect(buttonBox, &QDialogButtonBox::accepted, this, &ViewPropertiesDialog::accept);