From d9440ad4a6f936ca8acfdc7962e70963070f8959 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 27 May 2015 04:08:08 +0200 Subject: [PATCH] refs #432, components for core GUI * register: show applications connected with core * info area, allow to add new areas in core GUI --- .../components/coreinfoareacomponent.cpp | 75 ++++++ .../components/coreinfoareacomponent.h | 77 ++++++ .../components/coreinfoareacomponent.ui | 220 ++++++++++++++++++ .../components/corestatuscomponent.cpp | 27 +++ src/blackgui/components/corestatuscomponent.h | 43 ++++ .../components/corestatuscomponent.ui | 66 ++++++ src/blackgui/components/registercomponent.cpp | 44 ++++ src/blackgui/components/registercomponent.h | 53 +++++ src/blackgui/components/registercomponent.ui | 53 +++++ 9 files changed, 658 insertions(+) create mode 100644 src/blackgui/components/coreinfoareacomponent.cpp create mode 100644 src/blackgui/components/coreinfoareacomponent.h create mode 100644 src/blackgui/components/coreinfoareacomponent.ui create mode 100644 src/blackgui/components/corestatuscomponent.cpp create mode 100644 src/blackgui/components/corestatuscomponent.h create mode 100644 src/blackgui/components/corestatuscomponent.ui create mode 100644 src/blackgui/components/registercomponent.cpp create mode 100644 src/blackgui/components/registercomponent.h create mode 100644 src/blackgui/components/registercomponent.ui diff --git a/src/blackgui/components/coreinfoareacomponent.cpp b/src/blackgui/components/coreinfoareacomponent.cpp new file mode 100644 index 000000000..b9c10d4de --- /dev/null +++ b/src/blackgui/components/coreinfoareacomponent.cpp @@ -0,0 +1,75 @@ +/* Copyright (C) 2015 + * 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 "coreinfoareacomponent.h" +#include "ui_coreinfoareacomponent.h" +#include "blackgui/components/logcomponent.h" +#include "blackgui/components/corestatuscomponent.h" +#include "blackgui/stylesheetutility.h" +#include "blackgui/guiutility.h" +#include "blackmisc/icons.h" +#include +#include +#include +#include + +using namespace BlackMisc; +using namespace BlackGui; + +namespace BlackGui +{ + namespace Components + { + CCoreInfoAreaComponent::CCoreInfoAreaComponent(QWidget *parent) : + CInfoArea(parent), + ui(new Ui::CCoreInfoAreaComponent) + { + ui->setupUi(this); + initInfoArea(); + ps_toggleTabBarLocked(true); + } + + CCoreInfoAreaComponent::~CCoreInfoAreaComponent() + { } + + CLogComponent *CCoreInfoAreaComponent::getLogComponent() + { + return this->ui->comp_Log; + } + + CCoreStatusComponent *CCoreInfoAreaComponent::getStatusComponent() + { + return this->ui->comp_Status; + } + + QSize CCoreInfoAreaComponent::getPreferredSizeWhenFloating(int areaIndex) const + { + InfoArea area = static_cast(areaIndex); + switch (area) + { + case InfoAreaLog: + return QSize(400, 300); + default: + return QSize(400, 300); + } + } + + const QPixmap &CCoreInfoAreaComponent::indexToPixmap(int areaIndex) const + { + InfoArea area = static_cast(areaIndex); + switch (area) + { + case InfoAreaLog: + return CIcons::appLog16(); + default: + return CIcons::statusBar16(); + } + } + } // namespace +} // namespace diff --git a/src/blackgui/components/coreinfoareacomponent.h b/src/blackgui/components/coreinfoareacomponent.h new file mode 100644 index 000000000..a8854bb15 --- /dev/null +++ b/src/blackgui/components/coreinfoareacomponent.h @@ -0,0 +1,77 @@ +/* Copyright (C) 2015 + * 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_COREINFOAREACOMPONENT_H +#define BLACKGUI_COREINFOAREACOMPONENT_H + +#include "blackgui/blackguiexport.h" +#include "../infoarea.h" +#include +#include +#include + +namespace Ui { class CCoreInfoAreaComponent; } +namespace BlackGui +{ + namespace Components + { + // break compile dependency + class CLogComponent; + class CCoreStatusComponent; + + //! Main info area + class BLACKGUI_EXPORT CCoreInfoAreaComponent : public BlackGui::CInfoArea + { + Q_OBJECT + + public: + //! Constructor + explicit CCoreInfoAreaComponent(QWidget *parent = nullptr); + + //! Destructor + virtual ~CCoreInfoAreaComponent(); + + //! Info areas + enum InfoArea + { + // index must match tab index! + InfoAreaLog = 0, + InfoAreaStatus = 1, + InfoAreaNone = -1 + }; + + //! Log messages + CLogComponent *getLogComponent(); + + //! Simulator + CCoreStatusComponent *getStatusComponent(); + + public slots: + //! Toggle floating of given area + void toggleFloating(InfoArea infoArea) { CInfoArea::toggleFloatingByIndex(static_cast(infoArea)); } + + //! Select area + void selectArea(InfoArea infoArea) { CInfoArea::selectArea(static_cast(infoArea)); } + + protected: + //! \copydoc CInfoArea::getPreferredSizeWhenFloating + virtual QSize getPreferredSizeWhenFloating(int areaIndex) const override; + + //! \copydoc CInfoArea::indexToPixmap + virtual const QPixmap &indexToPixmap(int areaIndex) const override; + + private: + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/coreinfoareacomponent.ui b/src/blackgui/components/coreinfoareacomponent.ui new file mode 100644 index 000000000..d52b9735c --- /dev/null +++ b/src/blackgui/components/coreinfoareacomponent.ui @@ -0,0 +1,220 @@ + + + CCoreInfoAreaComponent + + + + 0 + 0 + 1533 + 242 + + + + Main info area + + + + :/own/icons/own/swift/swift24.png:/own/icons/own/swift/swift24.png + + + + + + false + + + false + + + false + + + QMainWindow::AllowTabbedDocks|QMainWindow::ForceTabbedDocks + + + + false + + + + 0 + 0 + + + + + + + 80 + 70 + + + + Qt::TopDockWidgetArea + + + Log + + + 4 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + + 0 + + + 0 + + + 2 + + + 0 + + + 0 + + + + + 0 + + + + + + + + + + + + + 165 + 66 + + + + Qt::TopDockWidgetArea + + + Status + + + 4 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + + 0 + + + 0 + + + 2 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + + + BlackGui::Components::CLogComponent + QWidget +
blackgui/components/logcomponent.h
+ 1 +
+ + BlackGui::CDockWidgetInfoArea + QDockWidget +
blackgui/dockwidgetinfoarea.h
+ 1 +
+ + BlackGui::Components::CCoreStatusComponent + QFrame +
blackgui/components/corestatuscomponent.h
+ 1 +
+
+ + + + +
diff --git a/src/blackgui/components/corestatuscomponent.cpp b/src/blackgui/components/corestatuscomponent.cpp new file mode 100644 index 000000000..e93222f4b --- /dev/null +++ b/src/blackgui/components/corestatuscomponent.cpp @@ -0,0 +1,27 @@ +/* Copyright (C) 2015 + * 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 "corestatuscomponent.h" +#include "ui_corestatuscomponent.h" + +namespace BlackGui +{ + namespace Components + { + CCoreStatusComponent::CCoreStatusComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CCoreStatusComponent) + { + ui->setupUi(this); + } + + CCoreStatusComponent::~CCoreStatusComponent() { } + + } // namespace +} // namespacee diff --git a/src/blackgui/components/corestatuscomponent.h b/src/blackgui/components/corestatuscomponent.h new file mode 100644 index 000000000..3d8c749f8 --- /dev/null +++ b/src/blackgui/components/corestatuscomponent.h @@ -0,0 +1,43 @@ +/* Copyright (C) 2015 + * 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. + */ + +#ifndef BLACKGUI_COMPONENTS_CORESTATUSCOMPONENT_H +#define BLACKGUI_COMPONENTS_CORESTATUSCOMPONENT_H + +#include "blackgui/blackguiexport.h" +#include +#include + +namespace Ui { class CCoreStatusComponent; } + +namespace BlackGui +{ + namespace Components + { + + //! Display status information about the core + class BLACKGUI_EXPORT CCoreStatusComponent : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CCoreStatusComponent(QWidget *parent = nullptr); + + //! Destructor + ~CCoreStatusComponent(); + + private: + QScopedPointer ui; + }; + + } // namespace +} // namespace + +#endif // guard diff --git a/src/blackgui/components/corestatuscomponent.ui b/src/blackgui/components/corestatuscomponent.ui new file mode 100644 index 000000000..8310d9b03 --- /dev/null +++ b/src/blackgui/components/corestatuscomponent.ui @@ -0,0 +1,66 @@ + + + CCoreStatusComponent + + + + 0 + 0 + 400 + 300 + + + + Frame + + + QFrame::NoFrame + + + QFrame::Plain + + + 0 + + + + 3 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Plain + + + 0 + + + + + + + + BlackGui::Components::CRegisterComponent + QFrame +
blackgui/components/registercomponent.h
+ 1 +
+
+ + +
diff --git a/src/blackgui/components/registercomponent.cpp b/src/blackgui/components/registercomponent.cpp new file mode 100644 index 000000000..ea7bb7ddd --- /dev/null +++ b/src/blackgui/components/registercomponent.cpp @@ -0,0 +1,44 @@ +/* Copyright (C) 2015 + * 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 "registercomponent.h" +#include "ui_registercomponent.h" +#include "blackcore/context_application.h" + +using namespace BlackCore; + +namespace BlackGui +{ + namespace Components + { + CRegisterComponent::CRegisterComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CRegisterComponent), + m_updateTimer(new CUpdateTimer("CRegisterComponent", &CRegisterComponent::ps_update, this)) + { + ui->setupUi(this); + } + + CRegisterComponent::~CRegisterComponent() + { } + + void CRegisterComponent::ps_update() + { + this->ui->tvp_RegisteredComponents->updateContainer(getIContextApplication()->getRegisteredApplications()); + } + + void CRegisterComponent::runtimeHasBeenSet() + { + Q_ASSERT_X(getIContextApplication(), Q_FUNC_INFO, "Missing context"); + m_updateTimer->setUpdateIntervalSeconds(20); + QObject::connect(getIContextApplication(), &IContextApplication::registrationChanged, this, &CRegisterComponent::ps_update); + } + + } // ns +} // ns diff --git a/src/blackgui/components/registercomponent.h b/src/blackgui/components/registercomponent.h new file mode 100644 index 000000000..d391c6d16 --- /dev/null +++ b/src/blackgui/components/registercomponent.h @@ -0,0 +1,53 @@ +/* Copyright (C) 2015 + * 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. + */ + +#ifndef BLACKGUI_COMPONENTS_REGISTERCOMPONENT_H +#define BLACKGUI_COMPONENTS_REGISTERCOMPONENT_H + +#include "blackgui/components/enableforruntime.h" +#include "blackgui/components/updatetimer.h" +#include + +namespace Ui { class CRegisterComponent; } + +namespace BlackGui +{ + namespace Components + { + //! Register components in the GUI + class BLACKGUI_EXPORT CRegisterComponent : + public QFrame, + public CEnableForRuntime + { + Q_OBJECT + + public: + //! Constructor + explicit CRegisterComponent(QWidget *parent = nullptr); + + //! Destructor + ~CRegisterComponent(); + + protected: + //! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet + virtual void runtimeHasBeenSet() override; + + private slots: + //! Update data + void ps_update(); + + private: + QScopedPointer ui; + QScopedPointer m_updateTimer; + }; + + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/registercomponent.ui b/src/blackgui/components/registercomponent.ui new file mode 100644 index 000000000..aa40fb15c --- /dev/null +++ b/src/blackgui/components/registercomponent.ui @@ -0,0 +1,53 @@ + + + CRegisterComponent + + + + 0 + 0 + 400 + 300 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + false + + + + + + + + BlackGui::Views::COriginatorView + QTableView +
blackgui/views/originatorview.h
+
+
+ + +