Changeset View
Changeset View
Standalone View
Standalone View
kcms/componentchooser/componentchooserterminal.cpp
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | 56 | TerminalSettings settings; | |||
---|---|---|---|---|---|
84 | // add a other option to add a new terminal emulator with KOpenWithDialog | 84 | // add a other option to add a new terminal emulator with KOpenWithDialog | ||
85 | addItem(QIcon::fromTheme(QStringLiteral("application-x-shellscript")), i18n("Other..."), QStringLiteral()); | 85 | addItem(QIcon::fromTheme(QStringLiteral("application-x-shellscript")), i18n("Other..."), QStringLiteral()); | ||
86 | 86 | | |||
87 | emit changed(false); | 87 | emit changed(false); | ||
88 | } | 88 | } | ||
89 | 89 | | |||
90 | void CfgTerminalEmulator::save(KConfig *) | 90 | void CfgTerminalEmulator::save(KConfig *) | ||
91 | { | 91 | { | ||
92 | if (currentIndex() == count() - 1) { | ||||
93 | // no terminal installed, nor selected | ||||
94 | return; | ||||
95 | } | ||||
96 | | ||||
92 | const QString terminal = currentData().toString(); | 97 | const QString terminal = currentData().toString(); | ||
93 | m_currentIndex = currentIndex(); | | |||
94 | 98 | | |||
95 | TerminalSettings settings; | 99 | TerminalSettings settings; | ||
96 | settings.setTerminalApplication(terminal); | 100 | settings.setTerminalApplication(terminal); | ||
97 | settings.save(); | 101 | settings.save(); | ||
98 | 102 | | |||
99 | m_currentIndex = currentIndex(); | 103 | m_currentIndex = currentIndex(); | ||
100 | 104 | | |||
101 | QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.klauncher5"), | 105 | QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.klauncher5"), | ||
102 | QStringLiteral("/KLauncher"), | 106 | QStringLiteral("/KLauncher"), | ||
103 | QStringLiteral("org.kde.KLauncher"), | 107 | QStringLiteral("org.kde.KLauncher"), | ||
104 | QStringLiteral("reparseConfiguration")); | 108 | QStringLiteral("reparseConfiguration")); | ||
105 | QDBusConnection::sessionBus().send(message); | 109 | QDBusConnection::sessionBus().send(message); | ||
106 | emit changed(false); | 110 | emit changed(false); | ||
107 | } | 111 | } | ||
108 | 112 | | |||
109 | void CfgTerminalEmulator::selectTerminalApp() | 113 | void CfgTerminalEmulator::selectTerminalApp() | ||
110 | { | 114 | { | ||
111 | QList<QUrl> urlList; | 115 | QList<QUrl> urlList; | ||
112 | KOpenWithDialog dlg(urlList, i18n("Select preferred terminal application:"), QString(), this); | 116 | KOpenWithDialog dlg(urlList, i18n("Select preferred terminal application:"), QString(), this); | ||
113 | // hide "Run in &terminal" here, we don't need it for a Terminal Application | 117 | // hide "Run in &terminal" here, we don't need it for a Terminal Application | ||
114 | dlg.hideRunInTerminal(); | 118 | dlg.hideRunInTerminal(); | ||
115 | dlg.setSaveNewApplications(true); | 119 | dlg.setSaveNewApplications(true); | ||
116 | if (dlg.exec() != QDialog::Accepted) { | 120 | if (dlg.exec() != QDialog::Accepted) { | ||
117 | setCurrentIndex(m_currentIndex); | 121 | setCurrentIndex(m_currentIndex == -1 ? 0 : m_currentIndex); | ||
ervin: This comes back often in this patch and feels a bit cryptic, probably worth having a properly… | |||||
118 | return; | 122 | return; | ||
119 | } | 123 | } | ||
120 | const auto service = dlg.service(); | 124 | const auto service = dlg.service(); | ||
121 | 125 | | |||
122 | // if the selected service is already in the list | 126 | // if the selected service is already in the list | ||
123 | const auto matching = model()->match(model()->index(0,0), Qt::DisplayRole, service->exec()); | 127 | const auto matching = model()->match(model()->index(0,0), Qt::DisplayRole, service->exec()); | ||
124 | if (!matching.isEmpty()) { | 128 | if (!matching.isEmpty()) { | ||
125 | const int index = matching.at(0).row(); | 129 | const int index = matching.at(0).row(); | ||
Show All 12 Lines |
This comes back often in this patch and feels a bit cryptic, probably worth having a properly named method for it.