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