Hide title bars of tabbed dockwidgets with Qt >= 5.6

parent 2b8f8a59
......@@ -18,11 +18,11 @@ the Free Software Foundation, either version 3 of the License, or
HideTitleBars::HideTitleBars(QObject* parent) :
QObject(parent)
{
QAction *showTitleBar = new QAction(i18n("Show Title Bars"), this);
showTitleBar->setCheckable(true);
showTitleBar->setChecked(KdenliveSettings::showtitlebars());
pCore->window()->addAction(QStringLiteral("show_titlebars"), showTitleBar);
connect(showTitleBar, SIGNAL(triggered(bool)), SLOT(slotShowTitleBars(bool)));
m_switchAction = new QAction(i18n("Show Title Bars"), this);
m_switchAction->setCheckable(true);
m_switchAction->setChecked(KdenliveSettings::showtitlebars());
pCore->window()->addAction(QStringLiteral("show_titlebars"), m_switchAction);
connect(m_switchAction, SIGNAL(triggered(bool)), SLOT(slotShowTitleBars(bool)));
slotShowTitleBars(KdenliveSettings::showtitlebars());
......@@ -36,6 +36,7 @@ void HideTitleBars::slotInstallRightClick()
tabs.at(i)->setContextMenuPolicy(Qt::CustomContextMenu);
connect(tabs.at(i), SIGNAL(customContextMenuRequested(QPoint)), SLOT(slotSwitchTitleBars()));
}
pCore->window()->updateDockTitleBars();
}
void HideTitleBars::slotShowTitleBars(bool show)
......@@ -44,7 +45,19 @@ void HideTitleBars::slotShowTitleBars(bool show)
for (int i = 0; i < docks.count(); ++i) {
QDockWidget* dock = docks.at(i);
if (show) {
dock->setTitleBarWidget(0);
QWidget *bar = dock->titleBarWidget();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
// Since Qt 5.6 we only display title bar in non tabbed dockwidgets
if (bar && pCore->window()->tabifiedDockWidgets(dock).isEmpty()) {
dock->setTitleBarWidget(0);
delete bar;
}
#else
if (bar) {
dock->setTitleBarWidget(0);
delete bar;
}
#endif
} else {
if (!dock->isFloating()) {
dock->setTitleBarWidget(new QWidget);
......@@ -56,7 +69,7 @@ void HideTitleBars::slotShowTitleBars(bool show)
void HideTitleBars::slotSwitchTitleBars()
{
slotShowTitleBars(!KdenliveSettings::showtitlebars());
m_switchAction->trigger();
}
......@@ -13,6 +13,7 @@ the Free Software Foundation, either version 3 of the License, or
#define HIDETITLEBARS_H
#include <QObject>
class QAction;
/**
* @class HideTitleBars
......@@ -26,6 +27,9 @@ class HideTitleBars : public QObject
public:
explicit HideTitleBars(QObject *parent = 0);
private:
QAction *m_switchAction;
private slots:
void slotInstallRightClick();
void slotShowTitleBars(bool show);
......
......@@ -240,6 +240,9 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
/// Add Widgets
setDockOptions(QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
setDockOptions(dockOptions() | QMainWindow::GroupedDragging);
#endif
setTabPosition(Qt::AllDockWidgetAreas, KdenliveSettings::verticaltabs() ? QTabWidget::East : QTabWidget::North);
QToolBar *timelineTb = new QToolBar(this);//pCore->window()->toolBar("timelineToolBar");
QWidget *ctn = new QWidget(this);
......@@ -3466,6 +3469,7 @@ QDockWidget *MainWindow::addDock(const QString &title, const QString &objectName
dockWidget->setObjectName(objectName);
dockWidget->setWidget(widget);
addDockWidget(area, dockWidget);
connect(dockWidget, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(updateDockTitleBars()));
return dockWidget;
}
......@@ -3503,15 +3507,30 @@ void MainWindow::doChangeStyle()
bool MainWindow::isTabbedWith(QDockWidget *widget, const QString & otherWidget)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
QList<QDockWidget *> tabbed = tabifiedDockWidgets(widget);
for (int i = 0; i < tabbed.count(); i++) {
if (tabbed.at(i)->objectName() == otherWidget)
return true;
}
return false;
#else
return false;
}
void MainWindow::updateDockTitleBars()
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QList <QDockWidget *> docks = pCore->window()->findChildren<QDockWidget *>();
for (int i = 0; i < docks.count(); ++i) {
QDockWidget* dock = docks.at(i);
if (dock->isFloating() || tabifiedDockWidgets(dock).isEmpty()) {
QWidget *bar = dock->titleBarWidget();
if (bar) {
dock->setTitleBarWidget(0);
delete bar;
}
} else {
dock->setTitleBarWidget(new QWidget);
}
}
#endif
}
......
......@@ -259,6 +259,7 @@ public slots:
void slotTimelineClipSelected(ClipItem* item, bool reloadStack = true, bool raise = true);
/** @brief Reload project profile in config dialog if changed. */
void slotRefreshProfiles();
void updateDockTitleBars();
private slots:
/** @brief Shows the shortcut dialog. */
......
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