Giter Site home page Giter Site logo

qt-advanced-docking-system's Introduction

Advanced Docking System for Qt

Gitter

Manages content widgets more like Visual Studio or similar programs. 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.

Layout of widgets Dropping widgets

Tested Compatible Environments

  • Windows 7 / 8 / 8.1 / 10
  • Ubuntu 15.10

Build

Open the build.pro with QtCreator and start the build, that's it. You can run the demo project and test it yourself.

Release & Development

The master branch is not guaranteed to be stable or does not even build, since it is the main working branch. If you want a version that builds, you should always use a release/beta tag.

Getting started / Example

The following example shows the minimum code required to use ADS.

MyWindow.h

#include <QMainWindow>
#include "ads/API.h"
#include "ads/ContainerWidget.h"
#include "ads/SectionContent.h"
class MyWindow : public QMainWindow
{
	Q_OBJECT
public:
	MyWindow(QWidget* parent);
	
private:
	// The main container for dockings.
	ADS_NS::ContainerWidget* _container;
	
	// You always want to keep a reference of your content,
	// in case you need to perform any action on it (show, hide, ...)
	ADS_NS::SectionContent::RefPtr _sc1; 
};

MyWindow.cpp

#include "MyWindow.h"
#include <QLabel>
MyWindow::MyWindow(QWidget* parent) : QMainWindow(parent)
{
	_container = new ADS_NS::ContainerWidget();
	setCentralWidget(_container);
	
	_sc1 = ADS_NS::SectionContent::newSectionContent(QString("Unique-Internal-Name"), _container, new QLabel("Visible Title"), new QLabel("Content Widget"));
	_container->addSectionContent(_sc1, NULL, ADS_NS::CenterDropArea);
}

static void initStyleSheet(QApplication& a)
{
	//Q_INIT_RESOURCE(ads); // If static linked.
	QFile f(":ads/stylesheets/default-windows.css");
	if (f.open(QFile::ReadOnly))
	{
		const QByteArray ba = f.readAll();
		f.close();
		a.setStyleSheet(QString(ba));
	}
}

int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	a.setQuitOnLastWindowClosed(true);
	initStyleSheet(a);

	MainWindow mw;
	mw.show();
	return a.exec();
}

Developers

Manuel Freiholz, Project Maintainer

License information

WTFPL

This projects uses the WTFPL license (Do What The Fuck You Want To Public License)

Using it? Let us know by creating a new issue (You don't have to, of course).

qt-advanced-docking-system's People

Contributors

mfreiholz avatar tanaxiusi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qt-advanced-docking-system's Issues

Squeeze or scroll tabs of sections

A SectionWidget always requires at least the width of the tab bar, which is not scrollable right now. In case of too many contents, this might be disturbing because the user can not downsize it's application as he may wants to.

Possible solutions:

  • Squeeze tabs like chrome (not so beautiful..?)
  • Make them scrollable (left to right), like the QTabBar.

tab menu cache does not update when some title is updated

When I change the title of some tab, this title is not directly translated into the cached menu that opens upon clicking on the down arrow.

I could fix this by temporarily offering an "updateSectionContentTabMenus" method to ContainerWidget that just calls on all sections the updateTabsMenu(), but it seems that this is not very clean. Maybe, setting a title should invalidate the corresponding containerWidget's cache. Not sure, if the pointers/references are set in a way that allows for that in an easy way.

C++11: clazy-range-loop

There was warning, I think need

for (const auto& ColorListEntry : qAsConst(ColorList)) {
...
}

Better handling of sizes when dropping contents

Currently it's unpredictable. It might be good to use the same width/height as the parent content, if dropped on existing content. In case of outer-drop we might use the preferred size of the content.

Handle content drops (Sizing)

  • Case: Dropping A to the bottom or top of B (vertical split):
    • A will use the width of B
    • A will use it's own height, if it is not greater than the half height of B. Otherwise it will use the half height of B.
  • Case: Dropping A to the left or right of B (horizontal split)
    • ... Same as before, but swap the words "height" with "width" :-)
  • Case: Dropping A to the outer top or bottom edge (full vertical split):
    • A will use the full width of the container
    • A will use it's own height, if it is not greater than the half height of the entire container. Otherwise it will use the half height of the container.
  • Case: Dropping A to the outer left or right edge (full horizontal split):
    • ... Same as before, but swap the words "height" with "width" :-)

