Changeset View
Changeset View
Standalone View
Standalone View
src/ViewContainer.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
52 | TabbedViewContainer::TabbedViewContainer(ViewManager *connectedViewManager, QWidget *parent) : | 52 | TabbedViewContainer::TabbedViewContainer(ViewManager *connectedViewManager, QWidget *parent) : | ||
53 | QTabWidget(parent), | 53 | QTabWidget(parent), | ||
54 | _connectedViewManager(connectedViewManager), | 54 | _connectedViewManager(connectedViewManager), | ||
55 | _newTabButton(new QToolButton()), | 55 | _newTabButton(new QToolButton()), | ||
56 | _closeTabButton(new QToolButton()), | 56 | _closeTabButton(new QToolButton()), | ||
57 | _contextMenuTabIndex(-1), | 57 | _contextMenuTabIndex(-1), | ||
58 | _navigationVisibility(ViewManager::NavigationVisibility::NavigationNotSet) | 58 | _navigationVisibility(ViewManager::NavigationVisibility::NavigationNotSet) | ||
59 | { | 59 | { | ||
60 | setAcceptDrops(true); | ||||
61 | | ||||
60 | auto tabBarWidget = new DetachableTabBar(); | 62 | auto tabBarWidget = new DetachableTabBar(); | ||
61 | setTabBar(tabBarWidget); | 63 | setTabBar(tabBarWidget); | ||
62 | setDocumentMode(true); | 64 | setDocumentMode(true); | ||
63 | setMovable(true); | 65 | setMovable(true); | ||
64 | 66 | connect(tabBarWidget, &DetachableTabBar::moveTabToWindow, this, &TabbedViewContainer::moveTabToWindow); | |||
65 | tabBar()->setContextMenuPolicy(Qt::CustomContextMenu); | 67 | tabBar()->setContextMenuPolicy(Qt::CustomContextMenu); | ||
66 | | ||||
67 | _newTabButton->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); | 68 | _newTabButton->setIcon(QIcon::fromTheme(QStringLiteral("document-new"))); | ||
68 | _newTabButton->setAutoRaise(true); | 69 | _newTabButton->setAutoRaise(true); | ||
69 | connect(_newTabButton, &QToolButton::clicked, this, [this]{ | 70 | connect(_newTabButton, &QToolButton::clicked, this, [this]{ | ||
70 | emit newViewRequest(); | 71 | emit newViewRequest(); | ||
71 | }); | 72 | }); | ||
72 | 73 | | |||
73 | _closeTabButton->setIcon(QIcon::fromTheme(QStringLiteral("tab-close"))); | 74 | _closeTabButton->setIcon(QIcon::fromTheme(QStringLiteral("tab-close"))); | ||
74 | _closeTabButton->setAutoRaise(true); | 75 | _closeTabButton->setAutoRaise(true); | ||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Line(s) | 140 | { | |||
140 | for(int i = 0, end = count(); i < end; i++) { | 141 | for(int i = 0, end = count(); i < end; i++) { | ||
141 | auto view = widget(i); | 142 | auto view = widget(i); | ||
142 | disconnect(view, &QWidget::destroyed, this, &Konsole::TabbedViewContainer::viewDestroyed); | 143 | disconnect(view, &QWidget::destroyed, this, &Konsole::TabbedViewContainer::viewDestroyed); | ||
143 | } | 144 | } | ||
144 | 145 | | |||
145 | emit destroyed(this); | 146 | emit destroyed(this); | ||
146 | } | 147 | } | ||
147 | 148 | | |||
149 | void TabbedViewContainer::moveTabToWindow(int index, QWidget *window) | ||||
150 | { | ||||
151 | const int id = viewProperties(widget(index))->identifier(); | ||||
152 | // This one line here will be removed as soon as I finish my new split handling. | ||||
153 | // it's hacky but it works. | ||||
154 | const auto widgets = window->findChildren<TabbedViewContainer*>(); | ||||
155 | const auto currentPos = QCursor::pos(); | ||||
156 | for(const auto dropWidget : widgets) { | ||||
157 | if (dropWidget->rect().contains(dropWidget->mapFromGlobal(currentPos))) { | ||||
158 | dropWidget->moveViewRequest(-1, id, this); | ||||
159 | removeView(widget(index)); | ||||
160 | } | ||||
161 | } | ||||
162 | } | ||||
163 | | ||||
148 | void TabbedViewContainer::konsoleConfigChanged() | 164 | void TabbedViewContainer::konsoleConfigChanged() | ||
149 | { | 165 | { | ||
150 | // if we start with --show-tabbar or --hide-tabbar we ignore the preferences. | 166 | // if we start with --show-tabbar or --hide-tabbar we ignore the preferences. | ||
151 | setTabBarAutoHide(KonsoleSettings::tabBarVisibility() == KonsoleSettings::EnumTabBarVisibility::ShowTabBarWhenNeeded); | 167 | setTabBarAutoHide(KonsoleSettings::tabBarVisibility() == KonsoleSettings::EnumTabBarVisibility::ShowTabBarWhenNeeded); | ||
152 | if (KonsoleSettings::tabBarVisibility() == KonsoleSettings::EnumTabBarVisibility::AlwaysShowTabBar) { | 168 | if (KonsoleSettings::tabBarVisibility() == KonsoleSettings::EnumTabBarVisibility::AlwaysShowTabBar) { | ||
153 | tabBar()->setVisible(true); | 169 | tabBar()->setVisible(true); | ||
154 | } else if (KonsoleSettings::tabBarVisibility() == KonsoleSettings::EnumTabBarVisibility::AlwaysHideTabBar) { | 170 | } else if (KonsoleSettings::tabBarVisibility() == KonsoleSettings::EnumTabBarVisibility::AlwaysHideTabBar) { | ||
155 | tabBar()->setVisible(false); | 171 | tabBar()->setVisible(false); | ||
▲ Show 20 Lines • Show All 295 Lines • Show Last 20 Lines |