summaryrefslogtreecommitdiff
path: root/metawatch/metawatchplugin.cpp
blob: 523230b49fdb90d48d97f262e38ac48596d55865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <QtGui/QFontDatabase>
#include <QtConnectivity/QBluetoothAddress>
#include "metawatchdigital.h"
#include "metawatchanalog.h"
#include "metawatchsimulator.h"
#include "metawatchplugin.h"

using namespace sowatch;
QTM_USE_NAMESPACE

bool MetaWatchPlugin::fontsLoaded = false;

MetaWatchPlugin::MetaWatchPlugin()
{
	if (!fontsLoaded) {
		QFontDatabase::addApplicationFont(SOWATCH_RESOURCES_DIR "/metawatch/fonts/metawatch_16pt_11pxl.ttf");
		QFontDatabase::addApplicationFont(SOWATCH_RESOURCES_DIR "/metawatch/fonts/metawatch_8pt_7pxl_CAPS.ttf");
		QFontDatabase::addApplicationFont(SOWATCH_RESOURCES_DIR "/metawatch/fonts/metawatch_8pt_5pxl_CAPS.ttf");
		// "MetaWatch Large 16pt", "MetaWatch Large caps 8pt", "MetaWatch Small caps 8pt"
		fontsLoaded = true;
	}
}

MetaWatchPlugin::~MetaWatchPlugin()
{

}

QStringList MetaWatchPlugin::drivers()
{
	QStringList d;
	d << "metawatch-digital" << "metawatch-analog";
	return d;
}

Watch* MetaWatchPlugin::getWatch(const QString& driver, QSettings& settings, QObject *parent)
{
	if (driver == "metawatch-digital") {
		QBluetoothAddress address(settings.value("address").toString());
		return new MetaWatchDigital(address, &settings, parent);
	} else if (driver == "metawatch-analog") {
		QBluetoothAddress address(settings.value("address").toString());
		return new MetaWatchAnalog(address, &settings, parent);
	} else {
		return 0;
	}
}

Q_EXPORT_PLUGIN2(metawatch, MetaWatchPlugin)