Changeset View
Standalone View
plugins/qthelp/qthelpconfig.cpp
Show All 30 Lines | |||||
31 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
32 | #include <KNS3/Button> | 32 | #include <KNS3/Button> | ||
33 | 33 | | |||
34 | #include "ui_qthelpconfig.h" | 34 | #include "ui_qthelpconfig.h" | ||
35 | #include "ui_qthelpconfigeditdialog.h" | 35 | #include "ui_qthelpconfigeditdialog.h" | ||
36 | #include "qthelp_config_shared.h" | 36 | #include "qthelp_config_shared.h" | ||
37 | #include "debug.h" | 37 | #include "debug.h" | ||
38 | #include "qthelpplugin.h" | 38 | #include "qthelpplugin.h" | ||
39 | #include "qthelpexternalassistant.h" | ||||
39 | 40 | | |||
40 | enum Column | 41 | enum Column | ||
41 | { | 42 | { | ||
42 | NameColumn, | 43 | NameColumn, | ||
43 | PathColumn, | 44 | PathColumn, | ||
44 | IconColumn, | 45 | IconColumn, | ||
45 | GhnsColumn, | 46 | GhnsColumn, | ||
46 | ConfigColumn | 47 | ConfigColumn | ||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | 98 | { | |||
114 | KNS3::Button *knsButton = new KNS3::Button(i18nc("Allow user to get some API documentation with GHNS", "Get New Documentation"), QStringLiteral("kdevelop-qthelp.knsrc"), m_configWidget->boxQchManage); | 115 | KNS3::Button *knsButton = new KNS3::Button(i18nc("Allow user to get some API documentation with GHNS", "Get New Documentation"), QStringLiteral("kdevelop-qthelp.knsrc"), m_configWidget->boxQchManage); | ||
115 | m_configWidget->tableCtrlLayout->insertWidget(1, knsButton); | 116 | m_configWidget->tableCtrlLayout->insertWidget(1, knsButton); | ||
116 | connect(knsButton, &KNS3::Button::dialogFinished, this, &QtHelpConfig::knsUpdate); | 117 | connect(knsButton, &KNS3::Button::dialogFinished, this, &QtHelpConfig::knsUpdate); | ||
117 | connect(m_configWidget->loadQtDocsCheckBox, &QCheckBox::toggled, | 118 | connect(m_configWidget->loadQtDocsCheckBox, &QCheckBox::toggled, | ||
118 | this, static_cast<void(QtHelpConfig::*)()>(&QtHelpConfig::changed)); | 119 | this, static_cast<void(QtHelpConfig::*)()>(&QtHelpConfig::changed)); | ||
119 | m_configWidget->qchSearchDir->setMode(KFile::Directory); | 120 | m_configWidget->qchSearchDir->setMode(KFile::Directory); | ||
120 | connect(m_configWidget->qchSearchDir, &KUrlRequester::textChanged, | 121 | connect(m_configWidget->qchSearchDir, &KUrlRequester::textChanged, | ||
121 | this, &QtHelpConfig::changed); | 122 | this, &QtHelpConfig::changed); | ||
123 | connect(m_configWidget->externalViewerCheckBox, &QCheckBox::toggled, | ||||
124 | this, static_cast<void(QtHelpConfig::*)()>(&QtHelpConfig::changed)); | ||||
125 | m_configWidget->externalViewerCheckBox->setToolTip(i18n("Use Qt's Assistant as an external viewer,\n" | ||||
126 | "instead of the embedded viewer.")); | ||||
kfunk: This is over-engineered. No one will find or use that feature.
This should call `assistant`… | |||||
Yeah, this works for me and as a PoC, not as a definitive solution. From having used this patch for months I would now suggest to let the user select the path to the assistant to be used. The checkbox in the config dialog thus becomes a path selector, and not setting that path will then equal not activating external viewer support. Figuring out the Qt prefix used by the project seems unnecessarily complex (if not only when there are multiple projects in a session), and I don't think there's something like a system-wide assistant even on Plasma desktops. This is even more true on Mac where the assistant executable lives in an app bundle that could be everywhere. Another thing to keep in mind is that the assistant remote control protocol doesn't allow to change collections on the fly. That's why I currently use a script: it allowed me to set up a help collection for Assistant that corresponds to the one KDevelop works with (which isn't an actual qhc collection as far as I understand). That allows me to a single assistant copy. rjvbb: Yeah, this works for me and as a PoC, not as a definitive solution.
From having used this… | |||||
127 | m_configWidget->externalViewerExecutable->setToolTip( | ||||
128 | i18n("The path to the Assistant copy to use as an external viewer,\n" | ||||
129 | "can also be a script calling the Assistant or any other\n" | ||||
130 | "application that understands the same remote control protocol.\n" | ||||
131 | "KDevelop will try to find the application when this is not set.\n" | ||||
132 | "It is your responsibility to ensure that the viewer is configured\n" | ||||
133 | "to use a qhc help collection matching KDevelop's collection!")); | ||||
134 | QString currentExtViewer; | ||||
135 | if (KDevelop::QtHelpExternalAssistant::self()->hasExternalViewer(¤tExtViewer)) { | ||||
136 | m_configWidget->externalViewerExecutable->setPlaceholderText( | ||||
137 | i18n("path to Qt Assistant (%1)", currentExtViewer)); | ||||
138 | } else { | ||||
139 | m_configWidget->externalViewerExecutable->setPlaceholderText( | ||||
140 | i18n("path to Qt Assistant")); | ||||
141 | } | ||||
142 | connect(m_configWidget->externalViewerExecutable, &KUrlRequester::textChanged, | ||||
143 | this, &QtHelpConfig::changed); | ||||
122 | 144 | | |||
123 | // Set availability information for QtHelp | 145 | // Set availability information for QtHelp | ||
124 | m_configWidget->messageAvailabilityQtDocs->setCloseButtonVisible(false); | 146 | m_configWidget->messageAvailabilityQtDocs->setCloseButtonVisible(false); | ||
125 | if(plugin->isQtHelpAvailable()) { | 147 | if(plugin->isQtHelpAvailable()) { | ||
126 | m_configWidget->messageAvailabilityQtDocs->setVisible(false); | 148 | m_configWidget->messageAvailabilityQtDocs->setVisible(false); | ||
127 | } else { | 149 | } else { | ||
128 | m_configWidget->messageAvailabilityQtDocs->setText( | 150 | m_configWidget->messageAvailabilityQtDocs->setText( | ||
129 | i18n("The command \"qmake -query\" could not provide a path to a QtHelp file (QCH).")); | 151 | i18n("The command \"qmake -query\" could not provide a path to a QtHelp file (QCH).")); | ||
130 | m_configWidget->loadQtDocsCheckBox->setVisible(false); | 152 | m_configWidget->loadQtDocsCheckBox->setVisible(false); | ||
153 | m_configWidget->externalViewerCheckBox->setVisible(false); | ||||
154 | m_configWidget->externalViewerExecutable->setVisible(false); | ||||
131 | } | 155 | } | ||
132 | reset(); | 156 | reset(); | ||
133 | } | 157 | } | ||
134 | 158 | | |||
135 | QtHelpConfig::~QtHelpConfig() | 159 | QtHelpConfig::~QtHelpConfig() | ||
136 | { | 160 | { | ||
137 | delete m_configWidget; | 161 | delete m_configWidget; | ||
138 | } | 162 | } | ||
Show All 10 Lines | 172 | for (int i = 0; i < m_configWidget->qchTable->topLevelItemCount(); i++) { | |||
149 | const QTreeWidgetItem* item = m_configWidget->qchTable->topLevelItem(i); | 173 | const QTreeWidgetItem* item = m_configWidget->qchTable->topLevelItem(i); | ||
150 | nameList << item->text(0); | 174 | nameList << item->text(0); | ||
151 | pathList << item->text(1); | 175 | pathList << item->text(1); | ||
152 | iconList << item->text(2); | 176 | iconList << item->text(2); | ||
153 | ghnsList << item->text(3); | 177 | ghnsList << item->text(3); | ||
154 | } | 178 | } | ||
155 | QString searchDir = m_configWidget->qchSearchDir->text(); | 179 | QString searchDir = m_configWidget->qchSearchDir->text(); | ||
156 | bool loadQtDoc = m_configWidget->loadQtDocsCheckBox->isChecked(); | 180 | bool loadQtDoc = m_configWidget->loadQtDocsCheckBox->isChecked(); | ||
181 | ExternalViewerSettings extViewer(m_configWidget->externalViewerCheckBox->isChecked(), | ||||
182 | m_configWidget->externalViewerExecutable->text()); | ||||
157 | 183 | | |||
158 | qtHelpWriteConfig(iconList, nameList, pathList, ghnsList, searchDir, loadQtDoc); | 184 | qtHelpWriteConfig(iconList, nameList, pathList, ghnsList, searchDir, loadQtDoc, extViewer); | ||
159 | static_cast<QtHelpPlugin*>(plugin())->readConfig(); | 185 | static_cast<QtHelpPlugin*>(plugin())->readConfig(); | ||
160 | } | 186 | } | ||
161 | 187 | | |||
162 | void QtHelpConfig::reset() | 188 | void QtHelpConfig::reset() | ||
163 | { | 189 | { | ||
164 | m_configWidget->qchTable->clear(); | 190 | m_configWidget->qchTable->clear(); | ||
165 | 191 | | |||
166 | QStringList iconList, nameList, pathList, ghnsList; | 192 | QStringList iconList, nameList, pathList, ghnsList; | ||
167 | QString searchDir; | 193 | QString searchDir; | ||
168 | bool loadQtDoc; | 194 | bool loadQtDoc; | ||
169 | qtHelpReadConfig(iconList, nameList, pathList, ghnsList, searchDir, loadQtDoc); | 195 | ExternalViewerSettings extViewer; | ||
196 | qtHelpReadConfig(iconList, nameList, pathList, ghnsList, searchDir, loadQtDoc, extViewer); | ||||
170 | 197 | | |||
171 | const int size = qMin(qMin(iconList.size(), nameList.size()), pathList.size()); | 198 | const int size = qMin(qMin(iconList.size(), nameList.size()), pathList.size()); | ||
172 | for(int i = 0; i < size; ++i) { | 199 | for(int i = 0; i < size; ++i) { | ||
173 | QString ghnsStatus = ghnsList.size()>i ? ghnsList.at(i) : QStringLiteral("0"); | 200 | QString ghnsStatus = ghnsList.size()>i ? ghnsList.at(i) : QStringLiteral("0"); | ||
174 | addTableItem(iconList.at(i), nameList.at(i), pathList.at(i), ghnsStatus); | 201 | addTableItem(iconList.at(i), nameList.at(i), pathList.at(i), ghnsStatus); | ||
175 | } | 202 | } | ||
176 | m_configWidget->qchSearchDir->setText(searchDir); | 203 | m_configWidget->qchSearchDir->setText(searchDir); | ||
177 | m_configWidget->loadQtDocsCheckBox->setChecked(loadQtDoc); | 204 | m_configWidget->loadQtDocsCheckBox->setChecked(loadQtDoc); | ||
205 | m_configWidget->externalViewerCheckBox->setChecked(extViewer.useExtViewer); | ||||
206 | m_configWidget->externalViewerExecutable->setText(extViewer.extViewerExecutable); | ||||
178 | 207 | | |||
179 | emit changed(); | 208 | emit changed(); | ||
180 | } | 209 | } | ||
181 | 210 | | |||
182 | void QtHelpConfig::defaults() | 211 | void QtHelpConfig::defaults() | ||
183 | { | 212 | { | ||
184 | bool change = false; | 213 | bool change = false; | ||
185 | if(m_configWidget->qchTable->topLevelItemCount() > 0) { | 214 | if(m_configWidget->qchTable->topLevelItemCount() > 0) { | ||
▲ Show 20 Lines • Show All 170 Lines • Show Last 20 Lines |
This is over-engineered. No one will find or use that feature.
This should call assistant directly, if at all.` The path to assistant can be deduced from the Qt prefix used by the project and use system-wide assistant as a fallack.