From 51a9e0a690da0d40691e148c155bfee1858b415b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Mon, 12 Jul 2021 13:14:39 +0800 Subject: Tidy up a bit --- controller.cxx | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'controller.cxx') diff --git a/controller.cxx b/controller.cxx index d0be5fb..5bf63e3 100644 --- a/controller.cxx +++ b/controller.cxx @@ -3,9 +3,9 @@ #include #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("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; -} -- cgit v1.2.3