Changeset View
Changeset View
Standalone View
Standalone View
src/ViewSplitter.cpp
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | 116 | { | |||
---|---|---|---|---|---|
119 | if (event->removed()) { | 119 | if (event->removed()) { | ||
120 | if (count() == 0) { | 120 | if (count() == 0) { | ||
121 | deleteLater(); | 121 | deleteLater(); | ||
122 | } | 122 | } | ||
123 | if (!findChild<TerminalDisplay*>()) { | 123 | if (!findChild<TerminalDisplay*>()) { | ||
124 | deleteLater(); | 124 | deleteLater(); | ||
125 | } | 125 | } | ||
126 | } | 126 | } | ||
127 | | ||||
128 | auto terminals = getToplevelSplitter()->findChildren<TerminalDisplay*>(); | ||||
129 | if (terminals.size() == 1) { | ||||
130 | terminals.at(0)->headerBar()->setVisible(false); | ||||
131 | } else { | ||||
132 | for(auto terminal : terminals) { | ||||
133 | terminal->headerBar()->setVisible(true); | ||||
134 | } | ||||
135 | } | ||||
127 | } | 136 | } | ||
128 | 137 | | |||
129 | void ViewSplitter::handleFocusDirection(Qt::Orientation orientation, int direction) | 138 | void ViewSplitter::handleFocusDirection(Qt::Orientation orientation, int direction) | ||
130 | { | 139 | { | ||
131 | auto terminalDisplay = activeTerminalDisplay(); | 140 | auto terminalDisplay = activeTerminalDisplay(); | ||
132 | auto parentSplitter = qobject_cast<ViewSplitter*>(terminalDisplay->parentWidget()); | 141 | auto parentSplitter = qobject_cast<ViewSplitter*>(terminalDisplay->parentWidget()); | ||
133 | auto topSplitter = parentSplitter->getToplevelSplitter(); | 142 | auto topSplitter = parentSplitter->getToplevelSplitter(); | ||
134 | 143 | | |||
Show All 10 Lines | 153 | const int newY = orientation != Qt::Vertical ? startMapped.y() + handleWidth | |||
145 | : direction == 1 ? startMapped.y() + terminalDisplay->height() + handleWidth | 154 | : direction == 1 ? startMapped.y() + terminalDisplay->height() + handleWidth | ||
146 | : startMapped.y() - handleWidth; | 155 | : startMapped.y() - handleWidth; | ||
147 | 156 | | |||
148 | const auto newPoint = QPoint(newX, newY); | 157 | const auto newPoint = QPoint(newX, newY); | ||
149 | auto child = topSplitter->childAt(newPoint); | 158 | auto child = topSplitter->childAt(newPoint); | ||
150 | 159 | | |||
151 | if (TerminalDisplay* terminal = qobject_cast<TerminalDisplay*>(child)) { | 160 | if (TerminalDisplay* terminal = qobject_cast<TerminalDisplay*>(child)) { | ||
152 | terminal->setFocus(Qt::OtherFocusReason); | 161 | terminal->setFocus(Qt::OtherFocusReason); | ||
153 | } else if (qobject_cast<QScrollBar*>(child)) { | | |||
154 | auto scrollbarTerminal = qobject_cast<TerminalDisplay*>(child->parent()); | | |||
155 | scrollbarTerminal->setFocus(Qt::OtherFocusReason); | | |||
156 | } else if (qobject_cast<QSplitterHandle*>(child)) { | 162 | } else if (qobject_cast<QSplitterHandle*>(child)) { | ||
157 | auto targetSplitter = qobject_cast<QSplitter*>(child->parent()); | 163 | auto targetSplitter = qobject_cast<QSplitter*>(child->parent()); | ||
158 | auto splitterTerminal = qobject_cast<TerminalDisplay*>(targetSplitter->widget(0)); | 164 | auto splitterTerminal = qobject_cast<TerminalDisplay*>(targetSplitter->widget(0)); | ||
159 | splitterTerminal->setFocus(Qt::OtherFocusReason); | 165 | splitterTerminal->setFocus(Qt::OtherFocusReason); | ||
166 | } else if (qobject_cast<QWidget*>(child)) { | ||||
167 | TerminalDisplay *terminalParent = nullptr; | ||||
168 | while(!terminalParent) { | ||||
169 | terminalParent = qobject_cast<TerminalDisplay*>(child->parentWidget()); | ||||
170 | child = child->parentWidget(); | ||||
171 | } | ||||
172 | terminalParent->setFocus(Qt::OtherFocusReason); | ||||
160 | } | 173 | } | ||
161 | } | 174 | } | ||
162 | 175 | | |||
163 | void ViewSplitter::focusUp() | 176 | void ViewSplitter::focusUp() | ||
164 | { | 177 | { | ||
165 | handleFocusDirection(Qt::Vertical, -1); | 178 | handleFocusDirection(Qt::Vertical, -1); | ||
166 | } | 179 | } | ||
167 | 180 | | |||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |