Changeset View
Changeset View
Standalone View
Standalone View
src/EditProfileDialog.cpp
Show All 23 Lines | |||||
24 | // Standard | 24 | // Standard | ||
25 | #include <cmath> | 25 | #include <cmath> | ||
26 | 26 | | |||
27 | // Qt | 27 | // Qt | ||
28 | #include <QBrush> | 28 | #include <QBrush> | ||
29 | #include <QDialog> | 29 | #include <QDialog> | ||
30 | #include <QDialogButtonBox> | 30 | #include <QDialogButtonBox> | ||
31 | #include <QFileDialog> | 31 | #include <QFileDialog> | ||
32 | #include <QFontDialog> | | |||
33 | #include <QInputDialog> | 32 | #include <QInputDialog> | ||
34 | #include <QIcon> | 33 | #include <QIcon> | ||
35 | #include <QLinearGradient> | 34 | #include <QLinearGradient> | ||
36 | #include <QPainter> | 35 | #include <QPainter> | ||
37 | #include <QPushButton> | 36 | #include <QPushButton> | ||
38 | #include <QRadialGradient> | 37 | #include <QRadialGradient> | ||
39 | #include <QStandardItem> | 38 | #include <QStandardItem> | ||
40 | #include <QTextCodec> | 39 | #include <QTextCodec> | ||
41 | #include <QTimer> | 40 | #include <QTimer> | ||
42 | #include <QUrl> | 41 | #include <QUrl> | ||
43 | #include <QVBoxLayout> | 42 | #include <QVBoxLayout> | ||
43 | #include <QStandardPaths> | ||||
44 | 44 | | |||
45 | // KDE | 45 | // KDE | ||
46 | #include <KCodecAction> | 46 | #include <KCodecAction> | ||
47 | #include <KIconDialog> | 47 | #include <KIconDialog> | ||
48 | #include <KLocalizedString> | 48 | #include <KLocalizedString> | ||
49 | #include <KMessageBox> | 49 | #include <KMessageBox> | ||
50 | #include <KNSCore/DownloadManager> | 50 | #include <KNSCore/DownloadManager> | ||
51 | #include <KWindowSystem> | 51 | #include <KWindowSystem> | ||
52 | 52 | | |||
53 | // Konsole | 53 | // Konsole | ||
54 | #include "ui_EditProfileGeneralPage.h" | ||||
55 | #include "ui_EditProfileTabsPage.h" | ||||
56 | #include "ui_EditProfileAppearancePage.h" | ||||
57 | #include "ui_EditProfileScrollingPage.h" | ||||
58 | #include "ui_EditProfileKeyboardPage.h" | ||||
59 | #include "ui_EditProfileMousePage.h" | ||||
60 | #include "ui_EditProfileAdvancedPage.h" | ||||
54 | #include "ColorSchemeManager.h" | 61 | #include "ColorSchemeManager.h" | ||
55 | #include "ui_EditProfileDialog.h" | | |||
56 | #include "KeyBindingEditor.h" | 62 | #include "KeyBindingEditor.h" | ||
57 | #include "KeyboardTranslator.h" | 63 | #include "KeyboardTranslator.h" | ||
58 | #include "KeyboardTranslatorManager.h" | 64 | #include "KeyboardTranslatorManager.h" | ||
59 | #include "ProfileManager.h" | 65 | #include "ProfileManager.h" | ||
60 | #include "ShellCommand.h" | 66 | #include "ShellCommand.h" | ||
61 | #include "WindowSystemInfo.h" | 67 | #include "WindowSystemInfo.h" | ||
62 | #include "Shortcut_p.h" | 68 | #include "Shortcut_p.h" | ||
69 | #include "FontDialog.h" | ||||
63 | 70 | | |||
64 | using namespace Konsole; | 71 | using namespace Konsole; | ||
65 | 72 | | |||
66 | EditProfileDialog::EditProfileDialog(QWidget *parent) : | 73 | EditProfileDialog::EditProfileDialog(QWidget *parent) | ||
67 | QDialog(parent), | 74 | : KPageDialog(parent) | ||
68 | _ui(nullptr), | 75 | , _generalUi(nullptr) | ||
69 | _tempProfile(nullptr), | 76 | , _tabsUi(nullptr) | ||
70 | _profile(nullptr), | 77 | , _appearanceUi(nullptr) | ||
71 | _pageNeedsUpdate(QVector<bool>()), | 78 | , _scrollingUi(nullptr) | ||
72 | _previewedProperties(QHash<int, QVariant>()), | 79 | , _keyboardUi(nullptr) | ||
73 | _delayedPreviewProperties(QHash<int, QVariant>()), | 80 | , _mouseUi(nullptr) | ||
74 | _delayedPreviewTimer(new QTimer(this)), | 81 | , _advancedUi(nullptr) | ||
75 | _colorDialog(nullptr), | 82 | , _tempProfile(nullptr) | ||
76 | mButtonBox(nullptr) | 83 | , _profile(nullptr) | ||
84 | , _previewedProperties(QHash<int, QVariant>()) | ||||
85 | , _delayedPreviewProperties(QHash<int, QVariant>()) | ||||
86 | , _delayedPreviewTimer(new QTimer(this)) | ||||
87 | , _colorDialog(nullptr) | ||||
88 | , _buttonBox(nullptr) | ||||
89 | , _fontDialog(nullptr) | ||||
77 | { | 90 | { | ||
78 | setWindowTitle(i18n("Edit Profile")); | 91 | setWindowTitle(i18n("Edit Profile")); | ||
79 | mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::Apply); | 92 | setFaceType(KPageDialog::List); | ||
80 | auto mainWidget = new QWidget(this); | 93 | | ||
81 | auto mainLayout = new QVBoxLayout; | 94 | _buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply); | ||
82 | setLayout(mainLayout); | 95 | setButtonBox(_buttonBox); | ||
83 | mainLayout->addWidget(mainWidget); | 96 | | ||
84 | QPushButton *okButton = mButtonBox->button(QDialogButtonBox::Ok); | 97 | QPushButton *okButton = _buttonBox->button(QDialogButtonBox::Ok); | ||
85 | okButton->setDefault(true); | 98 | okButton->setDefault(true); | ||
86 | connect(mButtonBox, &QDialogButtonBox::accepted, this, &Konsole::EditProfileDialog::accept); | 99 | connect(_buttonBox, &QDialogButtonBox::accepted, this, &Konsole::EditProfileDialog::accept); | ||
87 | connect(mButtonBox, &QDialogButtonBox::rejected, this, &Konsole::EditProfileDialog::reject); | 100 | connect(_buttonBox, &QDialogButtonBox::rejected, this, &Konsole::EditProfileDialog::reject); | ||
88 | 101 | | |||
89 | // disable the apply button , since no modification has been made | 102 | // disable the apply button , since no modification has been made | ||
90 | mButtonBox->button(QDialogButtonBox::Apply)->setEnabled(false); | 103 | _buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); | ||
91 | 104 | | |||
92 | connect(mButtonBox->button(QDialogButtonBox::Apply), | 105 | connect(_buttonBox->button(QDialogButtonBox::Apply), | ||
93 | &QPushButton::clicked, this, | 106 | &QPushButton::clicked, this, | ||
94 | &Konsole::EditProfileDialog::apply); | 107 | &Konsole::EditProfileDialog::apply); | ||
95 | 108 | | |||
96 | connect(_delayedPreviewTimer, &QTimer::timeout, this, | 109 | connect(_delayedPreviewTimer, &QTimer::timeout, this, | ||
97 | &Konsole::EditProfileDialog::delayedPreviewActivate); | 110 | &Konsole::EditProfileDialog::delayedPreviewActivate); | ||
98 | 111 | | |||
99 | _ui = new Ui::EditProfileDialog(); | 112 | // General page | ||
100 | _ui->setupUi(mainWidget); | 113 | | ||
101 | mainLayout->addWidget(mButtonBox); | 114 | const QString generalPageName = i18nc("@title:tab Generic, common options", "General"); | ||
115 | auto *generalPageWidget = new QWidget(this); | ||||
116 | _generalUi = new Ui::EditProfileGeneralPage(); | ||||
117 | _generalUi->setupUi(generalPageWidget); | ||||
118 | auto *generalPageItem = addPage(generalPageWidget, generalPageName); | ||||
119 | generalPageItem->setHeader(generalPageName); | ||||
120 | generalPageItem->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal"))); | ||||
121 | _pages[generalPageItem] = Page(&EditProfileDialog::setupGeneralPage); | ||||
122 | | ||||
123 | // Tabs page | ||||
124 | | ||||
125 | const QString tabsPageName = i18n("Tabs"); | ||||
126 | auto *tabsPageWidget = new QWidget(this); | ||||
127 | _tabsUi = new Ui::EditProfileTabsPage(); | ||||
128 | _tabsUi->setupUi(tabsPageWidget); | ||||
129 | auto *tabsPageItem = addPage(tabsPageWidget, tabsPageName); | ||||
130 | tabsPageItem->setHeader(tabsPageName); | ||||
131 | tabsPageItem->setIcon(QIcon::fromTheme(QStringLiteral("tab-duplicate"))); | ||||
132 | _pages[tabsPageItem] = Page(&EditProfileDialog::setupTabsPage); | ||||
133 | | ||||
134 | LabelsAligner tabsAligner(tabsPageWidget); | ||||
135 | tabsAligner.addLayout(dynamic_cast<QGridLayout *>(_tabsUi->tabMonitoringGroup->layout())); | ||||
136 | tabsAligner.addLayout(dynamic_cast<QGridLayout *>(_tabsUi->renameTabWidget->layout())); | ||||
137 | tabsAligner.updateLayouts(); | ||||
138 | tabsAligner.align(); | ||||
139 | | ||||
140 | // Appearance page | ||||
141 | | ||||
142 | const QString appearancePageName = i18n("Appearance"); | ||||
143 | auto *appearancePageWidget = new QWidget(this); | ||||
144 | _appearanceUi = new Ui::EditProfileAppearancePage(); | ||||
145 | _appearanceUi->setupUi(appearancePageWidget); | ||||
146 | auto *appearancePageItem = addPage(appearancePageWidget, appearancePageName); | ||||
147 | appearancePageItem->setHeader(appearancePageName); | ||||
148 | appearancePageItem->setIcon(QIcon::fromTheme(QStringLiteral("kcolorchooser"))); | ||||
149 | _pages[appearancePageItem] = Page(&EditProfileDialog::setupAppearancePage); | ||||
150 | | ||||
151 | LabelsAligner appearanceAligner(appearancePageWidget); | ||||
152 | appearanceAligner.addLayout(dynamic_cast<QGridLayout *>(_appearanceUi->miscTabLayout)); | ||||
153 | appearanceAligner.addLayout(dynamic_cast<QGridLayout *>(_appearanceUi->contentsGroup->layout())); | ||||
154 | appearanceAligner.updateLayouts(); | ||||
155 | appearanceAligner.align(); | ||||
156 | | ||||
157 | // Scrolling page | ||||
158 | | ||||
159 | const QString scrollingPageName = i18n("Scrolling"); | ||||
160 | auto *scrollingPageWidget = new QWidget(this); | ||||
161 | _scrollingUi = new Ui::EditProfileScrollingPage(); | ||||
162 | _scrollingUi->setupUi(scrollingPageWidget); | ||||
163 | auto *scrollingPageItem = addPage(scrollingPageWidget, scrollingPageName); | ||||
164 | scrollingPageItem->setHeader(scrollingPageName); | ||||
165 | scrollingPageItem->setIcon(QIcon::fromTheme(QStringLiteral("transform-move-vertical"))); | ||||
166 | _pages[scrollingPageItem] = Page(&EditProfileDialog::setupScrollingPage); | ||||
167 | | ||||
168 | // adjust "history size" label height to match history size widget's first radio button | ||||
169 | _scrollingUi->historySizeLabel->setFixedHeight(_scrollingUi->historySizeWidget->preferredLabelHeight()); | ||||
170 | | ||||
171 | // Keyboard page | ||||
172 | | ||||
173 | const QString keyboardPageName = i18n("Keyboard"); | ||||
174 | const QString keyboardPageTitle = i18n("Key bindings"); | ||||
175 | auto *keyboardPageWidget = new QWidget(this); | ||||
176 | _keyboardUi = new Ui::EditProfileKeyboardPage(); | ||||
177 | _keyboardUi->setupUi(keyboardPageWidget); | ||||
178 | auto *keyboardPageItem = addPage(keyboardPageWidget, keyboardPageName); | ||||
179 | keyboardPageItem->setHeader(keyboardPageTitle); | ||||
180 | keyboardPageItem->setIcon(QIcon::fromTheme(QStringLiteral("input-keyboard"))); | ||||
181 | _pages[keyboardPageItem] = Page(&EditProfileDialog::setupKeyboardPage); | ||||
182 | | ||||
183 | // Mouse page | ||||
184 | | ||||
185 | const QString mousePageName = i18n("Mouse"); | ||||
186 | auto *mousePageWidget = new QWidget(this); | ||||
187 | _mouseUi = new Ui::EditProfileMousePage(); | ||||
188 | _mouseUi->setupUi(mousePageWidget); | ||||
189 | auto *mousePageItem = addPage(mousePageWidget, mousePageName); | ||||
190 | mousePageItem->setHeader(mousePageName); | ||||
191 | mousePageItem->setIcon(QIcon::fromTheme(QStringLiteral("input-mouse"))); | ||||
192 | _pages[mousePageItem] = Page(&EditProfileDialog::setupMousePage); | ||||
193 | | ||||
194 | // Advanced page | ||||
195 | | ||||
196 | const QString advancedPageName = i18nc("@title:tab Complex options", "Advanced"); | ||||
197 | auto *advancedPageWidget = new QWidget(this); | ||||
198 | _advancedUi = new Ui::EditProfileAdvancedPage(); | ||||
199 | _advancedUi->setupUi(advancedPageWidget); | ||||
200 | auto *advancedPageItem = addPage(advancedPageWidget, advancedPageName); | ||||
201 | advancedPageItem->setHeader(advancedPageName); | ||||
202 | advancedPageItem->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); | ||||
203 | _pages[advancedPageItem] = Page(&EditProfileDialog::setupAdvancedPage); | ||||
102 | 204 | | |||
103 | // there are various setupXYZPage() methods to load the items | 205 | // there are various setupXYZPage() methods to load the items | ||
104 | // for each page and update their states to match the profile | 206 | // for each page and update their states to match the profile | ||
105 | // being edited. | 207 | // being edited. | ||
106 | // | 208 | // | ||
107 | // these are only called when needed ( ie. when the user clicks | 209 | // these are only called when needed ( ie. when the user clicks | ||
108 | // the tab to move to that page ). | 210 | // the tab to move to that page ). | ||
109 | // | 211 | // | ||
110 | // the _pageNeedsUpdate vector keeps track of the pages that have | 212 | // the _pageNeedsUpdate vector keeps track of the pages that have | ||
111 | // not been updated since the last profile change and will need | 213 | // not been updated since the last profile change and will need | ||
112 | // to be refreshed when the user switches to them | 214 | // to be refreshed when the user switches to them | ||
113 | _pageNeedsUpdate.resize(_ui->tabWidget->count()); | 215 | connect(this, &KPageDialog::currentPageChanged, | ||
114 | connect(_ui->tabWidget, &QTabWidget::currentChanged, this, | 216 | this, &Konsole::EditProfileDialog::preparePage); | ||
115 | &Konsole::EditProfileDialog::preparePage); | 217 | | ||
218 | QFontMetrics fm(font()); | ||||
219 | const int ch = fm.width(QLatin1Char('0')); | ||||
220 | | ||||
221 | // Increase width a bit instead of using possible minimum | ||||
222 | resize(sizeHint().width() + 10*ch, sizeHint().height()); | ||||
hindenburg: Can you explain why you expand the width here? On small screens, this causes the dialog to be… | |||||
IIRC to make text inputs in "tab titles" a bit wider by default. mglb: IIRC to make text inputs in "tab titles" a bit wider by default.
I got 553x585px with Noto Sans… | |||||
I'm testing on a non-plasma desktop (xfce) w/ 800x600 dimensions; without the resize, the dialog is small enough to be seen (725x560); with the resize, the height is around 560 and right side is cut off 10 pixels. hindenburg: I'm testing on a non-plasma desktop (xfce) w/ 800x600 dimensions; without the resize, the… | |||||
mglb: OK, so our results match. I'll post a patch tomorrow. | |||||
116 | 223 | | |||
117 | createTempProfile(); | 224 | createTempProfile(); | ||
118 | } | 225 | } | ||
119 | 226 | | |||
120 | EditProfileDialog::~EditProfileDialog() | 227 | EditProfileDialog::~EditProfileDialog() | ||
121 | { | 228 | { | ||
122 | delete _ui; | 229 | delete _generalUi; | ||
230 | delete _tabsUi; | ||||
231 | delete _appearanceUi; | ||||
232 | delete _scrollingUi; | ||||
233 | delete _keyboardUi; | ||||
234 | delete _mouseUi; | ||||
235 | delete _advancedUi; | ||||
123 | } | 236 | } | ||
124 | 237 | | |||
125 | void EditProfileDialog::save() | 238 | void EditProfileDialog::save() | ||
126 | { | 239 | { | ||
127 | if (_tempProfile->isEmpty()) { | 240 | if (_tempProfile->isEmpty()) { | ||
128 | return; | 241 | return; | ||
129 | } | 242 | } | ||
130 | 243 | | |||
131 | ProfileManager::instance()->changeProfile(_profile, _tempProfile->setProperties()); | 244 | ProfileManager::instance()->changeProfile(_profile, _tempProfile->setProperties()); | ||
132 | 245 | | |||
133 | // ensure that these settings are not undone by a call | 246 | // ensure that these settings are not undone by a call | ||
134 | // to unpreview() | 247 | // to unpreview() | ||
135 | QHashIterator<Profile::Property, QVariant> iter(_tempProfile->setProperties()); | 248 | QHashIterator<Profile::Property, QVariant> iter(_tempProfile->setProperties()); | ||
136 | while (iter.hasNext()) { | 249 | while (iter.hasNext()) { | ||
137 | iter.next(); | 250 | iter.next(); | ||
138 | _previewedProperties.remove(iter.key()); | 251 | _previewedProperties.remove(iter.key()); | ||
139 | } | 252 | } | ||
140 | 253 | | |||
141 | createTempProfile(); | 254 | createTempProfile(); | ||
142 | 255 | | |||
143 | mButtonBox->button(QDialogButtonBox::Apply)->setEnabled(false); | 256 | _buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); | ||
144 | } | 257 | } | ||
145 | 258 | | |||
146 | void EditProfileDialog::reject() | 259 | void EditProfileDialog::reject() | ||
147 | { | 260 | { | ||
148 | unpreviewAll(); | 261 | unpreviewAll(); | ||
149 | QDialog::reject(); | 262 | QDialog::reject(); | ||
150 | } | 263 | } | ||
151 | 264 | | |||
152 | void EditProfileDialog::accept() | 265 | void EditProfileDialog::accept() | ||
153 | { | 266 | { | ||
154 | // if the Apply button is disabled then no settings were changed | 267 | // if the Apply button is disabled then no settings were changed | ||
155 | // or the changes have already been saved by apply() | 268 | // or the changes have already been saved by apply() | ||
156 | if (mButtonBox->button(QDialogButtonBox::Apply)->isEnabled()) { | 269 | if (_buttonBox->button(QDialogButtonBox::Apply)->isEnabled()) { | ||
157 | if (!isValidProfileName()) { | 270 | if (!isValidProfileName()) { | ||
158 | return; | 271 | return; | ||
159 | } | 272 | } | ||
160 | save(); | 273 | save(); | ||
161 | } | 274 | } | ||
162 | 275 | | |||
163 | unpreviewAll(); | 276 | unpreviewAll(); | ||
164 | QDialog::accept(); | 277 | QDialog::accept(); | ||
Show All 37 Lines | 289 | { | |||
202 | 315 | | |||
203 | if ((_tempProfile->isPropertySet(Profile::Name) | 316 | if ((_tempProfile->isPropertySet(Profile::Name) | ||
204 | && _tempProfile->name().isEmpty()) | 317 | && _tempProfile->name().isEmpty()) | ||
205 | || (_profile->name().isEmpty() && _tempProfile->name().isEmpty())) { | 318 | || (_profile->name().isEmpty() && _tempProfile->name().isEmpty())) { | ||
206 | KMessageBox::sorry(this, | 319 | KMessageBox::sorry(this, | ||
207 | i18n("<p>Each profile must have a name before it can be saved " | 320 | i18n("<p>Each profile must have a name before it can be saved " | ||
208 | "into disk.</p>")); | 321 | "into disk.</p>")); | ||
209 | // revert the name in the dialog | 322 | // revert the name in the dialog | ||
210 | _ui->profileNameEdit->setText(_profile->name()); | 323 | _generalUi->profileNameEdit->setText(_profile->name()); | ||
211 | selectProfileName(); | 324 | selectProfileName(); | ||
212 | return false; | 325 | return false; | ||
213 | } else if (!_tempProfile->name().isEmpty() && otherExistingProfileNames.contains(_tempProfile->name())) { | 326 | } else if (!_tempProfile->name().isEmpty() && otherExistingProfileNames.contains(_tempProfile->name())) { | ||
214 | KMessageBox::sorry(this, | 327 | KMessageBox::sorry(this, | ||
215 | i18n("<p>A profile with this name already exists.</p>")); | 328 | i18n("<p>A profile with this name already exists.</p>")); | ||
216 | // revert the name in the dialog | 329 | // revert the name in the dialog | ||
217 | _ui->profileNameEdit->setText(_profile->name()); | 330 | _generalUi->profileNameEdit->setText(_profile->name()); | ||
218 | selectProfileName(); | 331 | selectProfileName(); | ||
219 | return false; | 332 | return false; | ||
220 | } else { | 333 | } else { | ||
221 | return true; | 334 | return true; | ||
222 | } | 335 | } | ||
223 | } | 336 | } | ||
224 | 337 | | |||
225 | QString EditProfileDialog::groupProfileNames(const ProfileGroup::Ptr group, int maxLength) | 338 | QString EditProfileDialog::groupProfileNames(const ProfileGroup::Ptr group, int maxLength) | ||
Show All 24 Lines | 362 | setWindowTitle(i18np("Editing profile: %2", | |||
250 | "Editing %1 profiles: %2", | 363 | "Editing %1 profiles: %2", | ||
251 | group->profiles().count(), | 364 | group->profiles().count(), | ||
252 | caption)); | 365 | caption)); | ||
253 | } else { | 366 | } else { | ||
254 | setWindowTitle(i18n("Edit Profile \"%1\"", profile->name())); | 367 | setWindowTitle(i18n("Edit Profile \"%1\"", profile->name())); | ||
255 | } | 368 | } | ||
256 | } | 369 | } | ||
257 | 370 | | |||
258 | void EditProfileDialog::setProfile(Profile::Ptr profile) | 371 | void EditProfileDialog::setProfile(Konsole::Profile::Ptr profile) | ||
259 | { | 372 | { | ||
260 | Q_ASSERT(profile); | 373 | Q_ASSERT(profile); | ||
261 | 374 | | |||
262 | _profile = profile; | 375 | _profile = profile; | ||
263 | 376 | | |||
264 | // update caption | 377 | // update caption | ||
265 | updateCaption(profile); | 378 | updateCaption(profile); | ||
266 | 379 | | |||
267 | // mark each page of the dialog as out of date | 380 | // mark each page of the dialog as out of date | ||
268 | // and force an update of the currently visible page | 381 | // and force an update of the currently visible page | ||
269 | // | 382 | // | ||
270 | // the other pages will be updated as necessary | 383 | // the other pages will be updated as necessary | ||
271 | _pageNeedsUpdate.fill(true); | 384 | for (Page &page: _pages) { | ||
272 | preparePage(_ui->tabWidget->currentIndex()); | 385 | page.needsUpdate = true; | ||
386 | } | ||||
387 | preparePage(currentPage()); | ||||
273 | 388 | | |||
274 | if (_tempProfile) { | 389 | if (_tempProfile) { | ||
275 | createTempProfile(); | 390 | createTempProfile(); | ||
276 | } | 391 | } | ||
277 | } | 392 | } | ||
278 | 393 | | |||
279 | const Profile::Ptr EditProfileDialog::lookupProfile() const | 394 | const Profile::Ptr EditProfileDialog::lookupProfile() const | ||
280 | { | 395 | { | ||
281 | return _profile; | 396 | return _profile; | ||
282 | } | 397 | } | ||
283 | 398 | | |||
284 | const QString EditProfileDialog::currentColorSchemeName() const | 399 | const QString EditProfileDialog::currentColorSchemeName() const | ||
285 | { | 400 | { | ||
286 | const QString ¤tColorSchemeName = lookupProfile()->colorScheme(); | 401 | const QString ¤tColorSchemeName = lookupProfile()->colorScheme(); | ||
287 | return currentColorSchemeName; | 402 | return currentColorSchemeName; | ||
288 | } | 403 | } | ||
289 | 404 | | |||
290 | void EditProfileDialog::preparePage(int page) | 405 | void EditProfileDialog::preparePage(KPageWidgetItem *current, KPageWidgetItem *before) | ||
291 | { | 406 | { | ||
292 | const Profile::Ptr profile = lookupProfile(); | 407 | Q_UNUSED(before); | ||
408 | Q_ASSERT(current); | ||||
409 | Q_ASSERT(_pages.contains(current)); | ||||
293 | 410 | | |||
294 | Q_ASSERT(_pageNeedsUpdate.count() > page); | 411 | const Profile::Ptr profile = lookupProfile(); | ||
412 | auto setupPage = _pages[current].setupPage; | ||||
295 | Q_ASSERT(profile); | 413 | Q_ASSERT(profile); | ||
414 | Q_ASSERT(setupPage); | ||||
296 | 415 | | |||
297 | QWidget *pageWidget = _ui->tabWidget->widget(page); | 416 | if (_pages[current].needsUpdate) { | ||
298 | 417 | (*this.*setupPage)(profile); | |||
299 | if (_pageNeedsUpdate[page]) { | 418 | _pages[current].needsUpdate = false; | ||
300 | if (pageWidget == _ui->generalTab) { | | |||
301 | setupGeneralPage(profile); | | |||
302 | } else if (pageWidget == _ui->tabsTab) { | | |||
303 | setupTabsPage(profile); | | |||
304 | } else if (pageWidget == _ui->appearanceTab) { | | |||
305 | setupAppearancePage(profile); | | |||
306 | } else if (pageWidget == _ui->scrollingTab) { | | |||
307 | setupScrollingPage(profile); | | |||
308 | } else if (pageWidget == _ui->keyboardTab) { | | |||
309 | setupKeyboardPage(profile); | | |||
310 | } else if (pageWidget == _ui->mouseTab) { | | |||
311 | setupMousePage(profile); | | |||
312 | } else if (pageWidget == _ui->advancedTab) { | | |||
313 | setupAdvancedPage(profile); | | |||
314 | } else { | | |||
315 | Q_ASSERT(false); | | |||
316 | } | | |||
317 | | ||||
318 | _pageNeedsUpdate[page] = false; | | |||
319 | } | 419 | } | ||
320 | } | 420 | } | ||
321 | 421 | | |||
322 | void EditProfileDialog::selectProfileName() | 422 | void Konsole::EditProfileDialog::selectProfileName() | ||
323 | { | 423 | { | ||
324 | _ui->profileNameEdit->setFocus(); | 424 | _generalUi->profileNameEdit->setFocus(); | ||
325 | _ui->profileNameEdit->selectAll(); | 425 | _generalUi->profileNameEdit->selectAll(); | ||
326 | } | 426 | } | ||
327 | 427 | | |||
328 | void EditProfileDialog::setupGeneralPage(const Profile::Ptr profile) | 428 | void EditProfileDialog::setupGeneralPage(const Profile::Ptr &profile) | ||
329 | { | 429 | { | ||
330 | // basic profile options | 430 | // basic profile options | ||
331 | { | 431 | { | ||
332 | _ui->profileNameEdit->setPlaceholderText(i18nc("@label:textbox", "Enter descriptive label")); | | |||
333 | | ||||
334 | ProfileGroup::Ptr group = profile->asGroup(); | 432 | ProfileGroup::Ptr group = profile->asGroup(); | ||
335 | if (!group || group->profiles().count() < 2) { | 433 | if (!group || group->profiles().count() < 2) { | ||
336 | _ui->profileNameEdit->setText(profile->name()); | 434 | _generalUi->profileNameEdit->setText(profile->name()); | ||
337 | _ui->profileNameEdit->setClearButtonEnabled(true); | 435 | _generalUi->profileNameEdit->setClearButtonEnabled(true); | ||
338 | } else { | 436 | } else { | ||
339 | _ui->profileNameEdit->setText(groupProfileNames(group, -1)); | 437 | _generalUi->profileNameEdit->setText(groupProfileNames(group, -1)); | ||
340 | _ui->profileNameEdit->setEnabled(false); | 438 | _generalUi->profileNameEdit->setEnabled(false); | ||
341 | _ui->profileNameLabel->setEnabled(false); | | |||
342 | } | 439 | } | ||
343 | } | 440 | } | ||
344 | 441 | | |||
345 | ShellCommand command(profile->command(), profile->arguments()); | 442 | ShellCommand command(profile->command(), profile->arguments()); | ||
346 | _ui->commandEdit->setText(command.fullCommand()); | 443 | _generalUi->commandEdit->setText(command.fullCommand()); | ||
347 | // If a "completion" is requested, consider changing this to KLineEdit | 444 | // If a "completion" is requested, consider changing this to KLineEdit | ||
348 | // and using KCompletion. | 445 | // and using KCompletion. | ||
349 | _ui->initialDirEdit->setText(profile->defaultWorkingDirectory()); | 446 | _generalUi->initialDirEdit->setText(profile->defaultWorkingDirectory()); | ||
350 | _ui->initialDirEdit->setClearButtonEnabled(true); | 447 | _generalUi->initialDirEdit->setClearButtonEnabled(true); | ||
351 | 448 | _generalUi->initialDirEdit->setPlaceholderText(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).value(0)); | |||
352 | _ui->dirSelectButton->setIcon(QIcon::fromTheme(QStringLiteral("folder-open"))); | 449 | | ||
353 | _ui->iconSelectButton->setIcon(QIcon::fromTheme(profile->icon())); | 450 | _generalUi->dirSelectButton->setIcon(QIcon::fromTheme(QStringLiteral("folder-open"))); | ||
354 | _ui->startInSameDirButton->setChecked(profile->startInCurrentSessionDir()); | 451 | _generalUi->iconSelectButton->setIcon(QIcon::fromTheme(profile->icon())); | ||
355 | 452 | _generalUi->startInSameDirButton->setChecked(profile->startInCurrentSessionDir()); | |||
356 | // terminal options | 453 | | ||
357 | _ui->terminalColumnsEntry->setValue(profile->terminalColumns()); | 454 | // initial terminal size | ||
358 | _ui->terminalRowsEntry->setValue(profile->terminalRows()); | 455 | const auto rowsSuffix = ki18ncp("Suffix of the number of columns (N columns)", " column", " columns"); | ||
359 | 456 | const auto colsSuffix = ki18ncp("Suffix of the number of rows (N rows)", " row", " rows"); | |||
360 | // window options | 457 | _generalUi->terminalColumnsEntry->setValue(profile->terminalColumns()); | ||
361 | _ui->showTerminalSizeHintButton->setChecked(profile->showTerminalSizeHint()); | 458 | _generalUi->terminalRowsEntry->setValue(profile->terminalRows()); | ||
362 | _ui->dimWhenInactiveCheckbox->setChecked(profile->dimWhenInactive()); | 459 | _generalUi->terminalColumnsEntry->setSuffix(colsSuffix); | ||
460 | _generalUi->terminalRowsEntry->setSuffix(rowsSuffix); | ||||
461 | // make width of initial terminal size spinboxes equal | ||||
462 | const int sizeEntryWidth = qMax(maxSpinBoxWidth(_generalUi->terminalColumnsEntry, colsSuffix), | ||||
463 | maxSpinBoxWidth(_generalUi->terminalRowsEntry, rowsSuffix)); | ||||
464 | _generalUi->terminalColumnsEntry->setFixedWidth(sizeEntryWidth); | ||||
465 | _generalUi->terminalRowsEntry->setFixedWidth(sizeEntryWidth); | ||||
363 | 466 | | |||
364 | // signals and slots | 467 | // signals and slots | ||
365 | connect(_ui->dirSelectButton, &QToolButton::clicked, this, | 468 | connect(_generalUi->dirSelectButton, &QToolButton::clicked, this, | ||
366 | &Konsole::EditProfileDialog::selectInitialDir); | 469 | &Konsole::EditProfileDialog::selectInitialDir); | ||
367 | connect(_ui->iconSelectButton, &QPushButton::clicked, this, | 470 | connect(_generalUi->iconSelectButton, &QPushButton::clicked, this, | ||
368 | &Konsole::EditProfileDialog::selectIcon); | 471 | &Konsole::EditProfileDialog::selectIcon); | ||
369 | connect(_ui->startInSameDirButton, &QCheckBox::toggled, this, | 472 | connect(_generalUi->startInSameDirButton, &QCheckBox::toggled, this, | ||
370 | &Konsole::EditProfileDialog::startInSameDir); | 473 | &Konsole::EditProfileDialog::startInSameDir); | ||
371 | connect(_ui->profileNameEdit, &QLineEdit::textChanged, this, | 474 | connect(_generalUi->profileNameEdit, &QLineEdit::textChanged, this, | ||
372 | &Konsole::EditProfileDialog::profileNameChanged); | 475 | &Konsole::EditProfileDialog::profileNameChanged); | ||
373 | connect(_ui->initialDirEdit, &QLineEdit::textChanged, this, | 476 | connect(_generalUi->initialDirEdit, &QLineEdit::textChanged, this, | ||
374 | &Konsole::EditProfileDialog::initialDirChanged); | 477 | &Konsole::EditProfileDialog::initialDirChanged); | ||
375 | connect(_ui->commandEdit, &QLineEdit::textChanged, this, | 478 | connect(_generalUi->commandEdit, &QLineEdit::textChanged, this, | ||
376 | &Konsole::EditProfileDialog::commandChanged); | 479 | &Konsole::EditProfileDialog::commandChanged); | ||
377 | connect(_ui->environmentEditButton, &QPushButton::clicked, this, | 480 | connect(_generalUi->environmentEditButton, &QPushButton::clicked, this, | ||
378 | &Konsole::EditProfileDialog::showEnvironmentEditor); | 481 | &Konsole::EditProfileDialog::showEnvironmentEditor); | ||
379 | 482 | | |||
380 | connect(_ui->terminalColumnsEntry, | 483 | connect(_generalUi->terminalColumnsEntry, | ||
381 | static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, | 484 | static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, | ||
382 | &Konsole::EditProfileDialog::terminalColumnsEntryChanged); | 485 | &Konsole::EditProfileDialog::terminalColumnsEntryChanged); | ||
383 | connect(_ui->terminalRowsEntry, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), | 486 | connect(_generalUi->terminalRowsEntry, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), | ||
384 | this, &Konsole::EditProfileDialog::terminalRowsEntryChanged); | 487 | this, &Konsole::EditProfileDialog::terminalRowsEntryChanged); | ||
385 | | ||||
386 | connect(_ui->showTerminalSizeHintButton, &QCheckBox::toggled, this, | | |||
387 | &Konsole::EditProfileDialog::showTerminalSizeHint); | | |||
388 | | ||||
389 | connect(_ui->dimWhenInactiveCheckbox, &QCheckBox::toggled, this, | | |||
390 | &Konsole::EditProfileDialog::setDimWhenInactive); | | |||
391 | } | 488 | } | ||
392 | 489 | | |||
393 | void EditProfileDialog::showEnvironmentEditor() | 490 | void EditProfileDialog::showEnvironmentEditor() | ||
394 | { | 491 | { | ||
395 | bool ok; | 492 | bool ok; | ||
396 | const Profile::Ptr profile = lookupProfile(); | 493 | const Profile::Ptr profile = lookupProfile(); | ||
397 | 494 | | |||
398 | QStringList currentEnvironment; | 495 | QStringList currentEnvironment; | ||
Show All 21 Lines | 515 | if(!text.isEmpty()) { | |||
420 | updateTempProfileProperty(Profile::Environment, newEnvironment); | 517 | updateTempProfileProperty(Profile::Environment, newEnvironment); | ||
421 | } else { | 518 | } else { | ||
422 | // the user could have removed all entries so we return an empty list | 519 | // the user could have removed all entries so we return an empty list | ||
423 | updateTempProfileProperty(Profile::Environment, newEnvironment); | 520 | updateTempProfileProperty(Profile::Environment, newEnvironment); | ||
424 | } | 521 | } | ||
425 | } | 522 | } | ||
426 | } | 523 | } | ||
427 | 524 | | |||
428 | void EditProfileDialog::setupTabsPage(const Profile::Ptr profile) | 525 | void EditProfileDialog::setupTabsPage(const Profile::Ptr &profile) | ||
429 | { | 526 | { | ||
430 | // tab title format | 527 | // tab title format | ||
431 | _ui->renameTabWidget->setTabTitleText(profile->localTabTitleFormat()); | 528 | _tabsUi->renameTabWidget->setTabTitleText(profile->localTabTitleFormat()); | ||
432 | _ui->renameTabWidget->setRemoteTabTitleText(profile->remoteTabTitleFormat()); | 529 | _tabsUi->renameTabWidget->setRemoteTabTitleText(profile->remoteTabTitleFormat()); | ||
433 | 530 | | |||
434 | connect(_ui->renameTabWidget, &Konsole::RenameTabWidget::tabTitleFormatChanged, this, | 531 | connect(_tabsUi->renameTabWidget, &Konsole::RenameTabWidget::tabTitleFormatChanged, this, | ||
435 | &Konsole::EditProfileDialog::tabTitleFormatChanged); | 532 | &Konsole::EditProfileDialog::tabTitleFormatChanged); | ||
436 | connect(_ui->renameTabWidget, &Konsole::RenameTabWidget::remoteTabTitleFormatChanged, this, | 533 | connect(_tabsUi->renameTabWidget, &Konsole::RenameTabWidget::remoteTabTitleFormatChanged, this, | ||
437 | &Konsole::EditProfileDialog::remoteTabTitleFormatChanged); | 534 | &Konsole::EditProfileDialog::remoteTabTitleFormatChanged); | ||
438 | 535 | | |||
439 | // tab monitoring | 536 | // tab monitoring | ||
440 | const int silenceSeconds = profile->silenceSeconds(); | 537 | const int silenceSeconds = profile->silenceSeconds(); | ||
441 | _ui->silenceSecondsSpinner->setValue(silenceSeconds); | 538 | _tabsUi->silenceSecondsSpinner->setValue(silenceSeconds); | ||
442 | _ui->silenceSecondsSpinner->setSuffix(ki18ncp("Unit of time", " second", " seconds")); | 539 | auto suffix = ki18ncp("Unit of time", " second", " seconds"); | ||
540 | _tabsUi->silenceSecondsSpinner->setSuffix(suffix); | ||||
541 | int silenceCheckBoxWidth = maxSpinBoxWidth(_generalUi->terminalColumnsEntry, suffix); | ||||
542 | _tabsUi->silenceSecondsSpinner->setFixedWidth(silenceCheckBoxWidth); | ||||
443 | 543 | | |||
444 | connect(_ui->silenceSecondsSpinner, | 544 | connect(_tabsUi->silenceSecondsSpinner, | ||
445 | static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, | 545 | static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, | ||
446 | &Konsole::EditProfileDialog::silenceSecondsChanged); | 546 | &Konsole::EditProfileDialog::silenceSecondsChanged); | ||
447 | } | 547 | } | ||
448 | 548 | | |||
449 | void EditProfileDialog::terminalColumnsEntryChanged(int value) | 549 | void EditProfileDialog::terminalColumnsEntryChanged(int value) | ||
450 | { | 550 | { | ||
451 | updateTempProfileProperty(Profile::TerminalColumns, value); | 551 | updateTempProfileProperty(Profile::TerminalColumns, value); | ||
452 | } | 552 | } | ||
Show All 28 Lines | 580 | { | |||
481 | updateTempProfileProperty(Profile::SilenceSeconds, seconds); | 581 | updateTempProfileProperty(Profile::SilenceSeconds, seconds); | ||
482 | } | 582 | } | ||
483 | 583 | | |||
484 | void EditProfileDialog::selectIcon() | 584 | void EditProfileDialog::selectIcon() | ||
485 | { | 585 | { | ||
486 | const QString &icon = KIconDialog::getIcon(KIconLoader::Desktop, KIconLoader::Application, | 586 | const QString &icon = KIconDialog::getIcon(KIconLoader::Desktop, KIconLoader::Application, | ||
487 | false, 0, false, this); | 587 | false, 0, false, this); | ||
488 | if (!icon.isEmpty()) { | 588 | if (!icon.isEmpty()) { | ||
489 | _ui->iconSelectButton->setIcon(QIcon::fromTheme(icon)); | 589 | _generalUi->iconSelectButton->setIcon(QIcon::fromTheme(icon)); | ||
490 | updateTempProfileProperty(Profile::Icon, icon); | 590 | updateTempProfileProperty(Profile::Icon, icon); | ||
491 | } | 591 | } | ||
492 | } | 592 | } | ||
493 | 593 | | |||
494 | void EditProfileDialog::profileNameChanged(const QString &name) | 594 | void EditProfileDialog::profileNameChanged(const QString &name) | ||
495 | { | 595 | { | ||
496 | updateTempProfileProperty(Profile::Name, name); | 596 | updateTempProfileProperty(Profile::Name, name); | ||
497 | updateTempProfileProperty(Profile::UntranslatedName, name); | 597 | updateTempProfileProperty(Profile::UntranslatedName, name); | ||
Show All 17 Lines | 612 | { | |||
515 | updateTempProfileProperty(Profile::Command, shellCommand.command()); | 615 | updateTempProfileProperty(Profile::Command, shellCommand.command()); | ||
516 | updateTempProfileProperty(Profile::Arguments, shellCommand.arguments()); | 616 | updateTempProfileProperty(Profile::Arguments, shellCommand.arguments()); | ||
517 | } | 617 | } | ||
518 | 618 | | |||
519 | void EditProfileDialog::selectInitialDir() | 619 | void EditProfileDialog::selectInitialDir() | ||
520 | { | 620 | { | ||
521 | const QUrl url = QFileDialog::getExistingDirectoryUrl(this, | 621 | const QUrl url = QFileDialog::getExistingDirectoryUrl(this, | ||
522 | i18n("Select Initial Directory"), | 622 | i18n("Select Initial Directory"), | ||
523 | QUrl::fromUserInput(_ui->initialDirEdit-> | 623 | QUrl::fromUserInput(_generalUi->initialDirEdit->text())); | ||
524 | text())); | | |||
525 | 624 | | |||
526 | if (!url.isEmpty()) { | 625 | if (!url.isEmpty()) { | ||
527 | _ui->initialDirEdit->setText(url.path()); | 626 | _generalUi->initialDirEdit->setText(url.path()); | ||
528 | } | 627 | } | ||
529 | } | 628 | } | ||
530 | 629 | | |||
531 | void EditProfileDialog::setupAppearancePage(const Profile::Ptr profile) | 630 | void EditProfileDialog::setupAppearancePage(const Profile::Ptr &profile) | ||
532 | { | 631 | { | ||
533 | auto delegate = new ColorSchemeViewDelegate(this); | 632 | auto delegate = new ColorSchemeViewDelegate(this); | ||
534 | _ui->colorSchemeList->setItemDelegate(delegate); | 633 | _appearanceUi->colorSchemeList->setItemDelegate(delegate); | ||
535 | 634 | | |||
536 | _ui->transparencyWarningWidget->setVisible(false); | 635 | _appearanceUi->transparencyWarningWidget->setVisible(false); | ||
537 | _ui->transparencyWarningWidget->setWordWrap(true); | 636 | _appearanceUi->transparencyWarningWidget->setWordWrap(true); | ||
538 | _ui->transparencyWarningWidget->setCloseButtonVisible(false); | 637 | _appearanceUi->transparencyWarningWidget->setCloseButtonVisible(false); | ||
539 | _ui->transparencyWarningWidget->setMessageType(KMessageWidget::Warning); | 638 | _appearanceUi->transparencyWarningWidget->setMessageType(KMessageWidget::Warning); | ||
540 | 639 | | |||
541 | _ui->colorSchemeMessageWidget->setVisible(false); | 640 | _appearanceUi->colorSchemeMessageWidget->setVisible(false); | ||
542 | _ui->colorSchemeMessageWidget->setWordWrap(true); | 641 | _appearanceUi->colorSchemeMessageWidget->setWordWrap(true); | ||
543 | _ui->colorSchemeMessageWidget->setCloseButtonVisible(false); | 642 | _appearanceUi->colorSchemeMessageWidget->setCloseButtonVisible(false); | ||
544 | _ui->colorSchemeMessageWidget->setMessageType(KMessageWidget::Warning); | 643 | _appearanceUi->colorSchemeMessageWidget->setMessageType(KMessageWidget::Warning); | ||
545 | 644 | | |||
546 | _ui->editColorSchemeButton->setEnabled(false); | 645 | _appearanceUi->editColorSchemeButton->setEnabled(false); | ||
547 | _ui->removeColorSchemeButton->setEnabled(false); | 646 | _appearanceUi->removeColorSchemeButton->setEnabled(false); | ||
548 | _ui->resetColorSchemeButton->setEnabled(false); | 647 | _appearanceUi->resetColorSchemeButton->setEnabled(false); | ||
549 | 648 | | |||
550 | _ui->downloadColorSchemeButton->setConfigFile(QStringLiteral("konsole.knsrc")); | 649 | _appearanceUi->downloadColorSchemeButton->setConfigFile(QStringLiteral("konsole.knsrc")); | ||
551 | 650 | | |||
552 | // setup color list | 651 | // setup color list | ||
553 | // select the colorScheme used in the current profile | 652 | // select the colorScheme used in the current profile | ||
554 | updateColorSchemeList(currentColorSchemeName()); | 653 | updateColorSchemeList(currentColorSchemeName()); | ||
555 | 654 | | |||
556 | _ui->colorSchemeList->setMouseTracking(true); | 655 | _appearanceUi->colorSchemeList->setMouseTracking(true); | ||
557 | _ui->colorSchemeList->installEventFilter(this); | 656 | _appearanceUi->colorSchemeList->installEventFilter(this); | ||
558 | _ui->colorSchemeList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | 657 | _appearanceUi->colorSchemeList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | ||
559 | 658 | | |||
560 | connect(_ui->colorSchemeList->selectionModel(), | 659 | connect(_appearanceUi->colorSchemeList->selectionModel(), | ||
561 | &QItemSelectionModel::selectionChanged, this, | 660 | &QItemSelectionModel::selectionChanged, this, | ||
562 | &Konsole::EditProfileDialog::colorSchemeSelected); | 661 | &Konsole::EditProfileDialog::colorSchemeSelected); | ||
563 | connect(_ui->colorSchemeList, &QListView::entered, this, | 662 | connect(_appearanceUi->colorSchemeList, &QListView::entered, this, | ||
564 | &Konsole::EditProfileDialog::previewColorScheme); | 663 | &Konsole::EditProfileDialog::previewColorScheme); | ||
565 | 664 | | |||
566 | updateColorSchemeButtons(); | 665 | updateColorSchemeButtons(); | ||
567 | 666 | | |||
568 | connect(_ui->editColorSchemeButton, &QPushButton::clicked, this, | 667 | connect(_appearanceUi->editColorSchemeButton, &QPushButton::clicked, this, | ||
569 | &Konsole::EditProfileDialog::editColorScheme); | 668 | &Konsole::EditProfileDialog::editColorScheme); | ||
570 | connect(_ui->removeColorSchemeButton, &QPushButton::clicked, this, | 669 | connect(_appearanceUi->removeColorSchemeButton, &QPushButton::clicked, this, | ||
571 | &Konsole::EditProfileDialog::removeColorScheme); | 670 | &Konsole::EditProfileDialog::removeColorScheme); | ||
572 | connect(_ui->newColorSchemeButton, &QPushButton::clicked, this, | 671 | connect(_appearanceUi->newColorSchemeButton, &QPushButton::clicked, this, | ||
573 | &Konsole::EditProfileDialog::newColorScheme); | 672 | &Konsole::EditProfileDialog::newColorScheme); | ||
574 | connect(_ui->downloadColorSchemeButton, &KNS3::Button::dialogFinished, this, | 673 | connect(_appearanceUi->downloadColorSchemeButton, &KNS3::Button::dialogFinished, this, | ||
575 | &Konsole::EditProfileDialog::gotNewColorSchemes); | 674 | &Konsole::EditProfileDialog::gotNewColorSchemes); | ||
576 | 675 | | |||
577 | connect(_ui->resetColorSchemeButton, &QPushButton::clicked, this, | 676 | connect(_appearanceUi->resetColorSchemeButton, &QPushButton::clicked, this, | ||
578 | &Konsole::EditProfileDialog::resetColorScheme); | 677 | &Konsole::EditProfileDialog::resetColorScheme); | ||
579 | 678 | | |||
679 | connect(_appearanceUi->chooseFontButton, &QAbstractButton::clicked, this, | ||||
680 | &EditProfileDialog::showFontDialog); | ||||
681 | | ||||
580 | // setup font preview | 682 | // setup font preview | ||
581 | const bool antialias = profile->antiAliasFonts(); | 683 | const bool antialias = profile->antiAliasFonts(); | ||
582 | 684 | | |||
583 | QFont profileFont = profile->font(); | 685 | QFont profileFont = profile->font(); | ||
584 | profileFont.setStyleStrategy(antialias ? QFont::PreferAntialias : QFont::NoAntialias); | 686 | profileFont.setStyleStrategy(antialias ? QFont::PreferAntialias : QFont::NoAntialias); | ||
585 | 687 | | |||
586 | _ui->fontPreviewLabel->installEventFilter(this); | 688 | _appearanceUi->fontPreview->setFont(profileFont); | ||
587 | _ui->fontPreviewLabel->setFont(profileFont); | 689 | _appearanceUi->fontPreview->setText(QStringLiteral("%1 %2pt").arg(profileFont.family()).arg(profileFont.pointSize())); | ||
588 | setFontInputValue(profileFont); | | |||
589 | | ||||
590 | // Always set to unchecked | | |||
591 | _ui->showAllFontsButton->setChecked(false); | | |||
592 | connect(_ui->showAllFontsButton, &QCheckBox::toggled, this, | | |||
593 | &Konsole::EditProfileDialog::showAllFontsButtonWarning); | | |||
594 | | ||||
595 | connect(_ui->fontSizeInput, | | |||
596 | static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, | | |||
597 | &Konsole::EditProfileDialog::setFontSize); | | |||
598 | connect(_ui->selectFontButton, &QPushButton::clicked, this, | | |||
599 | &Konsole::EditProfileDialog::showFontDialog); | | |||
600 | 690 | | |||
601 | // setup font smoothing | 691 | // setup font smoothing | ||
602 | _ui->antialiasTextButton->setChecked(antialias); | 692 | _appearanceUi->antialiasTextButton->setChecked(antialias); | ||
603 | connect(_ui->antialiasTextButton, &QCheckBox::toggled, this, | 693 | connect(_appearanceUi->antialiasTextButton, &QCheckBox::toggled, this, | ||
604 | &Konsole::EditProfileDialog::setAntialiasText); | 694 | &Konsole::EditProfileDialog::setAntialiasText); | ||
605 | 695 | | |||
606 | _ui->boldIntenseButton->setChecked(profile->boldIntense()); | 696 | _appearanceUi->boldIntenseButton->setChecked(profile->boldIntense()); | ||
607 | connect(_ui->boldIntenseButton, &QCheckBox::toggled, this, | 697 | connect(_appearanceUi->boldIntenseButton, &QCheckBox::toggled, this, | ||
608 | &Konsole::EditProfileDialog::setBoldIntense); | 698 | &Konsole::EditProfileDialog::setBoldIntense); | ||
609 | 699 | | |||
610 | _ui->useFontLineCharactersButton->setChecked(profile->useFontLineCharacters()); | 700 | _appearanceUi->useFontLineCharactersButton->setChecked(profile->useFontLineCharacters()); | ||
611 | connect(_ui->useFontLineCharactersButton, &QCheckBox::toggled, this, | 701 | connect(_appearanceUi->useFontLineCharactersButton, &QCheckBox::toggled, this, | ||
612 | &Konsole::EditProfileDialog::useFontLineCharacters); | 702 | &Konsole::EditProfileDialog::useFontLineCharacters); | ||
613 | 703 | | |||
614 | _ui->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled()); | 704 | _mouseUi->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled()); | ||
615 | connect(_ui->enableMouseWheelZoomButton, &QCheckBox::toggled, this, | 705 | connect(_mouseUi->enableMouseWheelZoomButton, &QCheckBox::toggled, this, | ||
616 | &Konsole::EditProfileDialog::toggleMouseWheelZoom); | 706 | &Konsole::EditProfileDialog::toggleMouseWheelZoom); | ||
617 | } | | |||
618 | 707 | | |||
619 | void EditProfileDialog::showAllFontsButtonWarning(bool enable) | 708 | // cursor options | ||
709 | const auto options = QVector<BooleanOption>{ | ||||
620 | { | 710 | { | ||
621 | if (enable) { | 711 | _appearanceUi->enableBlinkingCursorButton, Profile::BlinkingCursorEnabled, | ||
622 | KMessageBox::information(this, | 712 | SLOT(toggleBlinkingCursor(bool)) | ||
623 | QStringLiteral( | 713 | }, | ||
624 | "By its very nature, a terminal program requires font characters that are equal width (monospace). Any non monospaced font may cause display issues. This should not be necessary except in rare cases."), | 714 | }; | ||
625 | QStringLiteral("Warning")); | 715 | setupCheckBoxes(options, profile); | ||
716 | | ||||
717 | if (profile->useCustomCursorColor()) { | ||||
718 | _appearanceUi->customCursorColorButton->setChecked(true); | ||||
719 | } else { | ||||
720 | _appearanceUi->autoCursorColorButton->setChecked(true); | ||||
626 | } | 721 | } | ||
722 | | ||||
723 | _appearanceUi->customColorSelectButton->setColor(profile->customCursorColor()); | ||||
724 | | ||||
725 | connect(_appearanceUi->customCursorColorButton, &QRadioButton::clicked, this, &Konsole::EditProfileDialog::customCursorColor); | ||||
726 | connect(_appearanceUi->autoCursorColorButton, &QRadioButton::clicked, this, &Konsole::EditProfileDialog::autoCursorColor); | ||||
727 | connect(_appearanceUi->customColorSelectButton, &KColorButton::changed, this, &Konsole::EditProfileDialog::customCursorColorChanged); | ||||
728 | | ||||
729 | // Make radio buttons height equal | ||||
730 | int cursorColorRadioHeight = qMax(_appearanceUi->autoCursorColorButton->minimumSizeHint().height(), | ||||
731 | _appearanceUi->customColorSelectButton->minimumSizeHint().height()); | ||||
732 | _appearanceUi->autoCursorColorButton->setMinimumHeight(cursorColorRadioHeight); | ||||
733 | _appearanceUi->customCursorColorButton->setMinimumHeight(cursorColorRadioHeight); | ||||
734 | | ||||
735 | const ButtonGroupOptions cursorShapeOptions = { | ||||
736 | _appearanceUi->cursorShape, // group | ||||
737 | Profile::CursorShape, // profileProperty | ||||
738 | true, // preview | ||||
739 | { // buttons | ||||
740 | {_appearanceUi->cursorShapeBlock, Enum::BlockCursor}, | ||||
741 | {_appearanceUi->cursorShapeIBeam, Enum::IBeamCursor}, | ||||
742 | {_appearanceUi->cursorShapeUnderline, Enum::UnderlineCursor}, | ||||
743 | }, | ||||
744 | }; | ||||
745 | setupButtonGroup(cursorShapeOptions, profile); | ||||
746 | | ||||
747 | _appearanceUi->marginsSpinner->setValue(profile->terminalMargin()); | ||||
748 | connect(_appearanceUi->marginsSpinner, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &Konsole::EditProfileDialog::terminalMarginChanged); | ||||
749 | | ||||
750 | _appearanceUi->lineSpacingSpinner->setValue(profile->lineSpacing()); | ||||
751 | connect(_appearanceUi->lineSpacingSpinner, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &Konsole::EditProfileDialog::lineSpacingChanged); | ||||
752 | | ||||
753 | _appearanceUi->alignToCenterButton->setChecked(profile->terminalCenter()); | ||||
754 | connect(_appearanceUi->alignToCenterButton, &QCheckBox::toggled, this, | ||||
755 | &Konsole::EditProfileDialog::setTerminalCenter); | ||||
756 | | ||||
757 | _appearanceUi->showTerminalSizeHintButton->setChecked(profile->showTerminalSizeHint()); | ||||
758 | connect(_appearanceUi->showTerminalSizeHintButton, &QCheckBox::toggled, this, | ||||
759 | &Konsole::EditProfileDialog::showTerminalSizeHint); | ||||
760 | | ||||
761 | _appearanceUi->dimWhenInactiveCheckbox->setChecked(profile->dimWhenInactive()); | ||||
762 | connect(_appearanceUi->dimWhenInactiveCheckbox, &QCheckBox::toggled, this, | ||||
763 | &Konsole::EditProfileDialog::setDimWhenInactive); | ||||
627 | } | 764 | } | ||
628 | 765 | | |||
629 | void EditProfileDialog::setAntialiasText(bool enable) | 766 | void EditProfileDialog::setAntialiasText(bool enable) | ||
630 | { | 767 | { | ||
631 | QFont profileFont = _ui->fontPreviewLabel->font(); | | |||
632 | profileFont.setStyleStrategy(enable ? QFont::PreferAntialias : QFont::NoAntialias); | | |||
633 | | ||||
634 | // update preview to reflect text smoothing state | | |||
635 | fontSelected(profileFont); | | |||
636 | preview(Profile::AntiAliasFonts, enable); | 768 | preview(Profile::AntiAliasFonts, enable); | ||
637 | updateTempProfileProperty(Profile::AntiAliasFonts, enable); | 769 | updateTempProfileProperty(Profile::AntiAliasFonts, enable); | ||
770 | | ||||
771 | const QFont font = _profile->font(); | ||||
772 | updateFontPreview(font); | ||||
638 | } | 773 | } | ||
639 | 774 | | |||
640 | void EditProfileDialog::setBoldIntense(bool enable) | 775 | void EditProfileDialog::setBoldIntense(bool enable) | ||
641 | { | 776 | { | ||
642 | preview(Profile::BoldIntense, enable); | 777 | preview(Profile::BoldIntense, enable); | ||
643 | updateTempProfileProperty(Profile::BoldIntense, enable); | 778 | updateTempProfileProperty(Profile::BoldIntense, enable); | ||
644 | } | 779 | } | ||
645 | 780 | | |||
646 | void EditProfileDialog::useFontLineCharacters(bool enable) | 781 | void EditProfileDialog::useFontLineCharacters(bool enable) | ||
647 | { | 782 | { | ||
648 | preview(Profile::UseFontLineCharacters, enable); | 783 | preview(Profile::UseFontLineCharacters, enable); | ||
649 | updateTempProfileProperty(Profile::UseFontLineCharacters, enable); | 784 | updateTempProfileProperty(Profile::UseFontLineCharacters, enable); | ||
650 | } | 785 | } | ||
651 | 786 | | |||
787 | void EditProfileDialog::toggleBlinkingCursor(bool enable) | ||||
788 | { | ||||
789 | preview(Profile::BlinkingCursorEnabled, enable); | ||||
790 | updateTempProfileProperty(Profile::BlinkingCursorEnabled, enable); | ||||
791 | } | ||||
792 | | ||||
793 | void EditProfileDialog::setCursorShape(int index) | ||||
794 | { | ||||
795 | preview(Profile::CursorShape, index); | ||||
796 | updateTempProfileProperty(Profile::CursorShape, index); | ||||
797 | } | ||||
798 | | ||||
799 | void EditProfileDialog::autoCursorColor() | ||||
800 | { | ||||
801 | preview(Profile::UseCustomCursorColor, false); | ||||
802 | updateTempProfileProperty(Profile::UseCustomCursorColor, false); | ||||
803 | } | ||||
804 | | ||||
805 | void EditProfileDialog::customCursorColor() | ||||
806 | { | ||||
807 | preview(Profile::UseCustomCursorColor, true); | ||||
808 | updateTempProfileProperty(Profile::UseCustomCursorColor, true); | ||||
809 | } | ||||
810 | | ||||
811 | void EditProfileDialog::customCursorColorChanged(const QColor &color) | ||||
812 | { | ||||
813 | preview(Profile::CustomCursorColor, color); | ||||
814 | updateTempProfileProperty(Profile::CustomCursorColor, color); | ||||
815 | | ||||
816 | // ensure that custom cursor colors are enabled | ||||
817 | _appearanceUi->customCursorColorButton->click(); | ||||
818 | } | ||||
819 | | ||||
820 | void EditProfileDialog::terminalMarginChanged(int margin) | ||||
821 | { | ||||
822 | preview(Profile::TerminalMargin, margin); | ||||
823 | updateTempProfileProperty(Profile::TerminalMargin, margin); | ||||
824 | } | ||||
825 | | ||||
826 | void EditProfileDialog::lineSpacingChanged(int spacing) | ||||
827 | { | ||||
828 | preview(Profile::LineSpacing, spacing); | ||||
829 | updateTempProfileProperty(Profile::LineSpacing, spacing); | ||||
830 | } | ||||
831 | | ||||
832 | void EditProfileDialog::setTerminalCenter(bool enable) | ||||
833 | { | ||||
834 | preview(Profile::TerminalCenter, enable); | ||||
835 | updateTempProfileProperty(Profile::TerminalCenter, enable); | ||||
836 | } | ||||
837 | | ||||
652 | void EditProfileDialog::toggleMouseWheelZoom(bool enable) | 838 | void EditProfileDialog::toggleMouseWheelZoom(bool enable) | ||
653 | { | 839 | { | ||
654 | updateTempProfileProperty(Profile::MouseWheelZoomEnabled, enable); | 840 | updateTempProfileProperty(Profile::MouseWheelZoomEnabled, enable); | ||
655 | } | 841 | } | ||
656 | 842 | | |||
657 | void EditProfileDialog::toggleAlternateScrolling(bool enable) | 843 | void EditProfileDialog::toggleAlternateScrolling(bool enable) | ||
658 | { | 844 | { | ||
659 | updateTempProfileProperty(Profile::AlternateScrolling, enable); | 845 | updateTempProfileProperty(Profile::AlternateScrolling, enable); | ||
660 | } | 846 | } | ||
661 | 847 | | |||
662 | void EditProfileDialog::updateColorSchemeList(const QString &selectedColorSchemeName) | 848 | void EditProfileDialog::updateColorSchemeList(const QString &selectedColorSchemeName) | ||
663 | { | 849 | { | ||
664 | if (_ui->colorSchemeList->model() == nullptr) { | 850 | if (_appearanceUi->colorSchemeList->model() == nullptr) { | ||
665 | _ui->colorSchemeList->setModel(new QStandardItemModel(this)); | 851 | _appearanceUi->colorSchemeList->setModel(new QStandardItemModel(this)); | ||
666 | } | 852 | } | ||
667 | 853 | | |||
668 | const ColorScheme *selectedColorScheme = ColorSchemeManager::instance()->findColorScheme(selectedColorSchemeName); | 854 | const ColorScheme *selectedColorScheme = ColorSchemeManager::instance()->findColorScheme(selectedColorSchemeName); | ||
669 | 855 | | |||
670 | auto *model = qobject_cast<QStandardItemModel *>(_ui->colorSchemeList->model()); | 856 | auto *model = qobject_cast<QStandardItemModel *>(_appearanceUi->colorSchemeList->model()); | ||
671 | 857 | | |||
672 | Q_ASSERT(model); | 858 | Q_ASSERT(model); | ||
673 | 859 | | |||
674 | model->clear(); | 860 | model->clear(); | ||
675 | 861 | | |||
676 | QStandardItem *selectedItem = nullptr; | 862 | QStandardItem *selectedItem = nullptr; | ||
677 | 863 | | |||
678 | QList<const ColorScheme *> schemeList = ColorSchemeManager::instance()->allColorSchemes(); | 864 | QList<const ColorScheme *> schemeList = ColorSchemeManager::instance()->allColorSchemes(); | ||
Show All 11 Lines | 866 | foreach (const ColorScheme *scheme, schemeList) { | |||
690 | } | 876 | } | ||
691 | 877 | | |||
692 | model->appendRow(item); | 878 | model->appendRow(item); | ||
693 | } | 879 | } | ||
694 | 880 | | |||
695 | model->sort(0); | 881 | model->sort(0); | ||
696 | 882 | | |||
697 | if (selectedItem != nullptr) { | 883 | if (selectedItem != nullptr) { | ||
698 | _ui->colorSchemeList->updateGeometry(); | 884 | _appearanceUi->colorSchemeList->updateGeometry(); | ||
699 | _ui->colorSchemeList->selectionModel()->setCurrentIndex(selectedItem->index(), | 885 | _appearanceUi->colorSchemeList->selectionModel()->setCurrentIndex(selectedItem->index(), | ||
700 | QItemSelectionModel::Select); | 886 | QItemSelectionModel::Select); | ||
701 | 887 | | |||
702 | // update transparency warning label | 888 | // update transparency warning label | ||
703 | updateTransparencyWarning(); | 889 | updateTransparencyWarning(); | ||
704 | } | 890 | } | ||
705 | } | 891 | } | ||
706 | 892 | | |||
707 | void EditProfileDialog::updateKeyBindingsList(const QString &selectKeyBindingsName) | 893 | void EditProfileDialog::updateKeyBindingsList(const QString &selectKeyBindingsName) | ||
708 | { | 894 | { | ||
709 | if (_ui->keyBindingList->model() == nullptr) { | 895 | if (_keyboardUi->keyBindingList->model() == nullptr) { | ||
710 | _ui->keyBindingList->setModel(new QStandardItemModel(this)); | 896 | _keyboardUi->keyBindingList->setModel(new QStandardItemModel(this)); | ||
711 | } | 897 | } | ||
712 | 898 | | |||
713 | auto *model = qobject_cast<QStandardItemModel *>(_ui->keyBindingList->model()); | 899 | auto *model = qobject_cast<QStandardItemModel *>(_keyboardUi->keyBindingList->model()); | ||
714 | 900 | | |||
715 | Q_ASSERT(model); | 901 | Q_ASSERT(model); | ||
716 | 902 | | |||
717 | model->clear(); | 903 | model->clear(); | ||
718 | 904 | | |||
719 | QStandardItem *selectedItem = nullptr; | 905 | QStandardItem *selectedItem = nullptr; | ||
720 | 906 | | |||
721 | const QStringList &translatorNames = _keyManager->allTranslators(); | 907 | const QStringList &translatorNames = _keyManager->allTranslators(); | ||
Show All 15 Lines | 908 | for (const QString &translatorName : translatorNames) { | |||
737 | } | 923 | } | ||
738 | 924 | | |||
739 | model->appendRow(item); | 925 | model->appendRow(item); | ||
740 | } | 926 | } | ||
741 | 927 | | |||
742 | model->sort(0); | 928 | model->sort(0); | ||
743 | 929 | | |||
744 | if (selectedItem != nullptr) { | 930 | if (selectedItem != nullptr) { | ||
745 | _ui->keyBindingList->selectionModel()->setCurrentIndex(selectedItem->index(), | 931 | _keyboardUi->keyBindingList->selectionModel()->setCurrentIndex(selectedItem->index(), | ||
746 | QItemSelectionModel::Select); | 932 | QItemSelectionModel::Select); | ||
747 | } | 933 | } | ||
748 | } | 934 | } | ||
749 | 935 | | |||
750 | bool EditProfileDialog::eventFilter(QObject *watched, QEvent *event) | 936 | bool EditProfileDialog::eventFilter(QObject *watched, QEvent *event) | ||
751 | { | 937 | { | ||
752 | if (watched == _ui->colorSchemeList && event->type() == QEvent::Leave) { | 938 | if (watched == _appearanceUi->colorSchemeList && event->type() == QEvent::Leave) { | ||
753 | if (_tempProfile->isPropertySet(Profile::ColorScheme)) { | 939 | if (_tempProfile->isPropertySet(Profile::ColorScheme)) { | ||
754 | preview(Profile::ColorScheme, _tempProfile->colorScheme()); | 940 | preview(Profile::ColorScheme, _tempProfile->colorScheme()); | ||
755 | } else { | 941 | } else { | ||
756 | unpreview(Profile::ColorScheme); | 942 | unpreview(Profile::ColorScheme); | ||
757 | } | 943 | } | ||
758 | } | 944 | } | ||
759 | if (watched == _ui->fontPreviewLabel && event->type() == QEvent::FontChange) { | | |||
760 | const QFont &labelFont = _ui->fontPreviewLabel->font(); | | |||
761 | _ui->fontPreviewLabel->setText(i18n("%1", labelFont.family())); | | |||
762 | } | | |||
763 | 945 | | |||
764 | return QDialog::eventFilter(watched, event); | 946 | return QDialog::eventFilter(watched, event); | ||
765 | } | 947 | } | ||
766 | 948 | | |||
949 | QSize EditProfileDialog::sizeHint() const | ||||
950 | { | ||||
951 | // return QSize(); | ||||
952 | return QDialog::sizeHint(); | ||||
953 | } | ||||
954 | | ||||
767 | void EditProfileDialog::unpreviewAll() | 955 | void EditProfileDialog::unpreviewAll() | ||
768 | { | 956 | { | ||
769 | _delayedPreviewTimer->stop(); | 957 | _delayedPreviewTimer->stop(); | ||
770 | _delayedPreviewProperties.clear(); | 958 | _delayedPreviewProperties.clear(); | ||
771 | 959 | | |||
772 | QHash<Profile::Property, QVariant> map; | 960 | QHash<Profile::Property, QVariant> map; | ||
773 | QHashIterator<int, QVariant> iter(_previewedProperties); | 961 | QHashIterator<int, QVariant> iter(_previewedProperties); | ||
774 | while (iter.hasNext()) { | 962 | while (iter.hasNext()) { | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 1008 | { | |||
842 | 1030 | | |||
843 | // temporary change to color scheme | 1031 | // temporary change to color scheme | ||
844 | ProfileManager::instance()->changeProfile(_profile, map, false); | 1032 | ProfileManager::instance()->changeProfile(_profile, map, false); | ||
845 | } | 1033 | } | ||
846 | 1034 | | |||
847 | void EditProfileDialog::previewColorScheme(const QModelIndex &index) | 1035 | void EditProfileDialog::previewColorScheme(const QModelIndex &index) | ||
848 | { | 1036 | { | ||
849 | const QString &name = index.data(Qt::UserRole + 1).value<const ColorScheme *>()->name(); | 1037 | const QString &name = index.data(Qt::UserRole + 1).value<const ColorScheme *>()->name(); | ||
850 | | ||||
851 | delayedPreview(Profile::ColorScheme, name); | 1038 | delayedPreview(Profile::ColorScheme, name); | ||
852 | } | 1039 | } | ||
853 | 1040 | | |||
1041 | void EditProfileDialog::showFontDialog() | ||||
1042 | { | ||||
1043 | if (!_fontDialog) { | ||||
1044 | _fontDialog = new FontDialog(this); | ||||
1045 | connect(_fontDialog, &FontDialog::fontChanged, this, [this](const QFont font) { | ||||
1046 | preview(Profile::Font, font); | ||||
1047 | updateFontPreview(font); | ||||
1048 | }); | ||||
1049 | connect(_fontDialog, &FontDialog::accepted, this, [this]() { | ||||
1050 | const QFont font = _fontDialog->font(); | ||||
1051 | preview(Profile::Font, font); | ||||
1052 | updateTempProfileProperty(Profile::Font, font); | ||||
1053 | updateFontPreview(font); | ||||
1054 | }); | ||||
1055 | connect(_fontDialog, &FontDialog::rejected, this, [this]() { | ||||
1056 | unpreview(Profile::Font); | ||||
1057 | const QFont font = _profile->font(); | ||||
1058 | updateFontPreview(font); | ||||
1059 | }); | ||||
1060 | } | ||||
1061 | const QFont font = _profile->font(); | ||||
1062 | _fontDialog->setFont(font); | ||||
1063 | _fontDialog->exec(); | ||||
1064 | } | ||||
1065 | | ||||
1066 | void EditProfileDialog::updateFontPreview(QFont font) | ||||
1067 | { | ||||
1068 | bool aa = _profile->antiAliasFonts(); | ||||
1069 | font.setStyleStrategy(aa ? QFont::PreferAntialias : QFont::NoAntialias); | ||||
1070 | | ||||
1071 | _appearanceUi->fontPreview->setFont(font); | ||||
1072 | _appearanceUi->fontPreview->setText(QStringLiteral("%1 %2pt").arg(font.family()).arg(font.pointSize())); | ||||
1073 | } | ||||
1074 | | ||||
854 | void EditProfileDialog::removeColorScheme() | 1075 | void EditProfileDialog::removeColorScheme() | ||
855 | { | 1076 | { | ||
856 | QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes(); | 1077 | QModelIndexList selected = _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes(); | ||
857 | if (selected.isEmpty()) { | 1078 | if (selected.isEmpty()) { | ||
858 | return; | 1079 | return; | ||
859 | } | 1080 | } | ||
860 | 1081 | | |||
861 | // The actual delete runs async because we need to on-demand query | 1082 | // The actual delete runs async because we need to on-demand query | ||
862 | // files managed by KNS. Deleting files managed by KNS screws up the | 1083 | // files managed by KNS. Deleting files managed by KNS screws up the | ||
863 | // KNS states (entry gets shown as installed when in fact we deleted it). | 1084 | // KNS states (entry gets shown as installed when in fact we deleted it). | ||
864 | auto *manager = new KNSCore::DownloadManager(QStringLiteral("konsole.knsrc"), this); | 1085 | auto *manager = new KNSCore::DownloadManager(QStringLiteral("konsole.knsrc"), this); | ||
865 | connect(manager, &KNSCore::DownloadManager::searchResult, | 1086 | connect(manager, &KNSCore::DownloadManager::searchResult, | ||
866 | [=](const KNSCore::EntryInternal::List &entries) { | 1087 | this, [=](const KNSCore::EntryInternal::List &entries) { | ||
867 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const ColorScheme *>()->name(); | 1088 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const ColorScheme *>()->name(); | ||
868 | Q_ASSERT(!name.isEmpty()); | 1089 | Q_ASSERT(!name.isEmpty()); | ||
869 | bool uninstalled = false; | 1090 | bool uninstalled = false; | ||
870 | // Check if the theme was installed by KNS, if so uninstall it through | 1091 | // Check if the theme was installed by KNS, if so uninstall it through | ||
871 | // there and unload it. | 1092 | // there and unload it. | ||
872 | for (auto entry : entries) { | 1093 | for (auto &entry : entries) { | ||
873 | for (const auto &file : entry.installedFiles()) { | 1094 | for (const auto &file : entry.installedFiles()) { | ||
874 | if (ColorSchemeManager::colorSchemeNameFromPath(file) != name) { | 1095 | if (ColorSchemeManager::colorSchemeNameFromPath(file) != name) { | ||
875 | continue; | 1096 | continue; | ||
876 | } | 1097 | } | ||
877 | // Make sure the manager can unload it before uninstalling it. | 1098 | // Make sure the manager can unload it before uninstalling it. | ||
878 | if (ColorSchemeManager::instance()->unloadColorScheme(file)) { | 1099 | if (ColorSchemeManager::instance()->unloadColorScheme(file)) { | ||
879 | manager->uninstallEntry(entry); | 1100 | manager->uninstallEntry(entry); | ||
880 | uninstalled = true; | 1101 | uninstalled = true; | ||
881 | } | 1102 | } | ||
882 | } | 1103 | } | ||
883 | if (uninstalled) { | 1104 | if (uninstalled) { | ||
884 | break; | 1105 | break; | ||
885 | } | 1106 | } | ||
886 | } | 1107 | } | ||
887 | 1108 | | |||
888 | // If KNS wasn't able to remove it is a custom theme and we'll drop | 1109 | // If KNS wasn't able to remove it is a custom theme and we'll drop | ||
889 | // it manually. | 1110 | // it manually. | ||
890 | if (!uninstalled) { | 1111 | if (!uninstalled) { | ||
891 | uninstalled = ColorSchemeManager::instance()->deleteColorScheme(name); | 1112 | uninstalled = ColorSchemeManager::instance()->deleteColorScheme(name); | ||
892 | } | 1113 | } | ||
893 | 1114 | | |||
894 | if (uninstalled) { | 1115 | if (uninstalled) { | ||
895 | _ui->colorSchemeList->model()->removeRow(selected.first().row()); | 1116 | _appearanceUi->colorSchemeList->model()->removeRow(selected.first().row()); | ||
896 | } | 1117 | } | ||
897 | 1118 | | |||
898 | manager->deleteLater(); | 1119 | manager->deleteLater(); | ||
899 | }); | 1120 | }); | ||
900 | manager->checkForInstalled(); | 1121 | manager->checkForInstalled(); | ||
901 | } | 1122 | } | ||
902 | 1123 | | |||
903 | void EditProfileDialog::gotNewColorSchemes(const KNS3::Entry::List &changedEntries) | 1124 | void EditProfileDialog::gotNewColorSchemes(const KNS3::Entry::List &changedEntries) | ||
904 | { | 1125 | { | ||
905 | int failures = 0; | 1126 | int failures = 0; | ||
906 | for (auto entry : changedEntries) { | 1127 | for (auto &entry : changedEntries) { | ||
907 | switch (entry.status()) { | 1128 | switch (entry.status()) { | ||
908 | case KNS3::Entry::Installed: | 1129 | case KNS3::Entry::Installed: | ||
909 | for (const auto &file : entry.installedFiles()) { | 1130 | for (const auto &file : entry.installedFiles()) { | ||
910 | if (ColorSchemeManager::instance()->loadColorScheme(file)) { | 1131 | if (ColorSchemeManager::instance()->loadColorScheme(file)) { | ||
911 | continue; | 1132 | continue; | ||
912 | } | 1133 | } | ||
913 | qWarning() << "Failed to load file" << file; | 1134 | qWarning() << "Failed to load file" << file; | ||
914 | ++failures; | 1135 | ++failures; | ||
915 | } | 1136 | } | ||
916 | if (failures == entry.installedFiles().size()) { | 1137 | if (failures == entry.installedFiles().size()) { | ||
917 | _ui->colorSchemeMessageWidget->setText( | 1138 | _appearanceUi->colorSchemeMessageWidget->setText( | ||
918 | xi18nc("@info", | 1139 | xi18nc("@info", | ||
919 | "Scheme <resource>%1</resource> failed to load.", | 1140 | "Scheme <resource>%1</resource> failed to load.", | ||
920 | entry.name())); | 1141 | entry.name())); | ||
921 | _ui->colorSchemeMessageWidget->animatedShow(); | 1142 | _appearanceUi->colorSchemeMessageWidget->animatedShow(); | ||
922 | QTimer::singleShot(8000, | 1143 | QTimer::singleShot(8000, | ||
923 | _ui->colorSchemeMessageWidget, | 1144 | _appearanceUi->colorSchemeMessageWidget, | ||
924 | &KMessageWidget::animatedHide); | 1145 | &KMessageWidget::animatedHide); | ||
925 | } | 1146 | } | ||
926 | break; | 1147 | break; | ||
927 | case KNS3::Entry::Deleted: | 1148 | case KNS3::Entry::Deleted: | ||
928 | for (const auto &file : entry.uninstalledFiles()) { | 1149 | for (const auto &file : entry.uninstalledFiles()) { | ||
929 | if (ColorSchemeManager::instance()->unloadColorScheme(file)) { | 1150 | if (ColorSchemeManager::instance()->unloadColorScheme(file)) { | ||
930 | continue; | 1151 | continue; | ||
931 | } | 1152 | } | ||
Show All 12 Lines | |||||
944 | } | 1165 | } | ||
945 | } | 1166 | } | ||
946 | updateColorSchemeList(currentColorSchemeName()); | 1167 | updateColorSchemeList(currentColorSchemeName()); | ||
947 | } | 1168 | } | ||
948 | 1169 | | |||
949 | void EditProfileDialog::resetColorScheme() | 1170 | void EditProfileDialog::resetColorScheme() | ||
950 | { | 1171 | { | ||
951 | 1172 | | |||
952 | QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes(); | 1173 | QModelIndexList selected = _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes(); | ||
953 | 1174 | | |||
954 | if (!selected.isEmpty()) { | 1175 | if (!selected.isEmpty()) { | ||
955 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const ColorScheme *>()->name(); | 1176 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const ColorScheme *>()->name(); | ||
956 | 1177 | | |||
957 | ColorSchemeManager::instance()->deleteColorScheme(name); | 1178 | ColorSchemeManager::instance()->deleteColorScheme(name); | ||
958 | 1179 | | |||
959 | // select the colorScheme used in the current profile | 1180 | // select the colorScheme used in the current profile | ||
960 | updateColorSchemeList(currentColorSchemeName()); | 1181 | updateColorSchemeList(currentColorSchemeName()); | ||
961 | } | 1182 | } | ||
962 | } | 1183 | } | ||
963 | 1184 | | |||
964 | void EditProfileDialog::showColorSchemeEditor(bool isNewScheme) | 1185 | void EditProfileDialog::showColorSchemeEditor(bool isNewScheme) | ||
965 | { | 1186 | { | ||
966 | // Finding selected ColorScheme | 1187 | // Finding selected ColorScheme | ||
967 | QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes(); | 1188 | QModelIndexList selected = _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes(); | ||
968 | QAbstractItemModel *model = _ui->colorSchemeList->model(); | 1189 | QAbstractItemModel *model = _appearanceUi->colorSchemeList->model(); | ||
969 | const ColorScheme *colors = nullptr; | 1190 | const ColorScheme *colors = nullptr; | ||
970 | if (!selected.isEmpty()) { | 1191 | if (!selected.isEmpty()) { | ||
971 | colors = model->data(selected.first(), Qt::UserRole + 1).value<const ColorScheme *>(); | 1192 | colors = model->data(selected.first(), Qt::UserRole + 1).value<const ColorScheme *>(); | ||
972 | } else { | 1193 | } else { | ||
973 | colors = ColorSchemeManager::instance()->defaultColorScheme(); | 1194 | colors = ColorSchemeManager::instance()->defaultColorScheme(); | ||
974 | } | 1195 | } | ||
975 | 1196 | | |||
976 | Q_ASSERT(colors); | 1197 | Q_ASSERT(colors); | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 1232 | { | |||
1023 | // select the edited or the new colorScheme after saving the changes | 1244 | // select the edited or the new colorScheme after saving the changes | ||
1024 | updateColorSchemeList(selectedColorSchemeName); | 1245 | updateColorSchemeList(selectedColorSchemeName); | ||
1025 | 1246 | | |||
1026 | preview(Profile::ColorScheme, newScheme->name()); | 1247 | preview(Profile::ColorScheme, newScheme->name()); | ||
1027 | } | 1248 | } | ||
1028 | 1249 | | |||
1029 | void EditProfileDialog::colorSchemeSelected() | 1250 | void EditProfileDialog::colorSchemeSelected() | ||
1030 | { | 1251 | { | ||
1031 | QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes(); | 1252 | QModelIndexList selected = _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes(); | ||
1032 | 1253 | | |||
1033 | if (!selected.isEmpty()) { | 1254 | if (!selected.isEmpty()) { | ||
1034 | QAbstractItemModel *model = _ui->colorSchemeList->model(); | 1255 | QAbstractItemModel *model = _appearanceUi->colorSchemeList->model(); | ||
1035 | const auto *colors = model->data(selected.first(), Qt::UserRole + 1).value<const ColorScheme *>(); | 1256 | const auto *colors = model->data(selected.first(), Qt::UserRole + 1).value<const ColorScheme *>(); | ||
1036 | if (colors != nullptr) { | 1257 | if (colors != nullptr) { | ||
1037 | updateTempProfileProperty(Profile::ColorScheme, colors->name()); | 1258 | updateTempProfileProperty(Profile::ColorScheme, colors->name()); | ||
1038 | previewColorScheme(selected.first()); | 1259 | previewColorScheme(selected.first()); | ||
1039 | 1260 | | |||
1040 | updateTransparencyWarning(); | 1261 | updateTransparencyWarning(); | ||
1041 | } | 1262 | } | ||
1042 | } | 1263 | } | ||
1043 | 1264 | | |||
1044 | updateColorSchemeButtons(); | 1265 | updateColorSchemeButtons(); | ||
1045 | } | 1266 | } | ||
1046 | 1267 | | |||
1047 | void EditProfileDialog::updateColorSchemeButtons() | 1268 | void EditProfileDialog::updateColorSchemeButtons() | ||
1048 | { | 1269 | { | ||
1049 | enableIfNonEmptySelection(_ui->editColorSchemeButton, _ui->colorSchemeList->selectionModel()); | 1270 | enableIfNonEmptySelection(_appearanceUi->editColorSchemeButton, _appearanceUi->colorSchemeList->selectionModel()); | ||
1050 | 1271 | | |||
1051 | QModelIndexList selected = _ui->colorSchemeList->selectionModel()->selectedIndexes(); | 1272 | QModelIndexList selected = _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes(); | ||
1052 | 1273 | | |||
1053 | if (!selected.isEmpty()) { | 1274 | if (!selected.isEmpty()) { | ||
1054 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const ColorScheme *>()->name(); | 1275 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const ColorScheme *>()->name(); | ||
1055 | 1276 | | |||
1056 | bool isResettable = ColorSchemeManager::instance()->canResetColorScheme(name); | 1277 | bool isResettable = ColorSchemeManager::instance()->canResetColorScheme(name); | ||
1057 | _ui->resetColorSchemeButton->setEnabled(isResettable); | 1278 | _appearanceUi->resetColorSchemeButton->setEnabled(isResettable); | ||
1058 | 1279 | | |||
1059 | bool isDeletable = ColorSchemeManager::instance()->isColorSchemeDeletable(name); | 1280 | bool isDeletable = ColorSchemeManager::instance()->isColorSchemeDeletable(name); | ||
1060 | // if a colorScheme can be restored then it can't be deleted | 1281 | // if a colorScheme can be restored then it can't be deleted | ||
1061 | _ui->removeColorSchemeButton->setEnabled(isDeletable && !isResettable); | 1282 | _appearanceUi->removeColorSchemeButton->setEnabled(isDeletable && !isResettable); | ||
1062 | } else { | 1283 | } else { | ||
1063 | _ui->removeColorSchemeButton->setEnabled(false); | 1284 | _appearanceUi->removeColorSchemeButton->setEnabled(false); | ||
1064 | _ui->resetColorSchemeButton->setEnabled(false); | 1285 | _appearanceUi->resetColorSchemeButton->setEnabled(false); | ||
1065 | } | 1286 | } | ||
1066 | 1287 | | |||
1067 | } | 1288 | } | ||
1068 | 1289 | | |||
1069 | void EditProfileDialog::updateKeyBindingsButtons() | 1290 | void EditProfileDialog::updateKeyBindingsButtons() | ||
1070 | { | 1291 | { | ||
1071 | QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes(); | 1292 | QModelIndexList selected = _keyboardUi->keyBindingList->selectionModel()->selectedIndexes(); | ||
1072 | 1293 | | |||
1073 | if (!selected.isEmpty()) { | 1294 | if (!selected.isEmpty()) { | ||
1074 | _ui->editKeyBindingsButton->setEnabled(true); | 1295 | _keyboardUi->editKeyBindingsButton->setEnabled(true); | ||
1075 | 1296 | | |||
1076 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const KeyboardTranslator *>()->name(); | 1297 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const KeyboardTranslator *>()->name(); | ||
1077 | 1298 | | |||
1078 | bool isResettable = _keyManager->isTranslatorResettable(name); | 1299 | bool isResettable = _keyManager->isTranslatorResettable(name); | ||
1079 | _ui->resetKeyBindingsButton->setEnabled(isResettable); | 1300 | _keyboardUi->resetKeyBindingsButton->setEnabled(isResettable); | ||
1080 | 1301 | | |||
1081 | bool isDeletable = _keyManager->isTranslatorDeletable(name); | 1302 | bool isDeletable = _keyManager->isTranslatorDeletable(name); | ||
1082 | 1303 | | |||
1083 | // if a key bindings scheme can be reset then it can't be deleted | 1304 | // if a key bindings scheme can be reset then it can't be deleted | ||
1084 | _ui->removeKeyBindingsButton->setEnabled(isDeletable && !isResettable); | 1305 | _keyboardUi->removeKeyBindingsButton->setEnabled(isDeletable && !isResettable); | ||
1085 | } | 1306 | } | ||
1086 | } | 1307 | } | ||
1087 | 1308 | | |||
1088 | void EditProfileDialog::enableIfNonEmptySelection(QWidget *widget, QItemSelectionModel *selectionModel) | 1309 | void EditProfileDialog::enableIfNonEmptySelection(QWidget *widget, QItemSelectionModel *selectionModel) | ||
1089 | { | 1310 | { | ||
1090 | widget->setEnabled(selectionModel->hasSelection()); | 1311 | widget->setEnabled(selectionModel->hasSelection()); | ||
1091 | } | 1312 | } | ||
1092 | 1313 | | |||
1093 | void EditProfileDialog::updateTransparencyWarning() | 1314 | void EditProfileDialog::updateTransparencyWarning() | ||
1094 | { | 1315 | { | ||
1095 | // zero or one indexes can be selected | 1316 | // zero or one indexes can be selected | ||
1096 | foreach (const QModelIndex &index, _ui->colorSchemeList->selectionModel()->selectedIndexes()) { | 1317 | foreach (const QModelIndex &index, _appearanceUi->colorSchemeList->selectionModel()->selectedIndexes()) { | ||
1097 | bool needTransparency = index.data(Qt::UserRole + 1).value<const ColorScheme *>()->opacity() < 1.0; | 1318 | bool needTransparency = index.data(Qt::UserRole + 1).value<const ColorScheme *>()->opacity() < 1.0; | ||
1098 | 1319 | | |||
1099 | if (!needTransparency) { | 1320 | if (!needTransparency) { | ||
1100 | _ui->transparencyWarningWidget->setHidden(true); | 1321 | _appearanceUi->transparencyWarningWidget->setHidden(true); | ||
1101 | } else if (!KWindowSystem::compositingActive()) { | 1322 | } else if (!KWindowSystem::compositingActive()) { | ||
1102 | _ui->transparencyWarningWidget->setText(i18n( | 1323 | _appearanceUi->transparencyWarningWidget->setText(i18n( | ||
1103 | "This color scheme uses a transparent background" | 1324 | "This color scheme uses a transparent background" | ||
1104 | " which does not appear to be supported on your" | 1325 | " which does not appear to be supported on your" | ||
1105 | " desktop")); | 1326 | " desktop")); | ||
1106 | _ui->transparencyWarningWidget->setHidden(false); | 1327 | _appearanceUi->transparencyWarningWidget->setHidden(false); | ||
1107 | } else if (!WindowSystemInfo::HAVE_TRANSPARENCY) { | 1328 | } else if (!WindowSystemInfo::HAVE_TRANSPARENCY) { | ||
1108 | _ui->transparencyWarningWidget->setText(i18n( | 1329 | _appearanceUi->transparencyWarningWidget->setText(i18n( | ||
1109 | "Konsole was started before desktop effects were enabled." | 1330 | "Konsole was started before desktop effects were enabled." | ||
1110 | " You need to restart Konsole to see transparent background.")); | 1331 | " You need to restart Konsole to see transparent background.")); | ||
1111 | _ui->transparencyWarningWidget->setHidden(false); | 1332 | _appearanceUi->transparencyWarningWidget->setHidden(false); | ||
1112 | } | 1333 | } | ||
1113 | } | 1334 | } | ||
1114 | } | 1335 | } | ||
1115 | 1336 | | |||
1116 | void EditProfileDialog::createTempProfile() | 1337 | void EditProfileDialog::createTempProfile() | ||
1117 | { | 1338 | { | ||
1118 | _tempProfile = Profile::Ptr(new Profile); | 1339 | _tempProfile = Profile::Ptr(new Profile); | ||
1119 | _tempProfile->setHidden(true); | 1340 | _tempProfile->setHidden(true); | ||
Show All 28 Lines | 1354 | while (iter.hasNext()) { | |||
1148 | // then the user opened the edit key bindings dialog and clicked | 1369 | // then the user opened the edit key bindings dialog and clicked | ||
1149 | // OK, and could have add/removed a key bindings rule | 1370 | // OK, and could have add/removed a key bindings rule | ||
1150 | } else if (property == Profile::KeyBindings || (value != _profile->property<QVariant>(property))) { | 1371 | } else if (property == Profile::KeyBindings || (value != _profile->property<QVariant>(property))) { | ||
1151 | userModified = true; | 1372 | userModified = true; | ||
1152 | break; | 1373 | break; | ||
1153 | } | 1374 | } | ||
1154 | } | 1375 | } | ||
1155 | 1376 | | |||
1156 | mButtonBox->button(QDialogButtonBox::Apply)->setEnabled(userModified); | 1377 | _buttonBox->button(QDialogButtonBox::Apply)->setEnabled(userModified); | ||
1157 | } | 1378 | } | ||
1158 | 1379 | | |||
1159 | void EditProfileDialog::setupKeyboardPage(const Profile::Ptr /* profile */) | 1380 | void EditProfileDialog::setupKeyboardPage(const Profile::Ptr &/* profile */) | ||
1160 | { | 1381 | { | ||
1161 | // setup translator list | 1382 | // setup translator list | ||
1162 | updateKeyBindingsList(lookupProfile()->keyBindings()); | 1383 | updateKeyBindingsList(lookupProfile()->keyBindings()); | ||
1163 | 1384 | | |||
1164 | connect(_ui->keyBindingList->selectionModel(), | 1385 | connect(_keyboardUi->keyBindingList->selectionModel(), | ||
1165 | &QItemSelectionModel::selectionChanged, this, | 1386 | &QItemSelectionModel::selectionChanged, this, | ||
1166 | &Konsole::EditProfileDialog::keyBindingSelected); | 1387 | &Konsole::EditProfileDialog::keyBindingSelected); | ||
1167 | connect(_ui->newKeyBindingsButton, &QPushButton::clicked, this, | 1388 | connect(_keyboardUi->newKeyBindingsButton, &QPushButton::clicked, this, | ||
1168 | &Konsole::EditProfileDialog::newKeyBinding); | 1389 | &Konsole::EditProfileDialog::newKeyBinding); | ||
1169 | 1390 | | |||
1170 | _ui->editKeyBindingsButton->setEnabled(false); | 1391 | _keyboardUi->editKeyBindingsButton->setEnabled(false); | ||
1171 | _ui->removeKeyBindingsButton->setEnabled(false); | 1392 | _keyboardUi->removeKeyBindingsButton->setEnabled(false); | ||
1172 | _ui->resetKeyBindingsButton->setEnabled(false); | 1393 | _keyboardUi->resetKeyBindingsButton->setEnabled(false); | ||
1173 | 1394 | | |||
1174 | updateKeyBindingsButtons(); | 1395 | updateKeyBindingsButtons(); | ||
1175 | 1396 | | |||
1176 | connect(_ui->editKeyBindingsButton, &QPushButton::clicked, this, | 1397 | connect(_keyboardUi->editKeyBindingsButton, &QPushButton::clicked, this, | ||
1177 | &Konsole::EditProfileDialog::editKeyBinding); | 1398 | &Konsole::EditProfileDialog::editKeyBinding); | ||
1178 | connect(_ui->removeKeyBindingsButton, &QPushButton::clicked, this, | 1399 | connect(_keyboardUi->removeKeyBindingsButton, &QPushButton::clicked, this, | ||
1179 | &Konsole::EditProfileDialog::removeKeyBinding); | 1400 | &Konsole::EditProfileDialog::removeKeyBinding); | ||
1180 | connect(_ui->resetKeyBindingsButton, &QPushButton::clicked, this, | 1401 | connect(_keyboardUi->resetKeyBindingsButton, &QPushButton::clicked, this, | ||
1181 | &Konsole::EditProfileDialog::resetKeyBindings); | 1402 | &Konsole::EditProfileDialog::resetKeyBindings); | ||
1182 | } | 1403 | } | ||
1183 | 1404 | | |||
1184 | void EditProfileDialog::keyBindingSelected() | 1405 | void EditProfileDialog::keyBindingSelected() | ||
1185 | { | 1406 | { | ||
1186 | QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes(); | 1407 | QModelIndexList selected = _keyboardUi->keyBindingList->selectionModel()->selectedIndexes(); | ||
1187 | 1408 | | |||
1188 | if (!selected.isEmpty()) { | 1409 | if (!selected.isEmpty()) { | ||
1189 | QAbstractItemModel *model = _ui->keyBindingList->model(); | 1410 | QAbstractItemModel *model = _keyboardUi->keyBindingList->model(); | ||
1190 | const auto *translator = model->data(selected.first(), Qt::UserRole + 1) | 1411 | const auto *translator = model->data(selected.first(), Qt::UserRole + 1) | ||
1191 | .value<const KeyboardTranslator *>(); | 1412 | .value<const KeyboardTranslator *>(); | ||
1192 | if (translator != nullptr) { | 1413 | if (translator != nullptr) { | ||
1193 | updateTempProfileProperty(Profile::KeyBindings, translator->name()); | 1414 | updateTempProfileProperty(Profile::KeyBindings, translator->name()); | ||
1194 | } | 1415 | } | ||
1195 | } | 1416 | } | ||
1196 | 1417 | | |||
1197 | updateKeyBindingsButtons(); | 1418 | updateKeyBindingsButtons(); | ||
1198 | } | 1419 | } | ||
1199 | 1420 | | |||
1200 | void EditProfileDialog::removeKeyBinding() | 1421 | void EditProfileDialog::removeKeyBinding() | ||
1201 | { | 1422 | { | ||
1202 | QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes(); | 1423 | QModelIndexList selected = _keyboardUi->keyBindingList->selectionModel()->selectedIndexes(); | ||
1203 | 1424 | | |||
1204 | if (!selected.isEmpty()) { | 1425 | if (!selected.isEmpty()) { | ||
1205 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const KeyboardTranslator *>()->name(); | 1426 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const KeyboardTranslator *>()->name(); | ||
1206 | if (KeyboardTranslatorManager::instance()->deleteTranslator(name)) { | 1427 | if (KeyboardTranslatorManager::instance()->deleteTranslator(name)) { | ||
1207 | _ui->keyBindingList->model()->removeRow(selected.first().row()); | 1428 | _keyboardUi->keyBindingList->model()->removeRow(selected.first().row()); | ||
1208 | } | 1429 | } | ||
1209 | } | 1430 | } | ||
1210 | } | 1431 | } | ||
1211 | 1432 | | |||
1212 | void EditProfileDialog::showKeyBindingEditor(bool isNewTranslator) | 1433 | void EditProfileDialog::showKeyBindingEditor(bool isNewTranslator) | ||
1213 | { | 1434 | { | ||
1214 | QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes(); | 1435 | QModelIndexList selected = _keyboardUi->keyBindingList->selectionModel()->selectedIndexes(); | ||
1215 | QAbstractItemModel *model = _ui->keyBindingList->model(); | 1436 | QAbstractItemModel *model = _keyboardUi->keyBindingList->model(); | ||
1216 | 1437 | | |||
1217 | const KeyboardTranslator *translator = nullptr; | 1438 | const KeyboardTranslator *translator = nullptr; | ||
1218 | if (!selected.isEmpty()) { | 1439 | if (!selected.isEmpty()) { | ||
1219 | translator = model->data(selected.first(), Qt::UserRole + 1).value<const KeyboardTranslator *>(); | 1440 | translator = model->data(selected.first(), Qt::UserRole + 1).value<const KeyboardTranslator *>(); | ||
1220 | } else { | 1441 | } else { | ||
1221 | translator = _keyManager->defaultTranslator(); | 1442 | translator = _keyManager->defaultTranslator(); | ||
1222 | } | 1443 | } | ||
1223 | 1444 | | |||
Show All 21 Lines | |||||
1245 | 1466 | | |||
1246 | void EditProfileDialog::editKeyBinding() | 1467 | void EditProfileDialog::editKeyBinding() | ||
1247 | { | 1468 | { | ||
1248 | showKeyBindingEditor(false); | 1469 | showKeyBindingEditor(false); | ||
1249 | } | 1470 | } | ||
1250 | 1471 | | |||
1251 | void EditProfileDialog::resetKeyBindings() | 1472 | void EditProfileDialog::resetKeyBindings() | ||
1252 | { | 1473 | { | ||
1253 | QModelIndexList selected = _ui->keyBindingList->selectionModel()->selectedIndexes(); | 1474 | QModelIndexList selected = _keyboardUi->keyBindingList->selectionModel()->selectedIndexes(); | ||
1254 | 1475 | | |||
1255 | if (!selected.isEmpty()) { | 1476 | if (!selected.isEmpty()) { | ||
1256 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const KeyboardTranslator *>()->name(); | 1477 | const QString &name = selected.first().data(Qt::UserRole + 1).value<const KeyboardTranslator *>()->name(); | ||
1257 | 1478 | | |||
1258 | _keyManager->deleteTranslator(name); | 1479 | _keyManager->deleteTranslator(name); | ||
1259 | // find and load the translator | 1480 | // find and load the translator | ||
1260 | _keyManager->findTranslator(name); | 1481 | _keyManager->findTranslator(name); | ||
1261 | 1482 | | |||
1262 | updateKeyBindingsList(name); | 1483 | updateKeyBindingsList(name); | ||
1263 | } | 1484 | } | ||
1264 | } | 1485 | } | ||
1265 | 1486 | | |||
1266 | void EditProfileDialog::setupCheckBoxes(const QVector<BooleanOption>& options, const Profile::Ptr profile) | 1487 | void EditProfileDialog::setupCheckBoxes(const QVector<BooleanOption>& options, const Profile::Ptr &profile) | ||
1267 | { | 1488 | { | ||
1268 | for(const auto& option : options) { | 1489 | for(const auto& option : options) { | ||
1269 | option.button->setChecked(profile->property<bool>(option.property)); | 1490 | option.button->setChecked(profile->property<bool>(option.property)); | ||
1270 | connect(option.button, SIGNAL(toggled(bool)), this, option.slot); | 1491 | connect(option.button, SIGNAL(toggled(bool)), this, option.slot); | ||
1271 | } | 1492 | } | ||
1272 | } | 1493 | } | ||
1273 | 1494 | | |||
1274 | void EditProfileDialog::setupRadio(const QVector<RadioOption>& possibilities, int actual) | 1495 | void EditProfileDialog::setupRadio(const QVector<RadioOption>& possibilities, int actual) | ||
1275 | { | 1496 | { | ||
1276 | for(const auto& possibility : possibilities) { | 1497 | for(const auto& possibility : possibilities) { | ||
1277 | possibility.button->setChecked(possibility.value == actual); | 1498 | possibility.button->setChecked(possibility.value == actual); | ||
1278 | connect(possibility.button, SIGNAL(clicked()), this, possibility.slot); | 1499 | connect(possibility.button, SIGNAL(clicked()), this, possibility.slot); | ||
1279 | } | 1500 | } | ||
1280 | } | 1501 | } | ||
1281 | 1502 | | |||
1282 | void EditProfileDialog::setupScrollingPage(const Profile::Ptr profile) | 1503 | void EditProfileDialog::setupButtonGroup(const ButtonGroupOptions &options, const Profile::Ptr &profile) | ||
1283 | { | 1504 | { | ||
1284 | // setup scrollbar radio | 1505 | auto currentValue = profile->property<int>(options.profileProperty); | ||
1285 | auto scrollBarPosition = profile->property<int>(Profile::ScrollBarPosition); | 1506 | | ||
1507 | for (auto option: options.buttons) { | ||||
1508 | options.group->setId(option.button, option.value); | ||||
1509 | } | ||||
1510 | | ||||
1511 | Q_ASSERT(options.buttons.count() > 0); | ||||
1512 | auto *activeButton = options.group->button(currentValue); | ||||
1513 | if (!activeButton) { | ||||
1514 | activeButton = options.buttons[0].button; | ||||
1515 | } | ||||
1516 | activeButton->setChecked(true); | ||||
1286 | 1517 | | |||
1287 | const auto positions = QVector<RadioOption>{ {_ui->scrollBarHiddenButton, Enum::ScrollBarHidden, SLOT(hideScrollBar())}, | 1518 | connect(options.group, QOverload<int>::of(&QButtonGroup::buttonClicked), | ||
1288 | {_ui->scrollBarLeftButton, Enum::ScrollBarLeft, SLOT(showScrollBarLeft())}, | 1519 | this, [this, options](int value) { | ||
1289 | {_ui->scrollBarRightButton, Enum::ScrollBarRight, SLOT(showScrollBarRight())}}; | 1520 | if (options.preview) { | ||
1521 | preview(options.profileProperty, value); | ||||
1522 | } | ||||
1523 | updateTempProfileProperty(options.profileProperty, value); | ||||
1524 | }); | ||||
1525 | } | ||||
1290 | 1526 | | |||
1291 | setupRadio(positions, scrollBarPosition); | 1527 | void EditProfileDialog::setupScrollingPage(const Profile::Ptr &profile) | ||
1528 | { | ||||
1529 | // setup scrollbar radio | ||||
1530 | const ButtonGroupOptions scrollBarPositionOptions = { | ||||
1531 | _scrollingUi->scrollBarPosition, // group | ||||
1532 | Profile::ScrollBarPosition, // profileProperty | ||||
1533 | false, // preview | ||||
1534 | { // buttons | ||||
1535 | {_scrollingUi->scrollBarRightButton, Enum::ScrollBarRight}, | ||||
1536 | {_scrollingUi->scrollBarLeftButton, Enum::ScrollBarLeft}, | ||||
1537 | {_scrollingUi->scrollBarHiddenButton, Enum::ScrollBarHidden}, | ||||
1538 | }, | ||||
1539 | }; | ||||
1540 | setupButtonGroup(scrollBarPositionOptions, profile); | ||||
1292 | 1541 | | |||
1293 | // setup scrollback type radio | 1542 | // setup scrollback type radio | ||
1294 | auto scrollBackType = profile->property<int>(Profile::HistoryMode); | 1543 | auto scrollBackType = profile->property<int>(Profile::HistoryMode); | ||
1295 | _ui->historySizeWidget->setMode(Enum::HistoryModeEnum(scrollBackType)); | 1544 | _scrollingUi->historySizeWidget->setMode(Enum::HistoryModeEnum(scrollBackType)); | ||
1296 | connect(_ui->historySizeWidget, &Konsole::HistorySizeWidget::historyModeChanged, this, | 1545 | connect(_scrollingUi->historySizeWidget, &Konsole::HistorySizeWidget::historyModeChanged, this, | ||
1297 | &Konsole::EditProfileDialog::historyModeChanged); | 1546 | &Konsole::EditProfileDialog::historyModeChanged); | ||
1298 | 1547 | | |||
1299 | // setup scrollback line count spinner | 1548 | // setup scrollback line count spinner | ||
1300 | const int historySize = profile->historySize(); | 1549 | const int historySize = profile->historySize(); | ||
1301 | _ui->historySizeWidget->setLineCount(historySize); | 1550 | _scrollingUi->historySizeWidget->setLineCount(historySize); | ||
1302 | 1551 | | |||
1303 | // setup scrollpageamount type radio | 1552 | // setup scrollpageamount type radio | ||
1304 | auto scrollFullPage = profile->property<int>(Profile::ScrollFullPage); | 1553 | auto scrollFullPage = profile->property<int>(Profile::ScrollFullPage); | ||
1305 | 1554 | | |||
1306 | const auto pageamounts = QVector<RadioOption>{ | 1555 | const auto pageamounts = QVector<RadioOption>{ | ||
1307 | {_ui->scrollHalfPage, Enum::ScrollPageHalf, SLOT(scrollHalfPage())}, | 1556 | {_scrollingUi->scrollHalfPage, Enum::ScrollPageHalf, SLOT(scrollHalfPage())}, | ||
1308 | {_ui->scrollFullPage, Enum::ScrollPageFull, SLOT(scrollFullPage())} | 1557 | {_scrollingUi->scrollFullPage, Enum::ScrollPageFull, SLOT(scrollFullPage())} | ||
1309 | }; | 1558 | }; | ||
1310 | 1559 | | |||
1311 | setupRadio(pageamounts, scrollFullPage); | 1560 | setupRadio(pageamounts, scrollFullPage); | ||
1312 | 1561 | | |||
1313 | // signals and slots | 1562 | // signals and slots | ||
1314 | connect(_ui->historySizeWidget, &Konsole::HistorySizeWidget::historySizeChanged, this, | 1563 | connect(_scrollingUi->historySizeWidget, &Konsole::HistorySizeWidget::historySizeChanged, this, | ||
1315 | &Konsole::EditProfileDialog::historySizeChanged); | 1564 | &Konsole::EditProfileDialog::historySizeChanged); | ||
1316 | } | 1565 | } | ||
1317 | 1566 | | |||
1318 | void EditProfileDialog::historySizeChanged(int lineCount) | 1567 | void EditProfileDialog::historySizeChanged(int lineCount) | ||
1319 | { | 1568 | { | ||
1320 | updateTempProfileProperty(Profile::HistorySize, lineCount); | 1569 | updateTempProfileProperty(Profile::HistorySize, lineCount); | ||
1321 | } | 1570 | } | ||
1322 | 1571 | | |||
1323 | void EditProfileDialog::historyModeChanged(Enum::HistoryModeEnum mode) | 1572 | void EditProfileDialog::historyModeChanged(Enum::HistoryModeEnum mode) | ||
1324 | { | 1573 | { | ||
1325 | updateTempProfileProperty(Profile::HistoryMode, mode); | 1574 | updateTempProfileProperty(Profile::HistoryMode, mode); | ||
1326 | } | 1575 | } | ||
1327 | 1576 | | |||
1328 | void EditProfileDialog::hideScrollBar() | | |||
1329 | { | | |||
1330 | updateTempProfileProperty(Profile::ScrollBarPosition, Enum::ScrollBarHidden); | | |||
1331 | } | | |||
1332 | | ||||
1333 | void EditProfileDialog::showScrollBarLeft() | | |||
1334 | { | | |||
1335 | updateTempProfileProperty(Profile::ScrollBarPosition, Enum::ScrollBarLeft); | | |||
1336 | } | | |||
1337 | | ||||
1338 | void EditProfileDialog::showScrollBarRight() | | |||
1339 | { | | |||
1340 | updateTempProfileProperty(Profile::ScrollBarPosition, Enum::ScrollBarRight); | | |||
1341 | } | | |||
1342 | | ||||
1343 | void EditProfileDialog::scrollFullPage() | 1577 | void EditProfileDialog::scrollFullPage() | ||
1344 | { | 1578 | { | ||
1345 | updateTempProfileProperty(Profile::ScrollFullPage, Enum::ScrollPageFull); | 1579 | updateTempProfileProperty(Profile::ScrollFullPage, Enum::ScrollPageFull); | ||
1346 | } | 1580 | } | ||
1347 | 1581 | | |||
1348 | void EditProfileDialog::scrollHalfPage() | 1582 | void EditProfileDialog::scrollHalfPage() | ||
1349 | { | 1583 | { | ||
1350 | updateTempProfileProperty(Profile::ScrollFullPage, Enum::ScrollPageHalf); | 1584 | updateTempProfileProperty(Profile::ScrollFullPage, Enum::ScrollPageHalf); | ||
1351 | } | 1585 | } | ||
1352 | 1586 | | |||
1353 | void EditProfileDialog::setupMousePage(const Profile::Ptr profile) | 1587 | void EditProfileDialog::setupMousePage(const Profile::Ptr &profile) | ||
1354 | { | 1588 | { | ||
1355 | const auto options = QVector<BooleanOption>{ | 1589 | const auto options = QVector<BooleanOption>{ | ||
1356 | { | 1590 | { | ||
1357 | _ui->underlineLinksButton, Profile::UnderlineLinksEnabled, | 1591 | _mouseUi->underlineLinksButton, Profile::UnderlineLinksEnabled, | ||
1358 | SLOT(toggleUnderlineLinks(bool)) | 1592 | SLOT(toggleUnderlineLinks(bool)) | ||
1359 | }, | 1593 | }, | ||
1360 | { | 1594 | { | ||
1361 | _ui->underlineFilesButton, Profile::UnderlineFilesEnabled, | 1595 | _mouseUi->underlineFilesButton, Profile::UnderlineFilesEnabled, | ||
1362 | SLOT(toggleUnderlineFiles(bool)) | 1596 | SLOT(toggleUnderlineFiles(bool)) | ||
1363 | }, | 1597 | }, | ||
1364 | { | 1598 | { | ||
1365 | _ui->ctrlRequiredForDragButton, Profile::CtrlRequiredForDrag, | 1599 | _mouseUi->ctrlRequiredForDragButton, Profile::CtrlRequiredForDrag, | ||
1366 | SLOT(toggleCtrlRequiredForDrag(bool)) | 1600 | SLOT(toggleCtrlRequiredForDrag(bool)) | ||
1367 | }, | 1601 | }, | ||
1368 | { | 1602 | { | ||
1369 | _ui->copyTextAsHTMLButton, Profile::CopyTextAsHTML, | 1603 | _mouseUi->copyTextAsHTMLButton, Profile::CopyTextAsHTML, | ||
1370 | SLOT(toggleCopyTextAsHTML(bool)) | 1604 | SLOT(toggleCopyTextAsHTML(bool)) | ||
1371 | }, | 1605 | }, | ||
1372 | { | 1606 | { | ||
1373 | _ui->copyTextToClipboardButton, Profile::AutoCopySelectedText, | 1607 | _mouseUi->copyTextToClipboardButton, Profile::AutoCopySelectedText, | ||
1374 | SLOT(toggleCopyTextToClipboard(bool)) | 1608 | SLOT(toggleCopyTextToClipboard(bool)) | ||
1375 | }, | 1609 | }, | ||
1376 | { | 1610 | { | ||
1377 | _ui->trimLeadingSpacesButton, Profile::TrimLeadingSpacesInSelectedText, | 1611 | _mouseUi->trimLeadingSpacesButton, Profile::TrimLeadingSpacesInSelectedText, | ||
1378 | SLOT(toggleTrimLeadingSpacesInSelectedText(bool)) | 1612 | SLOT(toggleTrimLeadingSpacesInSelectedText(bool)) | ||
1379 | }, | 1613 | }, | ||
1380 | { | 1614 | { | ||
1381 | _ui->trimTrailingSpacesButton, Profile::TrimTrailingSpacesInSelectedText, | 1615 | _mouseUi->trimTrailingSpacesButton, Profile::TrimTrailingSpacesInSelectedText, | ||
1382 | SLOT(toggleTrimTrailingSpacesInSelectedText(bool)) | 1616 | SLOT(toggleTrimTrailingSpacesInSelectedText(bool)) | ||
1383 | }, | 1617 | }, | ||
1384 | { | 1618 | { | ||
1385 | _ui->openLinksByDirectClickButton, Profile::OpenLinksByDirectClickEnabled, | 1619 | _mouseUi->openLinksByDirectClickButton, Profile::OpenLinksByDirectClickEnabled, | ||
1386 | SLOT(toggleOpenLinksByDirectClick(bool)) | 1620 | SLOT(toggleOpenLinksByDirectClick(bool)) | ||
1387 | }, | 1621 | }, | ||
1388 | { | 1622 | { | ||
1389 | _ui->dropUrlsAsText, Profile::DropUrlsAsText, | 1623 | _mouseUi->dropUrlsAsText, Profile::DropUrlsAsText, | ||
1390 | SLOT(toggleDropUrlsAsText(bool)) | 1624 | SLOT(toggleDropUrlsAsText(bool)) | ||
1391 | }, | 1625 | }, | ||
1392 | { | 1626 | { | ||
1393 | _ui->enableAlternateScrollingButton, Profile::AlternateScrolling, | 1627 | _mouseUi->enableAlternateScrollingButton, Profile::AlternateScrolling, | ||
1394 | SLOT(toggleAlternateScrolling(bool)) | 1628 | SLOT(toggleAlternateScrolling(bool)) | ||
1395 | } | 1629 | } | ||
1396 | }; | 1630 | }; | ||
1397 | setupCheckBoxes(options, profile); | 1631 | setupCheckBoxes(options, profile); | ||
1398 | 1632 | | |||
1399 | // setup middle click paste mode | 1633 | // setup middle click paste mode | ||
1400 | const auto middleClickPasteMode = profile->property<int>(Profile::MiddleClickPasteMode); | 1634 | const auto middleClickPasteMode = profile->property<int>(Profile::MiddleClickPasteMode); | ||
1401 | const auto pasteModes = QVector<RadioOption> { | 1635 | const auto pasteModes = QVector<RadioOption> { | ||
1402 | {_ui->pasteFromX11SelectionButton, Enum::PasteFromX11Selection, SLOT(pasteFromX11Selection())}, | 1636 | {_mouseUi->pasteFromX11SelectionButton, Enum::PasteFromX11Selection, SLOT(pasteFromX11Selection())}, | ||
1403 | {_ui->pasteFromClipboardButton, Enum::PasteFromClipboard, SLOT(pasteFromClipboard())} }; | 1637 | {_mouseUi->pasteFromClipboardButton, Enum::PasteFromClipboard, SLOT(pasteFromClipboard())} }; | ||
1404 | setupRadio(pasteModes, middleClickPasteMode); | 1638 | setupRadio(pasteModes, middleClickPasteMode); | ||
1405 | 1639 | | |||
1406 | // interaction options | 1640 | // interaction options | ||
1407 | _ui->wordCharacterEdit->setText(profile->wordCharacters()); | 1641 | _mouseUi->wordCharacterEdit->setText(profile->wordCharacters()); | ||
1408 | | ||||
1409 | connect(_ui->wordCharacterEdit, &QLineEdit::textChanged, this, &Konsole::EditProfileDialog::wordCharactersChanged); | | |||
1410 | 1642 | | |||
1411 | auto tripleClickMode = profile->property<int>(Profile::TripleClickMode); | 1643 | connect(_mouseUi->wordCharacterEdit, &QLineEdit::textChanged, this, &Konsole::EditProfileDialog::wordCharactersChanged); | ||
1412 | _ui->tripleClickModeCombo->setCurrentIndex(tripleClickMode); | | |||
1413 | 1644 | | |||
1414 | connect(_ui->tripleClickModeCombo, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &Konsole::EditProfileDialog::TripleClickModeChanged); | 1645 | const ButtonGroupOptions tripleClickModeOptions = { | ||
1646 | _mouseUi->tripleClickMode, // group | ||||
1647 | Profile::TripleClickMode, // profileProperty | ||||
1648 | false, // preview | ||||
1649 | { // buttons | ||||
1650 | {_mouseUi->tripleClickSelectsTheWholeLine, Enum::SelectWholeLine}, | ||||
1651 | {_mouseUi->tripleClickSelectsFromMousePosition, Enum::SelectForwardsFromCursor}, | ||||
1652 | }, | ||||
1653 | }; | ||||
1654 | setupButtonGroup(tripleClickModeOptions, profile); | ||||
1415 | 1655 | | |||
1416 | _ui->openLinksByDirectClickButton->setEnabled(_ui->underlineLinksButton->isChecked() || _ui->underlineFilesButton->isChecked()); | 1656 | _mouseUi->openLinksByDirectClickButton->setEnabled(_mouseUi->underlineLinksButton->isChecked() || _mouseUi->underlineFilesButton->isChecked()); | ||
1417 | 1657 | | |||
1418 | _ui->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled()); | 1658 | _mouseUi->enableMouseWheelZoomButton->setChecked(profile->mouseWheelZoomEnabled()); | ||
1419 | connect(_ui->enableMouseWheelZoomButton, &QCheckBox::toggled, this, &Konsole::EditProfileDialog::toggleMouseWheelZoom); | 1659 | connect(_mouseUi->enableMouseWheelZoomButton, &QCheckBox::toggled, this, &Konsole::EditProfileDialog::toggleMouseWheelZoom); | ||
1420 | } | 1660 | } | ||
1421 | 1661 | | |||
1422 | void EditProfileDialog::setupAdvancedPage(const Profile::Ptr profile) | 1662 | void EditProfileDialog::setupAdvancedPage(const Profile::Ptr &profile) | ||
1423 | { | 1663 | { | ||
1424 | const auto options = QVector<BooleanOption>{ | 1664 | const auto options = QVector<BooleanOption>{ | ||
1425 | { | 1665 | { | ||
1426 | _ui->enableBlinkingTextButton, Profile::BlinkingTextEnabled, | 1666 | _advancedUi->enableBlinkingTextButton, Profile::BlinkingTextEnabled, | ||
1427 | SLOT(toggleBlinkingText(bool)) | 1667 | SLOT(toggleBlinkingText(bool)) | ||
1428 | }, | 1668 | }, | ||
1429 | { | 1669 | { | ||
1430 | _ui->enableFlowControlButton, Profile::FlowControlEnabled, | 1670 | _advancedUi->enableFlowControlButton, Profile::FlowControlEnabled, | ||
1431 | SLOT(toggleFlowControl(bool)) | 1671 | SLOT(toggleFlowControl(bool)) | ||
1432 | }, | 1672 | }, | ||
1433 | { | 1673 | { | ||
1434 | _ui->enableBlinkingCursorButton, Profile::BlinkingCursorEnabled, | 1674 | _appearanceUi->enableBlinkingCursorButton, Profile::BlinkingCursorEnabled, | ||
1435 | SLOT(toggleBlinkingCursor(bool)) | 1675 | SLOT(toggleBlinkingCursor(bool)) | ||
1436 | }, | 1676 | }, | ||
1437 | { | 1677 | { | ||
1438 | _ui->enableBidiRenderingButton, Profile::BidiRenderingEnabled, | 1678 | _advancedUi->enableBidiRenderingButton, Profile::BidiRenderingEnabled, | ||
1439 | SLOT(togglebidiRendering(bool)) | 1679 | SLOT(togglebidiRendering(bool)) | ||
1440 | }, | 1680 | }, | ||
1441 | { | 1681 | { | ||
1442 | _ui->enableReverseUrlHints, Profile::ReverseUrlHints, | 1682 | _advancedUi->enableReverseUrlHints, Profile::ReverseUrlHints, | ||
1443 | SLOT(toggleReverseUrlHints(bool)) | 1683 | SLOT(toggleReverseUrlHints(bool)) | ||
1444 | } | 1684 | } | ||
1445 | }; | 1685 | }; | ||
1446 | setupCheckBoxes(options, profile); | 1686 | setupCheckBoxes(options, profile); | ||
1447 | 1687 | | |||
1448 | // Setup the URL hints modifier checkboxes | 1688 | // Setup the URL hints modifier checkboxes | ||
1449 | { | 1689 | { | ||
1450 | auto modifiers = profile->property<int>(Profile::UrlHintsModifiers); | 1690 | auto modifiers = profile->property<int>(Profile::UrlHintsModifiers); | ||
1451 | _ui->urlHintsModifierShift->setChecked((modifiers &Qt::ShiftModifier) != 0u); | 1691 | _advancedUi->urlHintsModifierShift->setChecked((modifiers &Qt::ShiftModifier) != 0u); | ||
1452 | _ui->urlHintsModifierCtrl->setChecked((modifiers &Qt::ControlModifier) != 0u); | 1692 | _advancedUi->urlHintsModifierCtrl->setChecked((modifiers &Qt::ControlModifier) != 0u); | ||
1453 | _ui->urlHintsModifierAlt->setChecked((modifiers &Qt::AltModifier) != 0u); | 1693 | _advancedUi->urlHintsModifierAlt->setChecked((modifiers &Qt::AltModifier) != 0u); | ||
1454 | _ui->urlHintsModifierMeta->setChecked((modifiers &Qt::MetaModifier) != 0u); | 1694 | _advancedUi->urlHintsModifierMeta->setChecked((modifiers &Qt::MetaModifier) != 0u); | ||
1455 | connect(_ui->urlHintsModifierShift, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier); | 1695 | connect(_advancedUi->urlHintsModifierShift, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier); | ||
1456 | connect(_ui->urlHintsModifierCtrl, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier); | 1696 | connect(_advancedUi->urlHintsModifierCtrl, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier); | ||
1457 | connect(_ui->urlHintsModifierAlt, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier); | 1697 | connect(_advancedUi->urlHintsModifierAlt, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier); | ||
1458 | connect(_ui->urlHintsModifierMeta, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier); | 1698 | connect(_advancedUi->urlHintsModifierMeta, &QCheckBox::toggled, this, &EditProfileDialog::updateUrlHintsModifier); | ||
1459 | } | | |||
1460 | | ||||
1461 | const int lineSpacing = profile->lineSpacing(); | | |||
1462 | _ui->lineSpacingSpinner->setValue(lineSpacing); | | |||
1463 | | ||||
1464 | connect(_ui->lineSpacingSpinner, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &Konsole::EditProfileDialog::lineSpacingChanged); | | |||
1465 | | ||||
1466 | // cursor options | | |||
1467 | if (profile->useCustomCursorColor()) { | | |||
1468 | _ui->customCursorColorButton->setChecked(true); | | |||
1469 | } else { | | |||
1470 | _ui->autoCursorColorButton->setChecked(true); | | |||
1471 | } | 1699 | } | ||
1472 | 1700 | | |||
1473 | _ui->customColorSelectButton->setColor(profile->customCursorColor()); | | |||
1474 | | ||||
1475 | connect(_ui->customCursorColorButton, &QRadioButton::clicked, this, &Konsole::EditProfileDialog::customCursorColor); | | |||
1476 | connect(_ui->autoCursorColorButton, &QRadioButton::clicked, this, &Konsole::EditProfileDialog::autoCursorColor); | | |||
1477 | connect(_ui->customColorSelectButton, &KColorButton::changed, this, &Konsole::EditProfileDialog::customCursorColorChanged); | | |||
1478 | | ||||
1479 | auto shape = profile->property<int>(Profile::CursorShape); | | |||
1480 | _ui->cursorShapeCombo->setCurrentIndex(shape); | | |||
1481 | | ||||
1482 | connect(_ui->cursorShapeCombo, static_cast<void (KComboBox::*)(int)>(&KComboBox::activated), this, &Konsole::EditProfileDialog::setCursorShape); | | |||
1483 | | ||||
1484 | // encoding options | 1701 | // encoding options | ||
1485 | auto codecAction = new KCodecAction(this); | 1702 | auto codecAction = new KCodecAction(this); | ||
1486 | _ui->selectEncodingButton->setMenu(codecAction->menu()); | 1703 | _advancedUi->selectEncodingButton->setMenu(codecAction->menu()); | ||
1487 | connect(codecAction, static_cast<void (KCodecAction::*)(QTextCodec *)>(&KCodecAction::triggered), this, &Konsole::EditProfileDialog::setDefaultCodec); | 1704 | connect(codecAction, static_cast<void (KCodecAction::*)(QTextCodec *)>(&KCodecAction::triggered), this, &Konsole::EditProfileDialog::setDefaultCodec); | ||
1488 | 1705 | | |||
1489 | _ui->characterEncodingLabel->setText(profile->defaultEncoding()); | 1706 | _advancedUi->selectEncodingButton->setText(profile->defaultEncoding()); | ||
1490 | } | 1707 | } | ||
1491 | 1708 | | |||
1492 | void EditProfileDialog::setDefaultCodec(QTextCodec *codec) | 1709 | int EditProfileDialog::maxSpinBoxWidth(const KPluralHandlingSpinBox *spinBox, const KLocalizedString &suffix) | ||
1493 | { | 1710 | { | ||
1494 | QString name = QString::fromLocal8Bit(codec->name()); | 1711 | static const int cursorWidth = 2; | ||
1495 | 1712 | | |||
1496 | updateTempProfileProperty(Profile::DefaultEncoding, name); | 1713 | const QFontMetrics fm(spinBox->fontMetrics()); | ||
1497 | _ui->characterEncodingLabel->setText(name); | 1714 | const QString plural = suffix.subs(2).toString(); | ||
1715 | const QString singular = suffix.subs(1).toString(); | ||||
1716 | const QString min = QString::number(spinBox->minimum()); | ||||
1717 | const QString max = QString::number(spinBox->maximum()); | ||||
1718 | const int pluralWidth = fm.width(plural); | ||||
1719 | const int singularWidth = fm.width(singular); | ||||
1720 | const int minWidth = fm.width(min); | ||||
1721 | const int maxWidth = fm.width(max); | ||||
1722 | const int width = qMax(pluralWidth, singularWidth) + qMax(minWidth, maxWidth) + cursorWidth; | ||||
1723 | | ||||
1724 | // Based on QAbstractSpinBox::initStyleOption() from Qt | ||||
1725 | QStyleOptionSpinBox opt; | ||||
1726 | opt.initFrom(spinBox); | ||||
1727 | opt.activeSubControls = QStyle::SC_None; | ||||
1728 | opt.buttonSymbols = spinBox->buttonSymbols(); | ||||
1729 | // Assume all spinboxes have buttons | ||||
1730 | opt.subControls = QStyle::SC_SpinBoxFrame | QStyle::SC_SpinBoxEditField | ||||
1731 | | QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown; | ||||
1732 | opt.frame = spinBox->hasFrame(); | ||||
1733 | | ||||
1734 | const QSize hint(width, spinBox->sizeHint().height()); | ||||
1735 | const QSize spinBoxSize = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, hint, spinBox) | ||||
1736 | .expandedTo(QApplication::globalStrut()); | ||||
1737 | | ||||
1738 | return spinBoxSize.width(); | ||||
1498 | } | 1739 | } | ||
1499 | 1740 | | |||
1500 | void EditProfileDialog::customCursorColorChanged(const QColor &color) | 1741 | void EditProfileDialog::setDefaultCodec(QTextCodec *codec) | ||
1501 | { | 1742 | { | ||
1502 | updateTempProfileProperty(Profile::CustomCursorColor, color); | 1743 | QString name = QString::fromLocal8Bit(codec->name()); | ||
1503 | 1744 | | |||
1504 | // ensure that custom cursor colors are enabled | 1745 | updateTempProfileProperty(Profile::DefaultEncoding, name); | ||
1505 | _ui->customCursorColorButton->click(); | 1746 | _advancedUi->selectEncodingButton->setText(name); | ||
1506 | } | 1747 | } | ||
1507 | 1748 | | |||
1508 | void EditProfileDialog::wordCharactersChanged(const QString &text) | 1749 | void EditProfileDialog::wordCharactersChanged(const QString &text) | ||
1509 | { | 1750 | { | ||
1510 | updateTempProfileProperty(Profile::WordCharacters, text); | 1751 | updateTempProfileProperty(Profile::WordCharacters, text); | ||
1511 | } | 1752 | } | ||
1512 | 1753 | | |||
1513 | void EditProfileDialog::autoCursorColor() | | |||
1514 | { | | |||
1515 | updateTempProfileProperty(Profile::UseCustomCursorColor, false); | | |||
1516 | } | | |||
1517 | | ||||
1518 | void EditProfileDialog::customCursorColor() | | |||
1519 | { | | |||
1520 | updateTempProfileProperty(Profile::UseCustomCursorColor, true); | | |||
1521 | } | | |||
1522 | | ||||
1523 | void EditProfileDialog::setCursorShape(int index) | | |||
1524 | { | | |||
1525 | updateTempProfileProperty(Profile::CursorShape, index); | | |||
1526 | } | | |||
1527 | | ||||
1528 | void EditProfileDialog::togglebidiRendering(bool enable) | 1754 | void EditProfileDialog::togglebidiRendering(bool enable) | ||
1529 | { | 1755 | { | ||
1530 | updateTempProfileProperty(Profile::BidiRenderingEnabled, enable); | 1756 | updateTempProfileProperty(Profile::BidiRenderingEnabled, enable); | ||
1531 | } | 1757 | } | ||
1532 | 1758 | | |||
1533 | void EditProfileDialog::lineSpacingChanged(int spacing) | | |||
1534 | { | | |||
1535 | updateTempProfileProperty(Profile::LineSpacing, spacing); | | |||
1536 | } | | |||
1537 | | ||||
1538 | void EditProfileDialog::toggleBlinkingCursor(bool enable) | | |||
1539 | { | | |||
1540 | updateTempProfileProperty(Profile::BlinkingCursorEnabled, enable); | | |||
1541 | } | | |||
1542 | | ||||
1543 | void EditProfileDialog::toggleUnderlineLinks(bool enable) | 1759 | void EditProfileDialog::toggleUnderlineLinks(bool enable) | ||
1544 | { | 1760 | { | ||
1545 | updateTempProfileProperty(Profile::UnderlineLinksEnabled, enable); | 1761 | updateTempProfileProperty(Profile::UnderlineLinksEnabled, enable); | ||
1546 | 1762 | | |||
1547 | bool enableClick = _ui->underlineFilesButton->isChecked() || enable; | 1763 | bool enableClick = _mouseUi->underlineFilesButton->isChecked() || enable; | ||
1548 | _ui->openLinksByDirectClickButton->setEnabled(enableClick); | 1764 | _mouseUi->openLinksByDirectClickButton->setEnabled(enableClick); | ||
1549 | } | 1765 | } | ||
1550 | 1766 | | |||
1551 | void EditProfileDialog::toggleUnderlineFiles(bool enable) | 1767 | void EditProfileDialog::toggleUnderlineFiles(bool enable) | ||
1552 | { | 1768 | { | ||
1553 | updateTempProfileProperty(Profile::UnderlineFilesEnabled, enable); | 1769 | updateTempProfileProperty(Profile::UnderlineFilesEnabled, enable); | ||
1554 | 1770 | | |||
1555 | bool enableClick = _ui->underlineLinksButton->isChecked() || enable; | 1771 | bool enableClick = _mouseUi->underlineLinksButton->isChecked() || enable; | ||
1556 | _ui->openLinksByDirectClickButton->setEnabled(enableClick); | 1772 | _mouseUi->openLinksByDirectClickButton->setEnabled(enableClick); | ||
1557 | } | 1773 | } | ||
1558 | 1774 | | |||
1559 | void EditProfileDialog::toggleCtrlRequiredForDrag(bool enable) | 1775 | void EditProfileDialog::toggleCtrlRequiredForDrag(bool enable) | ||
1560 | { | 1776 | { | ||
1561 | updateTempProfileProperty(Profile::CtrlRequiredForDrag, enable); | 1777 | updateTempProfileProperty(Profile::CtrlRequiredForDrag, enable); | ||
1562 | } | 1778 | } | ||
1563 | 1779 | | |||
1564 | void EditProfileDialog::toggleDropUrlsAsText(bool enable) | 1780 | void EditProfileDialog::toggleDropUrlsAsText(bool enable) | ||
Show All 39 Lines | |||||
1604 | void EditProfileDialog::TripleClickModeChanged(int newValue) | 1820 | void EditProfileDialog::TripleClickModeChanged(int newValue) | ||
1605 | { | 1821 | { | ||
1606 | updateTempProfileProperty(Profile::TripleClickMode, newValue); | 1822 | updateTempProfileProperty(Profile::TripleClickMode, newValue); | ||
1607 | } | 1823 | } | ||
1608 | 1824 | | |||
1609 | void EditProfileDialog::updateUrlHintsModifier(bool) | 1825 | void EditProfileDialog::updateUrlHintsModifier(bool) | ||
1610 | { | 1826 | { | ||
1611 | Qt::KeyboardModifiers modifiers; | 1827 | Qt::KeyboardModifiers modifiers; | ||
1612 | if (_ui->urlHintsModifierShift->isChecked()) { | 1828 | if (_advancedUi->urlHintsModifierShift->isChecked()) { | ||
1613 | modifiers |= Qt::ShiftModifier; | 1829 | modifiers |= Qt::ShiftModifier; | ||
1614 | } | 1830 | } | ||
1615 | if (_ui->urlHintsModifierCtrl->isChecked()) { | 1831 | if (_advancedUi->urlHintsModifierCtrl->isChecked()) { | ||
1616 | modifiers |= Qt::ControlModifier; | 1832 | modifiers |= Qt::ControlModifier; | ||
1617 | } | 1833 | } | ||
1618 | if (_ui->urlHintsModifierAlt->isChecked()) { | 1834 | if (_advancedUi->urlHintsModifierAlt->isChecked()) { | ||
1619 | modifiers |= Qt::AltModifier; | 1835 | modifiers |= Qt::AltModifier; | ||
1620 | } | 1836 | } | ||
1621 | if (_ui->urlHintsModifierMeta->isChecked()) { | 1837 | if (_advancedUi->urlHintsModifierMeta->isChecked()) { | ||
1622 | modifiers |= Qt::MetaModifier; | 1838 | modifiers |= Qt::MetaModifier; | ||
1623 | } | 1839 | } | ||
1624 | updateTempProfileProperty(Profile::UrlHintsModifiers, int(modifiers)); | 1840 | updateTempProfileProperty(Profile::UrlHintsModifiers, int(modifiers)); | ||
1625 | } | 1841 | } | ||
1626 | 1842 | | |||
1627 | void EditProfileDialog::toggleReverseUrlHints(bool enable) | 1843 | void EditProfileDialog::toggleReverseUrlHints(bool enable) | ||
1628 | { | 1844 | { | ||
1629 | updateTempProfileProperty(Profile::ReverseUrlHints, enable); | 1845 | updateTempProfileProperty(Profile::ReverseUrlHints, enable); | ||
1630 | } | 1846 | } | ||
1631 | 1847 | | |||
1632 | void EditProfileDialog::toggleBlinkingText(bool enable) | 1848 | void EditProfileDialog::toggleBlinkingText(bool enable) | ||
1633 | { | 1849 | { | ||
1634 | updateTempProfileProperty(Profile::BlinkingTextEnabled, enable); | 1850 | updateTempProfileProperty(Profile::BlinkingTextEnabled, enable); | ||
1635 | } | 1851 | } | ||
1636 | 1852 | | |||
1637 | void EditProfileDialog::toggleFlowControl(bool enable) | 1853 | void EditProfileDialog::toggleFlowControl(bool enable) | ||
1638 | { | 1854 | { | ||
1639 | updateTempProfileProperty(Profile::FlowControlEnabled, enable); | 1855 | updateTempProfileProperty(Profile::FlowControlEnabled, enable); | ||
1640 | } | 1856 | } | ||
1641 | 1857 | | |||
1642 | void EditProfileDialog::fontSelected(const QFont &aFont) | | |||
1643 | { | | |||
1644 | QFont previewFont = aFont; | | |||
1645 | | ||||
1646 | setFontInputValue(aFont); | | |||
1647 | | ||||
1648 | _ui->fontPreviewLabel->setFont(previewFont); | | |||
1649 | | ||||
1650 | preview(Profile::Font, aFont); | | |||
1651 | updateTempProfileProperty(Profile::Font, aFont); | | |||
1652 | } | | |||
1653 | | ||||
1654 | void EditProfileDialog::showFontDialog() | | |||
1655 | { | | |||
1656 | QFont currentFont = _ui->fontPreviewLabel->font(); | | |||
1657 | bool showAllFonts = _ui->showAllFontsButton->isChecked(); | | |||
1658 | | ||||
1659 | bool result; | | |||
1660 | if (showAllFonts) { | | |||
1661 | currentFont = QFontDialog::getFont(&result, currentFont, this, | | |||
1662 | i18n("Select Any Font")); | | |||
1663 | } else { | | |||
1664 | currentFont = QFontDialog::getFont(&result, currentFont, this, | | |||
1665 | i18n("Select Fixed Width Font"), | | |||
1666 | QFontDialog::MonospacedFonts); | | |||
1667 | } | | |||
1668 | if (!result) { | | |||
1669 | return; | | |||
1670 | } | | |||
1671 | | ||||
1672 | fontSelected(currentFont); | | |||
1673 | } | | |||
1674 | | ||||
1675 | void EditProfileDialog::setFontSize(double pointSize) | | |||
1676 | { | | |||
1677 | QFont newFont = _ui->fontPreviewLabel->font(); | | |||
1678 | newFont.setPointSizeF(pointSize); | | |||
1679 | _ui->fontPreviewLabel->setFont(newFont); | | |||
1680 | | ||||
1681 | preview(Profile::Font, newFont); | | |||
1682 | updateTempProfileProperty(Profile::Font, newFont); | | |||
1683 | } | | |||
1684 | | ||||
1685 | void EditProfileDialog::setFontInputValue(const QFont &aFont) | | |||
1686 | { | | |||
1687 | _ui->fontSizeInput->setValue(aFont.pointSizeF()); | | |||
1688 | } | | |||
1689 | | ||||
1690 | ColorSchemeViewDelegate::ColorSchemeViewDelegate(QObject *parent) : | 1858 | ColorSchemeViewDelegate::ColorSchemeViewDelegate(QObject *parent) : | ||
1691 | QAbstractItemDelegate(parent) | 1859 | QAbstractItemDelegate(parent) | ||
1692 | { | 1860 | { | ||
1693 | } | 1861 | } | ||
1694 | 1862 | | |||
1695 | void ColorSchemeViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const | 1863 | void ColorSchemeViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const | ||
1696 | { | 1864 | { | ||
1697 | const auto *scheme = index.data(Qt::UserRole + 1).value<const ColorScheme *>(); | 1865 | const auto *scheme = index.data(Qt::UserRole + 1).value<const ColorScheme *>(); | ||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |
Can you explain why you expand the width here? On small screens, this causes the dialog to be much bigger and the right side of the dialog goes off the desktop edge. Removing this addition makes it appear as expected.