Port to Qt 6
diff --git a/ide/CellModel.cpp b/ide/CellModel.cpp
index c48953c..8ed684f 100644
--- a/ide/CellModel.cpp
+++ b/ide/CellModel.cpp
@@ -1,4 +1,5 @@
#include "CellModel.h"
+#include "Notebook.h"
CellModel::CellModel(Notebook *parent)
: QAbstractListModel(parent)
diff --git a/ide/CellModel.h b/ide/CellModel.h
index a946441..46f3628 100644
--- a/ide/CellModel.h
+++ b/ide/CellModel.h
@@ -3,9 +3,10 @@
#include <QAbstractListModel>
#include <qqml.h>
-#include "Notebook.h"
#include "Cell.h"
+class Notebook;
+
class CellModel : public QAbstractListModel
{
Q_OBJECT
diff --git a/ide/IdeMain.cpp b/ide/IdeMain.cpp
index d76c955..c8eae76 100644
--- a/ide/IdeMain.cpp
+++ b/ide/IdeMain.cpp
@@ -7,6 +7,10 @@
int ideMain(QGuiApplication *app)
{
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+#endif
+
QQmlApplicationEngine engine;
// This is done implicitly now.
diff --git a/ide/Notebook.h b/ide/Notebook.h
index 867c2e9..6a5d0cf 100644
--- a/ide/Notebook.h
+++ b/ide/Notebook.h
@@ -4,8 +4,7 @@
#include "Cell.h"
#include "NbRuntime.h"
-
-class CellModel;
+#include "CellModel.h"
class Notebook : public QObject
{
diff --git a/ide/qml/InsertRow.qml b/ide/qml/InsertRow.qml
index a60dab7..ee45430 100644
--- a/ide/qml/InsertRow.qml
+++ b/ide/qml/InsertRow.qml
@@ -11,8 +11,8 @@
color: Material.color(Material.Grey, Material.theme == Material.Dark ? Material.Shade800 : Material.Shade300)
height: 2
Layout.fillWidth: true
- Layout.topMargin: 14
- Layout.bottomMargin: 14
+ Layout.topMargin: 16
+ Layout.bottomMargin: 16
transitions: Transition {
NumberAnimation {
@@ -22,6 +22,23 @@
}
}
+ states: [
+ State {
+ when: mouseArea.containsMouse || addButton.hovered
+ PropertyChanges {
+ target: root
+ opacity: 1
+ }
+ },
+ State {
+ when: !mouseArea.containsMouse && !addButton.hovered
+ PropertyChanges {
+ target: root
+ opacity: 0
+ }
+ }
+ ]
+
MouseArea {
id: mouseArea
height: 30
@@ -29,22 +46,7 @@
anchors.centerIn: parent
hoverEnabled: true
- states: [
- State {
- when: mouseArea.containsMouse
- PropertyChanges {
- target: root
- opacity: 1
- }
- },
- State {
- when: !mouseArea.containsMouse
- PropertyChanges {
- target: root
- opacity: 0
- }
- }
- ]
+ propagateComposedEvents: true
}
Item {
@@ -61,6 +63,8 @@
flat: true
onClicked: root.insertClicked()
+
+ hoverEnabled: true
}
}
}
diff --git a/ide/qml/main.qml b/ide/qml/main.qml
index e561ae0..63eb004 100644
--- a/ide/qml/main.qml
+++ b/ide/qml/main.qml
@@ -65,15 +65,27 @@
Pane {
Layout.bottomMargin: 0
- Label {
- font.pointSize: 18
- text: "Notebook"
+ ColumnLayout {
+ Label {
+ font.pointSize: 18
+ text: "Notebook"
+ }
+
+ Label {
+ visible: codeEditor.count === 0
+
+ text: "Looks like you haven't created any cells yet. Click the + button below to create one."
+ }
}
}
InsertRow {
onInsertClicked: notebook.cellModel.insertCellBefore(0)
}
+
+ Item {
+ height: 5 // JANK!
+ }
}
delegate: NotebookCell {
@@ -90,7 +102,7 @@
status: model.status
cellActive: codeEditor.currentIndex === index
- onCodeEditingFinished: model.code = code
+ onCodeEditingFinished: code => model.code = code
onInsertBelowClicked: {
console.info(index);