From c6f3a7033d018ad9a855afaa5d7c0cbbe0e5b415 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 15 Aug 2017 02:15:57 +0200 Subject: [PATCH] Ref T125, own component for XSwiftBus settings. This component can be used in the installation and plugin UI. --- .../components/settingsxswiftbuscomponent.cpp | 45 +++++++++++++++++ .../components/settingsxswiftbuscomponent.h | 48 +++++++++++++++++++ .../components/settingsxswiftbuscomponent.ui | 43 +++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 src/blackgui/components/settingsxswiftbuscomponent.cpp create mode 100644 src/blackgui/components/settingsxswiftbuscomponent.h create mode 100644 src/blackgui/components/settingsxswiftbuscomponent.ui diff --git a/src/blackgui/components/settingsxswiftbuscomponent.cpp b/src/blackgui/components/settingsxswiftbuscomponent.cpp new file mode 100644 index 000000000..41d5ff12b --- /dev/null +++ b/src/blackgui/components/settingsxswiftbuscomponent.cpp @@ -0,0 +1,45 @@ +/* Copyright (C) 2017 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "settingsxswiftbuscomponent.h" +#include "ui_settingsxswiftbuscomponent.h" +#include "blackmisc/dbusserver.h" + +#include + +using namespace BlackMisc; + +namespace BlackGui +{ + namespace Components + { + CSettingsXSwiftBusComponent::CSettingsXSwiftBusComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CSettingsXSwiftBusComponent) + { + ui->setupUi(this); + ui->cb_XSwiftBusServer->addItem(CDBusServer::sessionBusAddress()); + ui->cb_XSwiftBusServer->addItem(CDBusServer::systemBusAddress()); + ui->cb_XSwiftBusServer->setCurrentText(m_xSwiftBusServerSetting.getThreadLocal()); + + connect(ui->cb_XSwiftBusServer, &QComboBox::currentTextChanged, this, &CSettingsXSwiftBusComponent::saveServer); + } + + CSettingsXSwiftBusComponent::~CSettingsXSwiftBusComponent() + { } + + void CSettingsXSwiftBusComponent::saveServer(const QString &dBusAddress) + { + if (dBusAddress != m_xSwiftBusServerSetting.getThreadLocal()) + { + m_xSwiftBusServerSetting.setAndSave(dBusAddress); + } + } + } // ns +} // ns diff --git a/src/blackgui/components/settingsxswiftbuscomponent.h b/src/blackgui/components/settingsxswiftbuscomponent.h new file mode 100644 index 000000000..30ad183ba --- /dev/null +++ b/src/blackgui/components/settingsxswiftbuscomponent.h @@ -0,0 +1,48 @@ +/* Copyright (C) 2017 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_SETTINGSXSWIFTBUSCOMPONENT_H +#define BLACKGUI_COMPONENTS_SETTINGSXSWIFTBUSCOMPONENT_H + +#include "blackmisc/simulation/settings/xswiftbussettings.h" +#include "blackmisc/settingscache.h" +#include "blackgui/blackguiexport.h" +#include +#include + +namespace Ui { class CSettingsXSwiftBusComponent; } +namespace BlackGui +{ + namespace Components + { + /*! + * XSwiftBus setup + */ + class BLACKGUI_EXPORT CSettingsXSwiftBusComponent : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CSettingsXSwiftBusComponent(QWidget *parent = nullptr); + + //! Dtor + virtual ~CSettingsXSwiftBusComponent(); + + private: + QScopedPointer ui; + BlackMisc::CSetting m_xSwiftBusServerSetting { this }; + + void saveServer(const QString &dBusAddress); + }; + } // ns +} // ns +#endif // guard diff --git a/src/blackgui/components/settingsxswiftbuscomponent.ui b/src/blackgui/components/settingsxswiftbuscomponent.ui new file mode 100644 index 000000000..d503c1b06 --- /dev/null +++ b/src/blackgui/components/settingsxswiftbuscomponent.ui @@ -0,0 +1,43 @@ + + + CSettingsXSwiftBusComponent + + + + 0 + 0 + 160 + 26 + + + + XSwiftBus settings + + + + 2 + + + 2 + + + 2 + + + 2 + + + + + XSwiftBus server: + + + + + + + + + + +