mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-24 23:31:32 +08:00
Updates default stylesheet and demo app
This commit is contained in:
parent
9bbc5e41a3
commit
34cf851e24
@ -22,7 +22,7 @@ class InternalContentData;
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* ContainerWidget is the main container to provide the docking
|
* ContainerWidget is the main container to provide the docking
|
||||||
* functionality. It manages mulitple Sections and all possible areas.
|
* functionality. It manages multiple sections with all possible areas.
|
||||||
*/
|
*/
|
||||||
class ADS_EXPORT_API ContainerWidget : public QFrame
|
class ADS_EXPORT_API ContainerWidget : public QFrame
|
||||||
{
|
{
|
||||||
@ -130,7 +130,7 @@ signals:
|
|||||||
/*!
|
/*!
|
||||||
* Emits whenever the "isActiveTab" state of a SectionContent changes.
|
* Emits whenever the "isActiveTab" state of a SectionContent changes.
|
||||||
* Whenever the users sets another tab as active, this signal gets invoked
|
* Whenever the users sets another tab as active, this signal gets invoked
|
||||||
* for the old now inactive tab and the new active tab (the order is unspecified).
|
* for the old tab and the new active tab (the order is unspecified).
|
||||||
*/
|
*/
|
||||||
void activeTabChanged(const SectionContent::RefPtr& sc, bool active);
|
void activeTabChanged(const SectionContent::RefPtr& sc, bool active);
|
||||||
|
|
||||||
|
@ -14,5 +14,6 @@
|
|||||||
<file>img/splitter-vertical.png</file>
|
<file>img/splitter-vertical.png</file>
|
||||||
<file>stylesheets/default-windows.css</file>
|
<file>stylesheets/default-windows.css</file>
|
||||||
<file>stylesheets/vendor-partsolutions.css</file>
|
<file>stylesheets/vendor-partsolutions.css</file>
|
||||||
|
<file>stylesheets/modern-windows.css</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -3,28 +3,69 @@
|
|||||||
* Note: Always use CSS-classes with and without "ads--" namespace to support Qt4 & Qt5
|
* Note: Always use CSS-classes with and without "ads--" namespace to support Qt4 & Qt5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QSplitter::handle {
|
ads--ContainerWidget,
|
||||||
|
ContainerWidget
|
||||||
|
{
|
||||||
background: palette(dark);
|
background: palette(dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
ads--ContainerWidget, ContainerWidget {
|
ads--ContainerWidget QSplitter::handle,
|
||||||
|
ContainerWidget QSplitter::handle
|
||||||
|
{
|
||||||
background: palette(dark);
|
background: palette(dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
ads--SectionWidget, SectionWidget {
|
ads--SectionWidget,
|
||||||
|
SectionWidget
|
||||||
|
{
|
||||||
background: palette(window);
|
background: palette(window);
|
||||||
}
|
|
||||||
|
|
||||||
ads--SectionTitleWidget, SectionTitleWidget {
|
|
||||||
background: palette(window);
|
|
||||||
border-right: 1px solid palette(light);
|
|
||||||
padding: 9px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ads--SectionTitleWidget[activeTab="true"], SectionTitleWidget[activeTab="true"] {
|
|
||||||
background: palette(light);
|
|
||||||
}
|
|
||||||
|
|
||||||
ads--SectionContentWidget, SectionContentWidget {
|
|
||||||
border: 1px solid palette(light);
|
border: 1px solid palette(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ads--SectionTitleWidget,
|
||||||
|
SectionTitleWidget
|
||||||
|
{
|
||||||
|
background: palette(window);
|
||||||
|
border-color: palette(light);
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 0 1px 0 0;
|
||||||
|
padding: 0 9px;
|
||||||
|
}
|
||||||
|
|
||||||
|
ads--SectionTitleWidget[activeTab="true"],
|
||||||
|
SectionTitleWidget[activeTab="true"]
|
||||||
|
{
|
||||||
|
/* background: palette(light);*/
|
||||||
|
/* background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 255, 255, 255), stop:1 rgba(240, 240, 240, 255));*/
|
||||||
|
background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:0.5, stop:0 palette(window), stop:1 palette(light));
|
||||||
|
}
|
||||||
|
|
||||||
|
ads--SectionContentWidget,
|
||||||
|
SectionContentWidget
|
||||||
|
{
|
||||||
|
background: palette(light);
|
||||||
|
border-color: palette(light);
|
||||||
|
border-style: solid;
|
||||||
|
border-width: 1px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Special: QLabels inside SectionTitleWidget
|
||||||
|
*/
|
||||||
|
ads--SectionTitleWidget QLabel,
|
||||||
|
SectionTitleWidget QLabel
|
||||||
|
{
|
||||||
|
color: palette(dark);
|
||||||
|
}
|
||||||
|
ads--SectionTitleWidget[activeTab="true"] QLabel,
|
||||||
|
SectionTitleWidget[activeTab="true"] QLabel
|
||||||
|
{
|
||||||
|
color: palette(foreground);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Special: QLabels inside SectionTitleWidget, which is floating
|
||||||
|
*/
|
||||||
|
ads--FloatingWidget ads--SectionTitleWidget QLabel,
|
||||||
|
FloatingWidget SectionTitleWidget QLabel
|
||||||
|
{
|
||||||
|
color: palette(foreground);
|
||||||
|
}
|
||||||
|
35
AdvancedDockingSystem/res/stylesheets/modern-windows.css
Normal file
35
AdvancedDockingSystem/res/stylesheets/modern-windows.css
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
QSplitter::handle {
|
||||||
|
background: palette(light);
|
||||||
|
}
|
||||||
|
|
||||||
|
ads--ContainerWidget, ContainerWidget {
|
||||||
|
background: palette(light);
|
||||||
|
}
|
||||||
|
|
||||||
|
ads--SectionWidget, SectionWidget {
|
||||||
|
background: palette(light);
|
||||||
|
}
|
||||||
|
|
||||||
|
ads--SectionTitleWidget, SectionTitleWidget {
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
ads--SectionTitleWidget QLabel, SectionTitleWidget QLabel {
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
ads--SectionTitleWidget[activeTab="true"], SectionTitleWidget[activeTab="true"] {
|
||||||
|
background: #000000;
|
||||||
|
border-right: 1px solid #000000;
|
||||||
|
padding: 9px;
|
||||||
|
}
|
||||||
|
ads--SectionTitleWidget[activeTab="true"] QLabel, SectionTitleWidget[activeTab="true"] QLabel {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
ads--SectionContentWidget, SectionContentWidget {
|
||||||
|
border: 1px solid #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
QAbstractItemView {
|
||||||
|
border: 0;
|
||||||
|
}
|
@ -14,13 +14,41 @@ IconTitleWidget::IconTitleWidget(const QIcon& icon, const QString& title, QWidge
|
|||||||
setLayout(l);
|
setLayout(l);
|
||||||
|
|
||||||
_iconLabel = new QLabel();
|
_iconLabel = new QLabel();
|
||||||
if (!icon.isNull())
|
|
||||||
_iconLabel->setPixmap(icon.pixmap(16, 16));
|
|
||||||
l->addWidget(_iconLabel);
|
l->addWidget(_iconLabel);
|
||||||
|
|
||||||
_titleLabel = new QLabel();
|
_titleLabel = new QLabel();
|
||||||
_titleLabel->setText(title);
|
|
||||||
l->addWidget(_titleLabel, 1);
|
l->addWidget(_titleLabel, 1);
|
||||||
|
|
||||||
|
setIcon(icon);
|
||||||
|
setTitle(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IconTitleWidget::setIcon(const QIcon& icon)
|
||||||
|
{
|
||||||
|
if (icon.isNull())
|
||||||
|
{
|
||||||
|
_iconLabel->setPixmap(QPixmap());
|
||||||
|
_iconLabel->setVisible(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_iconLabel->setPixmap(icon.pixmap(16, 16));
|
||||||
|
_iconLabel->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IconTitleWidget::setTitle(const QString& title)
|
||||||
|
{
|
||||||
|
if (title.isEmpty())
|
||||||
|
{
|
||||||
|
_titleLabel->setText(QString());
|
||||||
|
_titleLabel->setVisible(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_titleLabel->setText(title);
|
||||||
|
_titleLabel->setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconTitleWidget::polishUpdate()
|
void IconTitleWidget::polishUpdate()
|
||||||
|
@ -12,6 +12,10 @@ class IconTitleWidget : public QFrame
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent = 0);
|
explicit IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent = 0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setIcon(const QIcon& icon);
|
||||||
|
void setTitle(const QString& title);
|
||||||
void polishUpdate();
|
void polishUpdate();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -4,59 +4,27 @@
|
|||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
static void initStyleSheet(QApplication& a)
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QFile f(":/stylesheets/default-windows.css");
|
||||||
a.setQuitOnLastWindowClosed(true);
|
// QFile f(":/stylesheets/modern-windows.css");
|
||||||
|
// QFile f(":/stylesheets/vendor-partsolutions.css");
|
||||||
//Q_INIT_RESOURCE(ads);
|
|
||||||
|
|
||||||
// Load style sheet
|
|
||||||
// QFile f(":/stylesheets/default-windows.css");
|
|
||||||
QFile f(":/stylesheets/vendor-partsolutions.css");
|
|
||||||
if (f.open(QFile::ReadOnly))
|
if (f.open(QFile::ReadOnly))
|
||||||
{
|
{
|
||||||
QByteArray ba = f.readAll();
|
QByteArray ba = f.readAll();
|
||||||
f.close();
|
f.close();
|
||||||
a.setStyleSheet(QString(ba));
|
a.setStyleSheet(QString(ba));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
//Q_INIT_RESOURCE(ads);
|
||||||
|
a.setQuitOnLastWindowClosed(true);
|
||||||
|
initStyleSheet(a);
|
||||||
|
|
||||||
MainWindow mw;
|
MainWindow mw;
|
||||||
mw.show();
|
mw.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
// a.setStyleSheet(""
|
|
||||||
// " QSplitter::handle { border: 1px solid #000000; background: #000000; } "
|
|
||||||
// " ads--ContainerWidget { border: 1px solid #ff0000; background: #FFE6E6; padding: 6px; } "
|
|
||||||
// " ads--SectionWidget { border: 1px solid #00ff00; background: #E6FFE6; padding: 6px; } "
|
|
||||||
// " ads--SectionTitleWidget { border: 1px solid #0000ff; background: #E6E6FF; padding: 6px; } "
|
|
||||||
// " ads--SectionTitleWidget[activeTab=\"true\"] { border: 1px solid #0000ff; background: #9696FF; padding: 6px; } "
|
|
||||||
// " ads--SectionContentWidget { border: 1px solid #FFFF00; background: #FFFFE6; padding: 6px; } "
|
|
||||||
// );
|
|
||||||
|
|
||||||
//static void centerWidget(QWidget* widget)
|
|
||||||
//{
|
|
||||||
// if (widget)
|
|
||||||
// {
|
|
||||||
// QDesktopWidget deskWidget;
|
|
||||||
// const int screenIndex = deskWidget.primaryScreen();
|
|
||||||
// const QRect deskRect = deskWidget.availableGeometry(screenIndex);
|
|
||||||
// const int x = (deskRect.width() - widget->rect().width()) / 2;
|
|
||||||
// const int y = (deskRect.height() - widget->rect().height()) / 2;
|
|
||||||
// widget->move(x, y);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//static void resizeWidgetPerCent(QWidget* widget, qreal widthPC, qreal heightPC)
|
|
||||||
//{
|
|
||||||
// if (widget && widthPC >= 0.0 && heightPC >= 0.0)
|
|
||||||
// {
|
|
||||||
// QDesktopWidget deskWidget;
|
|
||||||
// const int screenIndex = deskWidget.primaryScreen();
|
|
||||||
// const QRect deskRect = deskWidget.availableGeometry(screenIndex);
|
|
||||||
// const int w = (deskRect.width() / 100) * widthPC;
|
|
||||||
// const int h = (deskRect.height() / 100) * heightPC;
|
|
||||||
// widget->resize(w, h);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
@ -47,6 +47,7 @@ static ADS_NS::SectionContent::RefPtr createCalendarSC(ADS_NS::ContainerWidget*
|
|||||||
static ADS_NS::SectionContent::RefPtr createFileSystemTreeSC(ADS_NS::ContainerWidget* container)
|
static ADS_NS::SectionContent::RefPtr createFileSystemTreeSC(ADS_NS::ContainerWidget* container)
|
||||||
{
|
{
|
||||||
QTreeView* w = new QTreeView();
|
QTreeView* w = new QTreeView();
|
||||||
|
w->setFrameShape(QFrame::NoFrame);
|
||||||
// QFileSystemModel* m = new QFileSystemModel(w);
|
// QFileSystemModel* m = new QFileSystemModel(w);
|
||||||
// m->setRootPath(QDir::currentPath());
|
// m->setRootPath(QDir::currentPath());
|
||||||
// w->setModel(m);
|
// w->setModel(m);
|
||||||
@ -84,14 +85,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->mainToolBar->hide();
|
|
||||||
ui->statusBar->hide();
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
QObject::connect(ui->actionAddSectionContent, &QAction::triggered, this, &MainWindow::onActionAddSectionContentTriggered);
|
|
||||||
#else
|
|
||||||
QObject::connect(ui->actionAddSectionContent, SIGNAL(triggered(bool)), this, SLOT(onActionAddSectionContentTriggered()));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
// ADS - Create main container (ContainerWidget).
|
||||||
_container = new ADS_NS::ContainerWidget();
|
_container = new ADS_NS::ContainerWidget();
|
||||||
_container->setOrientation(Qt::Vertical);
|
_container->setOrientation(Qt::Vertical);
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
@ -101,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
#endif
|
#endif
|
||||||
setCentralWidget(_container);
|
setCentralWidget(_container);
|
||||||
|
|
||||||
|
// ADS - Adding some contents.
|
||||||
// Test #1: Use high-level public API
|
// Test #1: Use high-level public API
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
@ -111,17 +107,17 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
sw = _container->addSectionContent(createCalendarSC(cw), sw, ADS_NS::RightDropArea);
|
sw = _container->addSectionContent(createCalendarSC(cw), sw, ADS_NS::RightDropArea);
|
||||||
sw = _container->addSectionContent(createFileSystemTreeSC(cw), sw, ADS_NS::CenterDropArea);
|
sw = _container->addSectionContent(createFileSystemTreeSC(cw), sw, ADS_NS::CenterDropArea);
|
||||||
|
|
||||||
// _container->addSectionContent(createCalendarSC(_container));
|
_container->addSectionContent(createCalendarSC(_container));
|
||||||
// _container->addSectionContent(createLongTextLabelSC(_container));
|
_container->addSectionContent(createLongTextLabelSC(_container));
|
||||||
// _container->addSectionContent(createLongTextLabelSC(_container));
|
_container->addSectionContent(createLongTextLabelSC(_container));
|
||||||
// _container->addSectionContent(createLongTextLabelSC(_container));
|
_container->addSectionContent(createLongTextLabelSC(_container));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default window geometry
|
// Default window geometry
|
||||||
resize(800, 600);
|
resize(800, 600);
|
||||||
|
|
||||||
// Restore window geometry and ContainerWidget state from last session
|
|
||||||
restoreGeometry(loadDataHelper("MainWindow"));
|
restoreGeometry(loadDataHelper("MainWindow"));
|
||||||
|
|
||||||
|
// ADS - Restore geometries and states of contents.
|
||||||
_container->restoreState(loadDataHelper("ContainerWidget"));
|
_container->restoreState(loadDataHelper("ContainerWidget"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,15 +14,6 @@
|
|||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget"/>
|
<widget class="QWidget" name="centralWidget"/>
|
||||||
<widget class="QToolBar" name="mainToolBar">
|
|
||||||
<attribute name="toolBarArea">
|
|
||||||
<enum>TopToolBarArea</enum>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="toolBarBreak">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
<addaction name="actionAddSectionContent"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QStatusBar" name="statusBar"/>
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
<widget class="QMenuBar" name="menuBar">
|
<widget class="QMenuBar" name="menuBar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@ -33,12 +24,54 @@
|
|||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menuFile">
|
||||||
|
<property name="title">
|
||||||
|
<string>File</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionExit"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuView">
|
||||||
|
<property name="title">
|
||||||
|
<string>View</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionDemo_1"/>
|
||||||
|
<addaction name="actionDemo_2"/>
|
||||||
|
<addaction name="actionDemo_3"/>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuAbout">
|
||||||
|
<property name="title">
|
||||||
|
<string>About</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menuFile"/>
|
||||||
|
<addaction name="menuView"/>
|
||||||
|
<addaction name="menuAbout"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionAddSectionContent">
|
<action name="actionAddSectionContent">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add SectionContent</string>
|
<string>Add SectionContent</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionDemo_1">
|
||||||
|
<property name="text">
|
||||||
|
<string>Demo 1</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionDemo_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Demo 2</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionDemo_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Demo 3</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionExit">
|
||||||
|
<property name="text">
|
||||||
|
<string>Exit</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -3,8 +3,8 @@ Manages content widgets more like Visual Studio or similar programs.
|
|||||||
I also try to get everything done with basic Qt functionality.
|
I also try to get everything done with basic Qt functionality.
|
||||||
Basic usage of QWidgets an QLayouts and using basic styles as much as possible.
|
Basic usage of QWidgets an QLayouts and using basic styles as much as possible.
|
||||||
|
|
||||||
![Layout of widgets](preview01.png)
|
![Layout of widgets](preview.png)
|
||||||
![Dropping widgets](preview02.png)
|
![Dropping widgets](preview-dragndrop.png)
|
||||||
|
|
||||||
## Tested Compatible Environments
|
## Tested Compatible Environments
|
||||||
- Windows 10 / Qt 5.5.1 / VC12
|
- Windows 10 / Qt 5.5.1 / VC12
|
||||||
|
BIN
preview-dragndrop.png
Normal file
BIN
preview-dragndrop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 191 KiB |
BIN
preview.png
Normal file
BIN
preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
BIN
preview01.png
BIN
preview01.png
Binary file not shown.
Before Width: | Height: | Size: 31 KiB |
BIN
preview02.png
BIN
preview02.png
Binary file not shown.
Before Width: | Height: | Size: 38 KiB |
Loading…
Reference in New Issue
Block a user