Integrated file selection dialogue with the main code. Improved the
[openvpnui.git] / src / OpenVPNUI.cpp
index 7575cb3..2df2800 100644 (file)
@@ -1,6 +1,6 @@
 /*
-  Copyright (C) 2013 Jolla Ltd.
-  Contact: Thomas Perl <thomas.perl@jollamobile.com>
+  Copyright (C) 2014 David Llewellyn-Jones
+  Contact: David Llewellyn-Jones <david@flypig.co.uk>
   All rights reserved.
 
   You may use this file under the terms of BSD license as follows:
   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+  Built using the standard template from Jolla
+  Copyright (C) 2013 Jolla Ltd.
+  Contact: Thomas Perl <thomas.perl@jollamobile.com>
 */
 
 #ifdef QT_QML_DEBUG
 
 #include <sailfishapp.h>
 #include "vpncontrol.h"
+#include "filemodel.h"
+#include "fileinfo.h"
+#include "searchengine.h"
+#include "engine.h"
 
 int main(int argc, char *argv[])
 {
+    qmlRegisterType<FileModel>("harbour.file.browser.FileModel", 1, 0, "FileModel");
+    qmlRegisterType<FileInfo>("harbour.file.browser.FileInfo", 1, 0, "FileInfo");
+    qmlRegisterType<SearchEngine>("harbour.file.browser.SearchEngine", 1, 0, "SearchEngine");
+
     int result;
 
     setuid(0);
@@ -52,6 +64,13 @@ int main(int argc, char *argv[])
     // To display the view, call "show()" (will show fullscreen on device).
 
     QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
+
+    // These values are used by QSettings to access the config file in
+    // /home/nemo/.local/share/flypig/OpenVPNUI.conf
+    QCoreApplication::setOrganizationName("flypig");
+    QCoreApplication::setOrganizationDomain("www.flypig.co.uk");
+    QCoreApplication::setApplicationName("OpenVPNUI");
+
     QScopedPointer<QQuickView> view(SailfishApp::createView());
 
     view->setSource(SailfishApp::pathTo("qml/OpenVPNUI.qml"));
@@ -61,12 +80,16 @@ int main(int argc, char *argv[])
     view->rootContext()->setContextProperty("VpnControl", vpnControl);
 
     vpnControl->initialise();
-    //QObject * page = view->findChild(QString("page"),Qt::FindChildrenRecursively);
 
-    //QObject::connect(vpnControl, SIGNAL(statusChanged(int)), page, SLOT(updateStatus(int)));
+    // QML global engine object
+    QScopedPointer<Engine> engine(new Engine);
+    view->rootContext()->setContextProperty("engine", engine.data());
+    // Store pointer to engine to access it in any class
+    QVariant engineVariant = qVariantFromValue(engine.data());
+    qApp->setProperty("engine", engineVariant);
 
+    // Run the application loop
     view->show();
-
     result = app->exec();
 
     delete vpnControl;