-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I5b729a1903aae656a483785d62ba6b43514b6949 Reviewed-on: https://codereview.kdab.com/c/kdab/kdutils/+/135718 Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Tested-by: Continuous Integration <build@kdab.com>
- Loading branch information
Showing
4 changed files
with
112 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This file is part of KDUtils. | ||
# | ||
# SPDX-FileCopyrightText: 2022-2024 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
# Contact KDAB at <info@kdab.com> for commercial licensing options. | ||
|
||
add_subdirectory(gui_window) |
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,18 @@ | ||
# This file is part of KDUtils. | ||
# | ||
# SPDX-FileCopyrightText: 2022-2024 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
# Contact KDAB at <info@kdab.com> for commercial licensing options. | ||
|
||
project(gui_window_example LANGUAGES CXX) | ||
|
||
add_executable( | ||
${PROJECT_NAME} | ||
gui_window.cpp | ||
) | ||
|
||
target_link_libraries( | ||
${PROJECT_NAME} KDGui | ||
) |
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,78 @@ | ||
/* | ||
This file is part of KDUtils. | ||
SPDX-FileCopyrightText: 2018-2024 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> | ||
Author: Miłosz Kosobucki <milosz.kosobucki@kdab.com> | ||
SPDX-License-Identifier: MIT | ||
Contact KDAB at <info@kdab.com> for commercial licensing options. | ||
*/ | ||
#include <KDGui/gui_application.h> | ||
#include <KDGui/window.h> | ||
#include <KDGui/gui_events.h> | ||
|
||
class ExampleWindow : public KDGui::Window | ||
{ | ||
void mouseMoveEvent(KDGui::MouseMoveEvent *ev) override | ||
{ | ||
spdlog::info("{}() buttons = {} at pos = ({}, {})", | ||
__FUNCTION__, | ||
ev->buttons(), | ||
ev->xPos(), | ||
ev->yPos()); | ||
} | ||
|
||
void mousePressEvent(KDGui::MousePressEvent *ev) override | ||
{ | ||
spdlog::info("{}() buttons = {} at pos = ({}, {})", | ||
__FUNCTION__, | ||
ev->buttons(), | ||
ev->xPos(), | ||
ev->yPos()); | ||
} | ||
|
||
void mouseReleaseEvent(KDGui::MouseReleaseEvent *ev) override | ||
{ | ||
spdlog::info("{}() buttons = {} at pos = ({}, {})", | ||
__FUNCTION__, | ||
ev->buttons(), | ||
ev->xPos(), | ||
ev->yPos()); | ||
} | ||
|
||
void mouseWheelEvent(KDGui::MouseWheelEvent *ev) override | ||
{ | ||
spdlog::info("{}() xDelta = {} yDelta = {}", | ||
__FUNCTION__, | ||
ev->xDelta(), | ||
ev->yDelta()); | ||
} | ||
|
||
void keyPressEvent(KDGui::KeyPressEvent *ev) override | ||
{ | ||
spdlog::info("{}() key = {}", __FUNCTION__, ev->key()); | ||
} | ||
|
||
void keyReleaseEvent(KDGui::KeyReleaseEvent *ev) override | ||
{ | ||
spdlog::info("{}() key = {}", __FUNCTION__, ev->key()); | ||
} | ||
}; | ||
|
||
int main() | ||
{ | ||
KDGui::GuiApplication app; | ||
|
||
ExampleWindow w; | ||
w.title = "KDGui window example"; | ||
w.visible = true; | ||
|
||
w.visible.valueChanged().connect([&app](bool visible) { | ||
if (!visible) { | ||
app.quit(); | ||
} | ||
}); | ||
|
||
app.exec(); | ||
} |