Changeset View
Changeset View
Standalone View
Standalone View
src/MainWindow.cpp
Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | 146 | { | |||
---|---|---|---|---|---|
152 | 152 | | |||
153 | setAttribute(Qt::WA_TranslucentBackground, useTranslucency); | 153 | setAttribute(Qt::WA_TranslucentBackground, useTranslucency); | ||
154 | setAttribute(Qt::WA_NoSystemBackground, false); | 154 | setAttribute(Qt::WA_NoSystemBackground, false); | ||
155 | WindowSystemInfo::HAVE_TRANSPARENCY = useTranslucency; | 155 | WindowSystemInfo::HAVE_TRANSPARENCY = useTranslucency; | ||
156 | } | 156 | } | ||
157 | 157 | | |||
158 | void MainWindow::rememberMenuAccelerators() | 158 | void MainWindow::rememberMenuAccelerators() | ||
159 | { | 159 | { | ||
160 | foreach (QAction *menuItem, menuBar()->actions()) { | 160 | for (auto *menuItem : menuBar()->actions()) { | ||
161 | QString itemText = menuItem->text(); | 161 | menuItem->setData(menuItem->text()); | ||
162 | menuItem->setData(itemText); | | |||
163 | } | 162 | } | ||
164 | } | 163 | } | ||
165 | 164 | | |||
166 | // remove accelerators for standard menu items (eg. &File, &View, &Edit) | 165 | // remove accelerators for standard menu items (eg. &File, &View, &Edit) | ||
167 | // etc. which are defined in kdelibs/kdeui/xmlgui/ui_standards.rc, again, | 166 | // etc. which are defined in kdelibs/kdeui/xmlgui/ui_standards.rc, again, | ||
168 | // to avoid conflicting with Alt+[Letter] terminal shortcuts | 167 | // to avoid conflicting with Alt+[Letter] terminal shortcuts | ||
169 | // | 168 | // | ||
170 | // TODO - Modify XMLGUI so that it allows the text for standard actions | 169 | // TODO - Modify XMLGUI so that it allows the text for standard actions | ||
171 | // defined in ui_standards.rc to be re-defined in the local application | 170 | // defined in ui_standards.rc to be re-defined in the local application | ||
172 | // XMLGUI file (konsoleui.rc in this case) - the text for standard items | 171 | // XMLGUI file (konsoleui.rc in this case) - the text for standard items | ||
173 | // can then be redefined there to exclude the standard accelerators | 172 | // can then be redefined there to exclude the standard accelerators | ||
174 | void MainWindow::removeMenuAccelerators() | 173 | void MainWindow::removeMenuAccelerators() | ||
175 | { | 174 | { | ||
176 | foreach (QAction *menuItem, menuBar()->actions()) { | 175 | for (auto *menuItem : menuBar()->actions()) { | ||
177 | menuItem->setText(menuItem->text().replace(QLatin1Char('&'), QString())); | 176 | menuItem->setText(menuItem->text().replace(QLatin1Char('&'), QString())); | ||
178 | } | 177 | } | ||
179 | } | 178 | } | ||
180 | 179 | | |||
181 | void MainWindow::restoreMenuAccelerators() | 180 | void MainWindow::restoreMenuAccelerators() | ||
182 | { | 181 | { | ||
183 | foreach (QAction *menuItem, menuBar()->actions()) { | 182 | for (auto *menuItem : menuBar()->actions()) { | ||
184 | QString itemText = menuItem->data().toString(); | 183 | menuItem->setText(menuItem->data().toString()); | ||
185 | menuItem->setText(itemText); | | |||
186 | } | 184 | } | ||
187 | } | 185 | } | ||
188 | 186 | | |||
189 | void MainWindow::correctStandardShortcuts() | 187 | void MainWindow::correctStandardShortcuts() | ||
190 | { | 188 | { | ||
191 | // replace F1 shortcut for help contents | 189 | // replace F1 shortcut for help contents | ||
192 | QAction *helpAction = actionCollection()->action(QStringLiteral("help_contents")); | 190 | QAction *helpAction = actionCollection()->action(QStringLiteral("help_contents")); | ||
193 | if (helpAction != nullptr) { | 191 | if (helpAction != nullptr) { | ||
▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Line(s) | 400 | { | |||
404 | // it if it is the non-default profile. | 402 | // it if it is the non-default profile. | ||
405 | if (sessionActions.size() > 2) { | 403 | if (sessionActions.size() > 2) { | ||
406 | // Update the 'New Tab' KActionMenu | 404 | // Update the 'New Tab' KActionMenu | ||
407 | if (_newTabMenuAction->menu() != nullptr) { | 405 | if (_newTabMenuAction->menu() != nullptr) { | ||
408 | _newTabMenuAction->menu()->clear(); | 406 | _newTabMenuAction->menu()->clear(); | ||
409 | } else { | 407 | } else { | ||
410 | _newTabMenuAction->setMenu(new QMenu()); | 408 | _newTabMenuAction->setMenu(new QMenu()); | ||
411 | } | 409 | } | ||
412 | foreach (QAction *sessionAction, sessionActions) { | 410 | for (auto *sessionAction : sessionActions) { | ||
413 | _newTabMenuAction->menu()->addAction(sessionAction); | 411 | _newTabMenuAction->menu()->addAction(sessionAction); | ||
414 | 412 | | |||
415 | // NOTE: defaultProfile seems to not work here, sigh. | 413 | // NOTE: defaultProfile seems to not work here, sigh. | ||
416 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | 414 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | ||
417 | if (profile && profile->name() == sessionAction->text().remove(QLatin1Char('&'))) { | 415 | if (profile && profile->name() == sessionAction->text().remove(QLatin1Char('&'))) { | ||
418 | QIcon icon(KIconLoader::global()->loadIcon(profile->icon(), KIconLoader::Small, 0, KIconLoader::DefaultState, QStringList(QStringLiteral("emblem-favorite")))); | 416 | QIcon icon(KIconLoader::global()->loadIcon(profile->icon(), KIconLoader::Small, 0, KIconLoader::DefaultState, QStringList(QStringLiteral("emblem-favorite")))); | ||
419 | sessionAction->setIcon(icon); | 417 | sessionAction->setIcon(icon); | ||
420 | _newTabMenuAction->menu()->setDefaultAction(sessionAction); | 418 | _newTabMenuAction->menu()->setDefaultAction(sessionAction); | ||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | 555 | { | |||
559 | // TODO: rework the dealing of this case to make it has its own confirmation | 557 | // TODO: rework the dealing of this case to make it has its own confirmation | ||
560 | // dialog. | 558 | // dialog. | ||
561 | if (qApp->isSavingSession()) { | 559 | if (qApp->isSavingSession()) { | ||
562 | return true; | 560 | return true; | ||
563 | } | 561 | } | ||
564 | 562 | | |||
565 | // Check what processes are running, excluding the shell | 563 | // Check what processes are running, excluding the shell | ||
566 | QStringList processesRunning; | 564 | QStringList processesRunning; | ||
567 | const auto uniqueSessions = QSet<Session*>::fromList(_viewManager->sessions()); | | |||
568 | 565 | | |||
569 | foreach (Session *session, uniqueSessions) { | 566 | // TODO: Verify if it's still needed to change the list to a set. | ||
567 | for (Session *session : QSet<Session*>::fromList(_viewManager->sessions())) { | ||||
570 | if ((session == nullptr) || !session->isForegroundProcessActive()) { | 568 | if ((session == nullptr) || !session->isForegroundProcessActive()) { | ||
571 | continue; | 569 | continue; | ||
572 | } | 570 | } | ||
573 | 571 | | |||
574 | const QString defaultProc = session->program().split(QLatin1Char('/')).last(); | 572 | const QString defaultProc = session->program().split(QLatin1Char('/')).last(); | ||
575 | const QString currentProc = session->foregroundProcessName().split(QLatin1Char('/')).last(); | 573 | const QString currentProc = session->foregroundProcessName().split(QLatin1Char('/')).last(); | ||
576 | 574 | | |||
577 | if (currentProc.isEmpty()) { | 575 | if (currentProc.isEmpty()) { | ||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | |||||
668 | 666 | | |||
669 | void MainWindow::readGlobalProperties(KConfig *config) | 667 | void MainWindow::readGlobalProperties(KConfig *config) | ||
670 | { | 668 | { | ||
671 | SessionManager::instance()->restoreSessions(config); | 669 | SessionManager::instance()->restoreSessions(config); | ||
672 | } | 670 | } | ||
673 | 671 | | |||
674 | void MainWindow::syncActiveShortcuts(KActionCollection *dest, const KActionCollection *source) | 672 | void MainWindow::syncActiveShortcuts(KActionCollection *dest, const KActionCollection *source) | ||
675 | { | 673 | { | ||
676 | foreach (QAction *qAction, source->actions()) { | 674 | for (auto *qAction : source->actions()) { | ||
677 | if (QAction *destQAction = dest->action(qAction->objectName())) { | 675 | if (QAction *destQAction = dest->action(qAction->objectName())) { | ||
678 | destQAction->setShortcut(qAction->shortcut()); | 676 | destQAction->setShortcut(qAction->shortcut()); | ||
679 | } | 677 | } | ||
680 | } | 678 | } | ||
681 | } | 679 | } | ||
682 | 680 | | |||
683 | void MainWindow::showShortcutsDialog() | 681 | void MainWindow::showShortcutsDialog() | ||
684 | { | 682 | { | ||
685 | KShortcutsDialog dialog(KShortcutsEditor::AllActions, | 683 | KShortcutsDialog dialog(KShortcutsEditor::AllActions, | ||
686 | KShortcutsEditor::LetterShortcutsDisallowed, this); | 684 | KShortcutsEditor::LetterShortcutsDisallowed, this); | ||
687 | 685 | | |||
688 | // add actions from this window and the current session controller | 686 | // add actions from this window and the current session controller | ||
689 | foreach (KXMLGUIClient *client, guiFactory()->clients()) { | 687 | for (KXMLGUIClient *client : guiFactory()->clients()) { | ||
690 | dialog.addCollection(client->actionCollection()); | 688 | dialog.addCollection(client->actionCollection()); | ||
691 | } | 689 | } | ||
692 | 690 | | |||
693 | if (dialog.configure()) { | 691 | if (dialog.configure()) { | ||
694 | // sync shortcuts for non-session actions (defined in "konsoleui.rc") in other main windows | 692 | // sync shortcuts for non-session actions (defined in "konsoleui.rc") in other main windows | ||
695 | foreach (QWidget *mainWindowWidget, QApplication::topLevelWidgets()) { | 693 | for (auto *mainWindowWidget : QApplication::topLevelWidgets()) { | ||
696 | auto *mainWindow = qobject_cast<MainWindow *>(mainWindowWidget); | 694 | auto *mainWindow = qobject_cast<MainWindow *>(mainWindowWidget); | ||
697 | if ((mainWindow != nullptr) && mainWindow != this) { | 695 | if ((mainWindow != nullptr) && mainWindow != this) { | ||
698 | syncActiveShortcuts(mainWindow->actionCollection(), actionCollection()); | 696 | syncActiveShortcuts(mainWindow->actionCollection(), actionCollection()); | ||
699 | } | 697 | } | ||
700 | } | 698 | } | ||
701 | // sync shortcuts for session actions (defined in "sessionui.rc") in other session controllers. | 699 | // sync shortcuts for session actions (defined in "sessionui.rc") in other session controllers. | ||
702 | // Controllers which are currently plugged in (ie. their actions are part of the current menu) | 700 | // Controllers which are currently plugged in (ie. their actions are part of the current menu) | ||
703 | // must be updated immediately via syncActiveShortcuts(). Other controllers will be updated | 701 | // must be updated immediately via syncActiveShortcuts(). Other controllers will be updated | ||
704 | // when they are plugged into a main window. | 702 | // when they are plugged into a main window. | ||
705 | foreach (SessionController *controller, SessionController::allControllers()) { | 703 | for (auto *controller : SessionController::allControllers()) { | ||
706 | controller->reloadXML(); | 704 | controller->reloadXML(); | ||
707 | if ((controller->factory() != nullptr) && controller != _pluggedController) { | 705 | if ((controller->factory() != nullptr) && controller != _pluggedController) { | ||
708 | syncActiveShortcuts(controller->actionCollection(), _pluggedController->actionCollection()); | 706 | syncActiveShortcuts(controller->actionCollection(), _pluggedController->actionCollection()); | ||
709 | } | 707 | } | ||
710 | } | 708 | } | ||
711 | } | 709 | } | ||
712 | } | 710 | } | ||
713 | 711 | | |||
▲ Show 20 Lines • Show All 180 Lines • Show Last 20 Lines |