Commit 818c0a7e authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add an option to hide the docker titlebars

Inspired by kdenlive, this small patch adds the option to show/hide the
titlebars of all dockers to the settings menu.

Patch by Moritz Molch. Thanks!
CCMAIL:kde@moritzmolch.de
REVIEW:122753
parent 4f3054a0
...@@ -216,6 +216,7 @@ ...@@ -216,6 +216,7 @@
<Action name="theme_menu" icon="" text="&amp;Themes" whatsThis="" toolTip="Themes" iconText="Themes" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/> <Action name="theme_menu" icon="" text="&amp;Themes" whatsThis="" toolTip="Themes" iconText="Themes" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/>
<Action name="fullscreen" icon="view-fullscreen" text="F&amp;ull Screen Mode" whatsThis="" toolTip="Display the window in full screen" iconText="Full Screen Mode" shortcut="Ctrl+Shift+F" defaultShortcut="Ctrl+Shift+F" isCheckable="false" statusTip=""/> <Action name="fullscreen" icon="view-fullscreen" text="F&amp;ull Screen Mode" whatsThis="" toolTip="Display the window in full screen" iconText="Full Screen Mode" shortcut="Ctrl+Shift+F" defaultShortcut="Ctrl+Shift+F" isCheckable="false" statusTip=""/>
<Action name="view_toggledockers" icon="" text="Show Dockers" whatsThis="" toolTip="Show Dockers" iconText="Show Dockers" shortcut="" defaultShortcut="" isCheckable="true" statusTip=""/> <Action name="view_toggledockers" icon="" text="Show Dockers" whatsThis="" toolTip="Show Dockers" iconText="Show Dockers" shortcut="" defaultShortcut="" isCheckable="true" statusTip=""/>
<Action name="view_toggledockertitlebars" icon="" text="Show Docker Titlebars" whatsThis="" toolTip="Show Docker Titlebars" iconText="Show Docker Titlebars" shortcut="" defaultShortcut="" isCheckable="true" statusTip=""/>
<Action name="settings_dockers_menu" icon="" text="Dockers" whatsThis="" toolTip="Dockers" iconText="Dockers" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/> <Action name="settings_dockers_menu" icon="" text="Dockers" whatsThis="" toolTip="Dockers" iconText="Dockers" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/>
<Action name="window" icon="" text="&amp;Window" whatsThis="" toolTip="Window" iconText="Window" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/> <Action name="window" icon="" text="&amp;Window" whatsThis="" toolTip="Window" iconText="Window" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/>
<Action name="windows_cascade" icon="" text="Cascade" whatsThis="" toolTip="Cascade" iconText="Cascade" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/> <Action name="windows_cascade" icon="" text="Cascade" whatsThis="" toolTip="Cascade" iconText="Cascade" shortcut="" defaultShortcut="" isCheckable="false" statusTip=""/>
......
...@@ -251,6 +251,7 @@ ...@@ -251,6 +251,7 @@
<Merge name="StandardToolBarMenuHandler" /> <Merge name="StandardToolBarMenuHandler" />
<Separator/> <Separator/>
<Action name="view_toggledockers"/> <Action name="view_toggledockers"/>
<Action name="view_toggledockertitlebars"/>
<Action name="settings_dockers_menu"/> <Action name="settings_dockers_menu"/>
<Separator/> <Separator/>
<Action name="theme_menu"/> <Action name="theme_menu"/>
......
...@@ -181,6 +181,7 @@ public: ...@@ -181,6 +181,7 @@ public:
, mdiNextWindow(0) , mdiNextWindow(0)
, mdiPreviousWindow(0) , mdiPreviousWindow(0)
, toggleDockers(0) , toggleDockers(0)
, toggleDockerTitleBars(0)
, dockWidgetMenu(new KActionMenu(i18nc("@action:inmenu", "&Dockers"), parent)) , dockWidgetMenu(new KActionMenu(i18nc("@action:inmenu", "&Dockers"), parent))
, windowMenu(new KActionMenu(i18nc("@action:inmenu", "&Window"), parent)) , windowMenu(new KActionMenu(i18nc("@action:inmenu", "&Window"), parent))
, documentMenu(new KActionMenu(i18nc("@action:inmenu", "New &View"), parent)) , documentMenu(new KActionMenu(i18nc("@action:inmenu", "New &View"), parent))
...@@ -237,6 +238,7 @@ public: ...@@ -237,6 +238,7 @@ public:
KisAction *mdiNextWindow; KisAction *mdiNextWindow;
KisAction *mdiPreviousWindow; KisAction *mdiPreviousWindow;
KisAction *toggleDockers; KisAction *toggleDockers;
KisAction *toggleDockerTitleBars;
KActionMenu *dockWidgetMenu; KActionMenu *dockWidgetMenu;
KActionMenu *windowMenu; KActionMenu *windowMenu;
...@@ -1660,6 +1662,11 @@ QDockWidget* KisMainWindow::createDockWidget(KoDockFactoryBase* factory) ...@@ -1660,6 +1662,11 @@ QDockWidget* KisMainWindow::createDockWidget(KoDockFactoryBase* factory)
if (titleBar && locked) if (titleBar && locked)
titleBar->setLocked(true); titleBar->setLocked(true);
if (titleBar) {
KisConfig cfg;
titleBar->setVisible(cfg.showDockerTitleBars());
}
d->dockWidgetsMap.insert(factory->id(), dockWidget); d->dockWidgetsMap.insert(factory->id(), dockWidget);
} else { } else {
dockWidget = d->dockWidgetsMap[factory->id()]; dockWidget = d->dockWidgetsMap[factory->id()];
...@@ -2059,6 +2066,13 @@ void KisMainWindow::createActions() ...@@ -2059,6 +2066,13 @@ void KisMainWindow::createActions()
actionManager->addAction("view_toggledockers", d->toggleDockers); actionManager->addAction("view_toggledockers", d->toggleDockers);
connect(d->toggleDockers, SIGNAL(toggled(bool)), SLOT(toggleDockersVisibility(bool))); connect(d->toggleDockers, SIGNAL(toggled(bool)), SLOT(toggleDockersVisibility(bool)));
d->toggleDockerTitleBars = new KisAction(i18nc("@action:inmenu", "Show Docker Titlebars"));
d->toggleDockerTitleBars->setCheckable(true);
KisConfig cfg;
d->toggleDockerTitleBars->setChecked(cfg.showDockerTitleBars());
actionManager->addAction("view_toggledockertitlebars", d->toggleDockerTitleBars);
connect(d->toggleDockerTitleBars, SIGNAL(toggled(bool)), SLOT(showDockerTitleBars(bool)));
actionCollection()->addAction("settings_dockers_menu", d->dockWidgetMenu); actionCollection()->addAction("settings_dockers_menu", d->dockWidgetMenu);
actionCollection()->addAction("window", d->windowMenu); actionCollection()->addAction("window", d->windowMenu);
...@@ -2137,5 +2151,17 @@ void KisMainWindow::initializeGeometry() ...@@ -2137,5 +2151,17 @@ void KisMainWindow::initializeGeometry()
restoreWorkspace(QByteArray::fromBase64(cfg.readEntry("ko_windowstate", QByteArray()))); restoreWorkspace(QByteArray::fromBase64(cfg.readEntry("ko_windowstate", QByteArray())));
} }
void KisMainWindow::showDockerTitleBars(bool show)
{
foreach (QDockWidget *dock, dockWidgets()) {
if (dock->titleBarWidget()) {
dock->titleBarWidget()->setVisible(show);
}
}
KisConfig cfg;
cfg.setShowDockerTitleBars(show);
}
#include <KisMainWindow.moc> #include <KisMainWindow.moc>
...@@ -316,6 +316,11 @@ private Q_SLOTS: ...@@ -316,6 +316,11 @@ private Q_SLOTS:
*/ */
void viewFullscreen(bool fullScreen); void viewFullscreen(bool fullScreen);
/**
* Toggle docker titlebars on/off.
*/
void showDockerTitleBars(bool show);
/** /**
* Reload file * Reload file
*/ */
......
...@@ -1027,6 +1027,16 @@ void KisConfig::setHideDockersFullscreen(const int value) const ...@@ -1027,6 +1027,16 @@ void KisConfig::setHideDockersFullscreen(const int value) const
m_cfg.writeEntry("hideDockersFullScreen", value); m_cfg.writeEntry("hideDockersFullScreen", value);
} }
bool KisConfig::showDockerTitleBars() const
{
return m_cfg.readEntry("showDockerTitleBars", true);
}
void KisConfig::setShowDockerTitleBars(const bool value) const
{
m_cfg.writeEntry("showDockerTitleBars", value);
}
int KisConfig::hideMenuFullscreen() const int KisConfig::hideMenuFullscreen() const
{ {
return m_cfg.readEntry("hideMenuFullScreen", (int)Qt::Checked); return m_cfg.readEntry("hideMenuFullScreen", (int)Qt::Checked);
......
...@@ -309,6 +309,9 @@ public: ...@@ -309,6 +309,9 @@ public:
int hideDockersFullscreen() const; int hideDockersFullscreen() const;
void setHideDockersFullscreen(const int value) const; void setHideDockersFullscreen(const int value) const;
bool showDockerTitleBars() const;
void setShowDockerTitleBars(const bool value) const;
int hideMenuFullscreen() const; int hideMenuFullscreen() const;
void setHideMenuFullscreen(const int value) const; void setHideMenuFullscreen(const int value) const;
......
...@@ -220,6 +220,7 @@ public: ...@@ -220,6 +220,7 @@ public:
KAction *uncompressToDir; KAction *uncompressToDir;
#endif #endif
KToggleAction *toggleDockers; KToggleAction *toggleDockers;
KToggleAction *toggleDockerTitleBars;
KRecentFilesAction *recent; KRecentFilesAction *recent;
bool isImporting; bool isImporting;
...@@ -366,9 +367,15 @@ KoMainWindow::KoMainWindow(const QByteArray nativeMimeType, const KComponentData ...@@ -366,9 +367,15 @@ KoMainWindow::KoMainWindow(const QByteArray nativeMimeType, const KComponentData
d->toggleDockers = new KToggleAction(i18n("Show Dockers"), this); d->toggleDockers = new KToggleAction(i18n("Show Dockers"), this);
d->toggleDockers->setChecked(true); d->toggleDockers->setChecked(true);
actionCollection()->addAction("view_toggledockers", d->toggleDockers); actionCollection()->addAction("view_toggledockers", d->toggleDockers);
connect(d->toggleDockers, SIGNAL(toggled(bool)), SLOT(toggleDockersVisibility(bool))); connect(d->toggleDockers, SIGNAL(toggled(bool)), SLOT(toggleDockersVisibility(bool)));
d->toggleDockerTitleBars = new KToggleAction(i18nc("@action:inmenu", "Show Docker Titlebars"), this);
KConfigGroup configGroupInterface = KGlobal::config()->group("Interface");
d->toggleDockerTitleBars->setChecked(configGroupInterface.readEntry("ShowDockerTitleBars", true));
d->toggleDockerTitleBars->setVisible(false);
actionCollection()->addAction("view_toggledockertitlebars", d->toggleDockerTitleBars);
connect(d->toggleDockerTitleBars, SIGNAL(toggled(bool)), SLOT(showDockerTitleBars(bool)));
d->dockWidgetMenu = new KActionMenu(i18n("Dockers"), this); d->dockWidgetMenu = new KActionMenu(i18n("Dockers"), this);
actionCollection()->addAction("settings_dockers_menu", d->dockWidgetMenu); actionCollection()->addAction("settings_dockers_menu", d->dockWidgetMenu);
d->dockWidgetMenu->setVisible(false); d->dockWidgetMenu->setVisible(false);
...@@ -506,6 +513,7 @@ void KoMainWindow::setRootDocument(KoDocument *doc, KoPart *part, bool deletePre ...@@ -506,6 +513,7 @@ void KoMainWindow::setRootDocument(KoDocument *doc, KoPart *part, bool deletePre
dockWidget->setVisible(false); dockWidget->setVisible(false);
} }
d->toggleDockerTitleBars->setVisible(false);
d->dockWidgetMenu->setVisible(false); d->dockWidgetMenu->setVisible(false);
} }
...@@ -519,6 +527,7 @@ void KoMainWindow::setRootDocument(KoDocument *doc, KoPart *part, bool deletePre ...@@ -519,6 +527,7 @@ void KoMainWindow::setRootDocument(KoDocument *doc, KoPart *part, bool deletePre
} }
if (doc) { if (doc) {
d->toggleDockerTitleBars->setVisible(true);
d->dockWidgetMenu->setVisible(true); d->dockWidgetMenu->setVisible(true);
d->m_registeredPart = d->rootPart.data(); d->m_registeredPart = d->rootPart.data();
...@@ -1860,6 +1869,11 @@ QDockWidget* KoMainWindow::createDockWidget(KoDockFactoryBase* factory) ...@@ -1860,6 +1869,11 @@ QDockWidget* KoMainWindow::createDockWidget(KoDockFactoryBase* factory)
if (titleBar && locked) if (titleBar && locked)
titleBar->setLocked(true); titleBar->setLocked(true);
if (titleBar) {
KConfigGroup configGroupInterface = KGlobal::config()->group("Interface");
titleBar->setVisible(configGroupInterface.readEntry("ShowDockerTitleBars", true));
}
d->dockWidgetsMap.insert(factory->id(), dockWidget); d->dockWidgetsMap.insert(factory->id(), dockWidget);
} else { } else {
dockWidget = d->dockWidgetsMap[ factory->id()]; dockWidget = d->dockWidgetsMap[ factory->id()];
...@@ -2065,8 +2079,13 @@ void KoMainWindow::setActivePart(KoPart *part, QWidget *widget ) ...@@ -2065,8 +2079,13 @@ void KoMainWindow::setActivePart(KoPart *part, QWidget *widget )
// Position and show toolbars according to user's preference // Position and show toolbars according to user's preference
setAutoSaveSettings(newPart->componentData().componentName(), false); setAutoSaveSettings(newPart->componentData().componentName(), false);
KConfigGroup configGroupInterface = KGlobal::config()->group("Interface");
const bool showDockerTitleBar = configGroupInterface.readEntry("ShowDockerTitleBars", true);
foreach (QDockWidget *wdg, d->dockWidgets) { foreach (QDockWidget *wdg, d->dockWidgets) {
if ((wdg->features() & QDockWidget::DockWidgetClosable) == 0) { if ((wdg->features() & QDockWidget::DockWidgetClosable) == 0) {
if (wdg->titleBarWidget()) {
wdg->titleBarWidget()->setVisible(showDockerTitleBar);
}
wdg->setVisible(true); wdg->setVisible(true);
} }
} }
...@@ -2113,7 +2132,17 @@ void KoMainWindow::slotDocumentTitleModified(const QString &caption, bool mod) ...@@ -2113,7 +2132,17 @@ void KoMainWindow::slotDocumentTitleModified(const QString &caption, bool mod)
} }
void KoMainWindow::showDockerTitleBars(bool show)
{
foreach (QDockWidget *dock, dockWidgets()) {
if (dock->titleBarWidget()) {
dock->titleBarWidget()->setVisible(show);
}
}
KConfigGroup configGroupInterface = KGlobal::config()->group("Interface");
configGroupInterface.writeEntry("ShowDockerTitleBars", show);
}
......
...@@ -285,6 +285,11 @@ public Q_SLOTS: ...@@ -285,6 +285,11 @@ public Q_SLOTS:
*/ */
void viewFullscreen(bool fullScreen); void viewFullscreen(bool fullScreen);
/**
* Toggle docker titlebars on/off.
*/
void showDockerTitleBars(bool show);
/** /**
* Reload file * Reload file
*/ */
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
<DefineGroup name="settings_top"/> <DefineGroup name="settings_top"/>
<Merge/> <Merge/>
<!-- <ActionList name="toolbarlist"/> --> <!-- <ActionList name="toolbarlist"/> -->
<Action name="view_toggledockertitlebars"/>
<Action name="settings_dockers_menu"/> <Action name="settings_dockers_menu"/>
<DefineGroup name="settings_show"/> <DefineGroup name="settings_show"/>
<Separator/> <Separator/>
......
...@@ -99,6 +99,10 @@ QSize KoDockWidgetTitleBar::minimumSizeHint() const ...@@ -99,6 +99,10 @@ QSize KoDockWidgetTitleBar::minimumSizeHint() const
QSize KoDockWidgetTitleBar::sizeHint() const QSize KoDockWidgetTitleBar::sizeHint() const
{ {
if (isHidden()) {
return QSize(0, 0);
}
QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget()); QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q); int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
......
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