Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Test QML charting library in new window #1909

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ if(GUI)
find_package(
Qt6
COMPONENTS Core
Charts
DBusTools
Gui
Widgets
Expand Down Expand Up @@ -378,7 +379,7 @@ if(GUI)
# Module gui libs
gui-qml ${NO_WHOLE_ARCHIVE_FLAG}
PRIVATE # External libs
Qt6::Qml ${CORE_LINK_LIBS} ${THREADING_LINK_LIBS}
Qt6::Qml Qt6::Widgets ${CORE_LINK_LIBS} ${THREADING_LINK_LIBS}
)

qt_generate_deploy_qml_app_script(
Expand Down
5 changes: 3 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
libglvnd.dev
q.qtbase
q.qtbase.dev
q.qtcharts
q.qtcharts.dev
q.qtsvg
q.qtshadertools
q.qttools
Expand Down Expand Up @@ -179,8 +181,7 @@
CMAKE_C_COMPILER_LAUNCHER = "${pkgs.ccache}/bin/ccache;${pkgs.distcc}/bin/distcc";
CMAKE_CXX_FLAGS_DEBUG = "-g -O0";
CXXL = "${pkgs.stdenv.cc.cc.lib}";
QML_IMPORT_PATH = "${qt-idaaas.packages.${system}.qtdeclarative}/lib/qt-6/qml/";
QML2_IMPORT_PATH = "${qt-idaaas.packages.${system}.qtdeclarative}/lib/qt-6/qml/";
QML_IMPORT_PATH = "${qt-idaaas.packages.${system}.qtdeclarative}/lib/qt-6/qml/:${qt-idaaas.packages.${system}.qtcharts}/lib/qt-6/qml/";
};

apps = {
Expand Down
8 changes: 5 additions & 3 deletions src/dissolve-gui-qml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#include "main/cli.h"
#include "main/dissolve.h"
#include "main/version.h"
#include <QGuiApplication>
#include <QApplication>
//#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QSurfaceFormat>
#include <clocale>
Expand All @@ -27,7 +28,9 @@ int main(int args, char **argv)
// Initialise random seed
srand(options.randomSeed().value_or((unsigned)time(nullptr)));

QGuiApplication app(args, argv);
Types::registerDissolveQmlTypes();

QApplication app(args, argv);

QQmlApplicationEngine engine;
const QUrl url(u"qrc:/main/qml/DissolveMain.qml"_qs);
Expand All @@ -37,7 +40,6 @@ int main(int args, char **argv)
Qt::QueuedConnection);
engine.load(url);

Types::registerDissolveQmlTypes();
QCoreApplication::setOrganizationName("Team Dissolve");
QCoreApplication::setOrganizationDomain("www.projectdissolve.com");
QCoreApplication::setApplicationName("Dissolve-GUI-QML");
Expand Down
2 changes: 1 addition & 1 deletion src/gui-qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ add_library(gui-qml)

target_include_directories(gui-qml PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src Qt6::Core)

target_link_libraries(gui-qml PRIVATE models base Qt6::QuickWidgets)
target_link_libraries(gui-qml PRIVATE models base Qt6::QuickWidgets Qt6::Charts)
24 changes: 24 additions & 0 deletions src/gui-qml/qml/DissolveMain.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Dissolve
import "charting" as C

ApplicationWindow {
id: dissolveWindow
Expand All @@ -9,6 +11,19 @@ ApplicationWindow {
visible: true
width: 819

/*
Test chart in window
*/
Window {
id: chartWindow
height: dissolveWindow.height/2; width: dissolveWindow.width/2

C.Data1D {
id: data1DChart
height: parent.height; width: parent.width
}
}

TabBar {
id: tabBar
width: parent.width
Expand Down Expand Up @@ -59,5 +74,14 @@ ApplicationWindow {
text: "Quit"
}
}

Menu {
title: "&TEST_CHART"

MenuItem {
text: "&1D..."
onTriggered: chartWindow.show()
}
}
}
}
24 changes: 24 additions & 0 deletions src/gui-qml/qml/charting/Data1D.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import QtQuick
import QtCharts

ChartView {
title: "1D Chart"
anchors.fill: parent
antialiasing: true

LineSeries {
id: lineSeries
name: "Test Line"
XYPoint{x: 0; y: 0}
XYPoint{x: 1; y: 2}
XYPoint{x: 2; y: 4}
XYPoint{x: 3; y: 6}
XYPoint{x: 4; y: 8}
XYPoint{x: 5; y: 10}
XYPoint{x: 6; y: 12}
XYPoint{x: 7; y: 14}
XYPoint{x: 8; y: 16}
XYPoint{x: 9; y: 18}
XYPoint{x: 10; y: 20}
}
}
1 change: 1 addition & 0 deletions src/gui-qml/resources.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="main">
<file>qml/DissolveMain.qml</file>
<file>qml/charting/Data1D.qml</file>
</qresource>
</RCC>
Loading