summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-07-09 16:33:22 +0200
committerJ-P Nurmi <jpnurmi@digia.com>2013-07-09 16:34:21 +0200
commitd2f94560e58b504238bfa8c27619b2842a54f19d (patch)
tree849ec00bbcfaadd624b2c7d0e0ba86740a0e35da
parent3cedaefda1bc407c716979fcd7db3edcf42704c3 (diff)
Add CocoaSettings stub
Change-Id: I83b0414f2904909b3028572e7bbc0991a54fee98 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
-rw-r--r--backend/backend.pri14
-rw-r--r--backend/cocoa/cocoa.pri8
-rw-r--r--backend/cocoa/cocoasettings.h67
-rw-r--r--backend/cocoa/cocoasettings.mm89
-rw-r--r--backend/dconf/dconf.pri11
-rw-r--r--include/settings.h6
-rw-r--r--main.cpp16
-rw-r--r--settings.pro9
-rw-r--r--src/settings.cpp63
9 files changed, 259 insertions, 24 deletions
diff --git a/backend/backend.pri b/backend/backend.pri
index 70f84d1..324981c 100644
--- a/backend/backend.pri
+++ b/backend/backend.pri
@@ -1,11 +1,3 @@
-INCLUDEPATH += $$PWD/dconf
-DEPENDPATH += $$PWD/dconf
-
-CONFIG += no_keywords link_pkgconfig
-PKGCONFIG += dconf
-
-SOURCES += \
- $$PWD/dconf/dconfsettings.cpp
-
-HEADERS += \
- $$PWD/dconf/dconfsettings.h
+mac:include(cocoa/cocoa.pri)
+else:unix:include(dconf/dconf.pri)
+else:error(Not implemented for $$first(QMAKE_PLATFORM))
diff --git a/backend/cocoa/cocoa.pri b/backend/cocoa/cocoa.pri
new file mode 100644
index 0000000..5d87908
--- /dev/null
+++ b/backend/cocoa/cocoa.pri
@@ -0,0 +1,8 @@
+INCLUDEPATH += $$PWD
+DEPENDPATH += $$PWD
+
+OBJECTIVE_SOURCES += \
+ $$PWD/cocoasettings.mm
+
+HEADERS += \
+ $$PWD/cocoasettings.h
diff --git a/backend/cocoa/cocoasettings.h b/backend/cocoa/cocoasettings.h
new file mode 100644
index 0000000..eb35623
--- /dev/null
+++ b/backend/cocoa/cocoasettings.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is prototype code for the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef COCOASETTINGS_H
+#define COCOASETTINGS_H
+
+#include "settings.h"
+
+class CocoaSettings : public Settings
+{
+ Q_OBJECT
+
+public:
+ explicit CocoaSettings(QObject *parent = 0);
+ ~CocoaSettings();
+
+ void remove(const QString &key);
+ void set(const QString &key, const QVariant &value);
+ bool get(const QString &key, QVariant *value) const;
+
+ QStringList children(const QString &prefix, ChildSpec spec) const;
+
+ void clear();
+ void sync();
+ void flush();
+ bool isWritable() const;
+ QString fileName() const;
+};
+
+#endif // COCOASETTINGS_H
diff --git a/backend/cocoa/cocoasettings.mm b/backend/cocoa/cocoasettings.mm
new file mode 100644
index 0000000..5d4ff06
--- /dev/null
+++ b/backend/cocoa/cocoasettings.mm
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is prototype code for the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "cocoasettings.h"
+
+CocoaSettings::CocoaSettings(QObject *parent) : Settings(parent)
+{
+}
+
+CocoaSettings::~CocoaSettings()
+{
+}
+
+void CocoaSettings::remove(const QString &key)
+{
+}
+
+void CocoaSettings::set(const QString &key, const QVariant &value)
+{
+}
+
+bool CocoaSettings::get(const QString &key, QVariant *value) const
+{
+ return false;
+}
+
+QStringList CocoaSettings::children(const QString &prefix, ChildSpec spec) const
+{
+ return QStringList();
+}
+
+void CocoaSettings::clear()
+{
+}
+
+void CocoaSettings::sync()
+{
+}
+
+void CocoaSettings::flush()
+{
+}
+
+bool CocoaSettings::isWritable() const
+{
+ return false;
+}
+
+QString CocoaSettings::fileName() const
+{
+ return QString();
+}
diff --git a/backend/dconf/dconf.pri b/backend/dconf/dconf.pri
new file mode 100644
index 0000000..69d68d6
--- /dev/null
+++ b/backend/dconf/dconf.pri
@@ -0,0 +1,11 @@
+INCLUDEPATH += $$PWD
+DEPENDPATH += $$PWD
+
+CONFIG += no_keywords link_pkgconfig
+PKGCONFIG += dconf
+
+SOURCES += \
+ $$PWD/dconfsettings.cpp
+
+HEADERS += \
+ $$PWD/dconfsettings.h
diff --git a/include/settings.h b/include/settings.h
index da88459..9b6b1e5 100644
--- a/include/settings.h
+++ b/include/settings.h
@@ -50,8 +50,10 @@ class Settings : public QObject
Q_OBJECT
public:
- explicit Settings(QObject *parent = 0) : QObject(parent) { }
- virtual ~Settings() {}
+ explicit Settings(QObject *parent = 0);
+ virtual ~Settings();
+
+ static Settings* create(QObject *parent = 0);
virtual void remove(const QString &key) = 0;
virtual void set(const QString &key, const QVariant &value) = 0;
diff --git a/main.cpp b/main.cpp
index c4770d9..d0308f2 100644
--- a/main.cpp
+++ b/main.cpp
@@ -40,9 +40,9 @@
****************************************************************************/
#include <QCoreApplication>
#include <QtDebug>
-#include "dconfsettings.h"
+#include "settings.h"
-static void printSettings(const DConfSettings *settings, const QString &prefix)
+static void printSettings(const Settings *settings, const QString &prefix)
{
const QStringList keys = settings->children(prefix, Settings::ChildKeys);
if (!keys.isEmpty()) {
@@ -64,15 +64,15 @@ int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
- DConfSettings settings;
+ Settings *settings = Settings::create(&app);
- printSettings(&settings, "/");
+ printSettings(settings, "/");
qDebug() << "\n\n";
- settings.set("/org/qt-project/bool", true);
- settings.set("/org/qt-project/chr", QChar('a'));
- settings.set("/org/qt-project/num", 123);
- settings.set("/org/qt-project/str", "foo");
+ settings->set("/org/qt-project/bool", true);
+ settings->set("/org/qt-project/chr", QChar('a'));
+ settings->set("/org/qt-project/num", 123);
+ settings->set("/org/qt-project/str", "foo");
return app.exec();
}
diff --git a/settings.pro b/settings.pro
index 17d2227..6f9df69 100644
--- a/settings.pro
+++ b/settings.pro
@@ -3,8 +3,11 @@ TARGET = settings
INCLUDEPATH += . include
QT = core
-# Input
-HEADERS += include/settings.h
-SOURCES += main.cpp
+HEADERS += \
+ include/settings.h
+
+SOURCES += \
+ main.cpp \
+ src/settings.cpp
include(backend/backend.pri)
diff --git a/src/settings.cpp b/src/settings.cpp
new file mode 100644
index 0000000..7505e28
--- /dev/null
+++ b/src/settings.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is prototype code for the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "settings.h"
+#ifdef Q_OS_MAC
+#include "cocoasettings.h"
+#else
+#include "dconfsettings.h"
+#endif
+
+Settings::Settings(QObject *parent) : QObject(parent)
+{
+}
+
+Settings::~Settings()
+{
+}
+
+Settings* Settings::create(QObject *parent)
+{
+#ifdef Q_OS_MAC
+ return new CocoaSettings(parent);
+#else
+ return new DConfSettings(parent);
+#endif
+}