Changeset View
Changeset View
Standalone View
Standalone View
src/TerminalHeaderBar.cpp
- This file was added.
1 | #include "TerminalHeaderBar.h" | ||||
---|---|---|---|---|---|
2 | | ||||
3 | #include "TerminalDisplay.h" | ||||
4 | #include "SessionController.h" | ||||
5 | #include "ViewProperties.h" | ||||
6 | | ||||
7 | #include <KLocalizedString> | ||||
8 | #include <QBoxLayout> | ||||
9 | #include <QToolButton> | ||||
10 | #include <QMenu> | ||||
11 | #include <QLabel> | ||||
12 | #include <QAction> | ||||
13 | #include <KToolBarLabelAction> | ||||
14 | #include <QToolButton> | ||||
15 | #include <QDebug> | ||||
16 | | ||||
17 | namespace Konsole { | ||||
18 | | ||||
19 | TerminalHeaderBar::TerminalHeaderBar(QWidget *parent) | ||||
20 | : QWidget(parent) | ||||
21 | { | ||||
22 | m_closeBtn = new QToolButton(this); | ||||
23 | m_closeBtn->setIcon(QIcon::fromTheme(QStringLiteral("tab-close"))); | ||||
24 | m_closeBtn->setToolTip(i18nc("@action:itooltip", "Close terminal")); | ||||
25 | m_closeBtn->setText(i18nc("@action:itooltip", "Close terminal")); | ||||
26 | m_closeBtn->setObjectName(QStringLiteral("close-terminal-button")); | ||||
27 | m_closeBtn->setAutoRaise(true); | ||||
28 | | ||||
29 | m_toggleExpandedMode = new QToolButton(this); | ||||
30 | m_toggleExpandedMode->setIcon(QIcon::fromTheme(QStringLiteral("format-font-size-more"))); // fake 'expand' icon. VDG input? | ||||
31 | m_toggleExpandedMode->setAutoRaise(true); | ||||
32 | | ||||
33 | m_terminalTitle = new QLabel(this); | ||||
34 | m_terminalIcon = new QLabel(this); | ||||
35 | m_terminalActivity = new QLabel(this); | ||||
36 | | ||||
37 | m_boxLayout = new QBoxLayout(QBoxLayout::LeftToRight); | ||||
38 | m_boxLayout->setSpacing(0); | ||||
39 | m_boxLayout->setMargin(0); | ||||
40 | | ||||
41 | // Layout Setup | ||||
42 | m_boxLayout->addStretch(); | ||||
43 | m_boxLayout->addWidget(m_terminalIcon); | ||||
44 | m_boxLayout->addWidget(m_terminalTitle); | ||||
45 | m_boxLayout->addWidget(m_terminalActivity); | ||||
46 | m_boxLayout->addStretch(); | ||||
47 | m_boxLayout->addWidget(m_toggleExpandedMode); | ||||
48 | m_boxLayout->addWidget(m_closeBtn); | ||||
49 | setLayout(m_boxLayout); | ||||
50 | | ||||
51 | setAutoFillBackground(true); | ||||
52 | } | ||||
53 | | ||||
54 | // Hack untill I can detangle the creation of the TerminalViews | ||||
55 | void TerminalHeaderBar::finishHeaderSetup(ViewProperties *properties) | ||||
56 | { | ||||
57 | //TODO: Fix ViewProperties signals. | ||||
58 | connect(properties, &Konsole::ViewProperties::titleChanged, this, | ||||
59 | [this, properties]{ | ||||
60 | m_terminalTitle->setText(properties->title()); | ||||
61 | }); | ||||
62 | | ||||
63 | connect(m_closeBtn, &QToolButton::clicked, this, [properties]{ | ||||
64 | auto controller = qobject_cast<SessionController*>(properties); | ||||
65 | controller->closeSession(); | ||||
66 | }); | ||||
67 | | ||||
68 | connect(properties, &Konsole::ViewProperties::iconChanged, this, [this, properties] { | ||||
69 | m_terminalIcon->setPixmap(properties->icon().pixmap(QSize(22,22))); | ||||
70 | }); | ||||
71 | | ||||
72 | connect(properties, &Konsole::ViewProperties::activity, this, [this]{ | ||||
73 | m_terminalActivity->setPixmap(QPixmap()); | ||||
74 | }); | ||||
75 | | ||||
76 | connect(m_toggleExpandedMode, &QToolButton::clicked, | ||||
77 | this, &TerminalHeaderBar::requestToggleExpansion); | ||||
78 | } | ||||
79 | | ||||
80 | void TerminalHeaderBar::terminalFocusIn() | ||||
81 | { | ||||
82 | m_terminalTitle->setEnabled(true); | ||||
83 | } | ||||
84 | | ||||
85 | void TerminalHeaderBar::terminalFocusOut() | ||||
86 | { | ||||
87 | // TODO: Don't focusOut if searchBar is enabled. | ||||
88 | m_terminalTitle->setEnabled(false); | ||||
89 | } | ||||
90 | | ||||
91 | } |