diff options
-rw-r--r-- | controller.cxx | 23 |
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; -} |