Skip to content

Commit

Permalink
cneben#248 backport of layouts and selection samples to qml module.
Browse files Browse the repository at this point in the history
Signed-off-by: cneben <[email protected]>
  • Loading branch information
cneben committed Sep 22, 2024
1 parent 0c60dd1 commit 1162b19
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 180 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ option(QUICK_QANAVA_BUILD_SAMPLES "Build QuickQanava samples" OFF)
add_subdirectory(samples/navigable)

add_subdirectory(samples/nodes)
#add_subdirectory(samples/layouts)
#add_subdirectory(samples/selection)
add_subdirectory(samples/layouts)
add_subdirectory(samples/selection)

#add_subdirectory(samples/style)
#add_subdirectory(samples/topology)
#endif()
2 changes: 0 additions & 2 deletions samples/groups/groups.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ int main( int argc, char** argv )
QQuickStyle::setStyle("Material");
QQmlApplicationEngine engine;
engine.addImportPath("../../src/");

QuickQanava::initialize(&engine);
engine.loadFromModule("SampleGroups", "SampleGroups");

return app.exec();
}
//-----------------------------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions samples/layouts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ cmake_minimum_required(VERSION 3.16)

project(QuickQanava_sample_layouts VERSION 2.5.0 LANGUAGES CXX)

# Require C++17
# Configure Qt
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml Quick QuickControls2)
qt_standard_project_setup(REQUIRES 6.6)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Configure Qt
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml Quick QuickControls2)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:QT_QML_DEBUG>)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} "../../src")

include_directories(${CMAKE_CURRENT_SOURCE_DIR} "../../src")
if(NOT TARGET QuickQanava)
add_subdirectory(../../ quickqanava_build) # Use ../../src as quickqanava_build subdirectory
# see https://stackoverflow.com/questions/50408169/cmake-error-add-subdirectory-not-given-a-binary-directory/50408555
Expand All @@ -32,6 +31,7 @@ add_executable(sample_layouts ${source_files} ${header_files} layouts.qrc)
target_include_directories(sample_layouts PUBLIC QuickQanava Qt${QT_VERSION_MAJOR}::QuickControls2)
target_link_libraries(sample_layouts
QuickQanava
QuickQanavaplugin
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::QuickControls2
Expand Down
157 changes: 0 additions & 157 deletions samples/layouts/default.qml

This file was deleted.

9 changes: 4 additions & 5 deletions samples/layouts/layouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ int main( int argc, char** argv )
{
QGuiApplication app(argc, argv);
QQuickStyle::setStyle("Material");
QQmlApplicationEngine* engine = new QQmlApplicationEngine();
//engine->addPluginPath(QStringLiteral("../../src")); // Necessary only for development when plugin is not installed to QTDIR/qml
//QuickQanava::initialize(engine);
engine->load(QUrl("qrc:/layouts.qml"));
QQmlApplicationEngine engine;
engine.addImportPath("../../src/");
QuickQanava::initialize(&engine);
engine.load(QUrl("qrc:/layouts.qml"));
const auto status = app.exec();
delete engine;
return status;
}
//-----------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions samples/layouts/layouts.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import QtQuick
import QtQuick.Controls.Material
import QtQuick.Layouts

import QuickQanava 2.0 as Qan
import "qrc:/QuickQanava" as Qan
import QuickQanava as Qan

ApplicationWindow {
id: window
Expand Down
7 changes: 4 additions & 3 deletions samples/selection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.16)

project(QuickQanava_sample_selection VERSION 2.5.0 LANGUAGES CXX)

# Configure Qt
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml Quick QuickControls2)
qt_standard_project_setup(REQUIRES 6.6)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Configure Qt
find_package(Qt6 REQUIRED COMPONENTS Core Quick Qml Quick QuickControls2)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:QT_QML_DEBUG>)
Expand All @@ -30,6 +30,7 @@ add_executable(sample_selection ${source_files} selection.qrc)
target_include_directories(sample_selection PUBLIC QuickQanava Qt${QT_VERSION_MAJOR}::QuickControls2)
target_link_libraries(sample_selection
QuickQanava
QuickQanavaplugin
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::QuickControls2
Expand Down
2 changes: 1 addition & 1 deletion samples/selection/selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ int main( int argc, char** argv )
QGuiApplication app(argc, argv);
QQuickStyle::setStyle("Material");
QQmlApplicationEngine engine;
engine.addImportPath("../../src/");
QuickQanava::initialize(&engine);
engine.addPluginPath(QStringLiteral("../../src")); // Necessary only for development when plugin is not installed to QTDIR/qml
engine.load(QUrl("qrc:/selection.qml"));
return app.exec();
}
Expand Down
5 changes: 2 additions & 3 deletions samples/selection/selection.qml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import QtQuick.Controls.Material
import QtQuick.Layouts
import Qt.labs.platform as Labs // ColorDialog

import QuickQanava 2.0 as Qan
import "qrc:/QuickQanava" as Qan
import QuickQanava as Qan

ApplicationWindow {
id: window
Expand Down Expand Up @@ -82,7 +81,7 @@ ApplicationWindow {
onGroupRightClicked: (group) => { window.notifyUser( "Group <b>" + group.label + "</b> right clicked" ) }
} // Qan.Graph: graph
focus: true
Keys.onPressed: {
Keys.onPressed: (event) => {
if (event.modifiers & Qt.ControlModifier && // CTRL+A
event.key === Qt.Key_A) {
topology.selectAll()
Expand Down

0 comments on commit 1162b19

Please sign in to comment.