This commit is contained in:
Nav
2021-06-21 00:14:31 +01:00
parent a9c6171ac2
commit 139e880646
20 changed files with 45 additions and 55 deletions

View File

@@ -47,12 +47,12 @@ namespace Bloom
* Insight consists of two threads - the main thread where the main Qt event loop runs (for the GUI), and
* a single worker thread to handle any blocking/time-expensive operations.
*/
QThread* workerThread;
QThread* workerThread = nullptr;
void startup();
public:
Insight(EventManager& eventManager): eventManager(eventManager) {};
explicit Insight(EventManager& eventManager): eventManager(eventManager) {};
void setApplicationConfig(const ApplicationConfig& applicationConfig) {
this->applicationConfig = applicationConfig;

View File

@@ -40,7 +40,7 @@ namespace Bloom
void onTargetControllerStateReported(Events::EventPointer<Events::TargetControllerStateReported> event);
public:
InsightWorker(EventManager& eventManager): eventManager(eventManager) {};
explicit InsightWorker(EventManager& eventManager): eventManager(eventManager) {};
void dispatchEvents() {
this->eventListener->dispatchCurrentEvents();

View File

@@ -14,7 +14,7 @@ namespace Bloom
QWidget* windowWidget = nullptr;
public:
AboutWindow(QWidget* parent);
explicit AboutWindow(QWidget* parent);
void show() {
if (this->windowWidget != nullptr) {

View File

@@ -1,5 +1,6 @@
#include <QtUiTools>
#include <QtSvg/QtSvg>
#include <utility>
#include "InsightWindow.hpp"
#include "AboutWindow.hpp"
@@ -25,7 +26,7 @@ void InsightWindow::init(
QApplication& application,
TargetDescriptor targetDescriptor
) {
this->targetDescriptor = targetDescriptor;
this->targetDescriptor = std::move(targetDescriptor);
auto mainWindowUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
@@ -50,7 +51,7 @@ void InsightWindow::init(
this->mainWindowWidget = uiLoader.load(&mainWindowUiFile);
this->mainWindowWidget->setStyleSheet(mainWindowStylesheet.readAll());
application.setWindowIcon(QIcon(
QApplication::setWindowIcon(QIcon(
QString::fromStdString(Paths::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Images/BloomIcon.svg"
)
@@ -166,7 +167,7 @@ void InsightWindow::activate() {
QString::fromStdString(targetVariant.name + " (" + targetVariant.packageName + ")")
);
if (this->isVariantSupported(targetVariant)) {
if (InsightWindow::isVariantSupported(targetVariant)) {
auto supportedVariantPtr = &(this->supportedVariantsByName.insert(
std::pair(QString::fromStdString(targetVariant.name).toLower(), targetVariant)
).first->second);

View File

@@ -48,7 +48,7 @@ namespace Bloom
const Targets::TargetVariant* selectedVariant = nullptr;
bool uiDisabled = false;
bool isVariantSupported(const Targets::TargetVariant& variant);
static bool isVariantSupported(const Targets::TargetVariant& variant);
void selectVariant(const Targets::TargetVariant* variant);
@@ -84,7 +84,7 @@ namespace Bloom
void onTargetIoPortsUpdate();
void close();
void openReportIssuesUrl();
void openGettingStartedUrl();
static void openGettingStartedUrl();
void openAboutWindow();
void togglePinIoState(InsightTargetWidgets::TargetPinWidget* pinWidget);

View File

@@ -32,7 +32,6 @@ void BodyWidget::drawWidget(QPainter& painter) {
painter.setPen(Qt::PenStyle::NoPen);
painter.setBrush(targetBodyColor);
auto parentContainerWidth = parentWidget->width();
// this->setFixedSize(parentContainerWidth, parentContainerHeight);
auto targetBodyHeight = 150;
auto targetBodyWidth = parentContainerWidth;

View File

@@ -16,23 +16,23 @@ namespace Bloom::InsightTargetWidgets::Dip
int disableAlphaLevel = 100;
protected:
void paintEvent(QPaintEvent* event);
void paintEvent(QPaintEvent* event) override;
void drawWidget(QPainter& painter);
public:
BodyWidget(QWidget* parent): QWidget(parent) {
explicit BodyWidget(QWidget* parent): QWidget(parent) {
this->setObjectName("target-body");
}
QColor getBodyColor() const {
[[nodiscard]] QColor getBodyColor() const {
return this->bodyColor;
}
void setBodyColor(QColor color) {
void setBodyColor(const QColor& color) {
this->bodyColor = color;
}
int getDisableAlphaLevel() const {
[[nodiscard]] int getDisableAlphaLevel() const {
return this->disableAlphaLevel;
}

View File

@@ -25,8 +25,8 @@ namespace Bloom::InsightTargetWidgets::Dip
BodyWidget* bodyWidget = nullptr;
protected:
void paintEvent(QPaintEvent* event);
void resizeEvent(QResizeEvent* event);
void paintEvent(QPaintEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void drawWidget(QPainter& painter);
public:

View File

@@ -1,25 +1,21 @@
#include <QPainter>
#include <QLayout>
#include <cmath>
#include <QEvent>
#include <QMenu>
#include <QContextMenuEvent>
#include "PinBodyWidget.hpp"
#include "src/Logger/Logger.hpp"
#include "src/Exceptions/Exception.hpp"
using namespace Bloom::InsightTargetWidgets::Dip;
using namespace Bloom::Targets;
using namespace Bloom::Exceptions;
void PinBodyWidget::paintEvent(QPaintEvent* event) {
auto painter = QPainter(this);
this->drawWidget(painter);
}
bool PinBodyWidget::event(QEvent* event)
{
bool PinBodyWidget::event(QEvent* event) {
if (this->isEnabled() && this->pinState.has_value() && this->pinState->ioDirection == TargetPinState::IoDirection::OUTPUT) {
switch (event->type()) {
case QEvent::Enter: {

View File

@@ -2,6 +2,7 @@
#include <QWidget>
#include <QMouseEvent>
#include <utility>
#include "src/Targets/TargetPinDescriptor.hpp"
@@ -38,8 +39,8 @@ namespace Bloom::InsightTargetWidgets::Dip
PinBodyWidget(
QWidget* parent,
const Targets::TargetPinDescriptor& pinDescriptor
): QWidget(parent), pinDescriptor(pinDescriptor) {
Targets::TargetPinDescriptor pinDescriptor
): QWidget(parent), pinDescriptor(std::move(pinDescriptor)) {
this->setFixedSize(PinBodyWidget::WIDTH, PinBodyWidget::HEIGHT);
this->setObjectName("target-pin-body");
}
@@ -52,7 +53,7 @@ namespace Bloom::InsightTargetWidgets::Dip
return this->bodyColor;
}
void setBodyColor(QColor color) {
void setBodyColor(const QColor& color) {
this->bodyColor = color;
}

View File

@@ -19,12 +19,8 @@ namespace Bloom::InsightTargetWidgets::Dip
QLabel* pinDirectionLabel = nullptr;
PinBodyWidget* bodyWidget = nullptr;
void setLabelColor(QString hexColor) {
void setLabelColor(const QString& hexColor) {
auto style = QString("QLabel { color: " + hexColor + "; }");
if (this->pinNumberLabel != nullptr) {
// this->pinNumberLabel->setStyleSheet(style);
}
if (this->pinNameLabel != nullptr) {
this->pinNameLabel->setStyleSheet(style);
}
@@ -43,7 +39,7 @@ namespace Bloom::InsightTargetWidgets::Dip
const Targets::TargetVariant& targetVariant
);
virtual void updatePinState(const Targets::TargetPinState& pinState) override {
void updatePinState(const Targets::TargetPinState& pinState) override {
TargetPinWidget::updatePinState(pinState);
if (pinState.ioDirection.has_value()) {

View File

@@ -1,5 +1,4 @@
#include <QPainter>
#include <cmath>
#include "BodyWidget.hpp"
#include "src/Logger/Logger.hpp"
@@ -48,4 +47,3 @@ void BodyWidget::drawWidget(QPainter& painter) {
15
));
}

View File

@@ -16,15 +16,15 @@ namespace Bloom::InsightTargetWidgets::Qfp
int disableAlphaLevel = 100;
protected:
void paintEvent(QPaintEvent* event);
void paintEvent(QPaintEvent* event) override;
void drawWidget(QPainter& painter);
public:
BodyWidget(QWidget* parent): QWidget(parent) {
explicit BodyWidget(QWidget* parent): QWidget(parent) {
this->setObjectName("target-body");
}
QColor getBodyColor() const {
[[nodiscard]] QColor getBodyColor() const {
return this->bodyColor;
}
@@ -32,7 +32,7 @@ namespace Bloom::InsightTargetWidgets::Qfp
this->bodyColor = color;
}
int getDisableAlphaLevel() const {
[[nodiscard]] int getDisableAlphaLevel() const {
return this->disableAlphaLevel;
}

View File

@@ -15,8 +15,7 @@ void PinBodyWidget::paintEvent(QPaintEvent* event) {
this->drawWidget(painter);
}
bool PinBodyWidget::event(QEvent* event)
{
bool PinBodyWidget::event(QEvent* event) {
if (this->isEnabled() && this->pinState.has_value() && this->pinState->ioDirection == TargetPinState::IoDirection::OUTPUT) {
switch (event->type()) {
case QEvent::Enter: {
@@ -86,4 +85,4 @@ void PinBodyWidget::drawWidget(QPainter& painter) {
pinWidth,
pinHeight
);
}
}

View File

@@ -2,6 +2,7 @@
#include <QWidget>
#include <QMouseEvent>
#include <utility>
#include "src/Targets/TargetPinDescriptor.hpp"
@@ -38,8 +39,8 @@ namespace Bloom::InsightTargetWidgets::Qfp
static const int WIDTH = 30;
static const int HEIGHT = 40;
PinBodyWidget(QWidget* parent, const Targets::TargetPinDescriptor& pinDescriptor, bool isVertical):
QWidget(parent), pinDescriptor(pinDescriptor), isVertical(isVertical) {
PinBodyWidget(QWidget* parent, Targets::TargetPinDescriptor pinDescriptor, bool isVertical):
QWidget(parent), pinDescriptor(std::move(pinDescriptor)), isVertical(isVertical) {
this->setObjectName("target-pin-body");
if (isVertical) {
@@ -58,7 +59,7 @@ namespace Bloom::InsightTargetWidgets::Qfp
return this->bodyColor;
}
void setBodyColor(QColor color) {
void setBodyColor(const QColor& color) {
this->bodyColor = color;
}

View File

@@ -24,11 +24,8 @@ namespace Bloom::InsightTargetWidgets::Qfp
bool isRightLayout = false;
bool isTopLayout = false;
void setLabelColor(QString hexColor) {
void setLabelColor(const QString& hexColor) {
auto style = QString("QLabel { color: " + hexColor + "; }");
if (this->pinNumberLabel != nullptr) {
// this->pinNumberLabel->setStyleSheet(style);
}
if (this->pinNameLabel != nullptr) {
this->pinNameLabel->setStyleSheet(style);
@@ -54,7 +51,7 @@ namespace Bloom::InsightTargetWidgets::Qfp
const Targets::TargetVariant& targetVariant
);
virtual void updatePinState(const Targets::TargetPinState& pinState) override {
void updatePinState(const Targets::TargetPinState& pinState) override {
TargetPinWidget::updatePinState(pinState);
if (pinState.ioDirection.has_value()) {

View File

@@ -28,7 +28,7 @@ namespace Bloom::InsightTargetWidgets::Qfp
BodyWidget* bodyWidget = nullptr;
protected:
void paintEvent(QPaintEvent* event);
void paintEvent(QPaintEvent* event) override;
void drawWidget(QPainter& painter);
public:

View File

@@ -1,6 +1,7 @@
#pragma once
#include <QWidget>
#include <utility>
#include <vector>
#include <map>
@@ -21,8 +22,8 @@ namespace Bloom::InsightTargetWidgets
std::vector<TargetPinWidget*> pinWidgets;
public:
TargetPackageWidget(const Targets::TargetVariant& targetVariant, QObject* insightWindowObj, QWidget* parent):
QWidget(parent), targetVariant(targetVariant) {};
TargetPackageWidget(Targets::TargetVariant targetVariant, QObject* insightWindowObj, QWidget* parent):
QWidget(parent), targetVariant(std::move(targetVariant)) {};
virtual void updatePinStates(std::map<int, Targets::TargetPinState> pinStatesByNumber) {
for (auto& pinWidget : this->pinWidgets) {

View File

@@ -1,6 +1,7 @@
#pragma once
#include <QWidget>
#include <utility>
#include "src/Targets/TargetVariant.hpp"
#include "src/Targets/TargetPinDescriptor.hpp"
@@ -19,9 +20,9 @@ namespace Bloom::InsightTargetWidgets
public:
TargetPinWidget(
QWidget* parent,
const Targets::TargetPinDescriptor& pinDescriptor,
const Targets::TargetVariant& targetVariant
): QWidget(parent), targetVariant(targetVariant), pinDescriptor(pinDescriptor) {
Targets::TargetPinDescriptor pinDescriptor,
Targets::TargetVariant targetVariant
): QWidget(parent), targetVariant(std::move(targetVariant)), pinDescriptor(std::move(pinDescriptor)) {
this->setDisabled(false);
};

View File

@@ -29,7 +29,7 @@ namespace Bloom
LogEntry(std::string message, LogLevel logLevel): message(std::move(message)), logLevel(logLevel) {
// Get thread name
std::array<char, 16> threadNameBuf;
std::array<char, 16> threadNameBuf = {};
if (pthread_getname_np(pthread_self(), threadNameBuf.data(), threadNameBuf.size()) == 0) {
/*