Changeset View
Changeset View
Standalone View
Standalone View
src/settings/viewpropertiesdialog.cpp
Show All 32 Lines | |||||
33 | 33 | | |||
34 | #ifdef HAVE_BALOO | 34 | #ifdef HAVE_BALOO | ||
35 | #include <Baloo/IndexerConfig> | 35 | #include <Baloo/IndexerConfig> | ||
36 | #endif | 36 | #endif | ||
37 | 37 | | |||
38 | #include <QButtonGroup> | 38 | #include <QButtonGroup> | ||
39 | #include <QCheckBox> | 39 | #include <QCheckBox> | ||
40 | #include <QComboBox> | 40 | #include <QComboBox> | ||
41 | #include <QFormLayout> | ||||
41 | #include <QGridLayout> | 42 | #include <QGridLayout> | ||
42 | #include <QGroupBox> | 43 | #include <QGroupBox> | ||
43 | #include <QLabel> | 44 | #include <QLabel> | ||
44 | #include <QListWidget> | 45 | #include <QListWidget> | ||
45 | #include <QPushButton> | 46 | #include <QPushButton> | ||
46 | #include <QRadioButton> | 47 | #include <QRadioButton> | ||
48 | #include <QSpacerItem> | ||||
47 | 49 | | |||
48 | #include <views/viewproperties.h> | 50 | #include <views/viewproperties.h> | ||
49 | 51 | | |||
50 | ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : | 52 | ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : | ||
51 | QDialog(dolphinView), | 53 | QDialog(dolphinView), | ||
52 | m_isDirty(false), | 54 | m_isDirty(false), | ||
53 | m_dolphinView(dolphinView), | 55 | m_dolphinView(dolphinView), | ||
54 | m_viewProps(nullptr), | 56 | m_viewProps(nullptr), | ||
Show All 13 Lines | 68 | { | |||
68 | const bool useGlobalViewProps = GeneralSettings::globalViewProps(); | 70 | const bool useGlobalViewProps = GeneralSettings::globalViewProps(); | ||
69 | 71 | | |||
70 | setWindowTitle(i18nc("@title:window", "View Properties")); | 72 | setWindowTitle(i18nc("@title:window", "View Properties")); | ||
71 | 73 | | |||
72 | const QUrl& url = dolphinView->url(); | 74 | const QUrl& url = dolphinView->url(); | ||
73 | m_viewProps = new ViewProperties(url); | 75 | m_viewProps = new ViewProperties(url); | ||
74 | m_viewProps->setAutoSaveEnabled(false); | 76 | m_viewProps->setAutoSaveEnabled(false); | ||
75 | 77 | | |||
76 | auto layout = new QVBoxLayout(this); | 78 | auto layout = new QFormLayout(this); | ||
77 | // Otherwise the dialog won't resize when we collapse the KCollapsibleGroupBox. | 79 | // Otherwise the dialog won't resize when we collapse the KCollapsibleGroupBox. | ||
78 | layout->setSizeConstraint(QLayout::SetFixedSize); | 80 | layout->setSizeConstraint(QLayout::SetFixedSize); | ||
79 | setLayout(layout); | 81 | setLayout(layout); | ||
80 | 82 | | |||
81 | auto propsGrid = new QWidget(this); | | |||
82 | layout->addWidget(propsGrid); | | |||
83 | | ||||
84 | // create 'Properties' group containing view mode, sorting, sort order and show hidden files | 83 | // create 'Properties' group containing view mode, sorting, sort order and show hidden files | ||
85 | QWidget* propsBox = this; | 84 | m_viewMode = new QComboBox(); | ||
86 | if (!useGlobalViewProps) { | | |||
87 | propsBox = new QGroupBox(i18nc("@title:group", "Properties"), this); | | |||
88 | layout->addWidget(propsBox); | | |||
89 | } | | |||
90 | | ||||
91 | QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsGrid); | | |||
92 | m_viewMode = new QComboBox(propsGrid); | | |||
93 | m_viewMode->addItem(QIcon::fromTheme(QStringLiteral("view-list-icons")), i18nc("@item:inlistbox", "Icons"), DolphinView::IconsView); | 85 | m_viewMode->addItem(QIcon::fromTheme(QStringLiteral("view-list-icons")), i18nc("@item:inlistbox", "Icons"), DolphinView::IconsView); | ||
94 | m_viewMode->addItem(QIcon::fromTheme(QStringLiteral("view-list-details")), i18nc("@item:inlistbox", "Compact"), DolphinView::CompactView); | 86 | m_viewMode->addItem(QIcon::fromTheme(QStringLiteral("view-list-details")), i18nc("@item:inlistbox", "Compact"), DolphinView::CompactView); | ||
95 | m_viewMode->addItem(QIcon::fromTheme(QStringLiteral("view-list-tree")), i18nc("@item:inlistbox", "Details"), DolphinView::DetailsView); | 87 | m_viewMode->addItem(QIcon::fromTheme(QStringLiteral("view-list-tree")), i18nc("@item:inlistbox", "Details"), DolphinView::DetailsView); | ||
96 | 88 | | |||
97 | QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsGrid); | 89 | m_sortOrder = new QComboBox(); | ||
98 | QWidget* sortingBox = new QWidget(propsGrid); | | |||
99 | | ||||
100 | m_sortOrder = new QComboBox(sortingBox); | | |||
101 | m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Ascending")); | 90 | m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Ascending")); | ||
102 | m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Descending")); | 91 | m_sortOrder->addItem(i18nc("@item:inlistbox Sort", "Descending")); | ||
103 | 92 | | |||
104 | m_sorting = new QComboBox(sortingBox); | 93 | m_sorting = new QComboBox(); | ||
105 | const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation(); | 94 | const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation(); | ||
106 | foreach (const KFileItemModel::RoleInfo& info, rolesInfo) { | 95 | foreach (const KFileItemModel::RoleInfo& info, rolesInfo) { | ||
107 | m_sorting->addItem(info.translation, info.role); | 96 | m_sorting->addItem(info.translation, info.role); | ||
108 | } | 97 | } | ||
109 | 98 | | |||
110 | m_sortFoldersFirst = new QCheckBox(i18nc("@option:check", "Show folders first")); | 99 | m_sortFoldersFirst = new QCheckBox(i18nc("@option:check", "Show folders first")); | ||
111 | m_previewsShown = new QCheckBox(i18nc("@option:check", "Show preview")); | 100 | m_previewsShown = new QCheckBox(i18nc("@option:check", "Show preview")); | ||
112 | m_showInGroups = new QCheckBox(i18nc("@option:check", "Show in groups")); | 101 | m_showInGroups = new QCheckBox(i18nc("@option:check", "Show in groups")); | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 127 | #endif | |||
157 | } | 146 | } | ||
158 | 147 | | |||
159 | additionalInfoBox->setLayout(innerLayout); | 148 | additionalInfoBox->setLayout(innerLayout); | ||
160 | 149 | | |||
161 | QHBoxLayout* sortingLayout = new QHBoxLayout(); | 150 | QHBoxLayout* sortingLayout = new QHBoxLayout(); | ||
162 | sortingLayout->setMargin(0); | 151 | sortingLayout->setMargin(0); | ||
163 | sortingLayout->addWidget(m_sortOrder); | 152 | sortingLayout->addWidget(m_sortOrder); | ||
164 | sortingLayout->addWidget(m_sorting); | 153 | sortingLayout->addWidget(m_sorting); | ||
165 | sortingBox->setLayout(sortingLayout); | | |||
166 | 154 | | |||
167 | QGridLayout* propsGridLayout = new QGridLayout(propsGrid); | 155 | layout->addRow(i18nc("@label:listbox", "View mode:"), m_viewMode); | ||
168 | propsGridLayout->addWidget(viewModeLabel, 0, 0, Qt::AlignRight); | 156 | layout->addRow(i18nc("@label:listbox", "Sorting:"), sortingLayout); | ||
169 | propsGridLayout->addWidget(m_viewMode, 0, 1); | 157 | | ||
170 | propsGridLayout->addWidget(sortingLabel, 1, 0, Qt::AlignRight); | 158 | layout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
elvisangelaccio: Please use `VERTICAL_SPACER_HEIGHT`. | |||||
171 | propsGridLayout->addWidget(sortingBox, 1, 1); | 159 | | ||
172 | 160 | layout->addRow(i18n("View options:"), m_sortFoldersFirst); | |||
173 | QVBoxLayout* propsBoxLayout = propsBox == this ? layout : new QVBoxLayout(propsBox); | 161 | layout->addRow(QString(), m_previewsShown); | ||
174 | propsBoxLayout->addWidget(propsGrid); | 162 | layout->addRow(QString(), m_showInGroups); | ||
175 | propsBoxLayout->addWidget(m_sortFoldersFirst); | 163 | layout->addRow(QString(), m_showHiddenFiles); | ||
176 | propsBoxLayout->addWidget(m_previewsShown); | | |||
177 | propsBoxLayout->addWidget(m_showInGroups); | | |||
178 | propsBoxLayout->addWidget(m_showHiddenFiles); | | |||
179 | propsBoxLayout->addWidget(additionalInfoBox); | | |||
180 | 164 | | |||
181 | connect(m_viewMode, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), | 165 | connect(m_viewMode, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), | ||
182 | this, &ViewPropertiesDialog::slotViewModeChanged); | 166 | this, &ViewPropertiesDialog::slotViewModeChanged); | ||
183 | connect(m_sorting, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), | 167 | connect(m_sorting, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), | ||
184 | this, &ViewPropertiesDialog::slotSortingChanged); | 168 | this, &ViewPropertiesDialog::slotSortingChanged); | ||
185 | connect(m_sortOrder, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), | 169 | connect(m_sortOrder, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), | ||
186 | this, &ViewPropertiesDialog::slotSortOrderChanged); | 170 | this, &ViewPropertiesDialog::slotSortOrderChanged); | ||
187 | connect(m_sortFoldersFirst, &QCheckBox::clicked, | 171 | connect(m_sortFoldersFirst, &QCheckBox::clicked, | ||
188 | this, &ViewPropertiesDialog::slotSortFoldersFirstChanged); | 172 | this, &ViewPropertiesDialog::slotSortFoldersFirstChanged); | ||
189 | connect(m_previewsShown, &QCheckBox::clicked, | 173 | connect(m_previewsShown, &QCheckBox::clicked, | ||
190 | this, &ViewPropertiesDialog::slotShowPreviewChanged); | 174 | this, &ViewPropertiesDialog::slotShowPreviewChanged); | ||
191 | connect(m_showInGroups, &QCheckBox::clicked, | 175 | connect(m_showInGroups, &QCheckBox::clicked, | ||
192 | this, &ViewPropertiesDialog::slotGroupedSortingChanged); | 176 | this, &ViewPropertiesDialog::slotGroupedSortingChanged); | ||
193 | connect(m_showHiddenFiles, &QCheckBox::clicked, | 177 | connect(m_showHiddenFiles, &QCheckBox::clicked, | ||
194 | this, &ViewPropertiesDialog::slotShowHiddenFilesChanged); | 178 | this, &ViewPropertiesDialog::slotShowHiddenFilesChanged); | ||
195 | 179 | | |||
196 | // Only show the following settings if the view properties are remembered | 180 | // Only show the following settings if the view properties are remembered | ||
197 | // for each directory: | 181 | // for each directory: | ||
198 | if (!useGlobalViewProps) { | 182 | if (!useGlobalViewProps) { | ||
199 | // create 'Apply View Properties To' group | 183 | // create 'Apply View Properties To' group | ||
200 | QGroupBox* applyBox = new QGroupBox(i18nc("@title:group", "Apply View Properties To"), this); | | |||
201 | layout->addWidget(applyBox); | | |||
202 | | ||||
203 | m_applyToCurrentFolder = new QRadioButton(i18nc("@option:radio Apply View Properties To", | 184 | m_applyToCurrentFolder = new QRadioButton(i18nc("@option:radio Apply View Properties To", | ||
204 | "Current folder"), applyBox); | 185 | "Current folder")); | ||
205 | m_applyToCurrentFolder->setChecked(true); | 186 | m_applyToCurrentFolder->setChecked(true); | ||
206 | m_applyToSubFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", | 187 | m_applyToSubFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", | ||
207 | "Current folder including all sub-folders"), applyBox); | 188 | "Current folder including all sub-folders")); | ||
208 | m_applyToAllFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", | 189 | m_applyToAllFolders = new QRadioButton(i18nc("@option:radio Apply View Properties To", | ||
209 | "All folders"), applyBox); | 190 | "All folders")); | ||
210 | 191 | | |||
211 | QButtonGroup* applyGroup = new QButtonGroup(this); | 192 | QButtonGroup* applyGroup = new QButtonGroup(this); | ||
212 | applyGroup->addButton(m_applyToCurrentFolder); | 193 | applyGroup->addButton(m_applyToCurrentFolder); | ||
213 | applyGroup->addButton(m_applyToSubFolders); | 194 | applyGroup->addButton(m_applyToSubFolders); | ||
214 | applyGroup->addButton(m_applyToAllFolders); | 195 | applyGroup->addButton(m_applyToAllFolders); | ||
215 | 196 | | |||
216 | QVBoxLayout* applyBoxLayout = new QVBoxLayout(applyBox); | 197 | layout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
217 | applyBoxLayout->addWidget(m_applyToCurrentFolder); | 198 | | ||
218 | applyBoxLayout->addWidget(m_applyToSubFolders); | 199 | layout->addRow(i18nc("@title:group", "Apply to:"), m_applyToCurrentFolder); | ||
219 | applyBoxLayout->addWidget(m_applyToAllFolders); | 200 | layout->addRow(QString(), m_applyToSubFolders); | ||
201 | layout->addRow(QString(), m_applyToAllFolders); | ||||
202 | layout->addRow(QString(), m_applyToAllFolders); | ||||
220 | 203 | | |||
221 | m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use these view properties as default"), this); | 204 | m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use these view properties as default"), this); | ||
222 | layout->addWidget(m_useAsDefault); | 205 | layout->addRow(QString(), m_useAsDefault); | ||
223 | 206 | | |||
224 | connect(m_applyToCurrentFolder, &QRadioButton::clicked, | 207 | connect(m_applyToCurrentFolder, &QRadioButton::clicked, | ||
225 | this, &ViewPropertiesDialog::markAsDirty); | 208 | this, &ViewPropertiesDialog::markAsDirty); | ||
226 | connect(m_applyToSubFolders, &QRadioButton::clicked, | 209 | connect(m_applyToSubFolders, &QRadioButton::clicked, | ||
227 | this, &ViewPropertiesDialog::markAsDirty); | 210 | this, &ViewPropertiesDialog::markAsDirty); | ||
228 | connect(m_applyToAllFolders, &QRadioButton::clicked, | 211 | connect(m_applyToAllFolders, &QRadioButton::clicked, | ||
229 | this, &ViewPropertiesDialog::markAsDirty); | 212 | this, &ViewPropertiesDialog::markAsDirty); | ||
230 | connect(m_useAsDefault, &QCheckBox::clicked, | 213 | connect(m_useAsDefault, &QCheckBox::clicked, | ||
231 | this, &ViewPropertiesDialog::markAsDirty); | 214 | this, &ViewPropertiesDialog::markAsDirty); | ||
232 | } | 215 | } | ||
233 | 216 | | |||
234 | layout->addStretch(); | 217 | layout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
218 | | ||||
219 | layout->addRow(additionalInfoBox); | ||||
235 | 220 | | |||
236 | auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply, this); | 221 | auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply, this); | ||
237 | connect(buttonBox, &QDialogButtonBox::accepted, this, &ViewPropertiesDialog::accept); | 222 | connect(buttonBox, &QDialogButtonBox::accepted, this, &ViewPropertiesDialog::accept); | ||
238 | connect(buttonBox, &QDialogButtonBox::rejected, this, &ViewPropertiesDialog::reject); | 223 | connect(buttonBox, &QDialogButtonBox::rejected, this, &ViewPropertiesDialog::reject); | ||
239 | layout->addWidget(buttonBox); | 224 | layout->addWidget(buttonBox); | ||
240 | 225 | | |||
241 | auto okButton = buttonBox->button(QDialogButtonBox::Ok); | 226 | auto okButton = buttonBox->button(QDialogButtonBox::Ok); | ||
242 | okButton->setShortcut(Qt::CTRL + Qt::Key_Return); | 227 | okButton->setShortcut(Qt::CTRL + Qt::Key_Return); | ||
▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines |
Please use VERTICAL_SPACER_HEIGHT.