Port to Qt 6
diff --git a/Parser.cpp b/Parser.cpp
index 9679b4c..68e5aef 100644
--- a/Parser.cpp
+++ b/Parser.cpp
@@ -51,14 +51,19 @@
QChar Parser::peek()
{
if (atEnd())
- return 0;
+ return QChar(0);
return _input[_pos];
}
QChar Parser::get()
{
- QChar c = _input[_pos++];
+ QChar c;
+
+ if (_pos < _input.size())
+ c = _input[_pos++];
+ else
+ return QChar(0);
if (c == '\n')
{
diff --git a/Token.h b/Token.h
index 41d8031..82c1906 100644
--- a/Token.h
+++ b/Token.h
@@ -55,7 +55,7 @@
int _intVal = 0;
QString _stringVal = "";
QList<T> _listVal;
- QChar _charVal = 0;
+ QChar _charVal = QChar(0);
};
class Token : public TokenBase<Token>
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);
diff --git a/main.cpp b/main.cpp
index 32f8e6f..0cb36e8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -267,6 +267,8 @@
int main(int argc, char *argv[])
{
+ QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
+
Application a(argc, argv);
a.setApplicationName("REFAL");
a.setApplicationVersion("1.0-a1");