1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-04-01 02:42:39 +08:00

Register custom button for close in example.

This commit is contained in:
Cynthia Pang 2023-10-20 17:02:59 +08:00
parent eee7e4d666
commit edd92596a6
6 changed files with 157 additions and 4 deletions

View File

@ -7,6 +7,7 @@ add_executable(AutoHideExample WIN32
main.cpp
mainwindow.cpp
mainwindow.ui
autohide.qrc
)
target_include_directories(AutoHideExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src")
target_link_libraries(AutoHideExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking)

View File

@ -27,6 +27,9 @@ HEADERS += \
FORMS += \
mainwindow.ui
RESOURCES += \
autohide.qrc
LIBS += -L$${ADS_OUT_ROOT}/lib
include(../../ads.pri)
INCLUDEPATH += ../../src

View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="adsautohide">
<file>images/minimize-button.svg</file>
</qresource>
</RCC>

View File

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
sodipodi:docname="minimize-button.svg"
inkscape:version="1.1.2 (b8e25be833, 2022-02-05)"
version="1.1"
id="svg2"
viewBox="0 0 16 16"
height="16px"
width="16px"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<style
id="style2" />
<defs
id="defs4">
<pattern
id="EMFhbasepattern"
patternUnits="userSpaceOnUse"
width="6"
height="6"
x="0"
y="0" />
<pattern
id="EMFhbasepattern-4"
patternUnits="userSpaceOnUse"
width="6"
height="6"
x="0"
y="0" />
<pattern
id="EMFhbasepattern-3"
patternUnits="userSpaceOnUse"
width="6"
height="6"
x="0"
y="0" />
<pattern
id="EMFhbasepattern-8"
patternUnits="userSpaceOnUse"
width="6"
height="6"
x="0"
y="0" />
</defs>
<sodipodi:namedview
inkscape:guide-bbox="true"
showguides="true"
inkscape:document-rotation="0"
inkscape:snap-global="true"
inkscape:snap-bbox-midpoints="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:bbox-nodes="true"
inkscape:bbox-paths="true"
inkscape:snap-bbox="true"
inkscape:window-maximized="1"
inkscape:window-y="-6"
inkscape:window-x="-6"
inkscape:window-height="1018"
inkscape:window-width="1920"
units="px"
showgrid="true"
inkscape:current-layer="g5228"
inkscape:document-units="px"
inkscape:cy="11.170077"
inkscape:cx="6.4744465"
inkscape:zoom="45.254834"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
borderopacity="1.0"
bordercolor="#666666"
pagecolor="#ffffff"
id="base"
inkscape:pagecheckerboard="0">
<inkscape:grid
id="grid3336"
type="xygrid" />
<sodipodi:guide
id="guide883"
orientation="1,0"
position="4,10" />
<sodipodi:guide
id="guide885"
orientation="0,-1"
position="10,12" />
<sodipodi:guide
id="guide887"
orientation="1,0"
position="12,2" />
<sodipodi:guide
id="guide889"
orientation="0,-1"
position="14,4" />
</sodipodi:namedview>
<g
transform="translate(0,-1036.3622)"
id="layer1"
inkscape:groupmode="layer"
inkscape:label="Layer 1">
<g
id="g5228"
transform="translate(628,-140.49998)">
<rect
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke-width:1.41421"
id="rect964"
width="8"
height="2.0000026"
x="-624"
y="1186.8622"
ry="1.0000013" />
</g>
</g>
<metadata
id="metadata12">
<rdf:RDF>
<rdf:Description
dc:language="en"
dc:format="image/svg+xml"
dc:date="2016-12-14"
dc:publisher="Iconscout"
dc:description="Menu, Bar, Lines, Option, List, Hamburger, Web"
dc:title="Menu, Bar, Lines, Option, List, Hamburger, Web"
about="https://iconscout.com/legal#licenses">
<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 />
</cc:Work>
</rdf:RDF>
</metadata>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -14,7 +14,7 @@
#include "AutoHideDockContainer.h"
#include "DockAreaWidget.h"
#include "DockAreaTitleBar.h"
#include "IconProvider.h"
using namespace ads;
@ -28,6 +28,10 @@ CMainWindow::CMainWindow(QWidget *parent)
CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false);
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideCloseButtonCollapsesDock, true);
CDockManager::iconProvider().registerCustomIcon(AutoHideDockAreaCloseIcon,
QIcon(":/adsautohide/images/minimize-button.svg"));
DockManager = new CDockManager(this);
// Set central widget

View File

@ -56,8 +56,6 @@ ads--CTitleBarButton {
#dockAreaCloseButton {
qproperty-icon: url(:/ads/images/close-button.svg),
url(:/ads/images/close-button-disabled.svg) disabled;
qproperty-iconSize: 16px;
}
@ -337,7 +335,6 @@ ads--CAutoHideDockContainer #dockAreaAutoHideButton {
ads--CAutoHideDockContainer #dockAreaCloseButton{
qproperty-icon: url(:/ads/images/close-button-focused.svg)
}