Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Fix handling of dock widget title bars.

Fixes #368
parent 86635c2e
......@@ -28,10 +28,17 @@ HideTitleBars::HideTitleBars(QObject *parent)
void HideTitleBars::slotInstallRightClick()
{
// install right click
QList<QTabBar *> tabs = pCore->window()->findChildren<QTabBar *>();
for (int i = 0; i < tabs.count(); ++i) {
tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
connect(tabs.at(i), &QWidget::customContextMenuRequested, this, &HideTitleBars::slotSwitchTitleBars);
for (QTabBar *tab : tabs) {
tab->setContextMenuPolicy(Qt::CustomContextMenu);
connect(tab, &QWidget::customContextMenuRequested, this, &HideTitleBars::slotSwitchTitleBars);
}
// connect
QList<QDockWidget *> docks = pCore->window()->findChildren<QDockWidget *>();
for (QDockWidget *dock : docks) {
connect(dock, &QDockWidget::dockLocationChanged, pCore->window(), &MainWindow::slotUpdateDockLocation);
connect(dock, &QDockWidget::topLevelChanged, pCore->window(), &MainWindow::updateDockTitleBars);
}
slotShowTitleBars(KdenliveSettings::showtitlebars());
}
......@@ -39,10 +46,8 @@ void HideTitleBars::slotInstallRightClick()
void HideTitleBars::slotShowTitleBars(bool show)
{
QList<QDockWidget *> docks = pCore->window()->findChildren<QDockWidget *>();
for (int i = 0; i < docks.count(); ++i) {
QDockWidget *dock = docks.at(i);
for (QDockWidget *dock : docks) {
QWidget *bar = dock->titleBarWidget();
auto handleRemoveBar = [&dock, &bar]() -> void {
if (bar) {
dock->setTitleBarWidget(nullptr);
......@@ -51,7 +56,7 @@ void HideTitleBars::slotShowTitleBars(bool show)
};
if (!show) {
if (!dock->isFloating() && (bar == nullptr)) {
if (!dock->isFloating() && bar == nullptr) {
dock->setTitleBarWidget(new QWidget());
}
continue;
......@@ -69,8 +74,7 @@ void HideTitleBars::slotShowTitleBars(bool show)
}
const bool hasVisibleDockSibling =
std::find_if(std::begin(docked), std::end(docked), [](QDockWidget *sub) { return sub->toggleViewAction()->isChecked(); }) != std::end(docked);
;
std::find_if(std::begin(docked), std::end(docked), [](QDockWidget *sub) { return sub->toggleViewAction()->isChecked() && !sub->isTopLevel(); }) != std::end(docked);
if (!hasVisibleDockSibling) {
handleRemoveBar();
......
......@@ -3216,8 +3216,7 @@ void MainWindow::buildDynamicActions()
actionCollection()->addAction(showTimeline->text(), showTimeline);
QList<QDockWidget *> docks = findChildren<QDockWidget *>();
for (int j = 0; j < docks.count(); ++j) {
QDockWidget *dock = docks.at(j);
for (auto dock : docks) {
QAction *dockInformations = dock->toggleViewAction();
if (!dockInformations) {
continue;
......@@ -3464,13 +3463,12 @@ QDockWidget *MainWindow::addDock(const QString &title, const QString &objectName
dockWidget->setObjectName(objectName);
dockWidget->setWidget(widget);
addDockWidget(area, dockWidget);
connect(dockWidget, &QDockWidget::dockLocationChanged, this, &MainWindow::slotUpdateDockLocation);
connect(dockWidget, &QDockWidget::topLevelChanged, this, &MainWindow::updateDockTitleBars);
return dockWidget;
}
void MainWindow::slotUpdateDockLocation(Qt::DockWidgetArea dockLocationArea)
{
qDebug()<<"== UPDATING DOCK LOCATION FOR: "<<dockLocationArea;
if (dockLocationArea == Qt::NoDockWidgetArea) {
updateDockTitleBars(false);
} else {
......@@ -3519,8 +3517,8 @@ void MainWindow::doChangeStyle()
bool MainWindow::isTabbedWith(QDockWidget *widget, const QString &otherWidget)
{
QList<QDockWidget *> tabbed = tabifiedDockWidgets(widget);
for (int i = 0; i < tabbed.count(); i++) {
if (tabbed.at(i)->objectName() == otherWidget) {
for (auto tab : tabbed) {
if (tab->objectName() == otherWidget) {
return true;
}
}
......@@ -3534,11 +3532,9 @@ void MainWindow::updateDockTitleBars(bool isTopLevel)
}
QList<QDockWidget *> docks = findChildren<QDockWidget *>();
//qDebug()<<"=== FOUND DOCKS: "<<docks.count();
for (int i = 0; i < docks.count(); ++i) {
QDockWidget *dock = docks.at(i);
for (QDockWidget *dock : docks) {
QWidget *bar = dock->titleBarWidget();
if (dock->isFloating()) {
//qDebug()<<"==== FOUND FLOATING: "<<dock->objectName();
if (bar) {
dock->setTitleBarWidget(nullptr);
delete bar;
......@@ -3555,7 +3551,7 @@ void MainWindow::updateDockTitleBars(bool isTopLevel)
}
bool hasVisibleDockSibling = false;
for (QDockWidget *sub : docked) {
if (sub->toggleViewAction()->isChecked()) {
if (sub->toggleViewAction()->isChecked() && !sub->isTopLevel()) {
// we have another docked widget, so tabs are visible and can be used instead of title bars
hasVisibleDockSibling = true;
break;
......
......@@ -269,6 +269,8 @@ public slots:
/** @brief Reload project profile in config dialog if changed. */
void slotRefreshProfiles();
void updateDockTitleBars(bool isTopLevel = true);
/** @brief Add/remove Dock tile bar depending on state (tabbed, floating, ...) */
void slotUpdateDockLocation(Qt::DockWidgetArea dockLocationArea);
void configureToolbars() override;
/** @brief Decreases the timeline zoom level by 1. */
void slotZoomIn(bool zoomOnMouse = false);
......@@ -283,8 +285,6 @@ private slots:
/** @brief Shows the shortcut dialog. */
void slotEditKeys();
void loadDockActions();
/** @brief Add/remove Dock tile bar depending on state (tabbed, floating, ...) */
void slotUpdateDockLocation(Qt::DockWidgetArea dockLocationArea);
/** @brief Reflects setting changes to the GUI. */
void updateConfiguration();
void slotConnectMonitors();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment