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