-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gui/docking: Add initial docking infrastructure
Signed-off-by: Andrei-Fabian-Pop <[email protected]>
- Loading branch information
1 parent
af4fe93
commit bed6560
Showing
16 changed files
with
666 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2024 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DOCKABLEAREA_H | ||
#define DOCKABLEAREA_H | ||
|
||
#ifdef USE_KDDOCKWIDGETS | ||
#include "docking/dockableareakdab.h" | ||
namespace scopy { | ||
using DockableArea = kdab::DockableArea; | ||
} | ||
#else | ||
#include "docking/dockableareaclassic.h" | ||
namespace scopy { | ||
using DockableArea = classic::DockableArea; | ||
} | ||
#endif | ||
|
||
#endif // DOCKABLEAREA_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2024 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DOCKABLEAREACLASSIC_H | ||
#define DOCKABLEAREACLASSIC_H | ||
|
||
#include "scopy-gui_export.h" | ||
#include <QWidget> | ||
#include "docking/dockableareainterface.h" | ||
|
||
namespace scopy::classic { | ||
class SCOPY_GUI_EXPORT DockableArea : public QWidget, public DockableAreaInterface | ||
{ | ||
Q_OBJECT | ||
Q_INTERFACES(scopy::DockableAreaInterface) | ||
public: | ||
explicit DockableArea(QWidget *parent = nullptr); | ||
~DockableArea() override = default; | ||
|
||
void addDockWrapper(DockWrapperInterface *wrapper) override; | ||
void setAllDockWrappers(const QList<DockWrapperInterface *> &wrappers) override; | ||
|
||
private: | ||
void init(); | ||
}; | ||
} // namespace scopy::classic | ||
|
||
#endif // DOCKABLEAREACLASSIC_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2024 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DOCKABLEAREAINTERFACE_H | ||
#define DOCKABLEAREAINTERFACE_H | ||
|
||
#include "docking/dockwrapperinterface.h" | ||
#include "scopy-gui_export.h" | ||
#include <QObject> | ||
|
||
namespace scopy { | ||
class SCOPY_GUI_EXPORT DockableAreaInterface | ||
{ | ||
public: | ||
virtual ~DockableAreaInterface() = default; | ||
virtual void addDockWrapper(DockWrapperInterface *wrapper) = 0; | ||
virtual void setAllDockWrappers(const QList<DockWrapperInterface *> &wrappers) = 0; | ||
}; | ||
} // namespace scopy | ||
|
||
Q_DECLARE_INTERFACE(scopy::DockableAreaInterface, "scopy::DockableAreaInterface") | ||
#endif // DOCKABLEAREAINTERFACE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2024 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DOCKABLEAREAKDAB_H | ||
#define DOCKABLEAREAKDAB_H | ||
|
||
#include "scopy-gui_export.h" | ||
#include <QWidget> | ||
#include <QList> | ||
#include "docking/dockableareainterface.h" | ||
#include "docking/dockwrapperinterface.h" | ||
#include <kddockwidgets/qtwidgets/views/MainWindow.h> | ||
|
||
namespace scopy::kdab { | ||
class SCOPY_GUI_EXPORT DockableArea : public KDDockWidgets::QtWidgets::MainWindow, public DockableAreaInterface | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit DockableArea(QWidget *parent = nullptr); | ||
~DockableArea() override = default; | ||
|
||
// Does not set affinities | ||
void addDockWrapper(DockWrapperInterface *wrapper) override; | ||
|
||
// Preffered as it also sets affinities | ||
void setAllDockWrappers(const QList<DockWrapperInterface *> &wrappers) override; | ||
|
||
private: | ||
static int s_dockableAreaId; | ||
}; | ||
} // namespace scopy::kdab | ||
#endif // DOCKABLEAREAKDAB_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2024 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DOCKSETTINGS_H | ||
#define DOCKSETTINGS_H | ||
|
||
#ifndef USE_KDDOCKWIDGETS | ||
namespace scopy { | ||
static void initDockWidgets() {} | ||
} // namespace scopy | ||
#else | ||
#include "scopy-gui_export.h" | ||
#include "style.h" | ||
#include "style_attributes.h" | ||
|
||
#include <kddockwidgets/Config.h> | ||
#include <kddockwidgets/core/TitleBar.h> | ||
#include <kddockwidgets/qtwidgets/TitleBar.h> | ||
#include <kddockwidgets/qtwidgets/ViewFactory.h> | ||
|
||
namespace scopy { | ||
// All of this just to hide a button | ||
class SCOPY_GUI_EXPORT NoCloseTitleBar : public KDDockWidgets::QtWidgets::TitleBar | ||
{ | ||
public: | ||
explicit NoCloseTitleBar(KDDockWidgets::Core::TitleBar *controller, KDDockWidgets::Core::View *parent = nullptr) | ||
: KDDockWidgets::QtWidgets::TitleBar(controller, parent) | ||
, m_controller(controller) | ||
{ | ||
Style::setBackgroundColor(this, json::theme::background_subtle, true); | ||
} | ||
|
||
void init() override | ||
{ | ||
m_controller->setHideDisabledButtons(KDDockWidgets::TitleBarButtonType::Close); | ||
KDDockWidgets::QtWidgets::TitleBar::init(); | ||
} | ||
|
||
private: | ||
KDDockWidgets::Core::TitleBar *const m_controller; | ||
}; | ||
|
||
class SCOPY_GUI_EXPORT TitleBarFactory : public KDDockWidgets::QtWidgets::ViewFactory | ||
{ | ||
Q_OBJECT | ||
public: | ||
KDDockWidgets::Core::View *createTitleBar(KDDockWidgets::Core::TitleBar *controller, | ||
KDDockWidgets::Core::View *parent) const override | ||
{ | ||
return new NoCloseTitleBar(controller, parent); | ||
} | ||
}; | ||
|
||
// Mark as static or inline to avoid ODR violation, this should only be used once in main.cpp anyway | ||
static void initDockWidgets() | ||
{ | ||
KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtWidgets); | ||
KDDockWidgets::Config::self().setViewFactory(new TitleBarFactory()); | ||
} | ||
} // namespace scopy | ||
|
||
#endif // USE_KDDOCKWIDGETS | ||
#endif // DOCKSETTINGS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2024 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DOCKWRAPPER_H | ||
#define DOCKWRAPPER_H | ||
|
||
#ifdef USE_KDDOCKWIDGETS | ||
#include "docking/dockwrapperkdab.h" | ||
using DockWrapper = scopy::kdab::DockWrapper; | ||
#else | ||
#include "docking/dockwrapperclassic.h" | ||
using DockWrapper = scopy::classic::DockWrapper; | ||
#endif // USE_KDDOCKWIDGETS | ||
#endif // DOCKWRAPPER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2024 Analog Devices Inc. | ||
* | ||
* This file is part of Scopy | ||
* (see https://www.github.com/analogdevicesinc/scopy). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DOCKWRAPPERCLASSIC_H | ||
#define DOCKWRAPPERCLASSIC_H | ||
|
||
#include "scopy-gui_export.h" | ||
#include <QWidget> | ||
#include "docking/dockwrapperinterface.h" | ||
|
||
namespace scopy::classic { | ||
class SCOPY_GUI_EXPORT DockWrapper : public QWidget, public DockWrapperInterface | ||
{ | ||
Q_OBJECT | ||
Q_INTERFACES(scopy::DockWrapperInterface) | ||
public: | ||
explicit DockWrapper(QString name, QWidget *parent = nullptr); | ||
|
||
void setInnerWidget(QWidget *innerWidget) override; | ||
QWidget *innerWidget() const override; | ||
|
||
void setActivated(bool isActivated) override; | ||
|
||
private: | ||
void init(); | ||
QWidget *m_innerWidget; | ||
}; | ||
} // namespace scopy::classic | ||
|
||
#endif // DOCKWRAPPERCLASSIC_H |
Oops, something went wrong.