Changeset View
Changeset View
Standalone View
Standalone View
src/MainWindow.cpp
Show First 20 Lines • Show All 491 Lines • ▼ Show 20 Line(s) | 481 | { | |||
---|---|---|---|---|---|
492 | } | 492 | } | ||
493 | } | 493 | } | ||
494 | 494 | | |||
495 | Session *MainWindow::createSession(Profile::Ptr profile, const QString &directory) | 495 | Session *MainWindow::createSession(Profile::Ptr profile, const QString &directory) | ||
496 | { | 496 | { | ||
497 | if (!profile) { | 497 | if (!profile) { | ||
498 | profile = ProfileManager::instance()->defaultProfile(); | 498 | profile = ProfileManager::instance()->defaultProfile(); | ||
499 | } | 499 | } | ||
500 | 500 | int sessionId = _viewManager->newSession(profile->name(), directory); | |||
501 | Session *session = SessionManager::instance()->createSession(profile); | 501 | return SessionManager::instance()->idToSession(sessionId); | ||
502 | | ||||
503 | if (!directory.isEmpty() && profile->startInCurrentSessionDir()) { | | |||
504 | session->setInitialWorkingDirectory(directory); | | |||
505 | } | | |||
506 | | ||||
507 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(_viewManager->managerId())); | | |||
508 | | ||||
509 | // create view before starting the session process so that the session | | |||
510 | // doesn't suffer a change in terminal size right after the session | | |||
511 | // starts. Some applications such as GNU Screen and Midnight Commander | | |||
512 | // don't like this happening | | |||
513 | createView(session); | | |||
514 | | ||||
515 | return session; | | |||
516 | } | 502 | } | ||
517 | 503 | | |||
518 | Session *MainWindow::createSSHSession(Profile::Ptr profile, const QUrl &url) | 504 | Session *MainWindow::createSSHSession(Profile::Ptr profile, const QUrl &url) | ||
519 | { | 505 | { | ||
520 | if (!profile) { | 506 | if (!profile) { | ||
521 | profile = ProfileManager::instance()->defaultProfile(); | 507 | profile = ProfileManager::instance()->defaultProfile(); | ||
522 | } | 508 | } | ||
523 | 509 | | |||
Show All 11 Lines | |||||
535 | } | 521 | } | ||
536 | 522 | | |||
537 | session->sendTextToTerminal(sshCommand, QLatin1Char('\r')); | 523 | session->sendTextToTerminal(sshCommand, QLatin1Char('\r')); | ||
538 | 524 | | |||
539 | // create view before starting the session process so that the session | 525 | // create view before starting the session process so that the session | ||
540 | // doesn't suffer a change in terminal size right after the session | 526 | // doesn't suffer a change in terminal size right after the session | ||
541 | // starts. some applications such as GNU Screen and Midnight Commander | 527 | // starts. some applications such as GNU Screen and Midnight Commander | ||
542 | // don't like this happening | 528 | // don't like this happening | ||
543 | createView(session); | 529 | _viewManager->createView(session); | ||
544 | 530 | | |||
545 | return session; | 531 | return session; | ||
546 | } | 532 | } | ||
547 | 533 | | |||
548 | void MainWindow::createView(Session *session) | | |||
549 | { | | |||
550 | _viewManager->createView(session); | | |||
551 | } | | |||
552 | | ||||
553 | void MainWindow::setFocus() | 534 | void MainWindow::setFocus() | ||
554 | { | 535 | { | ||
555 | _viewManager->activeView()->setFocus(); | 536 | _viewManager->activeView()->setFocus(); | ||
556 | } | 537 | } | ||
557 | 538 | | |||
558 | void MainWindow::newWindow() | 539 | void MainWindow::newWindow() | ||
559 | { | 540 | { | ||
560 | Profile::Ptr defaultProfile = ProfileManager::instance()->defaultProfile(); | 541 | Profile::Ptr defaultProfile = ProfileManager::instance()->defaultProfile(); | ||
▲ Show 20 Lines • Show All 208 Lines • ▼ Show 20 Line(s) | 749 | { | |||
769 | setMenuBarInitialVisibility(KonsoleSettings::showMenuBarByDefault()); | 750 | setMenuBarInitialVisibility(KonsoleSettings::showMenuBarByDefault()); | ||
770 | 751 | | |||
771 | if (KonsoleSettings::allowMenuAccelerators()) { | 752 | if (KonsoleSettings::allowMenuAccelerators()) { | ||
772 | restoreMenuAccelerators(); | 753 | restoreMenuAccelerators(); | ||
773 | } else { | 754 | } else { | ||
774 | removeMenuAccelerators(); | 755 | removeMenuAccelerators(); | ||
775 | } | 756 | } | ||
776 | 757 | | |||
777 | setNavigationVisibility(KonsoleSettings::tabBarVisibility()); | 758 | _viewManager->setNavigationVisibility(KonsoleSettings::tabBarVisibility()); | ||
778 | setNavigationPosition(KonsoleSettings::tabBarPosition()); | 759 | _viewManager->setNavigationPosition(KonsoleSettings::tabBarPosition()); | ||
779 | setNavigationBehavior(KonsoleSettings::newTabBehavior()); | 760 | _viewManager->setNavigationBehavior(KonsoleSettings::newTabBehavior()); | ||
780 | setNavigationTabWidthExpanding(KonsoleSettings::expandTabWidth()); | 761 | _viewManager->setNavigationTabWidthExpanding(KonsoleSettings::expandTabWidth()); | ||
781 | setShowQuickButtons(KonsoleSettings::showQuickButtons()); | 762 | _viewManager->setShowQuickButtons(KonsoleSettings::showQuickButtons()); | ||
782 | 763 | | |||
783 | if (KonsoleSettings::tabBarUseUserStyleSheet()) { | 764 | if (KonsoleSettings::tabBarUseUserStyleSheet()) { | ||
784 | setNavigationStyleSheetFromFile(KonsoleSettings::tabBarUserStyleSheetFile()); | 765 | setNavigationStyleSheetFromFile(KonsoleSettings::tabBarUserStyleSheetFile()); | ||
785 | } else { | 766 | } else { | ||
786 | // Apply default values | 767 | // Apply default values | ||
787 | setNavigationStyleSheet(KonsoleSettings::tabBarStyleSheet()); | 768 | _viewManager->setNavigationStyleSheet(KonsoleSettings::tabBarStyleSheet()); | ||
788 | } | 769 | } | ||
789 | 770 | | |||
790 | setAutoSaveSettings(QStringLiteral("MainWindow"), KonsoleSettings::saveGeometryOnExit()); | 771 | setAutoSaveSettings(QStringLiteral("MainWindow"), KonsoleSettings::saveGeometryOnExit()); | ||
791 | 772 | | |||
792 | updateWindowCaption(); | 773 | updateWindowCaption(); | ||
793 | } | 774 | } | ||
794 | 775 | | |||
795 | void MainWindow::setNavigationVisibility(int visibility) | | |||
796 | { | | |||
797 | _viewManager->setNavigationVisibility(visibility); | | |||
798 | } | | |||
799 | | ||||
800 | void MainWindow::setNavigationPosition(int position) | | |||
801 | { | | |||
802 | _viewManager->setNavigationPosition(position); | | |||
803 | } | | |||
804 | | ||||
805 | void MainWindow::setNavigationStyleSheet(const QString &styleSheet) | | |||
806 | { | | |||
807 | _viewManager->setNavigationStyleSheet(styleSheet); | | |||
808 | } | | |||
809 | | ||||
810 | void MainWindow::setNavigationBehavior(int behavior) | | |||
811 | { | | |||
812 | _viewManager->setNavigationBehavior(behavior); | | |||
813 | } | | |||
814 | | ||||
815 | void MainWindow::setNavigationTabWidthExpanding(bool expand) | | |||
816 | { | | |||
817 | _viewManager->setNavigationTabWidthExpanding(expand); | | |||
818 | } | | |||
819 | 776 | | |||
820 | void MainWindow::setNavigationStyleSheetFromFile(const QUrl &styleSheetFile) | 777 | void MainWindow::setNavigationStyleSheetFromFile(const QUrl &styleSheetFile) | ||
821 | { | 778 | { | ||
822 | // Let's only deal w/ local files for now | 779 | // Let's only deal w/ local files for now | ||
823 | if (!styleSheetFile.isLocalFile()) { | 780 | if (!styleSheetFile.isLocalFile()) { | ||
824 | setNavigationStyleSheet(KonsoleSettings::tabBarStyleSheet()); | 781 | _viewManager->setNavigationStyleSheet(KonsoleSettings::tabBarStyleSheet()); | ||
825 | } | 782 | } | ||
826 | 783 | | |||
827 | QFile file(styleSheetFile.toLocalFile()); | 784 | QFile file(styleSheetFile.toLocalFile()); | ||
828 | if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { | 785 | if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { | ||
829 | setNavigationStyleSheet(KonsoleSettings::tabBarStyleSheet()); | 786 | _viewManager->setNavigationStyleSheet(KonsoleSettings::tabBarStyleSheet()); | ||
830 | } | 787 | } | ||
831 | 788 | | |||
832 | QString styleSheetText; | 789 | QString styleSheetText; | ||
833 | QTextStream in(&file); | 790 | QTextStream in(&file); | ||
834 | while (!in.atEnd()) { | 791 | while (!in.atEnd()) { | ||
835 | styleSheetText.append(in.readLine()); | 792 | styleSheetText.append(in.readLine()); | ||
836 | } | 793 | } | ||
837 | 794 | | |||
838 | // Replace current style sheet w/ loaded file | 795 | // Replace current style sheet w/ loaded file | ||
839 | setNavigationStyleSheet(styleSheetText); | 796 | _viewManager->setNavigationStyleSheet(styleSheetText); | ||
840 | } | | |||
841 | | ||||
842 | void MainWindow::setShowQuickButtons(bool show) | | |||
843 | { | | |||
844 | _viewManager->setShowQuickButtons(show); | | |||
845 | } | 797 | } | ||
846 | 798 | | |||
847 | void MainWindow::activateMenuBar() | 799 | void MainWindow::activateMenuBar() | ||
848 | { | 800 | { | ||
849 | const QList<QAction *> menuActions = menuBar()->actions(); | 801 | const QList<QAction *> menuActions = menuBar()->actions(); | ||
850 | 802 | | |||
851 | if (menuActions.isEmpty()) { | 803 | if (menuActions.isEmpty()) { | ||
852 | return; | 804 | return; | ||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |