Compare commits
2 Commits
2.0
...
wip/gtk_wi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8d977c240 | ||
|
|
6385d252e4 |
@@ -147,7 +147,7 @@ endif()
|
||||
|
||||
# BEGIN frontend enabling
|
||||
if(KDDockWidgets_FRONTENDS)
|
||||
set(KDDockWidgets_ALL_FRONTENDS "qtwidgets;qtquick;dummy")
|
||||
set(KDDockWidgets_ALL_FRONTENDS "qtwidgets;qtquick;dummy;gtk")
|
||||
|
||||
foreach(frontend ${KDDockWidgets_FRONTENDS})
|
||||
if(NOT ${frontend} IN_LIST KDDockWidgets_ALL_FRONTENDS)
|
||||
@@ -175,6 +175,14 @@ if(KDDockWidgets_FRONTENDS)
|
||||
find_package(Qt${Qt_VERSION_MAJOR} ${QT_MIN_VERSION} NO_MODULE REQUIRED COMPONENTS Gui)
|
||||
set(KDDW_FRONTEND_DUMMY ON)
|
||||
endif()
|
||||
|
||||
# gtk
|
||||
if("gtk" IN_LIST KDDockWidgets_FRONTENDS)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||
pkg_check_modules(GTKMM REQUIRED IMPORTED_TARGET gtkmm-3.0)
|
||||
set(KDDW_FRONTEND_GTK ON)
|
||||
endif()
|
||||
else()
|
||||
set(ENABLED_FRONTENDS "")
|
||||
message("No frontends specified explicitly.")
|
||||
@@ -193,6 +201,15 @@ else()
|
||||
set(KDDW_FRONTEND_QTQUICK ON)
|
||||
endif()
|
||||
|
||||
#gtk
|
||||
find_package(PkgConfig)
|
||||
if(PkgConfig_Found)
|
||||
pkg_check_modules(GTK IMPORTED_TARGET gtk+-3.0)
|
||||
endif()
|
||||
if(Gtk_Found)
|
||||
set(KDDW_FRONTEND_GTK ON)
|
||||
endif()
|
||||
|
||||
if(NOT ENABLED_FRONTENDS)
|
||||
message(FATAL_ERROR "Failed to enable any frontends. Please install the required libraries and try again.")
|
||||
endif()
|
||||
@@ -222,6 +239,10 @@ if(KDDW_FRONTEND_QTQUICK)
|
||||
set(KDDockWidgets_DEPS "${KDDockWidgets_DEPS} quick quickcontrols2")
|
||||
endif()
|
||||
|
||||
if(KDDW_FRONTEND_GTK)
|
||||
add_definitions(-DKDDW_FRONTEND_GTK)
|
||||
endif()
|
||||
|
||||
if(NOT WIN32
|
||||
AND NOT APPLE
|
||||
AND NOT EMSCRIPTEN
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"KDDockWidgets_DEVELOPER_MODE": "ON",
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
|
||||
"KDDockWidgets_FUZZER": "OFF",
|
||||
"KDDockWidgets_FRONTENDS": "qtwidgets;qtquick;dummy"
|
||||
"KDDockWidgets_FRONTENDS": "qtwidgets;qtquick;dummy;gtk"
|
||||
},
|
||||
"warnings": {
|
||||
"uninitialized": true
|
||||
@@ -29,7 +29,7 @@
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
|
||||
"KDDockWidgets_FUZZER": "OFF",
|
||||
"ECM_ENABLE_SANITIZERS": "'address;undefined'",
|
||||
"KDDockWidgets_FRONTENDS": "qtwidgets;qtquick;dummy"
|
||||
"KDDockWidgets_FRONTENDS": "qtwidgets;qtquick;dummy;gtk"
|
||||
},
|
||||
"warnings": {
|
||||
"uninitialized": true
|
||||
@@ -381,4 +381,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ version: 1.0.{build}-{branch}
|
||||
branches:
|
||||
except:
|
||||
- gh-pages
|
||||
- wip/v2
|
||||
- wip/gtk_window
|
||||
|
||||
# Do not build on tags (GitHub and BitBucket)
|
||||
skip_tags: false
|
||||
|
||||
@@ -8,4 +8,4 @@
|
||||
- In `Platform.cpp` add the needed `#include "yourplatform/Platform_yourplatform.h` include
|
||||
- Edit `Platform::tests_initPlatform()` and add your enumerator
|
||||
- Edit `Platform_yourfrontend::name()` to return an ID for your frontend
|
||||
- Run `./bin/tst_platform -tc="Platform::Platform,Platform::name"` , make sure it passes
|
||||
- Run `./bin/tst_platform Platform::Platform Platform::name` , make sure it passes
|
||||
|
||||
@@ -210,6 +210,10 @@ set(KDDW_FRONTEND_DUMMY_SRCS dummy/ViewFactory_dummy.cpp dummy/Platform_dummy.cp
|
||||
dummy/views/View_dummy.cpp dummy/TestHelpers_dummy.cpp
|
||||
)
|
||||
|
||||
set(KDDW_FRONTEND_GTK_SRCS gtk/Platform_gtk.cpp gtk/TestHelpers_gtk.cpp gtk/ViewFactory_gtk.cpp gtk/Window_gtk.cpp
|
||||
gtk/views/View_gtk.cpp
|
||||
)
|
||||
|
||||
set(KDDW_PUBLIC_HEADERS
|
||||
docks_export.h
|
||||
Config.h
|
||||
@@ -286,7 +290,11 @@ if(KDDW_FRONTEND_DUMMY)
|
||||
set(DOCKSLIBS_SRCS ${DOCKSLIBS_SRCS} ${KDDW_FRONTEND_DUMMY_SRCS})
|
||||
endif()
|
||||
|
||||
# Generate C/C++ CamelCase forwarding headers (only public includes)
|
||||
if(KDDW_FRONTEND_GTK)
|
||||
set(DOCKSLIBS_SRCS ${DOCKSLIBS_SRCS} ${KDDW_FRONTEND_GTK_SRCS})
|
||||
endif()
|
||||
|
||||
#Generate C/C++ CamelCase forwarding headers (only public includes)
|
||||
include(ECMGenerateHeaders)
|
||||
ecm_generate_headers(
|
||||
camelcase_HEADERS
|
||||
@@ -408,6 +416,18 @@ if(KDDW_FRONTEND_DUMMY)
|
||||
target_compile_definitions(kddockwidgets PUBLIC KDDW_FRONTEND_DUMMY)
|
||||
endif()
|
||||
|
||||
if(KDDW_FRONTEND_GTK)
|
||||
target_link_libraries(kddockwidgets PUBLIC PkgConfig::GTK PkgConfig::GTKMM)
|
||||
endif()
|
||||
|
||||
if(KDDW_FRONTEND_GTK)
|
||||
target_link_libraries(kddockwidgets PRIVATE PkgConfig::GTK PkgConfig::GTKMM)
|
||||
endif()
|
||||
|
||||
if(KDDockWidgets_CODE_COVERAGE)
|
||||
target_link_libraries(kddockwidgets PUBLIC coverage_options)
|
||||
endif()
|
||||
|
||||
if(KDDockWidgets_CODE_COVERAGE)
|
||||
target_link_libraries(kddockwidgets PUBLIC coverage_options)
|
||||
endif()
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
#include "dummy/Platform_dummy.h"
|
||||
#endif
|
||||
|
||||
#ifdef KDDW_FRONTEND_GTK
|
||||
#include "gtk/Platform_gtk.h"
|
||||
#endif
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
void KDDockWidgets::initFrontend(FrontendType type)
|
||||
@@ -40,6 +44,10 @@ void KDDockWidgets::initFrontend(FrontendType type)
|
||||
case FrontendType::QtQuick:
|
||||
#ifdef KDDW_FRONTEND_QTQUICK
|
||||
new Platform_qtquick();
|
||||
#endif
|
||||
case FrontendType::Gtk:
|
||||
#ifdef KDDW_FRONTEND_GTK
|
||||
new Platform_gtk();
|
||||
#endif
|
||||
break;
|
||||
case FrontendType::Dummy:
|
||||
|
||||
@@ -98,7 +98,8 @@ Q_DECLARE_FLAGS(IconPlaces, IconPlace)
|
||||
enum class FrontendType {
|
||||
QtWidgets = 1,
|
||||
QtQuick,
|
||||
Dummy ///< Just for boiler-plate / copy-paste purposes
|
||||
Dummy, ///< Just for boiler-plate / copy-paste purposes
|
||||
Gtk
|
||||
};
|
||||
Q_ENUM_NS(FrontendType)
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
#include "dummy/Platform_dummy.h"
|
||||
#endif
|
||||
|
||||
#ifdef KDDW_FRONTEND_GTK
|
||||
#include "gtk/Platform_gtk.h"
|
||||
#endif
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <qglobal.h>
|
||||
@@ -117,6 +121,10 @@ void Platform::tests_initPlatform(int &argc, char **argv, KDDockWidgets::Fronten
|
||||
case FrontendType::Dummy:
|
||||
#ifdef KDDW_FRONTEND_DUMMY
|
||||
platform = new Platform_dummy(argc, argv);
|
||||
break;
|
||||
case FrontendType::Gtk:
|
||||
#ifdef KDDW_FRONTEND_GTK
|
||||
platform = new Platform_gtk(argc, argv);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@@ -146,6 +154,8 @@ void Platform::tests_deinitPlatform()
|
||||
delete plat;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**static*/
|
||||
std::vector<KDDockWidgets::FrontendType> Platform::frontendTypes()
|
||||
{
|
||||
@@ -171,6 +181,10 @@ std::vector<KDDockWidgets::FrontendType> Platform::frontendTypes()
|
||||
types.push_back(FrontendType::QtWidgets);
|
||||
#endif
|
||||
|
||||
#ifdef KDDW_FRONTEND_GTK
|
||||
types.push_back(FrontendType::Gtk);
|
||||
#endif
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
125
src/gtk/Platform_gtk.cpp
Normal file
125
src/gtk/Platform_gtk.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#include "Platform_gtk.h"
|
||||
#include "kddockwidgets/KDDockWidgets.h"
|
||||
|
||||
#include "Window_gtk.h"
|
||||
#include "views/View_gtk.h"
|
||||
#include "private/Platform_p.h"
|
||||
#include "ViewFactory_gtk.h"
|
||||
|
||||
#include <QScreen>
|
||||
#include <QApplication>
|
||||
#include <QLineEdit>
|
||||
#include <QAbstractButton>
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
|
||||
|
||||
Platform_gtk::Platform_gtk()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void Platform_gtk::init()
|
||||
{
|
||||
}
|
||||
|
||||
Platform_gtk::~Platform_gtk()
|
||||
{
|
||||
}
|
||||
|
||||
const char *Platform_gtk::name() const
|
||||
{
|
||||
return "gtk";
|
||||
}
|
||||
|
||||
bool Platform_gtk::hasActivePopup() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ViewFactory *Platform_gtk::createDefaultViewFactory()
|
||||
{
|
||||
return new ViewFactory_gtk();
|
||||
}
|
||||
|
||||
Window::Ptr Platform_gtk::windowAt(QPoint) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
int Platform_gtk::screenNumberFor(View *) const
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
QSize Platform_gtk::screenSizeFor(View *) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
View *Platform_gtk::createView(View *) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Platform_gtk::usesFallbackMouseGrabber() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform_gtk::inDisallowedDragView(QPoint) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void Platform_gtk::ungrabMouse()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<View> Platform_gtk::focusedView() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QVector<std::shared_ptr<Window>> Platform_gtk::windows() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void Platform_gtk::sendEvent(View *, QEvent *) const
|
||||
{
|
||||
}
|
||||
|
||||
int Platform_gtk::screenNumberFor(std::shared_ptr<Window>) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void Platform_gtk::installMessageHandler()
|
||||
{
|
||||
}
|
||||
|
||||
void Platform_gtk::uninstallMessageHandler()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<Window> Platform_gtk::tests_createWindow()
|
||||
{
|
||||
auto gtkWindow = new Gtk::Window();
|
||||
return std::make_shared<Window_gtk>(gtkWindow);
|
||||
}
|
||||
88
src/gtk/Platform_gtk.h
Normal file
88
src/gtk/Platform_gtk.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "kddockwidgets/Platform.h"
|
||||
|
||||
#include <gtkmm/application.h>
|
||||
|
||||
namespace KDDockWidgets {
|
||||
|
||||
namespace Controllers {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
/// @brief implements functions specific to a particular platform
|
||||
/// A platform can be for example qtwidgets, qtquick, etc.
|
||||
class DOCKS_EXPORT Platform_gtk : public Platform
|
||||
{
|
||||
public:
|
||||
Platform_gtk();
|
||||
~Platform_gtk() override;
|
||||
const char *name() const override;
|
||||
bool hasActivePopup() const override;
|
||||
ViewFactory *createDefaultViewFactory() override;
|
||||
std::shared_ptr<Window> windowAt(QPoint globalPos) const override;
|
||||
|
||||
int screenNumberFor(View *) const override;
|
||||
QSize screenSizeFor(View *) const override;
|
||||
|
||||
View *createView(View *parent = nullptr) const override;
|
||||
bool inDisallowedDragView(QPoint globalPos) const override;
|
||||
bool usesFallbackMouseGrabber() const override;
|
||||
void ungrabMouse() override;
|
||||
|
||||
#ifdef DOCKS_DEVELOPER_MODE
|
||||
explicit Platform_gtk(int &argc, char **argv);
|
||||
void tests_initPlatform_impl() override;
|
||||
void tests_deinitPlatform_impl() override;
|
||||
View *tests_createView(CreateViewOptions, View *parent = nullptr) override;
|
||||
View *tests_createFocusableView(CreateViewOptions, View *parent = nullptr) override;
|
||||
View *tests_createNonClosableView(View *parent = nullptr) override;
|
||||
Controllers::MainWindow *createMainWindow(const QString &uniqueName, CreateViewOptions,
|
||||
MainWindowOptions options = MainWindowOption_HasCentralFrame,
|
||||
View *parent = nullptr, Qt::WindowFlags = {}) const override;
|
||||
bool tests_waitForWindowActive(std::shared_ptr<Window>, int timeout) const override;
|
||||
bool tests_waitForResize(View *, int timeout) const override;
|
||||
bool tests_waitForResize(Controller *, int timeout) const override;
|
||||
bool tests_waitForEvent(QObject *w, QEvent::Type type, int timeout) const override;
|
||||
bool tests_waitForEvent(View *, QEvent::Type type, int timeout) const override;
|
||||
bool tests_waitForEvent(std::shared_ptr<Window>, QEvent::Type type, int timeout) const override;
|
||||
bool tests_waitForDeleted(View *, int timeout) const override;
|
||||
bool tests_waitForDeleted(QObject *, int timeout) const override;
|
||||
std::shared_ptr<Window> tests_createWindow() override;
|
||||
void tests_sendEvent(std::shared_ptr<Window> window, QEvent *ev) const override;
|
||||
void tests_wait(int ms) override;
|
||||
#endif
|
||||
|
||||
bool isProcessingAppQuitEvent() const override;
|
||||
QString applicationName() const override;
|
||||
QString organizationName() const override;
|
||||
void setMouseCursor(Qt::CursorShape) override;
|
||||
void restoreMouseCursor() override;
|
||||
DisplayType displayType() const override;
|
||||
bool isLeftMouseButtonPressed() const override;
|
||||
|
||||
std::shared_ptr<View> focusedView() const override;
|
||||
QVector<std::shared_ptr<Window>> windows() const override;
|
||||
void sendEvent(View *, QEvent *) const override;
|
||||
int screenNumberFor(std::shared_ptr<Window>) const override;
|
||||
void installMessageHandler() override;
|
||||
void uninstallMessageHandler() override;
|
||||
|
||||
protected:
|
||||
void init();
|
||||
|
||||
private:
|
||||
Glib::RefPtr<Gtk::Application> m_application;
|
||||
};
|
||||
}
|
||||
243
src/gtk/TestHelpers_gtk.cpp
Normal file
243
src/gtk/TestHelpers_gtk.cpp
Normal file
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group
|
||||
company <info@kdab.com> Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#include "kddockwidgets/KDDockWidgets.h"
|
||||
#include "Platform_gtk.h"
|
||||
#include "views/View_gtk.h"
|
||||
// #include "views/MainWindow_gtk.h"
|
||||
#include "kddockwidgets/controllers/MainWindow.h"
|
||||
|
||||
#include <gtkmm/window.h>
|
||||
#include <gtkmm/applicationwindow.h>
|
||||
#include <gtkmm/button.h>
|
||||
#include <gtkmm/main.h>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
#ifdef DOCKS_DEVELOPER_MODE
|
||||
|
||||
namespace KDDockWidgets {
|
||||
|
||||
class TestView_gtk : public Views::View_gtk
|
||||
{
|
||||
public:
|
||||
explicit TestView_gtk(Platform::CreateViewOptions opts, QWidget *)
|
||||
: Views::View_gtk(nullptr, Type::None, nullptr /* TODO parent*/)
|
||||
, m_opts(opts)
|
||||
{
|
||||
}
|
||||
|
||||
~TestView_gtk();
|
||||
|
||||
QSize sizeHint() const override
|
||||
{
|
||||
return m_opts.sizeHint;
|
||||
}
|
||||
|
||||
QSize maxSizeHint() const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
Platform::CreateViewOptions m_opts;
|
||||
};
|
||||
|
||||
class FocusableTestView_gtk : public Views::View_gtk
|
||||
{
|
||||
public:
|
||||
explicit FocusableTestView_gtk(Platform::CreateViewOptions opts, QWidget *)
|
||||
: Views::View_gtk(nullptr, Type::None, nullptr /* TODO parent*/)
|
||||
, m_opts(opts)
|
||||
{
|
||||
}
|
||||
|
||||
~FocusableTestView_gtk();
|
||||
|
||||
QSize sizeHint() const override
|
||||
{
|
||||
return m_opts.sizeHint;
|
||||
}
|
||||
|
||||
QSize maxSizeHint() const override
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
Platform::CreateViewOptions m_opts;
|
||||
};
|
||||
|
||||
class NonClosableTestView_gtk : public Views::View_gtk
|
||||
{
|
||||
public:
|
||||
explicit NonClosableTestView_gtk(QWidget *)
|
||||
: Views::View_gtk(nullptr, Type::None, nullptr /* TODO parent*/)
|
||||
{
|
||||
}
|
||||
|
||||
~NonClosableTestView_gtk();
|
||||
};
|
||||
|
||||
TestView_gtk::~TestView_gtk() = default;
|
||||
NonClosableTestView_gtk::~NonClosableTestView_gtk() = default;
|
||||
FocusableTestView_gtk::~FocusableTestView_gtk() = default;
|
||||
|
||||
}
|
||||
|
||||
Platform_gtk::Platform_gtk(int &argc, char **argv)
|
||||
: Platform()
|
||||
{
|
||||
m_application = Gtk::Application::create(argc, argv, "com.kdab.kddockwidgets.tests");
|
||||
init();
|
||||
}
|
||||
|
||||
void Platform_gtk::tests_initPlatform_impl()
|
||||
{
|
||||
}
|
||||
|
||||
void Platform_gtk::tests_deinitPlatform_impl()
|
||||
{
|
||||
}
|
||||
|
||||
View *Platform_gtk::tests_createView(CreateViewOptions, View *)
|
||||
{
|
||||
|
||||
// GtkWidget *root = gtk_button_new_with_label("button1");
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
View *Platform_gtk::tests_createFocusableView(CreateViewOptions, View *)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
View *Platform_gtk::tests_createNonClosableView(View *)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
Controllers::MainWindow *Platform_gtk::createMainWindow(const QString &,
|
||||
CreateViewOptions, MainWindowOptions,
|
||||
View *, Qt::WindowFlags) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
bool Platform_gtk::tests_waitForWindowActive(std::shared_ptr<Window>, int timeout) const
|
||||
{
|
||||
( void )timeout;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform_gtk::tests_waitForResize(View *, int timeout) const
|
||||
{
|
||||
( void )timeout;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform_gtk::tests_waitForResize(Controller *, int timeout) const
|
||||
{
|
||||
( void )timeout;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform_gtk::tests_waitForEvent(QObject *w, QEvent::Type type, int timeout) const
|
||||
{
|
||||
( void )w;
|
||||
( void )type;
|
||||
( void )timeout;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform_gtk::tests_waitForEvent(View *, QEvent::Type type, int timeout) const
|
||||
{
|
||||
( void )type;
|
||||
( void )timeout;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform_gtk::tests_waitForEvent(std::shared_ptr<Window>, QEvent::Type type, int timeout) const
|
||||
{
|
||||
( void )type;
|
||||
( void )timeout;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform_gtk::tests_waitForDeleted(View *, int timeout) const
|
||||
{
|
||||
( void )timeout;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform_gtk::tests_waitForDeleted(QObject *, int timeout) const
|
||||
{
|
||||
( void )timeout;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Platform_gtk::tests_sendEvent(std::shared_ptr<Window> window, QEvent *ev) const
|
||||
{
|
||||
( void )window;
|
||||
( void )ev;
|
||||
}
|
||||
|
||||
void Platform_gtk::tests_wait(int ms)
|
||||
{
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
long elapsed = 0;
|
||||
|
||||
while (elapsed < ms) {
|
||||
Gtk::Main::iteration();
|
||||
|
||||
const auto end = std::chrono::steady_clock::now();
|
||||
elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
||||
}
|
||||
}
|
||||
|
||||
bool Platform_gtk::isProcessingAppQuitEvent() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QString Platform_gtk::applicationName() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QString Platform_gtk::organizationName() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void Platform_gtk::setMouseCursor(Qt::CursorShape)
|
||||
{
|
||||
}
|
||||
|
||||
void Platform_gtk::restoreMouseCursor()
|
||||
{
|
||||
}
|
||||
|
||||
Platform::DisplayType Platform_gtk::displayType() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
bool Platform_gtk::isLeftMouseButtonPressed() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
#endif
|
||||
185
src/gtk/ViewFactory_gtk.cpp
Normal file
185
src/gtk/ViewFactory_gtk.cpp
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#include "ViewFactory_gtk.h"
|
||||
#include "Config.h"
|
||||
|
||||
#include "private/Utils_p.h"
|
||||
|
||||
#include "kddockwidgets/controllers/TabBar.h"
|
||||
#include "kddockwidgets/controllers/Stack.h"
|
||||
#include "kddockwidgets/controllers/FloatingWindow.h"
|
||||
#include "kddockwidgets/controllers/indicators/ClassicIndicators.h"
|
||||
#include "kddockwidgets/controllers/indicators/NullIndicators.h"
|
||||
#include "kddockwidgets/controllers/indicators/SegmentedIndicators.h"
|
||||
#include "kddockwidgets/controllers/MainWindow.h"
|
||||
|
||||
#include "qtwidgets/views/ClassicIndicatorsWindow_qtwidgets.h"
|
||||
#include "qtwidgets/views/SegmentedIndicatorsOverlay_qtwidgets.h"
|
||||
#include "qtwidgets/views/FloatingWindow_qtwidgets.h"
|
||||
#include "qtwidgets/views/DockWidget_qtwidgets.h"
|
||||
#include "qtwidgets/views/DropArea_qtwidgets.h"
|
||||
#include "qtwidgets/views/Group_qtwidgets.h"
|
||||
#include "qtwidgets/views/View_qtwidgets.h"
|
||||
#include "qtwidgets/views/Separator_qtwidgets.h"
|
||||
#include "qtwidgets/views/TitleBar_qtwidgets.h"
|
||||
#include "qtwidgets/views/TabBar_qtwidgets.h"
|
||||
#include "qtwidgets/views/SideBar_qtwidgets.h"
|
||||
#include "qtwidgets/views/Stack_qtwidgets.h"
|
||||
#include "qtwidgets/views/MainWindow_qtwidgets.h"
|
||||
#include "qtwidgets/views/MDILayout_qtwidgets.h"
|
||||
#include "qtwidgets/views/RubberBand_qtwidgets.h"
|
||||
|
||||
#include "views/ClassicIndicatorWindowViewInterface.h"
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
|
||||
// clazy:excludeall=ctor-missing-parent-argument
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
|
||||
ViewFactory_gtk::~ViewFactory_gtk()
|
||||
{
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createDockWidget(const QString &uniqueName,
|
||||
DockWidgetOptions options,
|
||||
LayoutSaverOptions layoutSaverOptions,
|
||||
Qt::WindowFlags windowFlags) const
|
||||
{
|
||||
return new Views::DockWidget_qtwidgets(uniqueName, options, layoutSaverOptions, windowFlags);
|
||||
}
|
||||
|
||||
|
||||
View *ViewFactory_gtk::createGroup(Controllers::Group *controller, View *parent = nullptr) const
|
||||
{
|
||||
return new Views::Group_qtwidgets(controller, Views::View_qtwidgets<QWidget>::asQWidget(parent));
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createTitleBar(Controllers::TitleBar *titleBar, View *parent) const
|
||||
{
|
||||
return new Views::TitleBar_qtwidgets(titleBar, parent);
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createTabBar(Controllers::TabBar *tabBar, View *parent) const
|
||||
{
|
||||
return new Views::TabBar_qtwidgets(tabBar, Views::View_qtwidgets<QWidget>::asQWidget(parent));
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createStack(Controllers::Stack *controller, View *parent) const
|
||||
{
|
||||
return new Views::Stack_qtwidgets(controller, Views::View_qtwidgets<QWidget>::asQWidget(parent));
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createSeparator(Controllers::Separator *controller, View *parent) const
|
||||
{
|
||||
return new Views::Separator_qtwidgets(controller, parent);
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createFloatingWindow(Controllers::FloatingWindow *controller,
|
||||
Controllers::MainWindow *parent, Qt::WindowFlags windowFlags) const
|
||||
{
|
||||
auto mainwindow = qobject_cast<QMainWindow *>(Views::View_qtwidgets<QWidget>::asQWidget(parent));
|
||||
return new Views::FloatingWindow_qtwidgets(controller, mainwindow, windowFlags);
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createRubberBand(View *) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createSideBar(Controllers::SideBar *controller,
|
||||
View *parent) const
|
||||
{
|
||||
return new Views::SideBar_qtwidgets(controller, Views::View_qtwidgets<QWidget>::asQWidget(parent));
|
||||
}
|
||||
|
||||
QAbstractButton *ViewFactory_gtk::createTitleBarButton(QWidget *parent, TitleBarButtonType type) const
|
||||
{
|
||||
if (!parent) {
|
||||
qWarning() << Q_FUNC_INFO << "Parent not provided";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto button = new Views::Button(parent);
|
||||
button->setIcon(iconForButtonType(type, parent->devicePixelRatioF()));
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
// iconForButtonType impl is the same for QtQuick and QtWidgets
|
||||
QIcon ViewFactory_gtk::iconForButtonType(TitleBarButtonType type, qreal dpr) const
|
||||
{
|
||||
QString iconName;
|
||||
switch (type) {
|
||||
case TitleBarButtonType::AutoHide:
|
||||
iconName = QStringLiteral("auto-hide");
|
||||
break;
|
||||
case TitleBarButtonType::UnautoHide:
|
||||
iconName = QStringLiteral("unauto-hide");
|
||||
break;
|
||||
case TitleBarButtonType::Close:
|
||||
iconName = QStringLiteral("close");
|
||||
break;
|
||||
case TitleBarButtonType::Minimize:
|
||||
iconName = QStringLiteral("min");
|
||||
break;
|
||||
case TitleBarButtonType::Maximize:
|
||||
iconName = QStringLiteral("max");
|
||||
break;
|
||||
case TitleBarButtonType::Normal:
|
||||
// We're using the same icon as dock/float
|
||||
iconName = QStringLiteral("dock-float");
|
||||
break;
|
||||
case TitleBarButtonType::Float:
|
||||
iconName = QStringLiteral("dock-float");
|
||||
break;
|
||||
}
|
||||
|
||||
if (iconName.isEmpty())
|
||||
return {};
|
||||
|
||||
QIcon icon(QStringLiteral(":/img/%1.png").arg(iconName));
|
||||
if (!scalingFactorIsSupported(dpr))
|
||||
return icon;
|
||||
|
||||
// Not using Qt's sugar syntax, which doesn't support 1.5x anyway when we need it.
|
||||
// Simply add the high-res files and Qt will pick them when needed
|
||||
|
||||
if (scalingFactorIsSupported(1.5))
|
||||
icon.addFile(QStringLiteral(":/img/%1-1.5x.png").arg(iconName));
|
||||
|
||||
icon.addFile(QStringLiteral(":/img/%1-2x.png").arg(iconName));
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createDropArea(Controllers::DropArea *controller, View *parent) const
|
||||
{
|
||||
return new Views::DropArea_qtwidgets(controller, parent);
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createMDILayout(Controllers::MDILayout *controller, View *parent) const
|
||||
{
|
||||
return new Views::MDILayout_qtwidgets(controller, parent);
|
||||
}
|
||||
|
||||
View *ViewFactory_gtk::createSegmentedDropIndicatorOverlayView(Controllers::SegmentedIndicators *, View *) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Views::ClassicIndicatorWindowViewInterface *ViewFactory_gtk::createClassicIndicatorWindow(Controllers::ClassicIndicators *) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
86
src/gtk/ViewFactory_gtk.h
Normal file
86
src/gtk/ViewFactory_gtk.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#ifndef KDDOCKWIDGETS_ViewFactory_GTK_H
|
||||
#define KDDOCKWIDGETS_ViewFactory_GTK_H
|
||||
#pragma once
|
||||
|
||||
#include "kddockwidgets/ViewFactory.h"
|
||||
|
||||
// clazy:excludeall=ctor-missing-parent-argument
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief A factory class for allowing the user to customize some internal widgets.
|
||||
*
|
||||
* @author Sérgio Martins \<sergio.martins@kdab.com\>
|
||||
*/
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
namespace KDDockWidgets {
|
||||
|
||||
class DropIndicatorOverlay;
|
||||
|
||||
namespace Controllers {
|
||||
class MDILayoutWidget;
|
||||
class DropArea;
|
||||
class Separator;
|
||||
class TabBar;
|
||||
class SideBar;
|
||||
class FloatingWindow;
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The default ViewFactory for QtWidgets frontend.
|
||||
*/
|
||||
class DOCKS_EXPORT ViewFactory_gtk : public ViewFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ViewFactory_gtk() = default;
|
||||
~ViewFactory_gtk() override;
|
||||
|
||||
View *createDockWidget(const QString &uniqueName,
|
||||
DockWidgetOptions = {},
|
||||
LayoutSaverOptions = {},
|
||||
Qt::WindowFlags = {}) const override;
|
||||
|
||||
View *createGroup(Controllers::Group *, View *parent) const override;
|
||||
View *createTitleBar(Controllers::TitleBar *, View *parent) const override;
|
||||
View *createStack(Controllers::Stack *, View *parent) const override;
|
||||
View *createTabBar(Controllers::TabBar *tabBar, View *parent) const override;
|
||||
View *createSeparator(Controllers::Separator *, View *parent = nullptr) const override;
|
||||
View *createFloatingWindow(Controllers::FloatingWindow *,
|
||||
Controllers::MainWindow *parent = nullptr,
|
||||
Qt::WindowFlags windowFlags = {}) const override;
|
||||
View *createRubberBand(View *parent) const override;
|
||||
View *createSideBar(Controllers::SideBar *, View *parent) const override;
|
||||
View *createDropArea(Controllers::DropArea *, View *parent) const override;
|
||||
View *createMDILayout(Controllers::MDILayout *, View *parent) const override;
|
||||
QIcon iconForButtonType(TitleBarButtonType type, qreal dpr) const override;
|
||||
QAbstractButton *createTitleBarButton(QWidget *parent, TitleBarButtonType) const;
|
||||
|
||||
Views::ClassicIndicatorWindowViewInterface *createClassicIndicatorWindow(Controllers::ClassicIndicators *) const override;
|
||||
|
||||
View *createSegmentedDropIndicatorOverlayView(Controllers::SegmentedIndicators *controller, View *parent = nullptr) const override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(ViewFactory_gtk)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
183
src/gtk/Window_gtk.cpp
Normal file
183
src/gtk/Window_gtk.cpp
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
|
||||
#include "Window_gtk.h"
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
Window_gtk::Window_gtk(Gtk::Window *topLevel)
|
||||
: Window()
|
||||
, m_window(topLevel)
|
||||
{
|
||||
m_window->show();
|
||||
}
|
||||
|
||||
Window_gtk::~Window_gtk() = default;
|
||||
|
||||
std::shared_ptr<View> Window_gtk::rootView() const
|
||||
{
|
||||
// TODOgtk
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Window::Ptr Window_gtk::transientParent() const
|
||||
{
|
||||
// TODOgtk
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Window_gtk::setGeometry(QRect rect) const
|
||||
{
|
||||
m_window->move(rect.x(), rect.y());
|
||||
m_window->resize(rect.width(), rect.height());
|
||||
}
|
||||
|
||||
void Window_gtk::setVisible(bool is)
|
||||
{
|
||||
m_window->set_visible(is);
|
||||
}
|
||||
|
||||
bool Window_gtk::supportsHonouringLayoutMinSize() const
|
||||
{
|
||||
// maybe...
|
||||
return false;
|
||||
}
|
||||
|
||||
void Window_gtk::setWindowState(WindowState state)
|
||||
{
|
||||
switch (state) {
|
||||
case WindowState::None:
|
||||
// TODOgtk: Show normal
|
||||
break;
|
||||
case WindowState::Minimized:
|
||||
// TODOgtk: Show minimized
|
||||
break;
|
||||
case WindowState::Maximized:
|
||||
// TODOgtk: Show maximized
|
||||
break;
|
||||
case WindowState::FullScreen:
|
||||
// TODOgtkgtk: Show maximized
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QRect Window_gtk::geometry() const
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
|
||||
m_window->get_position(x, y);
|
||||
m_window->get_size(width, height);
|
||||
|
||||
return QRect(x, y, width, height);
|
||||
}
|
||||
|
||||
bool Window_gtk::isVisible() const
|
||||
{
|
||||
return m_window->is_visible();
|
||||
}
|
||||
|
||||
WId Window_gtk::handle() const
|
||||
{
|
||||
return WId(m_window);
|
||||
}
|
||||
|
||||
bool Window_gtk::equals(std::shared_ptr<Window> other) const
|
||||
{
|
||||
if (!other)
|
||||
return false;
|
||||
|
||||
auto otherGtk = static_cast<Window_gtk *>(other.get());
|
||||
return m_window == otherGtk->m_window;
|
||||
}
|
||||
|
||||
void Window_gtk::setFramePosition(QPoint)
|
||||
{
|
||||
}
|
||||
|
||||
QRect Window_gtk::frameGeometry() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void Window_gtk::resize(int width, int height)
|
||||
{
|
||||
m_window->resize(width, height);
|
||||
}
|
||||
|
||||
bool Window_gtk::isActive() const
|
||||
{
|
||||
return m_window->is_active();
|
||||
}
|
||||
|
||||
WindowState Window_gtk::windowState() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QPoint Window_gtk::mapFromGlobal(QPoint) const
|
||||
{
|
||||
// TODOgtk
|
||||
return {};
|
||||
}
|
||||
|
||||
QPoint Window_gtk::mapToGlobal(QPoint) const
|
||||
{
|
||||
// TODOgtk
|
||||
return {};
|
||||
}
|
||||
|
||||
QScreen *Window_gtk::screen() const
|
||||
{
|
||||
// Needs a KDDockWidgets::Screen class
|
||||
return {};
|
||||
}
|
||||
|
||||
void Window_gtk::destroy()
|
||||
{
|
||||
delete m_window;
|
||||
}
|
||||
|
||||
QSize Window_gtk::minSize() const
|
||||
{
|
||||
// TODOgtk
|
||||
return {};
|
||||
}
|
||||
|
||||
QSize Window_gtk::maxSize() const
|
||||
{
|
||||
// TODOgtk
|
||||
return {};
|
||||
}
|
||||
|
||||
QPoint Window_gtk::fromNativePixels(QPoint pt) const
|
||||
{
|
||||
/// Only used on Windows...
|
||||
return pt;
|
||||
}
|
||||
|
||||
bool Window_gtk::isFullScreen() const
|
||||
{
|
||||
// TODOgtk
|
||||
return false;
|
||||
}
|
||||
|
||||
void Window_gtk::setProperty(const char *, const QVariant &)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant Window_gtk::property(const char *) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
53
src/gtk/Window_gtk.h
Normal file
53
src/gtk/Window_gtk.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "kddockwidgets/Window.h"
|
||||
|
||||
#include <gtkmm/window.h>
|
||||
|
||||
namespace KDDockWidgets {
|
||||
class DOCKS_EXPORT Window_gtk : public Window
|
||||
{
|
||||
public:
|
||||
explicit Window_gtk(Gtk::Window *topLevel);
|
||||
~Window_gtk() override;
|
||||
std::shared_ptr<View> rootView() const override;
|
||||
Window::Ptr transientParent() const override;
|
||||
void setGeometry(QRect) const override;
|
||||
void setVisible(bool) override;
|
||||
bool supportsHonouringLayoutMinSize() const override;
|
||||
void setWindowState(WindowState) override;
|
||||
QRect geometry() const override;
|
||||
bool isVisible() const override;
|
||||
WId handle() const override;
|
||||
bool equals(std::shared_ptr<Window> other) const override;
|
||||
void setFramePosition(QPoint targetPos) override;
|
||||
QRect frameGeometry() const override;
|
||||
void resize(int width, int height) override;
|
||||
bool isActive() const override;
|
||||
WindowState windowState() const override;
|
||||
QPoint mapFromGlobal(QPoint globalPos) const override;
|
||||
QPoint mapToGlobal(QPoint localPos) const override;
|
||||
QScreen *screen() const override;
|
||||
void destroy() override;
|
||||
QSize minSize() const override;
|
||||
QSize maxSize() const override;
|
||||
QPoint fromNativePixels(QPoint) const override;
|
||||
bool isFullScreen() const override;
|
||||
void setProperty(const char *name, const QVariant &value) override;
|
||||
QVariant property(const char *name) const override;
|
||||
|
||||
private:
|
||||
Gtk::Window *const m_window;
|
||||
};
|
||||
}
|
||||
339
src/gtk/views/View_gtk.cpp
Normal file
339
src/gtk/views/View_gtk.cpp
Normal file
@@ -0,0 +1,339 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#include "View_gtk.h"
|
||||
#include "private/Utils_p.h"
|
||||
#include "private/View_p.h"
|
||||
#include "private/multisplitter/Item_p.h"
|
||||
#include "../Window_gtk.h"
|
||||
|
||||
#include <qpa/qplatformwindow.h>
|
||||
#include <QGuiApplication>
|
||||
#include <QFile>
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
using namespace KDDockWidgets::Views;
|
||||
|
||||
|
||||
|
||||
View_gtk::View_gtk(KDDockWidgets::Controller *controller, Type type,
|
||||
void *parent, Qt::WindowFlags)
|
||||
: View(controller, type)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
}
|
||||
|
||||
void View_gtk::setGeometry(QRect)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void View_gtk::move(int, int)
|
||||
{
|
||||
}
|
||||
|
||||
bool View_gtk::close()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool View_gtk::isVisible() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void View_gtk::setVisible(bool)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::setSize(int, int)
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<View> View_gtk::rootView() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void View_gtk::setAttribute(Qt::WidgetAttribute, bool)
|
||||
{
|
||||
}
|
||||
|
||||
bool View_gtk::testAttribute(Qt::WidgetAttribute) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void View_gtk::setFlag(Qt::WindowType, bool)
|
||||
{
|
||||
}
|
||||
|
||||
Qt::WindowFlags View_gtk::flags() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void View_gtk::free_impl()
|
||||
{
|
||||
// QObject::deleteLater();
|
||||
delete this;
|
||||
}
|
||||
|
||||
QSize View_gtk::sizeHint() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QSize View_gtk::minSize() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QSize View_gtk::maxSizeHint() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QSize View_gtk::maximumSize() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QRect View_gtk::geometry() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QRect View_gtk::normalGeometry() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void View_gtk::setNormalGeometry(QRect)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::setMaximumSize(QSize)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::setWidth(int)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::setHeight(int)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::setFixedWidth(int)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::setFixedHeight(int)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::show()
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::hide()
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::updateGeometry()
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::update()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void View_gtk::setParent(View *)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::raiseAndActivate()
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::activateWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::raise()
|
||||
{
|
||||
}
|
||||
|
||||
QVariant View_gtk::property(const char *) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
bool View_gtk::isRootView() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QPoint View_gtk::mapToGlobal(QPoint) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QPoint View_gtk::mapFromGlobal(QPoint) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QPoint View_gtk::mapTo(View *, QPoint) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void View_gtk::setWindowOpacity(double)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::setSizePolicy(SizePolicy, SizePolicy)
|
||||
{
|
||||
}
|
||||
|
||||
SizePolicy View_gtk::verticalSizePolicy() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
SizePolicy View_gtk::horizontalSizePolicy() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void View_gtk::setWindowTitle(const QString &)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::setWindowIcon(const QIcon &)
|
||||
{
|
||||
}
|
||||
|
||||
bool View_gtk::isActiveWindow() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void View_gtk::showNormal()
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::showMinimized()
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::showMaximized()
|
||||
{
|
||||
}
|
||||
|
||||
bool View_gtk::isMinimized() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
bool View_gtk::isMaximized() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::shared_ptr<Window> View_gtk::window() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::shared_ptr<View> View_gtk::childViewAt(QPoint) const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::shared_ptr<View> View_gtk::parentView() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::shared_ptr<View> View_gtk::asWrapper()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void View_gtk::setObjectName(const QString &)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::grabMouse()
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::releaseMouse()
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::releaseKeyboard()
|
||||
{
|
||||
// Not needed for QtQuick
|
||||
}
|
||||
|
||||
void View_gtk::setFocus(Qt::FocusReason)
|
||||
{
|
||||
}
|
||||
|
||||
bool View_gtk::hasFocus() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Qt::FocusPolicy View_gtk::focusPolicy() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void View_gtk::setFocusPolicy(Qt::FocusPolicy)
|
||||
{
|
||||
}
|
||||
|
||||
QString View_gtk::objectName() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void View_gtk::setMinimumSize(QSize)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::render(QPainter *)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::setCursor(Qt::CursorShape)
|
||||
{
|
||||
}
|
||||
|
||||
void View_gtk::setMouseTracking(bool)
|
||||
{
|
||||
}
|
||||
|
||||
QVector<std::shared_ptr<View>> View_gtk::childViews() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void View_gtk::setZOrder(int)
|
||||
{
|
||||
}
|
||||
143
src/gtk/views/View_gtk.h
Normal file
143
src/gtk/views/View_gtk.h
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2020-2022 Klarälvdalens Datakonsult AB, a KDAB Group
|
||||
company <info@kdab.com> Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "kddockwidgets/Controller.h"
|
||||
#include "kddockwidgets/View.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QResizeEvent>
|
||||
#include <QScopedValueRollback>
|
||||
#include <QScreen>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace KDDockWidgets::Views {
|
||||
|
||||
|
||||
class DOCKS_EXPORT View_gtk : public View
|
||||
{
|
||||
public:
|
||||
using View::close;
|
||||
using View::height;
|
||||
using View::minimumHeight;
|
||||
|
||||
using View::minimumWidth;
|
||||
using View::rect;
|
||||
using View::resize;
|
||||
using View::width;
|
||||
|
||||
explicit View_gtk(KDDockWidgets::Controller *controller, Type type,
|
||||
void *parent, Qt::WindowFlags windowFlags = {});
|
||||
|
||||
~View_gtk() override = default;
|
||||
|
||||
void free_impl() override;
|
||||
QSize sizeHint() const override;
|
||||
QSize minSize() const override;
|
||||
QSize maxSizeHint() const override;
|
||||
QSize maximumSize() const override;
|
||||
QRect geometry() const override;
|
||||
QRect normalGeometry() const override;
|
||||
void setNormalGeometry(QRect geo);
|
||||
void setGeometry(QRect) override;
|
||||
void setMaximumSize(QSize sz) override;
|
||||
|
||||
bool isVisible() const override;
|
||||
void setVisible(bool is) override;
|
||||
|
||||
void move(int x, int y) override;
|
||||
void setSize(int w, int h) override;
|
||||
|
||||
void setWidth(int w) override;
|
||||
void setHeight(int h) override;
|
||||
void setFixedWidth(int w) override;
|
||||
void setFixedHeight(int h) override;
|
||||
void show() override;
|
||||
void hide() override;
|
||||
void updateGeometry();
|
||||
void update() override;
|
||||
void setParent(View *parent) override;
|
||||
void raiseAndActivate() override;
|
||||
void activateWindow() override;
|
||||
void raise() override;
|
||||
QVariant property(const char *name) const override;
|
||||
bool isRootView() const override;
|
||||
QPoint mapToGlobal(QPoint localPt) const override;
|
||||
QPoint mapFromGlobal(QPoint globalPt) const override;
|
||||
QPoint mapTo(View *parent, QPoint pos) const override;
|
||||
void setWindowOpacity(double v) override;
|
||||
void setSizePolicy(SizePolicy, SizePolicy) override;
|
||||
SizePolicy verticalSizePolicy() const override;
|
||||
SizePolicy horizontalSizePolicy() const override;
|
||||
|
||||
bool close() override;
|
||||
void setFlag(Qt::WindowType f, bool on = true) override;
|
||||
void setAttribute(Qt::WidgetAttribute attr, bool enable = true) override;
|
||||
bool testAttribute(Qt::WidgetAttribute attr) const override;
|
||||
Qt::WindowFlags flags() const override;
|
||||
|
||||
void setWindowTitle(const QString &title) override;
|
||||
void setWindowIcon(const QIcon &icon) override;
|
||||
bool isActiveWindow() const override;
|
||||
|
||||
void showNormal() override;
|
||||
void showMinimized() override;
|
||||
void showMaximized() override;
|
||||
|
||||
bool isMinimized() const override;
|
||||
bool isMaximized() const override;
|
||||
|
||||
std::shared_ptr<Window> window() const override;
|
||||
std::shared_ptr<View> childViewAt(QPoint p) const override;
|
||||
std::shared_ptr<View> rootView() const override;
|
||||
std::shared_ptr<View> parentView() const override;
|
||||
std::shared_ptr<View> asWrapper() override;
|
||||
|
||||
void setObjectName(const QString &name) override;
|
||||
void grabMouse() override;
|
||||
void releaseMouse() override;
|
||||
void releaseKeyboard() override;
|
||||
void setFocus(Qt::FocusReason reason) override;
|
||||
Qt::FocusPolicy focusPolicy() const override;
|
||||
bool hasFocus() const override;
|
||||
void setFocusPolicy(Qt::FocusPolicy) override;
|
||||
QString objectName() const override;
|
||||
void setMinimumSize(QSize sz) override;
|
||||
void render(QPainter *) override;
|
||||
void setCursor(Qt::CursorShape shape) override;
|
||||
void setMouseTracking(bool enable) override;
|
||||
QVector<std::shared_ptr<View>> childViews() const override;
|
||||
void setZOrder(int) override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(View_gtk)
|
||||
// GtkWidget *m_widget = nullptr;
|
||||
};
|
||||
|
||||
inline View_gtk *asView_gtk(View *view)
|
||||
{
|
||||
if (!view)
|
||||
return nullptr;
|
||||
return static_cast<View_gtk *>(view);
|
||||
}
|
||||
|
||||
inline View_gtk *asView_gtk(Controller *controller)
|
||||
{
|
||||
if (!controller)
|
||||
return nullptr;
|
||||
|
||||
return static_cast<View_gtk *>(controller->view());
|
||||
}
|
||||
|
||||
} // namespace KDDockWidgets::Views
|
||||
Reference in New Issue
Block a user