Changeset View
Changeset View
Standalone View
Standalone View
src/MainWindow.cpp
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Line(s) | 76 | { | |||
---|---|---|---|---|---|
111 | connect(_viewManager, &Konsole::ViewManager::updateWindowIcon, this, | 111 | connect(_viewManager, &Konsole::ViewManager::updateWindowIcon, this, | ||
112 | &Konsole::MainWindow::updateWindowIcon); | 112 | &Konsole::MainWindow::updateWindowIcon); | ||
113 | connect(_viewManager, &Konsole::ViewManager::newViewWithProfileRequest, | 113 | connect(_viewManager, &Konsole::ViewManager::newViewWithProfileRequest, | ||
114 | this, &Konsole::MainWindow::newFromProfile); | 114 | this, &Konsole::MainWindow::newFromProfile); | ||
115 | connect(_viewManager, &Konsole::ViewManager::newViewRequest, | 115 | connect(_viewManager, &Konsole::ViewManager::newViewRequest, | ||
116 | this, &Konsole::MainWindow::newTab); | 116 | this, &Konsole::MainWindow::newTab); | ||
117 | connect(_viewManager, &Konsole::ViewManager::viewDetached, this, | 117 | connect(_viewManager, &Konsole::ViewManager::viewDetached, this, | ||
118 | &Konsole::MainWindow::viewDetached); | 118 | &Konsole::MainWindow::viewDetached); | ||
119 | connect(_viewManager, &Konsole::ViewManager::tabDetached, this, | ||||
120 | &Konsole::MainWindow::tabDetached); | ||||
119 | 121 | | |||
120 | setCentralWidget(_viewManager->widget()); | 122 | setCentralWidget(_viewManager->widget()); | ||
121 | 123 | | |||
122 | // disable automatically generated accelerators in top-level | 124 | // disable automatically generated accelerators in top-level | ||
123 | // menu items - to avoid conflicting with Alt+[Letter] shortcuts | 125 | // menu items - to avoid conflicting with Alt+[Letter] shortcuts | ||
124 | // in terminal applications | 126 | // in terminal applications | ||
125 | KAcceleratorManager::setNoAccel(menuBar()); | 127 | KAcceleratorManager::setNoAccel(menuBar()); | ||
126 | 128 | | |||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 310 | { | |||
309 | KActionCollection *collection = actionCollection(); | 311 | KActionCollection *collection = actionCollection(); | ||
310 | 312 | | |||
311 | // File Menu | 313 | // File Menu | ||
312 | _newTabMenuAction = new KActionMenu(QIcon::fromTheme(QStringLiteral("tab-new")), | 314 | _newTabMenuAction = new KActionMenu(QIcon::fromTheme(QStringLiteral("tab-new")), | ||
313 | i18nc("@action:inmenu", "&New Tab"), collection); | 315 | i18nc("@action:inmenu", "&New Tab"), collection); | ||
314 | collection->setDefaultShortcut(_newTabMenuAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_T); | 316 | collection->setDefaultShortcut(_newTabMenuAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_T); | ||
315 | collection->setShortcutsConfigurable(_newTabMenuAction, true); | 317 | collection->setShortcutsConfigurable(_newTabMenuAction, true); | ||
316 | _newTabMenuAction->setAutoRepeat(false); | 318 | _newTabMenuAction->setAutoRepeat(false); | ||
317 | connect(_newTabMenuAction, &KActionMenu::triggered, | 319 | connect(_newTabMenuAction, &KActionMenu::triggered, | ||
318 | this, [this] { newTab(_viewManager->activeContainer());}); | 320 | this, [this] { newTab(_viewManager->activeContainer());}); | ||
anthonyfieroni: Can you connect like:
```
connect(_newTabMenuAction, &KActionMenu::triggered, this, &MainWindow… | |||||
319 | collection->addAction(QStringLiteral("new-tab"), _newTabMenuAction); | 321 | collection->addAction(QStringLiteral("new-tab"), _newTabMenuAction); | ||
320 | collection->setShortcutsConfigurable(_newTabMenuAction, true); | 322 | collection->setShortcutsConfigurable(_newTabMenuAction, true); | ||
321 | 323 | | |||
322 | QAction* menuAction = collection->addAction(QStringLiteral("clone-tab")); | 324 | QAction* menuAction = collection->addAction(QStringLiteral("clone-tab")); | ||
323 | menuAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-duplicate"))); | 325 | menuAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-duplicate"))); | ||
324 | menuAction->setText(i18nc("@action:inmenu", "&Clone Tab")); | 326 | menuAction->setText(i18nc("@action:inmenu", "&Clone Tab")); | ||
325 | collection->setDefaultShortcut(menuAction, QKeySequence()); | 327 | collection->setDefaultShortcut(menuAction, QKeySequence()); | ||
326 | menuAction->setAutoRepeat(false); | 328 | menuAction->setAutoRepeat(false); | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | |||||
383 | { | 385 | { | ||
384 | return _bookmarkHandler; | 386 | return _bookmarkHandler; | ||
385 | } | 387 | } | ||
386 | 388 | | |||
387 | void MainWindow::setProfileList(ProfileList *list) | 389 | void MainWindow::setProfileList(ProfileList *list) | ||
388 | { | 390 | { | ||
389 | profileListChanged(list->actions()); | 391 | profileListChanged(list->actions()); | ||
390 | 392 | | |||
391 | connect(list, &Konsole::ProfileList::profileSelected, this, | 393 | connect(list, &Konsole::ProfileList::profileSelected, this, | ||
392 | [this](const Profile::Ptr &profile) { newFromProfile(_viewManager->activeContainer(), profile);}); | 394 | [this](const Profile::Ptr &profile) { newFromProfile(_viewManager->activeContainer(), profile);}); | ||
Same as above connect(list, &Konsole::ProfileList::profileSelected, this, &MainWindow::newFromProfile); anthonyfieroni: Same as above
```
connect(list, &Konsole::ProfileList::profileSelected, this, &MainWindow… | |||||
393 | 395 | | |||
394 | connect(list, &Konsole::ProfileList::actionsChanged, this, | 396 | connect(list, &Konsole::ProfileList::actionsChanged, this, | ||
395 | &Konsole::MainWindow::profileListChanged); | 397 | &Konsole::MainWindow::profileListChanged); | ||
396 | } | 398 | } | ||
397 | 399 | | |||
398 | void MainWindow::profileListChanged(const QList<QAction *> &sessionActions) | 400 | void MainWindow::profileListChanged(const QList<QAction *> &sessionActions) | ||
399 | { | 401 | { | ||
400 | // If only 1 profile is to be shown in the menu, only display | 402 | // If only 1 profile is to be shown in the menu, only display | ||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Line(s) | 461 | Q_FOREACH (const auto &url, urls) { | |||
462 | } else if (url.scheme() == QLatin1String("ssh")) { | 464 | } else if (url.scheme() == QLatin1String("ssh")) { | ||
463 | createSSHSession(_viewManager->activeContainer(), defaultProfile, url); | 465 | createSSHSession(_viewManager->activeContainer(), defaultProfile, url); | ||
464 | } | 466 | } | ||
465 | } | 467 | } | ||
466 | } | 468 | } | ||
467 | 469 | | |||
468 | void MainWindow::newTab(TabbedViewContainer *tabWidget) | 470 | void MainWindow::newTab(TabbedViewContainer *tabWidget) | ||
469 | { | 471 | { | ||
472 | qDebug() << "New Tab Triggered"; | ||||
470 | Profile::Ptr defaultProfile = ProfileManager::instance()->defaultProfile(); | 473 | Profile::Ptr defaultProfile = ProfileManager::instance()->defaultProfile(); | ||
471 | createSession(tabWidget, defaultProfile, activeSessionDir()); | 474 | createSession(tabWidget, defaultProfile, activeSessionDir()); | ||
472 | } | 475 | } | ||
473 | 476 | | |||
474 | void MainWindow::cloneTab() | 477 | void MainWindow::cloneTab() | ||
475 | { | 478 | { | ||
476 | Q_ASSERT(_pluggedController); | 479 | Q_ASSERT(_pluggedController); | ||
477 | 480 | | |||
Show All 21 Lines | 493 | { | |||
499 | } | 502 | } | ||
500 | 503 | | |||
501 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(_viewManager->managerId())); | 504 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(_viewManager->managerId())); | ||
502 | 505 | | |||
503 | // create view before starting the session process so that the session | 506 | // create view before starting the session process so that the session | ||
504 | // doesn't suffer a change in terminal size right after the session | 507 | // doesn't suffer a change in terminal size right after the session | ||
505 | // starts. Some applications such as GNU Screen and Midnight Commander | 508 | // starts. Some applications such as GNU Screen and Midnight Commander | ||
506 | // don't like this happening | 509 | // don't like this happening | ||
507 | _viewManager->createView(tabWidget, session); | 510 | auto newView = _viewManager->createView(session); | ||
508 | 511 | _viewManager->activeContainer()->addView(newView); | |||
509 | return session; | 512 | return session; | ||
510 | } | 513 | } | ||
511 | 514 | | |||
512 | Session *MainWindow::createSSHSession(TabbedViewContainer *tabWidget, Profile::Ptr profile, const QUrl &url) | 515 | Session *MainWindow::createSSHSession(TabbedViewContainer *tabWidget, Profile::Ptr profile, const QUrl &url) | ||
513 | { | 516 | { | ||
514 | if (!profile) { | 517 | if (!profile) { | ||
515 | profile = ProfileManager::instance()->defaultProfile(); | 518 | profile = ProfileManager::instance()->defaultProfile(); | ||
516 | } | 519 | } | ||
Show All 12 Lines | |||||
529 | } | 532 | } | ||
530 | 533 | | |||
531 | session->sendTextToTerminal(sshCommand, QLatin1Char('\r')); | 534 | session->sendTextToTerminal(sshCommand, QLatin1Char('\r')); | ||
532 | 535 | | |||
533 | // create view before starting the session process so that the session | 536 | // create view before starting the session process so that the session | ||
534 | // doesn't suffer a change in terminal size right after the session | 537 | // doesn't suffer a change in terminal size right after the session | ||
535 | // starts. some applications such as GNU Screen and Midnight Commander | 538 | // starts. some applications such as GNU Screen and Midnight Commander | ||
536 | // don't like this happening | 539 | // don't like this happening | ||
537 | _viewManager->createView(tabWidget, session); | 540 | auto newView = _viewManager->createView(session); | ||
538 | 541 | _viewManager->activeContainer()->addView(newView); | |||
539 | return session; | 542 | return session; | ||
540 | } | 543 | } | ||
541 | 544 | | |||
542 | void MainWindow::setFocus() | 545 | void MainWindow::setFocus() | ||
543 | { | 546 | { | ||
544 | _viewManager->activeView()->setFocus(); | 547 | _viewManager->activeView()->setFocus(); | ||
545 | } | 548 | } | ||
546 | 549 | | |||
▲ Show 20 Lines • Show All 344 Lines • Show Last 20 Lines |
Can you connect like: