refs #139 added keyboard key list to settings, so values can be changed

This commit is contained in:
Klaus Basan
2014-02-17 02:31:23 +01:00
parent bb5865936b
commit 87352df468
6 changed files with 90 additions and 40 deletions

View File

@@ -7,9 +7,10 @@
#include "coreruntime.h" #include "coreruntime.h"
#include "blackmisc/settingutilities.h" #include "blackmisc/settingutilities.h"
using namespace BlackMisc;
using namespace BlackMisc::Settings; using namespace BlackMisc::Settings;
using namespace BlackMisc::Network; using namespace BlackMisc::Network;
using namespace BlackMisc; using namespace BlackMisc::Hardware;
namespace BlackCore namespace BlackCore
{ {
@@ -17,7 +18,7 @@ namespace BlackCore
/* /*
* Init this context * Init this context
*/ */
CContextSettings::CContextSettings(CCoreRuntime *runtime) : IContextSettings(runtime), m_settingsNetwork() CContextSettings::CContextSettings(CCoreRuntime *runtime) : IContextSettings(runtime)
{ {
// create some dummy settings // create some dummy settings
// this would actually be reading the settings from disk .. // this would actually be reading the settings from disk ..
@@ -28,6 +29,17 @@ namespace BlackCore
this->m_settingsNetwork.addTrafficNetworkServer(CServer("Europe CC", "VATSIM Server", "5.9.155.43", 6809, CUser("vatsimid", "Black Client", "", "vatsimpw"))); this->m_settingsNetwork.addTrafficNetworkServer(CServer("Europe CC", "VATSIM Server", "5.9.155.43", 6809, CUser("vatsimid", "Black Client", "", "vatsimpw")));
this->m_settingsNetwork.addTrafficNetworkServer(CServer("UK", "VATSIM Server", "109.169.48.148", 6809, CUser("vatsimid", "Black Client", "", "vatsimpw"))); this->m_settingsNetwork.addTrafficNetworkServer(CServer("UK", "VATSIM Server", "109.169.48.148", 6809, CUser("vatsimid", "Black Client", "", "vatsimpw")));
this->m_settingsNetwork.addTrafficNetworkServer(CServer("USA-W", "VATSIM Server", "64.151.108.52", 6809, CUser("vatsimid", "Black Client", "", "vatsimpw"))); this->m_settingsNetwork.addTrafficNetworkServer(CServer("USA-W", "VATSIM Server", "64.151.108.52", 6809, CUser("vatsimid", "Black Client", "", "vatsimpw")));
// hotkeys
this->m_hotkeys.initAsHotkeyList();
}
/*
* Hotkeys
*/
Hardware::CKeyboardKeyList CContextSettings::getHotkeys() const
{
return this->m_hotkeys;
} }
/* /*
@@ -45,15 +57,40 @@ namespace BlackCore
{ {
Q_ASSERT(path.length() > 3); Q_ASSERT(path.length() > 3);
Q_ASSERT(path.indexOf('/') >= 0); Q_ASSERT(path.indexOf('/') >= 0);
BlackMisc::CStatusMessageList msgs;
if (path.contains(IContextSettings::PathRoot()))
{
if (path.contains(IContextSettings::PathHotkeys()))
{
if (command == CSettingUtilities::CmdUpdate())
{
BlackMisc::Hardware::CKeyboardKeyList hotkeys = value.value<BlackMisc::Hardware::CKeyboardKeyList>();
this->m_hotkeys = hotkeys;
emit this->changedSettings();
msgs.push_back(CStatusMessage::getInfoMessage("set hotkeys"));
return msgs;
}
}
}
// next level
QString nextLevelPath = CSettingUtilities::removeLeadingPath(path); QString nextLevelPath = CSettingUtilities::removeLeadingPath(path);
BlackMisc::CStatusMessageList msgs = CSettingUtilities::wrongPathMessages(path);
bool changed = false; bool changed = false;
if (path.startsWith(IContextSettings::PathNetworkSettings())) if (path.startsWith(IContextSettings::PathNetworkSettings()))
{ {
msgs = this->m_settingsNetwork.value(nextLevelPath, command, value, changed); msgs = this->m_settingsNetwork.value(nextLevelPath, command, value, changed);
if (changed) emit this->changedNetworkSettings(); if (changed)
{
emit this->changedNetworkSettings();
emit this->changedSettings();
}
}
else
{
// wrong path
msgs = CSettingUtilities::wrongPathMessages(path);
} }
return msgs; return msgs;
} }
} // namespace } // namespace

View File

@@ -9,8 +9,8 @@
#include "blackcore/coreruntime.h" #include "blackcore/coreruntime.h"
#include "blackcore/dbus_server.h" #include "blackcore/dbus_server.h"
#include "blackcore/context_settings_interface.h" #include "blackcore/context_settings_interface.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/statusmessagelist.h" #include "blackmisc/statusmessagelist.h"
#include "blackmisc/hwkeyboardkeylist.h"
#include <QObject> #include <QObject>
#define BLACKCORE_CONTEXTSETTINGS_INTERFACENAME "blackcore.contextsettings" #define BLACKCORE_CONTEXTSETTINGS_INTERFACENAME "blackcore.contextsettings"
@@ -29,50 +29,37 @@ namespace BlackCore
public: public:
/*! //! \brief Constructor
* Context
* \param runtime
*/
CContextSettings(CCoreRuntime *runtime); CContextSettings(CCoreRuntime *runtime);
/*! //! Destructor
* Destructor
*/
virtual ~CContextSettings() {} virtual ~CContextSettings() {}
/*! //! \brief Register myself in DBus
* \brief Register myself in DBus
* \param server
*/
void registerWithDBus(CDBusServer *server) void registerWithDBus(CDBusServer *server)
{ {
server->addObject(IContextSettings::ServicePath(), this); server->addObject(IContextSettings::ServicePath(), this);
} }
/*! //! \brief Runtime
* \brief Runtime
* \return
*/
const CCoreRuntime *getRuntime() const const CCoreRuntime *getRuntime() const
{ {
return static_cast<CCoreRuntime *>(this->parent()); return static_cast<CCoreRuntime *>(this->parent());
} }
/*! //! \copydoc IContextSettings::value()
* \copydoc IContextSettings::value()
*/
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const QVariant &value); virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const QVariant &value);
public slots: public slots:
/*! //! \copydoc IContextSettings::getNetworkSettings()
* \copydoc IContextSettings::getNetworkSettings()
*/
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const; virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const;
//! \copydoc IContextSettings::getHotkeys()
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const;
private: private:
BlackMisc::Settings::CSettingsNetwork m_settingsNetwork; BlackMisc::Settings::CSettingsNetwork m_settingsNetwork;
BlackMisc::Hardware::CKeyboardKeyList m_hotkeys;
}; };
} }

View File

@@ -40,6 +40,14 @@ namespace BlackCore
return this->m_dBusInterface->callDBusRet<BlackMisc::Settings::CSettingsNetwork>(QLatin1Literal("getNetworkSettings")); return this->m_dBusInterface->callDBusRet<BlackMisc::Settings::CSettingsNetwork>(QLatin1Literal("getNetworkSettings"));
} }
/*
* Relay tp DBus
*/
BlackMisc::Hardware::CKeyboardKeyList IContextSettings::getHotkeys() const
{
return this->m_dBusInterface->callDBusRet<BlackMisc::Hardware::CKeyboardKeyList>(QLatin1Literal("getHotkeys"));
}
/* /*
* Relay to DBus, but make this no slot * Relay to DBus, but make this no slot
*/ */

View File

@@ -10,6 +10,7 @@
#include "blackmisc/genericdbusinterface.h" #include "blackmisc/genericdbusinterface.h"
#include "blackmisc/settingutilities.h" #include "blackmisc/settingutilities.h"
#include "blackmisc/setnetwork.h" #include "blackmisc/setnetwork.h"
#include "blackmisc/hwkeyboardkeylist.h"
#include <QObject> #include <QObject>
#include <QVariant> #include <QVariant>
#include <QDBusAbstractInterface> #include <QDBusAbstractInterface>
@@ -53,7 +54,7 @@ namespace BlackCore
/*! /*!
* \brief Path for network settings * \brief Path for network settings
* \remark no to be confused with DBus paths * \remarks no to be confused with DBus paths
*/ */
static const QString &PathNetworkSettings() static const QString &PathNetworkSettings()
{ {
@@ -61,6 +62,26 @@ namespace BlackCore
return s; return s;
} }
/*!
* \brief Path for network settings
* \remarks no to be confused with DBus paths
*/
static const QString &PathRoot()
{
static QString s("root");
return s;
}
/*!
* \brief Path for hotkeys
* \remarks no to be confused with DBus paths
*/
static const QString &PathHotkeys()
{
static QString s("hotkeys");
return s;
}
/*! /*!
* \brief DBus version constructor * \brief DBus version constructor
*/ */
@@ -102,26 +123,25 @@ namespace BlackCore
IContextSettings(QObject *parent = nullptr) : QObject(parent), m_dBusInterface(nullptr) {} IContextSettings(QObject *parent = nullptr) : QObject(parent), m_dBusInterface(nullptr) {}
signals: signals:
//! \brief Settings have been changed
void changedSettings();
/*! //! \brief Network settings have been changed
* \brief Settings have been changed
*/
void changedNetworkSettings(); void changedNetworkSettings();
public slots: public slots:
/*! //! \brief Network settings
* \brief Network settings
*/
virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const; virtual BlackMisc::Settings::CSettingsNetwork getNetworkSettings() const;
//! \brief Hotkeys
virtual BlackMisc::Hardware::CKeyboardKeyList getHotkeys() const;
/*! /*!
* \brief DBus version of value method. * \brief DBus version of value method.
* \remarks Basically an unwanted signature as this is different from the "local" signature and * \remarks Basically an unwanted signature as this is different from the "local" signature and
* contains explicit DBus types (a: QDbusArgument, b: type for conversion). * contains explicit DBus types (a: QDbusArgument, b: type for conversion).
* If this can be removed, fine. * If this can be removed, fine.
*
*/ */
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, QDBusVariant value, int unifiedBlackMetaType); virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, QDBusVariant value, int unifiedBlackMetaType);
}; };

View File

@@ -127,7 +127,7 @@ namespace BlackMisc
// TODO: This needs to be refactored to a smarter way to delegate commands // TODO: This needs to be refactored to a smarter way to delegate commands
changedFlag = false; changedFlag = false;
CStatusMessageList msgs; CStatusMessageList msgs;
if (path == CSettingsNetwork::PathTrafficServer()) if (path == CSettingsNetwork::ValueTrafficServer())
{ {
const CServer server = value.value<CServer>(); const CServer server = value.value<CServer>();
if (command == CSettingsNetwork::CmdSetCurrentServer()) if (command == CSettingsNetwork::CmdSetCurrentServer())

View File

@@ -50,7 +50,7 @@ namespace BlackMisc
* \brief Path * \brief Path
* \return * \return
*/ */
static const QString &PathTrafficServer() static const QString &ValueTrafficServer()
{ {
static const QString cmd("trafficserver"); static const QString cmd("trafficserver");
return cmd; return cmd;
@@ -66,7 +66,6 @@ namespace BlackMisc
/*! /*!
* Traffic network server objects * Traffic network server objects
* \return
*/ */
BlackMisc::Network::CServerList getTrafficNetworkServers() const { return m_trafficNetworkServers; } BlackMisc::Network::CServerList getTrafficNetworkServers() const { return m_trafficNetworkServers; }
@@ -77,7 +76,6 @@ namespace BlackMisc
/*! /*!
* \brief URL of booking service * \brief URL of booking service
* \return
*/ */
QString getBookingServiceUrl() const { return "http://vatbook.euroutepro.com/xml2.php"; } QString getBookingServiceUrl() const { return "http://vatbook.euroutepro.com/xml2.php"; }