Changeset View
Changeset View
Standalone View
Standalone View
src/settings/viewmodes/viewsettingstab.cpp
Show All 17 Lines | |||||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | #include "viewsettingstab.h" | 20 | #include "viewsettingstab.h" | ||
21 | 21 | | |||
22 | #include "dolphin_compactmodesettings.h" | 22 | #include "dolphin_compactmodesettings.h" | ||
23 | #include "dolphin_detailsmodesettings.h" | 23 | #include "dolphin_detailsmodesettings.h" | ||
24 | #include "dolphin_iconsmodesettings.h" | 24 | #include "dolphin_iconsmodesettings.h" | ||
25 | #include "dolphinfontrequester.h" | 25 | #include "dolphinfontrequester.h" | ||
26 | #include "global.h" | ||||
26 | #include "views/zoomlevelinfo.h" | 27 | #include "views/zoomlevelinfo.h" | ||
27 | 28 | | |||
28 | #include <KLocalizedString> | 29 | #include <KLocalizedString> | ||
29 | 30 | | |||
30 | #include <QApplication> | 31 | #include <QApplication> | ||
31 | #include <QCheckBox> | 32 | #include <QCheckBox> | ||
32 | #include <QComboBox> | 33 | #include <QComboBox> | ||
33 | #include <QGroupBox> | | |||
34 | #include <QHelpEvent> | 34 | #include <QHelpEvent> | ||
35 | #include <QLabel> | 35 | #include <QFormLayout> | ||
36 | #include <QVBoxLayout> | | |||
37 | 36 | | |||
38 | ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) : | 37 | ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) : | ||
39 | QWidget(parent), | 38 | QWidget(parent), | ||
40 | m_mode(mode), | 39 | m_mode(mode), | ||
41 | m_defaultSizeSlider(nullptr), | 40 | m_defaultSizeSlider(nullptr), | ||
42 | m_previewSizeSlider(nullptr), | 41 | m_previewSizeSlider(nullptr), | ||
43 | m_fontRequester(nullptr), | 42 | m_fontRequester(nullptr), | ||
44 | m_widthBox(nullptr), | 43 | m_widthBox(nullptr), | ||
45 | m_maxLinesBox(nullptr), | 44 | m_maxLinesBox(nullptr), | ||
46 | m_expandableFolders(nullptr) | 45 | m_expandableFolders(nullptr) | ||
47 | { | 46 | { | ||
48 | QVBoxLayout* topLayout = new QVBoxLayout(this); | 47 | QFormLayout* topLayout = new QFormLayout(this); | ||
49 | 48 | | |||
50 | // Create "Icon Size" group | | |||
51 | QGroupBox* iconSizeGroup = new QGroupBox(this); | | |||
52 | iconSizeGroup->setTitle(i18nc("@title:group", "Icon Size")); | | |||
53 | 49 | | |||
50 | // Create "Icon Size" section | ||||
54 | const int minRange = ZoomLevelInfo::minimumLevel(); | 51 | const int minRange = ZoomLevelInfo::minimumLevel(); | ||
55 | const int maxRange = ZoomLevelInfo::maximumLevel(); | 52 | const int maxRange = ZoomLevelInfo::maximumLevel(); | ||
56 | 53 | | |||
57 | QLabel* defaultLabel = new QLabel(i18nc("@label:listbox", "Default:"), this); | 54 | m_defaultSizeSlider = new QSlider(Qt::Horizontal); | ||
58 | m_defaultSizeSlider = new QSlider(Qt::Horizontal, this); | | |||
59 | m_defaultSizeSlider->setPageStep(1); | 55 | m_defaultSizeSlider->setPageStep(1); | ||
60 | m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow); | 56 | m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow); | ||
61 | m_defaultSizeSlider->setRange(minRange, maxRange); | 57 | m_defaultSizeSlider->setRange(minRange, maxRange); | ||
62 | connect(m_defaultSizeSlider, &QSlider::valueChanged, | 58 | connect(m_defaultSizeSlider, &QSlider::valueChanged, | ||
63 | this, &ViewSettingsTab::slotDefaultSliderMoved); | 59 | this, &ViewSettingsTab::slotDefaultSliderMoved); | ||
60 | topLayout->addRow(i18nc("@label:listbox", "Default icon size:"), m_defaultSizeSlider); | ||||
64 | 61 | | |||
65 | QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this); | 62 | m_previewSizeSlider = new QSlider(Qt::Horizontal); | ||
66 | m_previewSizeSlider = new QSlider(Qt::Horizontal, this); | | |||
67 | m_previewSizeSlider->setPageStep(1); | 63 | m_previewSizeSlider->setPageStep(1); | ||
68 | m_previewSizeSlider->setTickPosition(QSlider::TicksBelow); | 64 | m_previewSizeSlider->setTickPosition(QSlider::TicksBelow); | ||
69 | m_previewSizeSlider->setRange(minRange, maxRange); | 65 | m_previewSizeSlider->setRange(minRange, maxRange); | ||
70 | connect(m_previewSizeSlider, &QSlider::valueChanged, | 66 | connect(m_previewSizeSlider, &QSlider::valueChanged, | ||
71 | this, &ViewSettingsTab::slotPreviewSliderMoved); | 67 | this, &ViewSettingsTab::slotPreviewSliderMoved); | ||
68 | topLayout->addRow(i18nc("@label:listbox", "Preview icon size:"), m_previewSizeSlider); | ||||
69 | | ||||
70 | | ||||
71 | topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||||
72 | | ||||
73 | | ||||
74 | // Create "Label" section | ||||
75 | m_fontRequester = new DolphinFontRequester(this); | ||||
76 | topLayout->addRow(i18nc("@label:listbox", "Label font:"), m_fontRequester); | ||||
72 | 77 | | |||
73 | QGridLayout* layout = new QGridLayout(iconSizeGroup); | | |||
74 | layout->addWidget(defaultLabel, 0, 0, Qt::AlignRight); | | |||
75 | layout->addWidget(m_defaultSizeSlider, 0, 1); | | |||
76 | layout->addWidget(previewLabel, 1, 0, Qt::AlignRight); | | |||
77 | layout->addWidget(m_previewSizeSlider, 1, 1); | | |||
78 | | ||||
79 | // Create "Text" group | | |||
80 | QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this); | | |||
81 | | ||||
82 | QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup); | | |||
83 | m_fontRequester = new DolphinFontRequester(textGroup); | | |||
84 | | ||||
85 | QGridLayout* textGroupLayout = new QGridLayout(textGroup); | | |||
86 | textGroupLayout->addWidget(fontLabel, 0, 0, Qt::AlignRight); | | |||
87 | textGroupLayout->addWidget(m_fontRequester, 0, 1); | | |||
88 | 78 | | |||
89 | switch (m_mode) { | 79 | switch (m_mode) { | ||
90 | case IconsMode: { | 80 | case IconsMode: { | ||
91 | QLabel* widthLabel = new QLabel(i18nc("@label:listbox", "Width:"), textGroup); | 81 | m_widthBox = new QComboBox(); | ||
92 | m_widthBox = new QComboBox(textGroup); | 82 | m_widthBox->addItem(i18nc("@item:inlistbox Label width", "Small")); | ||
93 | m_widthBox->addItem(i18nc("@item:inlistbox Text width", "Small")); | 83 | m_widthBox->addItem(i18nc("@item:inlistbox Label width", "Medium")); | ||
94 | m_widthBox->addItem(i18nc("@item:inlistbox Text width", "Medium")); | 84 | m_widthBox->addItem(i18nc("@item:inlistbox Label width", "Large")); | ||
95 | m_widthBox->addItem(i18nc("@item:inlistbox Text width", "Large")); | 85 | m_widthBox->addItem(i18nc("@item:inlistbox Label width", "Huge")); | ||
96 | m_widthBox->addItem(i18nc("@item:inlistbox Text width", "Huge")); | 86 | topLayout->addRow(i18nc("@label:listbox", "Label width:"), m_widthBox); | ||
97 | 87 | | |||
98 | QLabel* maxLinesLabel = new QLabel(i18nc("@label:listbox", "Maximum lines:"), textGroup); | 88 | m_maxLinesBox = new QComboBox(); | ||
elvisangelaccio: Why the change from `KComboBox` to `QComboBox`? | |||||
Because KComboBox didn't display correctly within a QFormLayout. QComboBox is a drop-in replacement, so it seemed like an acceptable way to fix the issue. I also found references in commit messages for several other KDE projects to replacing KComboBox with QComboBox, so it seemed to align with the overall code direction anyway. ngraham: Because `KComboBox` didn't display correctly within a `QFormLayout`. `QComboBox` is a drop-in… | |||||
99 | m_maxLinesBox = new QComboBox(textGroup); | | |||
100 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "Unlimited")); | 89 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "Unlimited")); | ||
101 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "1")); | 90 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "1")); | ||
102 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "2")); | 91 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "2")); | ||
103 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "3")); | 92 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "3")); | ||
104 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "4")); | 93 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "4")); | ||
105 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "5")); | 94 | m_maxLinesBox->addItem(i18nc("@item:inlistbox Maximum lines", "5")); | ||
106 | 95 | topLayout->addRow(i18nc("@label:listbox", "Maximum lines:"), m_maxLinesBox); | |||
107 | textGroupLayout->addWidget(widthLabel, 2, 0, Qt::AlignRight); | | |||
108 | textGroupLayout->addWidget(m_widthBox, 2, 1); | | |||
109 | textGroupLayout->addWidget(maxLinesLabel, 3, 0, Qt::AlignRight); | | |||
110 | textGroupLayout->addWidget(m_maxLinesBox, 3, 1); | | |||
111 | break; | 96 | break; | ||
112 | } | 97 | } | ||
113 | case CompactMode: { | 98 | case CompactMode: { | ||
114 | QLabel* maxWidthLabel = new QLabel(i18nc("@label:listbox", "Maximum width:"), textGroup); | 99 | m_widthBox = new QComboBox(); | ||
115 | m_widthBox = new QComboBox(textGroup); | | |||
116 | m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Unlimited")); | 100 | m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Unlimited")); | ||
117 | m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Small")); | 101 | m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Small")); | ||
118 | m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Medium")); | 102 | m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Medium")); | ||
119 | m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Large")); | 103 | m_widthBox->addItem(i18nc("@item:inlistbox Maximum width", "Large")); | ||
120 | 104 | topLayout->addRow(i18nc("@label:listbox", "Maximum width:"), m_widthBox); | |||
121 | textGroupLayout->addWidget(maxWidthLabel, 2, 0, Qt::AlignRight); | | |||
122 | textGroupLayout->addWidget(m_widthBox, 2, 1); | | |||
123 | break; | 105 | break; | ||
124 | } | 106 | } | ||
125 | case DetailsMode: | 107 | case DetailsMode: | ||
126 | m_expandableFolders = new QCheckBox(i18nc("@option:check", "Expandable folders"), this); | 108 | m_expandableFolders = new QCheckBox(i18nc("@option:check", "Expandable")); | ||
109 | topLayout->addRow(i18nc("@label:checkbox", "Folders:"), m_expandableFolders); | ||||
elvisangelaccio: How about "Expandable on click" ? | |||||
That wording would imply that the folders themselves are clickable to expand them, which isn't accurate. ngraham: That wording would imply that the folders themselves are clickable to expand them, which isn't… | |||||
127 | break; | 110 | break; | ||
128 | default: | 111 | default: | ||
129 | break; | 112 | break; | ||
130 | } | 113 | } | ||
131 | 114 | | |||
132 | topLayout->addWidget(iconSizeGroup); | | |||
133 | topLayout->addWidget(textGroup); | | |||
134 | if (m_expandableFolders) { | | |||
135 | topLayout->addWidget(m_expandableFolders); | | |||
136 | } | | |||
137 | topLayout->addStretch(1); | | |||
138 | | ||||
139 | loadSettings(); | 115 | loadSettings(); | ||
140 | 116 | | |||
141 | connect(m_defaultSizeSlider, &QSlider::valueChanged, this, &ViewSettingsTab::changed); | 117 | connect(m_defaultSizeSlider, &QSlider::valueChanged, this, &ViewSettingsTab::changed); | ||
142 | connect(m_previewSizeSlider, &QSlider::valueChanged, this, &ViewSettingsTab::changed); | 118 | connect(m_previewSizeSlider, &QSlider::valueChanged, this, &ViewSettingsTab::changed); | ||
143 | connect(m_fontRequester, &DolphinFontRequester::changed, this, &ViewSettingsTab::changed); | 119 | connect(m_fontRequester, &DolphinFontRequester::changed, this, &ViewSettingsTab::changed); | ||
144 | 120 | | |||
145 | switch (m_mode) { | 121 | switch (m_mode) { | ||
146 | case IconsMode: | 122 | case IconsMode: | ||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |
Why the change from KComboBox to QComboBox?