Changeset View
Changeset View
Standalone View
Standalone View
kcms/componentchooser/componentchooserbrowser.cpp
Show All 35 Lines | |||||
36 | 36 | | |||
37 | void CfgBrowser::selectBrowser(int index) | 37 | void CfgBrowser::selectBrowser(int index) | ||
38 | { | 38 | { | ||
39 | if (index == count() -1) { | 39 | if (index == count() -1) { | ||
40 | QList<QUrl> urlList; | 40 | QList<QUrl> urlList; | ||
41 | KOpenWithDialog dlg(QStringLiteral("x-scheme-handler/http"), QString(), this); | 41 | KOpenWithDialog dlg(QStringLiteral("x-scheme-handler/http"), QString(), this); | ||
42 | dlg.setSaveNewApplications(true); | 42 | dlg.setSaveNewApplications(true); | ||
43 | if (dlg.exec() != QDialog::Accepted) { | 43 | if (dlg.exec() != QDialog::Accepted) { | ||
44 | setCurrentIndex(m_currentIndex); | 44 | setCurrentIndex(m_currentIndex == -1 ? 0 : m_currentIndex); | ||
45 | return; | 45 | return; | ||
46 | } | 46 | } | ||
47 | 47 | | |||
48 | const auto service = dlg.service(); | 48 | const auto service = dlg.service(); | ||
49 | 49 | | |||
50 | // check if the selected service is already in the list | 50 | // check if the selected service is already in the list | ||
51 | const auto matching = model()->match(model()->index(0,0), Qt::UserRole, service->storageId()); | 51 | const auto matching = model()->match(model()->index(0,0), Qt::UserRole, service->storageId()); | ||
52 | if (!matching.isEmpty()) { | 52 | if (!matching.isEmpty()) { | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 70 | { | |||
99 | // add a other option to add a new browser | 99 | // add a other option to add a new browser | ||
100 | addItem(QIcon::fromTheme(QStringLiteral("application-x-shellscript")), i18n("Other...")); | 100 | addItem(QIcon::fromTheme(QStringLiteral("application-x-shellscript")), i18n("Other...")); | ||
101 | 101 | | |||
102 | emit changed(false); | 102 | emit changed(false); | ||
103 | } | 103 | } | ||
104 | 104 | | |||
105 | void CfgBrowser::save(KConfig *) | 105 | void CfgBrowser::save(KConfig *) | ||
106 | { | 106 | { | ||
107 | if (currentIndex() == count() - 1) { | ||||
bport: add a space between - and 1
By the way this check seems strange to me, can you confirm it… | |||||
Once the user has added browsers to the list, they appear as before last entries. meven: Once the user has added browsers to the list, they appear as before last entries.
`… | |||||
108 | // no browser installed, nor selected | ||||
109 | return; | ||||
110 | } | ||||
111 | | ||||
107 | const QString browserStorageId = currentData().toString(); | 112 | const QString browserStorageId = currentData().toString(); | ||
108 | 113 | | |||
109 | BrowserSettings settings; | 114 | BrowserSettings settings; | ||
110 | settings.setBrowserApplication(browserStorageId); | 115 | settings.setBrowserApplication(browserStorageId); | ||
111 | settings.save(); | 116 | settings.save(); | ||
112 | 117 | | |||
113 | // Save the default browser as scheme handler for http(s) in mimeapps.list | 118 | // Save the default browser as scheme handler for http(s) in mimeapps.list | ||
114 | KSharedConfig::Ptr mimeAppList = KSharedConfig::openConfig(QStringLiteral("mimeapps.list"), KConfig::NoGlobals, QStandardPaths::GenericConfigLocation); | 119 | KSharedConfig::Ptr mimeAppList = KSharedConfig::openConfig(QStringLiteral("mimeapps.list"), KConfig::NoGlobals, QStandardPaths::GenericConfigLocation); | ||
Show All 17 Lines |
add a space between - and 1
By the way this check seems strange to me, can you confirm it still allow to save custom browser ?