camper/src/Main.qml

64 lines
1.2 KiB
QML
Raw Normal View History

2024-12-19 00:05:12 +00:00
pragma ComponentBehavior: Bound
2024-12-14 00:19:20 +00:00
import QtQuick
import QtQuick.Controls
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
import Camper
2024-12-14 00:19:20 +00:00
ApplicationWindow {
height: 480
title: pageStack.title ? qsTr("%1 — Camper").arg(pageStack.title) : qsTr("Camper")
2024-12-14 00:19:20 +00:00
visible: true
width: 640
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
StackView {
id: pageStack
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
property string title: (currentItem as Page)?.title ?? ""
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
anchors.fill: parent
focus: true
initialItem: loginPage
}
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
Component {
id: loginPage
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
LoginPage {
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
}
}
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
Component {
id: reservationsPage
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
ReservationsPage {
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
}
}
ErrorNotification {
id: errorNotification
anchors {
bottom: parent.bottom
bottomMargin: 8
left: parent.left
margins: 18 * 4
right: parent.right
}
}
Connections {
function onClosed() {
pageStack.replace(null, loginPage);
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
}
function onErrorOcurred(errorMessage) {
errorNotification.show(errorMessage);
}
function onOpened() {
pageStack.replace(reservationsPage);
}
Add a very ugly login page to test database connection I want to perform all SQL queries in a thread, to avoid freezing the UI, that sometimes might happen when there is a lot of data to fetch; should not happen very often, though. Neither libpq nor Qt SQL allow queries on the same connection from differents threads, and, in Qt SQL, all queries must be performed from the same thread where the connection was established. In Qt5 i had to either create a connection per thread, or use a QThread-derived object to hold the connection and use signals and slots to pass query and response data between the UI and database threads; it was usable but not pretty. With Qt6 and Concurrent’s QThreadPool now i can use QFutures instead, that are not as cumbersome as with Qt5, because i no longer need QFutureWatcher. I still have the problem that all queries must be done from within the same thread, and QThreadPool uses an arbitrary thread. The solution is to create a “pool” with a single, non-expirable thread, and call all Concurrent::run onto that pool. I have to test it properly, and first need to open the database to test whether that, at least, works. I added a simple “login page” for that, and to make a first attempt to error messages; i use a control that is like Kirigami’s InlineMessage for now, but i am not sure. I also do not know how i will configure database’s connection details. I usually make use of pg_service.conf, because then the application only need to know its service name, but i am not sure whether other people would find it as comfortable as i do.
2024-12-16 11:59:19 +00:00
target: Database
}
2024-12-14 00:19:20 +00:00
}