mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 21:25:44 +08:00
Added showcase for custom title bar widget to demo application
This commit is contained in:
parent
efb9b879dd
commit
c4872c6b10
@ -57,6 +57,8 @@
|
|||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <QAxWidget>
|
#include <QAxWidget>
|
||||||
@ -68,6 +70,8 @@
|
|||||||
#include "DockManager.h"
|
#include "DockManager.h"
|
||||||
#include "DockWidget.h"
|
#include "DockWidget.h"
|
||||||
#include "DockAreaWidget.h"
|
#include "DockAreaWidget.h"
|
||||||
|
#include "DockAreaTitleBar.h"
|
||||||
|
#include "DockAreaTabBar.h"
|
||||||
#include "FloatingDockContainer.h"
|
#include "FloatingDockContainer.h"
|
||||||
|
|
||||||
|
|
||||||
@ -315,10 +319,32 @@ void MainWindowPrivate::createContent()
|
|||||||
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
|
FileSystemWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
|
||||||
appendFeaturStringToWindowTitle(FileSystemWidget);
|
appendFeaturStringToWindowTitle(FileSystemWidget);
|
||||||
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
|
auto TopDockArea = DockManager->addDockWidget(ads::TopDockWidgetArea, FileSystemWidget);
|
||||||
|
|
||||||
|
// We create a calender widget and clear all flags to prevent the dock area
|
||||||
|
// from closing
|
||||||
DockWidget = createCalendarDockWidget(ViewMenu);
|
DockWidget = createCalendarDockWidget(ViewMenu);
|
||||||
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetClosable, false);
|
||||||
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetMovable, false);
|
||||||
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetFloatable, false);
|
||||||
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
|
DockWidget->setTabToolTip(QString("Tab ToolTip\nHodie est dies magna"));
|
||||||
DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
auto DockArea = DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea);
|
||||||
|
|
||||||
|
// Now we add a custom button to the dock area title bar that will create
|
||||||
|
// new editor widgets when clicked
|
||||||
|
auto CustomButton = new QToolButton(DockArea);
|
||||||
|
CustomButton->setToolTip(QObject::tr("Create Editor"));
|
||||||
|
CustomButton->setIcon(svgIcon(":/adsdemo/images/plus.svg"));
|
||||||
|
CustomButton->setAutoRaise(true);
|
||||||
|
auto TitleBar = DockArea->titleBar();
|
||||||
|
int Index = TitleBar->indexOf(TitleBar->tabBar());
|
||||||
|
TitleBar->insertWidget(Index + 1, CustomButton);
|
||||||
|
QObject::connect(CustomButton, &QToolButton::clicked, [=]()
|
||||||
|
{
|
||||||
|
auto DockWidget = createEditorWidget(ui.menuView);
|
||||||
|
DockWidget->setFeature(ads::CDockWidget::DockWidgetDeleteOnClose, true);
|
||||||
|
DockManager->addDockWidgetTabToArea(DockWidget, DockArea);
|
||||||
|
_this->connect(DockWidget, SIGNAL(closeRequested()), SLOT(onEditorCloseRequested()));
|
||||||
|
});
|
||||||
|
|
||||||
// Test dock area docking
|
// Test dock area docking
|
||||||
auto RighDockArea = DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), TopDockArea);
|
auto RighDockArea = DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), TopDockArea);
|
||||||
|
@ -11,5 +11,6 @@
|
|||||||
<file>images/grid_on.svg</file>
|
<file>images/grid_on.svg</file>
|
||||||
<file>images/custom-menu-button.svg</file>
|
<file>images/custom-menu-button.svg</file>
|
||||||
<file>app.css</file>
|
<file>app.css</file>
|
||||||
|
<file>images/plus.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
123
demo/images/plus.svg
Normal file
123
demo/images/plus.svg
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
width="16px"
|
||||||
|
height="16px"
|
||||||
|
viewBox="0 0 16 16"
|
||||||
|
id="svg2"
|
||||||
|
version="1.1"
|
||||||
|
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
|
||||||
|
sodipodi:docname="plus.svg">
|
||||||
|
<defs
|
||||||
|
id="defs4">
|
||||||
|
<pattern
|
||||||
|
y="0"
|
||||||
|
x="0"
|
||||||
|
height="6"
|
||||||
|
width="6"
|
||||||
|
patternUnits="userSpaceOnUse"
|
||||||
|
id="EMFhbasepattern" />
|
||||||
|
<pattern
|
||||||
|
y="0"
|
||||||
|
x="0"
|
||||||
|
height="6"
|
||||||
|
width="6"
|
||||||
|
patternUnits="userSpaceOnUse"
|
||||||
|
id="EMFhbasepattern-4" />
|
||||||
|
<pattern
|
||||||
|
y="0"
|
||||||
|
x="0"
|
||||||
|
height="6"
|
||||||
|
width="6"
|
||||||
|
patternUnits="userSpaceOnUse"
|
||||||
|
id="EMFhbasepattern-3" />
|
||||||
|
<pattern
|
||||||
|
y="0"
|
||||||
|
x="0"
|
||||||
|
height="6"
|
||||||
|
width="6"
|
||||||
|
patternUnits="userSpaceOnUse"
|
||||||
|
id="EMFhbasepattern-8" />
|
||||||
|
</defs>
|
||||||
|
<sodipodi:namedview
|
||||||
|
id="base"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:zoom="22.627417"
|
||||||
|
inkscape:cx="-2.5629517"
|
||||||
|
inkscape:cy="7.4271635"
|
||||||
|
inkscape:document-units="px"
|
||||||
|
inkscape:current-layer="g5228"
|
||||||
|
showgrid="true"
|
||||||
|
units="px"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1017"
|
||||||
|
inkscape:window-x="1912"
|
||||||
|
inkscape:window-y="-8"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:snap-bbox="true"
|
||||||
|
inkscape:bbox-paths="true"
|
||||||
|
inkscape:bbox-nodes="true"
|
||||||
|
inkscape:snap-bbox-edge-midpoints="true"
|
||||||
|
inkscape:snap-bbox-midpoints="true"
|
||||||
|
inkscape:snap-global="true">
|
||||||
|
<inkscape:grid
|
||||||
|
type="xygrid"
|
||||||
|
id="grid3336" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<g
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
transform="translate(0,-1036.3622)">
|
||||||
|
<g
|
||||||
|
transform="translate(628,-140.49998)"
|
||||||
|
id="g5228">
|
||||||
|
<path
|
||||||
|
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m -620.5,1189.8622 v -11"
|
||||||
|
id="path822-5"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
<path
|
||||||
|
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||||
|
d="m -615,1184.3622 h -11"
|
||||||
|
id="path822-5-2"
|
||||||
|
inkscape:connector-curvature="0" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<metadata
|
||||||
|
id="metadata12">
|
||||||
|
<rdf:RDF>
|
||||||
|
<rdf:Description
|
||||||
|
about="https://iconscout.com/legal#licenses"
|
||||||
|
dc:title="Menu, Bar, Lines, Option, List, Hamburger, Web"
|
||||||
|
dc:description="Menu, Bar, Lines, Option, List, Hamburger, Web"
|
||||||
|
dc:publisher="Iconscout"
|
||||||
|
dc:date="2016-12-14"
|
||||||
|
dc:format="image/svg+xml"
|
||||||
|
dc:language="en">
|
||||||
|
<dc:creator>
|
||||||
|
<rdf:Bag>
|
||||||
|
<rdf:li>Jemis Mali</rdf:li>
|
||||||
|
</rdf:Bag>
|
||||||
|
</dc:creator>
|
||||||
|
</rdf:Description>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title></dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.6 KiB |
@ -460,7 +460,7 @@ void CDockAreaTitleBar::updateDockWidgetActionsButtons()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InsertIndex = 2;
|
int InsertIndex = indexOf(d->TabsMenuButton);
|
||||||
for (auto Action : Actions)
|
for (auto Action : Actions)
|
||||||
{
|
{
|
||||||
auto Button = new CTitleBarButton(true, this);
|
auto Button = new CTitleBarButton(true, this);
|
||||||
|
@ -856,6 +856,13 @@ void CDockAreaWidget::closeOtherAreas()
|
|||||||
{
|
{
|
||||||
dockContainer()->closeOtherAreas(this);
|
dockContainer()->closeOtherAreas(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
CDockAreaTitleBar* CDockAreaWidget::titleBar() const
|
||||||
|
{
|
||||||
|
return d->TitleBar;
|
||||||
|
}
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -44,6 +44,7 @@ struct DockAreaWidgetPrivate;
|
|||||||
class CDockManager;
|
class CDockManager;
|
||||||
class CDockContainerWidget;
|
class CDockContainerWidget;
|
||||||
class DockContainerWidgetPrivate;
|
class DockContainerWidgetPrivate;
|
||||||
|
class CDockAreaTitleBar;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,6 +265,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
DockWidgetAreas allowedAreas() const;
|
DockWidgetAreas allowedAreas() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the title bar of this dock area
|
||||||
|
*/
|
||||||
|
CDockAreaTitleBar* titleBar() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* This activates the tab for the given tab index.
|
* This activates the tab for the given tab index.
|
||||||
|
Loading…
Reference in New Issue
Block a user