Support for grouped dragging

Hi,

I just found your advanced docking system and I have to admit I'm excited. It is really great and I searched for an improved Qt docking system for a long time. I had already thought about trying an implementation myself. I would like to say a big thank you for this great gift - I really like it.

The only thing that is missing for me is grouped dragging like it is suported by Qt since Qt 5.6. Maybe I will try to implment it myself and contribute it back.

Best regards,

Uwe

The generated dynamic library cannot be used in my project

Hello, my default development environment is Qt 5.15.2 with MSVC 2019 64-bit, and I have built both the .lib and .dll files using qmake. However, I am encountering compilation errors when trying to use them in my project. I have also attempted to modify the .pro file, but it has not resolved the issue.
Here is the .pro file after my modifications.

TEMPLATE = lib

CONFIG += c++17

DEFINES += ADS_NAMESPACE_ENABLED ADS_EXPORT
QT += core

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

INCLUDEPATH += $$PWD/include

RESOURCES += \
	res/ads.qrc

!isEmpty(target.path): INSTALLS += target
include(AdvancedDockingSystem.pri)

And here is the part in my project related to importing the library and header files.

win32: LIBS += -L$$PWD/lib/ -lAdvancedDockingSystem
INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD/include

The error message is:

error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: __cdecl ContainerWidget::ContainerWidget(class QWidget *)" (__imp_??0ContainerWidget@@QEAA@PEAVQWidget@@@Z),函数 "public: __cdecl TableViewForm::TableViewForm(class QWidget *)" (??0TableViewForm@@QEAA@PEAVQWidget@@@Z) 中引用了该符号
tableviewform.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: virtual __cdecl ContainerWidget::~ContainerWidget(void)" (__imp_??1ContainerWidget@@UEAA@XZ),函数 "public: virtual void * __cdecl ContainerWidget::`scalar deleting destructor'(unsigned int)" (??_GContainerWidget@@UEAAPEAXI@Z) 中引用了该符号
tableviewform.obj : error LNK2019: 无法解析的外部符号 "__declspec(dllimport) public: class SectionWidget * __cdecl ContainerWidget::addSectionContent(class QSharedPointer<class SectionContent> const &,class SectionWidget *,enum DropArea)" (__imp_?addSectionContent@ContainerWidget@@QEAAPEAVSectionWidget@@AEBV?$QSharedPointer@VSectionContent@@@@PEAV2@W4DropArea@@@Z),函数 "public: __cdecl TableViewForm::TableViewForm(class QWidget *)" (??0TableViewForm@@QEAA@PEAVQWidget@@@Z) 中引用了该符号
tableviewform.obj : error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __cdecl ContainerWidget::metaObject(void)const " (?metaObject@ContainerWidget@@UEBAPEBUQMetaObject@@XZ)
tableviewform.obj : error LNK2001: 无法解析的外部符号 "public: virtual int __cdecl ContainerWidget::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@ContainerWidget@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
tableviewform.obj : error LNK2001: 无法解析的外部符号 "public: virtual void * __cdecl ContainerWidget::qt_metacast(char const *)" (?qt_metacast@ContainerWidget@@UEAAPEAXPEBD@Z)

Pinning to outer areas

Show them with vertical title headers on the edge, without contents. Only show contents temporary on click until another view gets focus.

About topLevelChanged

I connect the Singnal [ads::CDockWidget::topLevelChanged]

connect(tmp, &ads::CDockWidget::topLevelChanged, this, [&](bool topLevel) { ads::CDockWidget* dockw = ((ads::CDockWidget*)sender()); });

I want to konw where is the dockw? left,right,bottom or top?
And if it is left or right,i want to resize dockw.
How to do it?
Thank you

Cannot launch demo in Visual Studio

I am planning to integrate AdvancedDockingSystem into my little project, but have come across some difficulties.

I am using Qt 5.13.0 with Visual Studio 2019 on Windows 10. According to the README, I checked out to the commit tagged 1.0.0. And with the help of Qt VS Tools, I can convert Qt Creator project .pro files into Visual Studio solution and projects in the solution.

However, as I started to build and run the project AdvancedDockingSystemDemo, although it can be successfully built, once the executable is launched, there pops up an error message as follows:

Error Message

(It is in simplified Chinese and the meaning in English is approximately Code cannot be executed due to the missing AdvancedDockingSystem1.dll. Re-installation of the program may solve the problem.)

The error message indicates that something named AdvancedDockingSystem1.dll is missing, so the program cannot be launched. So what does the problem come from and how can I solve it?

Thanks!

PS: I tried on Qt Creator and everything seems to work perfectly. And I think it may have something to do with the static linking done by Qt Creator (Visual Studio dynamically links Qt libraries to the built executable).

Visible floating rubberband - Qt4 only

mfaqtungdqd2dlkgpl

Reproduce

  • Create a layout with a vertical splitter (one content in top section and two contents in bottom section)
  • Now quickly drag one of the bottom contents to the north, over the splitter. It's important to do this quick. Mouse-Down and Mouse-Move needs to happen at the same time.
  • Moving the MainWindow arround and clicking on the splitter (not the buggy floating one), will remove the false splitter.

Ideas

Seems to be a Qt4 Bug with event handling, since i can't reproduce this behavior with Qt5. The QSplitter seems to get the mouse-press event, which actually is a event of the SectionTitleWidget to handle the movement.

Does anyone have an idea?

API: Add signals for show/hide of contents

In some cases it might be useful to know, if the visibility of a content changes.

signals:
  void sectionContentVisibilityChanged(const SectionContent::RefPtr& sc, bool visible);
// OR  
signals:
  void sectionContentShown(const SectionContent::RefPtr& sc);
  void sectionContentHidden(const SectionContent::RefPtr& sc);

add possibility to add custom button to title widget

I'd like to have one or multiple custom buttons added to the title widget, probably left to the menu button.

It could be put into the title widget but say we have 5 buttons that could apply to any of the multiple tabs. This would bloat the menu since they would be multiplied by the number of tabs. So, for 3 tabs and 5 buttons, we'd actually had 15 buttons, although 5 would be sufficient. Writing an answer here at Github shows the same system: Write and Preview tabs are available but all the tool buttons like bold, italic, quote, ... are common for both of those tabs.

Docking inside floating windows

Looking for a suitable docking system for my project in Qt I found your code and liked it a lot. The only thing I miss is the possibility to dock widgets inside floatable windows. I was thinking on modifying the code myself to try and pass a sectionwidget directly inside the floatablewidget so i have something to dock into inside the floating window. Do you see any problem with this approach?

Great system - I might use it, if stable

I have already pulled and tried out this docking system and am very pleased with it so far. If this works stable, I would love to use it with my commercial Desktop app "PokerRanger". Your first release seems to be a beta, so I am not sure whether I can really utilize it as of now since I need a certain degree of stability. Do you happen to know of any large/possibly commercial applications that are interested in using it as well? Could be interesting to know

dockmanager savesate only save the layout of first dock area

I want to save the dock layout to a file and reload it when reopen.
the code of save dock layout :

    QFile file("VisualLayout.ini");
	if (file.open(QIODevice::WriteOnly))
	{
		QDataStream out(&file);
		out << _dockMan->saveState();
		file.close();
	}

and the code of load the config file:

 QFile file("VisualLayout.ini");
	if (file.open(QIODevice::ReadOnly))
	{
		QByteArray ba;
		QDataStream in(&file);
		in >> ba;
		file.close();
        
		if (_dockMan->restoreState(ba))
		{
			qDebug() << QString("good");
		}
		else
		{
			qDebug() << QString("failed");
		}
	}

but it just reload the 1st dock area layout, and totally ignored other dock area.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.