Does not work yet, even the test.
classes/timecontrol/hourglassclock.cpp \
classes/timecontrol/hourglasstimecontrol.cpp \
classes/screenlitkeeper.cpp \
- classes/wrappedclockswidget.cpp
+ classes/wrappedclockswidget.cpp \
+ classes/settings.cpp
HEADERS += chessclockwindow.h \
classes/turninformation.h \
classes/timecontrol/hourglasstimecontrol.h \
classes/timecontrol/hourglassclock.h \
classes/screenlitkeeper.h \
- classes/wrappedclockswidget.h
+ classes/wrappedclockswidget.h \
+ classes/settings.h
OTHER_FILES += \
--- /dev/null
+#include "settings.h"
+#include <QSettings>
+
+
+Settings::Settings(QObject *parent) :
+ QObject(parent)
+{
+}
+
+int Settings::value(WrappedClocksWidget::TimeControlType timeControl, QString key)
+{
+
+
+ QSettings settings;
+
+
+
+settings.beginGroup(getGroupName(timeControl));
+
+}
+
+void Settings::setValue()
+{
+
+}
+
+QString Settings::getGroupName(WrappedClocksWidget::TimeControlType timeControl)
+{
+ //Using same groups and keys in QSettings as the maemo version
+ //just in case Maemo version would move to use QML someday
+
+
+ QString groupString;
+
+ switch (timeControl)
+ {
+
+ case WrappedClocksWidget::NormalClock:
+
+ groupString = "Normal clock";
+ break;
+
+ case WrappedClocksWidget::AdditionBefore:
+
+ groupString = "Addition before";
+ break;
+
+ case WrappedClocksWidget::AdditionAfter:
+ groupString = "Addition after";
+ break;
+
+ case WrappedClocksWidget::Delay:
+ groupString = "Delay";
+ break;
+
+ case WrappedClocksWidget::DelayAfter:
+ groupString = "Delay after";
+ break;
+
+
+ case WrappedClocksWidget::HourGlass:
+ groupString = "Hour glass";
+ break;
+
+ default: //If QML sends an invalid value give the value for normal clock
+
+ groupString = "Normal Clock";
+ break;
+
+ }
+return groupString;
+
+}
+
+ int Settings::getTurnsPerAddition(WrappedClocksWidget::TimeControlType timeControl, QString player)
+ {
+
+ QSettings settings;
+ settings.beginGroup(getGroupName(timeControl));
+
+ if (player == "white")
+ return settings.value("WhitePerTurns",1).toInt();
+
+ if (player == "black");
+ return settings.value("BlackPerTurns",1).toInt();
+
+ return 0; //for invalid input
+
+
+ }
+
--- /dev/null
+#ifndef SETTINGS_H
+#define SETTINGS_H
+
+#include <QObject>
+#include <QVariant>
+#include "classes/wrappedclockswidget.h"
+
+class Settings : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Settings(QObject *parent = 0);
+
+ Q_INVOKABLE int value(WrappedClocksWidget::TimeControlType timeControl, QString key);
+
+ Q_INVOKABLE int getTurnsPerAddition(WrappedClocksWidget::TimeControlType timeControl, QString player);
+
+
+signals:
+
+public slots:
+
+ void setValue();
+
+protected:
+
+ QString getGroupName(WrappedClocksWidget::TimeControlType);
+
+};
+
+#endif // SETTINGS_H
#include <QtGui/QApplication>
#include <QtDeclarative>
#include "classes/wrappedclockswidget.h"
+#include "classes/settings.h"
int main(int argc, char *argv[])
app.setStyleSheet("* {color: white}");
qmlRegisterType<WrappedClocksWidget>("ChessClocks", 1, 0, "WrappedClocksWidget");
+ qmlRegisterType<Settings>("ChessClocks", 1, 0, "Settings");
QDeclarativeView view;
view.setSource(QUrl("qrc:/qml/main.qml"));
property bool askAddition
property bool askTurnsPerAddition
+ property int test
+
+ Settings {id: settings}
+ Component.onCompleted:
+ {test = settings.value("test") }
+
tools: ToolBarLayout
{
ToolIcon { iconId: "toolbar-back"; onClicked: pageStack.pop() }