summaryrefslogtreecommitdiff
path: root/controller.cxx
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-12 13:14:39 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2021-07-12 13:14:39 +0800
commit51a9e0a690da0d40691e148c155bfee1858b415b (patch)
tree130d48c475297ebcbf3b30a365bba2bf75a2546d /controller.cxx
parent088159182a5a6d3533a7812b48323125fefc1e61 (diff)
Tidy up a bit
Diffstat (limited to 'controller.cxx')
-rw-r--r--controller.cxx23
1 files changed, 11 insertions, 12 deletions
diff --git a/controller.cxx b/controller.cxx
index d0be5fb..5bf63e3 100644
--- a/controller.cxx
+++ b/controller.cxx
@@ -3,9 +3,9 @@
#include <qicclient.hxx>
#include "controller.hxx"
-static Controller* controller;
static QQmlApplicationEngine* engine;
static QString* certFile = nullptr;
+static Controller* controller;
using namespace QICClient;
static Client* shop = nullptr;
static Catalog* allProducts = nullptr;
@@ -22,13 +22,18 @@ Controller::Controller(QObject* parent) : QObject{parent}
connect(engine->rootObjects()[0], SIGNAL(signUp(QString)), this, SLOT(signUp(QString)));
}
+Controller::~Controller()
+{
+ if (::allProducts) delete ::allProducts;
+ if (shop) delete shop;
+}
+
void Controller::signUp(QString const& brand)
{
#ifdef __ANDROID__
QString certAsset{CA_BUNDLE};
- certFile = new QString{QDir{
- QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)
- }.absolutePath() % certAsset.remove(0, certAsset.lastIndexOf("/"))};
+ certFile = new QString{QDir{QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)}
+ .absolutePath() % certAsset.remove(0, certAsset.lastIndexOf("/"))};
QFile{"assets:" % certAsset}.copy(*certFile);
#endif
controller = this;
@@ -49,11 +54,11 @@ void Controller::link(QString const& brand)
{
auto window = engine->rootObjects()[0];
QMetaObject::invokeMethod(window, "push", Q_ARG(QVariant, "Link"), Q_ARG(QVariant, brand));
- connect(window, SIGNAL(pushed()), controller, SIGNAL(pushed()));
+ connect(window, SIGNAL(pushed()), this, SIGNAL(pushed()));
connect(this, &Controller::pushed, [this,window]() {
connect(window->findChild<QObject*>("link"), SIGNAL(activated(QString)),
this, SLOT(allProducts(QString)));
- });
+ });
}
void Controller::allProducts(QString const& brand)
@@ -69,9 +74,3 @@ void Controller::allProducts(QString const& brand)
});
shop->allProducts();
}
-
-Controller::~Controller()
-{
- if (::allProducts) delete ::allProducts;
- if (shop) delete shop;
-}