Changeset View
Changeset View
Standalone View
Standalone View
src/drkonqidialog.cpp
Show First 20 Lines • Show All 167 Lines • ▼ Show 20 Line(s) | |||||
168 | 168 | | |||
169 | void DrKonqiDialog::buildDialogButtons() | 169 | void DrKonqiDialog::buildDialogButtons() | ||
170 | { | 170 | { | ||
171 | const CrashedApplication *crashedApp = DrKonqi::crashedApplication(); | 171 | const CrashedApplication *crashedApp = DrKonqi::crashedApplication(); | ||
172 | 172 | | |||
173 | //Set dialog buttons | 173 | //Set dialog buttons | ||
174 | m_buttonBox->setStandardButtons(QDialogButtonBox::Close); | 174 | m_buttonBox->setStandardButtons(QDialogButtonBox::Close); | ||
175 | 175 | | |||
176 | //Report bug button: User1 | | |||
177 | QPushButton* reportButton = new QPushButton(m_buttonBox); | | |||
178 | KGuiItem2 reportItem(i18nc("@action:button", "Report &Bug"), | | |||
179 | QIcon::fromTheme(QStringLiteral("tools-report-bug")), | | |||
180 | i18nc("@info:tooltip", "Starts the bug report assistant.")); | | |||
181 | KGuiItem::assign(reportButton, reportItem); | | |||
182 | m_buttonBox->addButton(reportButton, QDialogButtonBox::ActionRole); | | |||
183 | | ||||
184 | bool enableReportAssistant = !crashedApp->bugReportAddress().isEmpty() && | | |||
185 | crashedApp->fakeExecutableBaseName() != QLatin1String("drkonqi") && | | |||
186 | !DrKonqi::isSafer(); | | |||
187 | reportButton->setEnabled(enableReportAssistant); | | |||
188 | connect(reportButton, &QPushButton::clicked, this, &DrKonqiDialog::startBugReportAssistant); | | |||
189 | | ||||
190 | //Default debugger button and menu (only for developer mode): User2 | 176 | //Default debugger button and menu (only for developer mode): User2 | ||
191 | DebuggerManager *debuggerManager = DrKonqi::debuggerManager(); | 177 | DebuggerManager *debuggerManager = DrKonqi::debuggerManager(); | ||
192 | m_debugButton = new QPushButton(m_buttonBox); | 178 | m_debugButton = new QPushButton(this); | ||
193 | KGuiItem2 debugItem(i18nc("@action:button this is the debug menu button label which contains the debugging applications", | 179 | KGuiItem2 debugItem(i18nc("@action:button this is the debug menu button label which contains the debugging applications", | ||
194 | "&Debug"), QIcon::fromTheme(QStringLiteral("applications-development")), | 180 | "&Debug"), | ||
195 | i18nc("@info:tooltip", "Starts a program to debug " | 181 | QIcon::fromTheme(QStringLiteral("applications-development")), | ||
196 | "the crashed application.")); | 182 | i18nc("@info:tooltip", "Starts a program to debug the crashed application.")); | ||
197 | KGuiItem::assign(m_debugButton, debugItem); | 183 | KGuiItem::assign(m_debugButton, debugItem); | ||
198 | m_debugButton->setVisible(debuggerManager->showExternalDebuggers()); | 184 | m_debugButton->setVisible(false); | ||
199 | // Do not add the button unless it is visible, otherwise the Box will force | | |||
200 | // it visible as it calls show() explicitly. | | |||
201 | if (m_debugButton->isVisible()) { | | |||
202 | m_buttonBox->addButton(m_debugButton, QDialogButtonBox::ActionRole); | | |||
203 | } | | |||
204 | 185 | | |||
205 | m_debugMenu = new QMenu(this); | 186 | m_debugMenu = new QMenu(this); | ||
206 | m_debugButton->setMenu(m_debugMenu); | 187 | m_debugButton->setMenu(m_debugMenu); | ||
207 | 188 | | |||
189 | // Only add the debugger if requested by the config or if a KDevelop session is running. | ||||
190 | const bool showExternal = debuggerManager->showExternalDebuggers(); | ||||
sitter: CamelCase | |||||
208 | QList<AbstractDebuggerLauncher*> debuggers = debuggerManager->availableExternalDebuggers(); | 191 | QList<AbstractDebuggerLauncher*> debuggers = debuggerManager->availableExternalDebuggers(); | ||
209 | foreach(AbstractDebuggerLauncher *launcher, debuggers) { | 192 | foreach(AbstractDebuggerLauncher *launcher, debuggers) { | ||
193 | if (showExternal || qobject_cast<DBusInterfaceLauncher*>(launcher)) { | ||||
210 | addDebugger(launcher); | 194 | addDebugger(launcher); | ||
211 | } | 195 | } | ||
sitter: We always use curly braces for ifs in Plasma | |||||
196 | } | ||||
212 | 197 | | |||
213 | connect(debuggerManager, &DebuggerManager::externalDebuggerAdded, this, &DrKonqiDialog::addDebugger); | 198 | connect(debuggerManager, &DebuggerManager::externalDebuggerAdded, this, &DrKonqiDialog::addDebugger); | ||
214 | connect(debuggerManager, &DebuggerManager::externalDebuggerRemoved, this, &DrKonqiDialog::removeDebugger); | 199 | connect(debuggerManager, &DebuggerManager::externalDebuggerRemoved, this, &DrKonqiDialog::removeDebugger); | ||
215 | connect(debuggerManager, &DebuggerManager::debuggerRunning, this, &DrKonqiDialog::enableDebugMenu); | 200 | connect(debuggerManager, &DebuggerManager::debuggerRunning, this, &DrKonqiDialog::enableDebugMenu); | ||
216 | 201 | | |||
202 | //Report bug button: User1 | ||||
203 | QPushButton *reportButton = new QPushButton(m_buttonBox); | ||||
sitter: * goes to the right of the space. | |||||
204 | KGuiItem2 reportItem(i18nc("@action:button", "Report &Bug"), | ||||
205 | QIcon::fromTheme(QStringLiteral("tools-report-bug")), | ||||
206 | i18nc("@info:tooltip", "Starts the bug report assistant.")); | ||||
207 | KGuiItem::assign(reportButton, reportItem); | ||||
208 | m_buttonBox->addButton(reportButton, QDialogButtonBox::ActionRole); | ||||
209 | | ||||
210 | reportButton->setEnabled(!crashedApp->bugReportAddress().isEmpty() && | ||||
could probably just do away with this and merge the condition into the setEnabled call below. the variable doesn't seem to do much in the way of readability. sitter: could probably just do away with this and merge the condition into the setEnabled call below. | |||||
211 | crashedApp->fakeExecutableBaseName() != QLatin1String("drkonqi") && | ||||
212 | !DrKonqi::isSafer()); | ||||
213 | connect(reportButton, &QPushButton::clicked, this, &DrKonqiDialog::startBugReportAssistant); | ||||
214 | | ||||
217 | //Restart application button | 215 | //Restart application button | ||
218 | KGuiItem2 restartItem(i18nc("@action:button", "&Restart Application"), | 216 | KGuiItem2 restartItem(i18nc("@action:button", "&Restart Application"), | ||
219 | QIcon::fromTheme(QStringLiteral("system-reboot")), | 217 | QIcon::fromTheme(QStringLiteral("system-reboot")), | ||
220 | i18nc("@info:tooltip", "Use this button to restart " | 218 | i18nc("@info:tooltip", "Use this button to restart " | ||
221 | "the crashed application.")); | 219 | "the crashed application.")); | ||
222 | m_restartButton = new QPushButton(m_buttonBox); | 220 | m_restartButton = new QPushButton(m_buttonBox); | ||
223 | KGuiItem::assign(m_restartButton, restartItem); | 221 | KGuiItem::assign(m_restartButton, restartItem); | ||
224 | m_restartButton->setEnabled(!crashedApp->hasBeenRestarted() && | 222 | m_restartButton->setEnabled(!crashedApp->hasBeenRestarted() && | ||
Show All 14 Lines | |||||
239 | { | 237 | { | ||
240 | QAction *action = new QAction(QIcon::fromTheme(QStringLiteral("applications-development")), | 238 | QAction *action = new QAction(QIcon::fromTheme(QStringLiteral("applications-development")), | ||
241 | i18nc("@action:inmenu 1 is the debugger name", | 239 | i18nc("@action:inmenu 1 is the debugger name", | ||
242 | "Debug in %1", | 240 | "Debug in %1", | ||
243 | launcher->name()), m_debugMenu); | 241 | launcher->name()), m_debugMenu); | ||
244 | m_debugMenu->addAction(action); | 242 | m_debugMenu->addAction(action); | ||
245 | connect(action, &QAction::triggered, launcher, &AbstractDebuggerLauncher::start); | 243 | connect(action, &QAction::triggered, launcher, &AbstractDebuggerLauncher::start); | ||
246 | m_debugMenuActions.insert(launcher, action); | 244 | m_debugMenuActions.insert(launcher, action); | ||
245 | | ||||
246 | // Make sure that the debug button is the first button with action role to be | ||||
247 | // inserted, then add the other buttons. See removeDebugger below for more information. | ||||
248 | if (!m_debugButtonInBox) { | ||||
sitter: CamelCase
Should be `= false` | |||||
249 | auto buttons = m_buttonBox->buttons(); | ||||
250 | m_buttonBox->addButton(m_debugButton, QDialogButtonBox::ActionRole); | ||||
sitter: No single letter variables please. | |||||
251 | m_debugButton->setVisible(true); | ||||
252 | for (QAbstractButton *button : buttons) { | ||||
253 | if (m_buttonBox->buttonRole(button) == QDialogButtonBox::ActionRole) { | ||||
254 | m_buttonBox->addButton(button, QDialogButtonBox::ActionRole); | ||||
255 | } | ||||
256 | } | ||||
257 | m_debugButtonInBox = true; | ||||
258 | } | ||||
247 | } | 259 | } | ||
248 | 260 | | |||
249 | void DrKonqiDialog::removeDebugger(AbstractDebuggerLauncher *launcher) | 261 | void DrKonqiDialog::removeDebugger(AbstractDebuggerLauncher *launcher) | ||
sitter: No single letter variables please. | |||||
250 | { | 262 | { | ||
251 | QAction *action = m_debugMenuActions.take(launcher); | 263 | QAction *action = m_debugMenuActions.take(launcher); | ||
252 | if ( action ) { | 264 | if ( action ) { | ||
253 | m_debugMenu->removeAction(action); | 265 | m_debugMenu->removeAction(action); | ||
254 | action->deleteLater(); | 266 | action->deleteLater(); | ||
267 | // Remove the button from the box, otherwise the box will force | ||||
268 | // it visible as it calls show() explicitly. (QTBUG-3651) | ||||
269 | if (m_debugMenu->isEmpty()) { | ||||
270 | m_buttonBox->removeButton(m_debugButton); | ||||
271 | m_debugButton->setVisible(false); | ||||
272 | m_debugButton->setParent(this); | ||||
273 | m_debugButtonInBox = false; | ||||
274 | } | ||||
255 | } else { | 275 | } else { | ||
256 | qCWarning(DRKONQI_LOG) << "Invalid launcher"; | 276 | qCWarning(DRKONQI_LOG) << "Invalid launcher"; | ||
257 | } | 277 | } | ||
258 | } | 278 | } | ||
259 | 279 | | |||
260 | void DrKonqiDialog::enableDebugMenu(bool debuggerRunning) | 280 | void DrKonqiDialog::enableDebugMenu(bool debuggerRunning) | ||
261 | { | 281 | { | ||
262 | m_debugButton->setEnabled(!debuggerRunning); | 282 | m_debugButton->setEnabled(!debuggerRunning); | ||
Show All 38 Lines |
CamelCase