Tidying
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Bloom
|
||||
QWidget* windowWidget = nullptr;
|
||||
|
||||
public:
|
||||
AboutWindow(QWidget* parent);
|
||||
explicit AboutWindow(QWidget* parent);
|
||||
|
||||
void show() {
|
||||
if (this->windowWidget != nullptr) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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) {
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user