From 3ff6918b1ff744eef37e48751187e4c81d1be79b Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 21 May 2024 08:37:35 +0200 Subject: [PATCH] Added configflags example to test use of CDockManager config flags --- examples/configflags/CMakeLists.txt | 28 ++++++++++++ examples/configflags/configflags.pro | 34 +++++++++++++++ examples/configflags/main.cpp | 10 +++++ examples/configflags/mainwindow.cpp | 65 ++++++++++++++++++++++++++++ examples/configflags/mainwindow.h | 27 ++++++++++++ examples/configflags/mainwindow.ui | 47 ++++++++++++++++++++ examples/examples.pro | 3 +- 7 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 examples/configflags/CMakeLists.txt create mode 100644 examples/configflags/configflags.pro create mode 100644 examples/configflags/main.cpp create mode 100644 examples/configflags/mainwindow.cpp create mode 100644 examples/configflags/mainwindow.h create mode 100644 examples/configflags/mainwindow.ui diff --git a/examples/configflags/CMakeLists.txt b/examples/configflags/CMakeLists.txt new file mode 100644 index 000000000..c231ee7f3 --- /dev/null +++ b/examples/configflags/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.5) +project(ads_example_centralwidget VERSION ${VERSION_SHORT}) +find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} 5.5 COMPONENTS Core Gui Widgets REQUIRED) +set(CMAKE_INCLUDE_CURRENT_DIR ON) +add_executable(configFlagsExample WIN32 + main.cpp + mainwindow.cpp + mainwindow.ui +) +target_include_directories(CentralWidgetExample PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../../src") +target_link_libraries(CentralWidgetExample PRIVATE qt${QT_VERSION_MAJOR}advanceddocking) +target_link_libraries(CentralWidgetExample PUBLIC Qt${QT_VERSION_MAJOR}::Core + Qt${QT_VERSION_MAJOR}::Gui + Qt${QT_VERSION_MAJOR}::Widgets) +set_target_properties(CentralWidgetExample PROPERTIES + AUTOMOC ON + AUTORCC ON + AUTOUIC ON + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF + VERSION ${VERSION_SHORT} + EXPORT_NAME "Qt Advanced Docking System Central Widget Example" + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/lib" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${ads_PlatformDir}/bin" +) diff --git a/examples/configflags/configflags.pro b/examples/configflags/configflags.pro new file mode 100644 index 000000000..83271745d --- /dev/null +++ b/examples/configflags/configflags.pro @@ -0,0 +1,34 @@ +ADS_OUT_ROOT = $${OUT_PWD}/../.. + +QT += core gui widgets + +TARGET = ConfigFlagsExample +DESTDIR = $${ADS_OUT_ROOT}/lib +TEMPLATE = app +CONFIG += c++14 +CONFIG += debug_and_release +adsBuildStatic { + DEFINES += ADS_STATIC +} + +# The following define makes your compiler emit warnings if you use +# any Qt feature that has been marked deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +LIBS += -L$${ADS_OUT_ROOT}/lib +include(../../ads.pri) +INCLUDEPATH += ../../src +DEPENDPATH += ../../src + diff --git a/examples/configflags/main.cpp b/examples/configflags/main.cpp new file mode 100644 index 000000000..fa4c4fdea --- /dev/null +++ b/examples/configflags/main.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + CMainWindow w; + w.show(); + return a.exec(); +} diff --git a/examples/configflags/mainwindow.cpp b/examples/configflags/mainwindow.cpp new file mode 100644 index 000000000..2ce359b10 --- /dev/null +++ b/examples/configflags/mainwindow.cpp @@ -0,0 +1,65 @@ +#include "mainwindow.h" + +#include "ui_mainwindow.h" + +#include +#include + +#include "DockAreaWidget.h" +#include "DockAreaTitleBar.h" + + +using namespace ads; + + +CMainWindow::CMainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::CMainWindow) +{ + ui->setupUi(this); + + // Add the toolbar + auto toolbar_ = addToolBar("Top Toolbar"); + + // Create the dock manager + ads::CDockManager::setConfigFlags(ads::CDockManager::DefaultOpaqueConfig); + ads::CDockManager::setConfigFlag(ads::CDockManager::DockAreaHasCloseButton, + false); + ads::CDockManager::setConfigFlag(ads::CDockManager::DockAreaHasUndockButton, + false); + ads::CDockManager::setConfigFlag( + ads::CDockManager::DockAreaHasTabsMenuButton, false); + auto DockManager = new ads::CDockManager(this); + + // Create a dockable widget + QLabel *l1 = new QLabel(); + l1->setWordWrap(true); + l1->setAlignment(Qt::AlignTop | Qt::AlignLeft); + l1->setText("Docking widget 1"); + ads::CDockWidget *dockWidget1 = new ads::CDockWidget("Dock 1"); + dockWidget1->setWidget(l1); + DockManager->addDockWidget(ads::LeftDockWidgetArea, dockWidget1); + + QLabel *l2 = new QLabel(); + l2->setWordWrap(true); + l2->setAlignment(Qt::AlignTop | Qt::AlignLeft); + l2->setText("Docking widget 2"); + ads::CDockWidget *dockWidget2 = new ads::CDockWidget("Dock 2"); + dockWidget2->setWidget(l2); + DockManager->addDockWidget(ads::RightDockWidgetArea, dockWidget2); + + // Add menu actions + ui->menuView->addAction(dockWidget1->toggleViewAction()); + ui->menuView->addAction(dockWidget2->toggleViewAction()); + toolbar_->addAction(dockWidget1->toggleViewAction()); + toolbar_->addAction(dockWidget2->toggleViewAction()); +} + + +CMainWindow::~CMainWindow() +{ + delete ui; +} + + + diff --git a/examples/configflags/mainwindow.h b/examples/configflags/mainwindow.h new file mode 100644 index 000000000..a2b45da77 --- /dev/null +++ b/examples/configflags/mainwindow.h @@ -0,0 +1,27 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include +#include + +#include "DockManager.h" +#include "DockAreaWidget.h" +#include "DockWidget.h" + +QT_BEGIN_NAMESPACE +namespace Ui { class CMainWindow; } +QT_END_NAMESPACE + +class CMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + CMainWindow(QWidget *parent = nullptr); + ~CMainWindow(); + +private: + Ui::CMainWindow *ui; +}; +#endif // MAINWINDOW_H diff --git a/examples/configflags/mainwindow.ui b/examples/configflags/mainwindow.ui new file mode 100644 index 000000000..f7d3b09e8 --- /dev/null +++ b/examples/configflags/mainwindow.ui @@ -0,0 +1,47 @@ + + + CMainWindow + + + + 0 + 0 + 1284 + 757 + + + + MainWindow + + + + + + 0 + 0 + 1284 + 21 + + + + + View + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + + diff --git a/examples/examples.pro b/examples/examples.pro index 4e4547a0f..e2b0705aa 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -8,4 +8,5 @@ SUBDIRS = \ sidebar \ deleteonclose \ emptydockarea \ - dockindock + dockindock \ + configflags