1 #include "AppManager.h"
6 static AppManager
*s_am
= nullptr;
7 static Shows
*s_shows
= nullptr;
9 AppManager::AppManager(QObject
* parent
) :
13 s_shows
= new Shows(dataDirectory(), this);
15 connect(this, &AppManager::internalNewSource
,
16 this, [this](QUrl sourceFile
){
17 m_view
->setSource(sourceFile
);
18 currentPage
= sourceFile
;
19 }, Qt::QueuedConnection
);
22 AppManager::~AppManager()
27 QString
AppManager::dataDirectory(void) const
29 return QStringLiteral("/home/tlb/dev/git/android-qt-sandbox/data/");
32 void AppManager::initializeView(QUrl url
)
34 m_view
= new QQuickView();
35 m_view
->setFlags(Qt::Window
);
36 m_view
->setResizeMode(QQuickView::SizeRootObjectToView
);
37 m_view
->resize({450, 800});
39 m_view
->setSource(url
);
41 // this url is the base of the stack.
45 AppManager
*AppManager::create(QQmlEngine
*qmlEngine
, QJSEngine
*jsEngine
)
47 QJSEngine::setObjectOwnership(s_am
, QJSEngine::CppOwnership
);
51 QObject
*AppManager::shows(void)
56 void AppManager::requestBack()
58 fprintf(stderr
, "[AM] received request go back\n");
59 if(m_pageHistory
.size() > 0){
60 // we have something to go back to.
61 fprintf(stderr
, "[AM] -- going back to %s\n",
62 m_pageHistory
.top().toString().toStdString().c_str());
63 emit
internalNewSource(m_pageHistory
.pop());
65 fprintf(stderr
, "[AM] --error, no where to run to\n");
69 void AppManager::requestNewSource(QUrl sourceFile
)
71 fprintf(stderr
, "[AM] received request to load source file '%s'\n",
72 sourceFile
.toString().toStdString().c_str());
73 if(QFile::exists(sourceFile
.toString().remove("qrc"))){
74 // when we go someplace new, push what we have now into the stack.
75 m_pageHistory
.push(currentPage
);
76 currentPage
= sourceFile
;
77 emit
internalNewSource(sourceFile
);
79 fprintf(stderr
, "[AM] --error! no such file\n");