mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Added configflags example to test use of CDockManager config flags
This commit is contained in:
parent
ac3af4c6cd
commit
3ff6918b1f
28
examples/configflags/CMakeLists.txt
Normal file
28
examples/configflags/CMakeLists.txt
Normal file
@ -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"
|
||||||
|
)
|
34
examples/configflags/configflags.pro
Normal file
34
examples/configflags/configflags.pro
Normal file
@ -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
|
||||||
|
|
10
examples/configflags/main.cpp
Normal file
10
examples/configflags/main.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <mainwindow.h>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
CMainWindow w;
|
||||||
|
w.show();
|
||||||
|
return a.exec();
|
||||||
|
}
|
65
examples/configflags/mainwindow.cpp
Normal file
65
examples/configflags/mainwindow.cpp
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QToolBar>
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
27
examples/configflags/mainwindow.h
Normal file
27
examples/configflags/mainwindow.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef MAINWINDOW_H
|
||||||
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QWidgetAction>
|
||||||
|
|
||||||
|
#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
|
47
examples/configflags/mainwindow.ui
Normal file
47
examples/configflags/mainwindow.ui
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CMainWindow</class>
|
||||||
|
<widget class="QMainWindow" name="CMainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1284</width>
|
||||||
|
<height>757</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>MainWindow</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget"/>
|
||||||
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>1284</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<widget class="QMenu" name="menuView">
|
||||||
|
<property name="title">
|
||||||
|
<string>View</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menuView"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QToolBar" name="toolBar">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>toolBar</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="toolBarArea">
|
||||||
|
<enum>TopToolBarArea</enum>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="toolBarBreak">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -8,4 +8,5 @@ SUBDIRS = \
|
|||||||
sidebar \
|
sidebar \
|
||||||
deleteonclose \
|
deleteonclose \
|
||||||
emptydockarea \
|
emptydockarea \
|
||||||
dockindock
|
dockindock \
|
||||||
|
configflags
|
||||||
|
Loading…
Reference in New Issue
Block a user