summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-02-02 12:58:03 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-02-02 12:58:03 +0800
commit4a64f8d229461abbe262ba66ee189d9c3fa4c5ff (patch)
treef8159059fc2b25bf3840fd68289b6f0315a0aab6
parent8a9b4521d3e1b68d35ab6221f6317329be7e8122 (diff)
Conform to updated qrtclient & design
-rw-r--r--Home.qml53
-rw-r--r--Login.qml6
-rw-r--r--LoginPassword.qml10
-rw-r--r--TicketHistory.qml2
-rw-r--r--controller.cxx114
-rw-r--r--controller.hxx17
-rw-r--r--kelakon.pro31
-rw-r--r--main.cxx1
-rw-r--r--main.qml5
9 files changed, 99 insertions, 140 deletions
diff --git a/Home.qml b/Home.qml
index 33caa1b..c836ecf 100644
--- a/Home.qml
+++ b/Home.qml
@@ -1,43 +1,44 @@
-import QtQuick 2.12
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import "larva/features"
+import "larva/components"
HomeForm {
- menuButton.onClicked: drawer.open()
- profileButton.onClicked: pageView.push("Profile.qml")
+ //menuButton.onClicked: drawer.open()
+ //profileButton.onClicked: pageView.push("Profile.qml")
- Drawer {
- id: drawer
- width: window.width * 0.8
- height: window.height
- visible: false
+ StackLayout {
+ id: layout
+ anchors.fill: parent
- DayListForm {
- todayItemDelegate {
- text: qsTr("Today")
- onClicked: {
- contentView.push("TicketList.qml")
- var ticketList = contentView.currentItem
- ticketList.title = qsTr("Today")
- drawer.close()
- }
- }
+ Page {}
- futureItemDelegate {
- text:qsTr("Future")
- onClicked: {
- contentView.push("TicketList.qml")
- var ticketList = contentView.currentItem
- ticketList.title = qsTr("Future ticket")
- drawer.close()
+ TaskListForm {
+ listView {
+ model: ticketList
+ delegate: ListItemSingleTextForm {
+ title.text: subject
+ delegate.onClicked: {
+ window.ticketHistoryList(id,
+ true)
+ }
}
}
}
+
+ Page {}
}
contentView.initialItem: TicketList {
- title: qsTr("Today")
+ title: qsTr("Projects")
+ }
+
+ footer: MainTabBarForm {
+ id: tabBar
+ width: parent.width
+ leftTabButton.onClicked: layout.currentIndex = 0
+ middleTabButton.onClicked: layout.currentIndex = 1
+ rightTabButton.onClicked: layout.currentIndex = 2
}
}
diff --git a/Login.qml b/Login.qml
index 4bff754..2902407 100644
--- a/Login.qml
+++ b/Login.qml
@@ -1,5 +1,4 @@
import QtQuick 2.15
-import KelakonUser 0.1
import "larva/features"
LoginForm {
@@ -16,8 +15,9 @@ LoginForm {
}
continueButton.onClicked: {
- User.name = emailTextField.text
- contentView.push("LoginPassword.qml")
+ contentView.push("LoginPassword.qml", {
+ "name": emailTextField.text
+ })
}
}
}
diff --git a/LoginPassword.qml b/LoginPassword.qml
index d224526..d779408 100644
--- a/LoginPassword.qml
+++ b/LoginPassword.qml
@@ -1,15 +1,13 @@
import QtQuick 2.15
-import KelakonUser 0.1
import "larva/features"
LoginPasswordForm {
- emailTextLabel.text: User.name
+ property string name
+
+ emailTextLabel.text: name
passwordTextField.onTextChanged:
if (!passwordTextField.text || !continueButton.enabled)
continueButton.enabled = !continueButton.enabled
- continueButton.onClicked: {
- User.password = passwordTextField.text
- window.logIn(User.name, User.password)
- }
+ continueButton.onClicked: window.logIn(name, passwordTextField.text)
}
diff --git a/TicketHistory.qml b/TicketHistory.qml
index be6435b..dbe630b 100644
--- a/TicketHistory.qml
+++ b/TicketHistory.qml
@@ -15,7 +15,7 @@ TaskDetailForm {
listView {
height: 1000
- model: ticketHistoryList
+ model: historyList
delegate: TaskHistoryForm {
creatorText.text: creator
ticketDescription.text: content
diff --git a/controller.cxx b/controller.cxx
index f9f5884..eaf819d 100644
--- a/controller.cxx
+++ b/controller.cxx
@@ -1,90 +1,60 @@
-#ifdef ANDROID
#include <QStringBuilder>
-#endif
#include <QQmlApplicationEngine>
#include <QtQml>
-#include <qrtclient.hxx>
#include <qrtclient/user.hxx>
#include "controller.hxx"
-Controller::Controller(QObject* parent)
- : QObject{parent}
+Controller::Controller(QObject* parent) : QObject{parent}
{
-#ifdef ANDROID
- QDir location{QStandardPaths::writableLocation(QStandardPaths
- ::AppDataLocation)};
- QString path{location.absolutePath() % "/ca-certificates.crt"};
- QFile file{"assets:/certs/ca-certificates.crt"};
- file.copy(path);
+ auto dir = QDir{QStandardPaths::writableLocation(
+ QStandardPaths::AppDataLocation)};
+ auto dirPath = dir.absolutePath();
+#ifdef __ANDROID__
+ QString cert{CA_BUNDLE};
+ QString certPath{dirPath % cert.remove(0, cert.lastIndexOf("/"))};
+ QFile{"assets:" % cert}.copy(certPath);
+#else
+ dir.mkpath(dirPath);
#endif
- using RTClient::Client;
- auto client = new Client{"https://rt.darapsa.co.id"
-#ifdef ANDROID
- , path.toLatin1().constData()
+ rt = new Client{SERVER_URL,
+ QString{dirPath % "/cookies.txt"}.toLatin1().constData()
+#ifdef __ANDROID__
+ , certPath.toLatin1().constData()
#endif
};
- client->moveToThread(&thread);
- connect(&thread, &QThread::finished, client, &QObject::deleteLater);
-
auto engine = static_cast<QQmlApplicationEngine*>(parent);
- auto rootObjects = engine->rootObjects();
- auto appWindow = rootObjects[0];
-
- using RTClient::User;
- auto typeId = qmlRegisterSingletonType<User>("KelakonUser", 0, 1, "User"
- , [](QQmlEngine *engine
- , QJSEngine *scriptEngine) -> QObject* {
- Q_UNUSED(engine)
- Q_UNUSED(scriptEngine)
- return new User;
- });
- auto qUser = engine->singletonInstance<User*>(typeId);
-
- using RTClient::TicketList;
- ticketList = new TicketList;
- engine->rootContext()->setContextProperty("ticketList", ticketList);
-
- using RTClient::TicketHistoryList;
- ticketHistoryList = new TicketHistoryList;
- engine->rootContext()->setContextProperty("ticketHistoryList"
- , ticketHistoryList);
-
- connect(appWindow, SIGNAL(logIn(QString, QString))
- , client, SLOT(logIn(QString, QString)));
-
- connect(client, &Client::loggedIn
- , client, static_cast<void (Client::*)(QString const&)>
+ engine->load(QUrl(QStringLiteral("qrc:/main.qml")));
+ auto context = engine->rootContext();
+ auto window = engine->rootObjects()[0];
+ connect(window, SIGNAL(logIn(QString, QString)),
+ rt, SLOT(logIn(QString, QString)));
+ connect(rt, &Client::loggedIn,
+ rt, static_cast<void (Client::*)(QString const&)>
(&Client::userShow));
-
- connect(client, &Client::userShown
- , [this,qUser,appWindow](rtclient_user* user) {
- if (user) {
- emit checked(QString{user->name});
- qUser->update(user);
- QMetaObject::invokeMethod(appWindow, "pushHome");
- }
+ connect(rt, &Client::userShown, [this](User const& user) {
+ rt->searchTicket(user.name());
});
-
- connect(this, &Controller::checked, client, &Client::searchTicket);
-
- connect(client, &Client::searchedTicket, ticketList, &TicketList::update);
-
- connect(appWindow, SIGNAL(ticketHistory(int, bool))
- , client, SLOT(ticketHistory(int, bool)));
-
- connect(client, &Client::gotTicketHistory
- , ticketHistoryList, &TicketHistoryList::update);
-
- connect(appWindow, SIGNAL(ticketNew(QString, QString))
- , client, SLOT(ticketNew(QString, QString)));
-
- thread.start();
+ connect(rt, &Client::searchedTicket,
+ [this,context,window](TicketList const& list) {
+ ticketList = new TicketList{list};
+ context->setContextProperty("ticketList", ticketList);
+ QMetaObject::invokeMethod(window, "pushHome");
+ });
+ connect(window, SIGNAL(ticketHistoryList(int, bool)),
+ rt, SLOT(ticketHistoryList(int, bool)));
+ connect(rt, &Client::gotTicketHistoryList,
+ [this,context,window](TicketHistoryList const& list) {
+ historyList = new TicketHistoryList{list};
+ context->setContextProperty("historyList", historyList);
+ QMetaObject::invokeMethod(window, "pushTicketHistory");
+ });
+ connect(window, SIGNAL(ticketNew(QString, QString)),
+ rt, SLOT(ticketNew(QString, QString)));
}
Controller::~Controller()
{
- thread.quit();
- thread.wait();
- delete ticketHistoryList;
- delete ticketList;
+ if (historyList) delete historyList;
+ if (ticketList) delete ticketList;
+ if (rt) delete rt;
}
diff --git a/controller.hxx b/controller.hxx
index f92527c..1709aab 100644
--- a/controller.hxx
+++ b/controller.hxx
@@ -1,25 +1,22 @@
#ifndef CONTROLLER_HXX
#define CONTROLLER_HXX
-#include <QThread>
+#include <qrtclient.hxx>
#include <qrtclient/ticket.hxx>
#include <qrtclient/tickethistory.hxx>
+using namespace RTClient;
+
class Controller : public QObject
{
Q_OBJECT
-
public:
Controller(QObject* parent = nullptr);
~Controller();
-
- signals:
- void checked(QString const& name);
-
private:
- QThread thread;
- RTClient::TicketList* ticketList;
- RTClient::TicketHistoryList* ticketHistoryList;
+ Client* rt;
+ TicketList* ticketList;
+ TicketHistoryList* historyList;
};
-#endif // CONTROLLER_HXX
+#endif
diff --git a/kelakon.pro b/kelakon.pro
index fa19e07..a7f5c31 100644
--- a/kelakon.pro
+++ b/kelakon.pro
@@ -1,31 +1,23 @@
QT += quick
-
+DEFINES += \
+ SERVER_URL=\\\"$$SERVER_URL\\\" \
+ CA_BUNDLE=\\\"$$CA_BUNDLE\\\"
+debug: DEFINES += DEBUG
HEADERS += controller.hxx
-
SOURCES += \
controller.cxx \
main.cxx
-
RESOURCES += \
kelakon.qrc \
larva.qrc \
larva/material-design-icons.qrc
-
-LIBS += \
- -lcurl \
- -lrtclient
-
-!android {
- LIBS += -lqrtclient
-}
-
+LIBS += -lrtclient
android {
PREFIX = $$ANDROID_NDK_PATH/toolchains/llvm/prebuilt/$$ANDROID_NDK_HOST/sysroot/usr
TRIPLE = aarch64-linux-android
contains(ANDROID_TARGET_ARCH,armeabi-v7a): TRIPLE = arm-linux-androideabi
contains(ANDROID_TARGET_ARCH,x86): TRIPLE = i686-linux-android
contains(ANDROID_TARGET_ARCH,x86_64): TRIPLE = x86_64-linux-android
-
LIBS += \
-L$$PREFIX/lib/$$TRIPLE/$$API \
-L$$QT_ANDROID_LIBDIR \
@@ -36,16 +28,15 @@ android {
$$PREFIX/lib/$$TRIPLE/$$API/libcurl.so \
$$PREFIX/lib/$$TRIPLE/$$API/librtclient.so \
$$QT_ANDROID_LIBDIR/libqrtclient_$${ANDROID_TARGET_ARCH}.so
-
QT += svg
- certs.path = /assets/certs
- certs.files = /etc/ssl/certs/ca-certificates.crt
- INSTALLS += certs
+ assets.path = /assets
+ assets.files = $$CA_BUNDLE
+ INSTALLS += assets
}
-
+!android: LIBS += -lqrtclient
macx {
INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib
}
-
-debug: DEFINES += DEBUG
+wasm: QMAKE_CXXFLAGS += -std=c++11
+!wasm: LIBS += -lcurl
diff --git a/main.cxx b/main.cxx
index 23f9e4d..5db1826 100644
--- a/main.cxx
+++ b/main.cxx
@@ -7,7 +7,6 @@ int main(int argc, char* argv[])
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
- engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
Controller controller{&engine};
return app.exec();
}
diff --git a/main.qml b/main.qml
index 523f0d6..c4bb7df 100644
--- a/main.qml
+++ b/main.qml
@@ -4,11 +4,14 @@ import "larva/features"
ApplicationWindow {
signal logIn(string name, string password)
- signal ticketHistory(int id, bool longFormat)
+ signal ticketHistoryList(int id, bool longFormat)
signal ticketNew(string queue, string requestor)
function pushHome() {
pageView.push("Home.qml")
}
+ function pushTicketHistory() {
+ pageView.push("TicketHistory.qml")
+ }
id: window
visible: true