Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions gui/include/gui/widgets/animatedloadingbutton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2025 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/

#ifndef ANIMATEDLOADINGBUTTON_H
#define ANIMATEDLOADINGBUTTON_H

#include "scopy-gui_export.h"

#include <QWidget>
#include <animationpushbutton.h>

namespace scopy {
class SCOPY_GUI_EXPORT AnimatedLoadingButton : public AnimationPushButton
{
Q_OBJECT
public:
explicit AnimatedLoadingButton(const QString &text, QWidget *parent = nullptr);

signals:

private:
};
} // namespace scopy
#endif // ANIMATEDLOADINGBUTTON_H
2 changes: 2 additions & 0 deletions gui/include/gui/widgets/infoiconwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class SCOPY_GUI_EXPORT InfoIconWidget : public QWidget
static QWidget *addHoveringInfoToWidget(QWidget *w, QString infoMessage, QWidget *parent,
HoverPosition pos = HP_RIGHT);

QLabel *infoIcon() const;

private:
QVBoxLayout *m_layout;
QLabel *m_infoIcon;
Expand Down
43 changes: 43 additions & 0 deletions gui/src/widgets/animatedloadingbutton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2025 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "animatedloadingbutton.h"

#include <QLoggingCategory>
#include <style.h>
#include <QMovie>

Q_LOGGING_CATEGORY(CAT_GUI_ANIMATION_LOADING_BTN, "AnimatedLoadingButton")

using namespace scopy;

AnimatedLoadingButton::AnimatedLoadingButton(const QString &text, QWidget *parent)
: AnimationPushButton{parent}
{
setText(text);

QMovie *movie = new QMovie(":/gui/loading.gif");
setAnimation(movie, 20000);
setAutoDefault(true);

Style::setStyle(this, style::properties::button::basicButton);
}

#include "moc_animatedloadingbutton.cpp"
2 changes: 2 additions & 0 deletions gui/src/widgets/infoiconwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,6 @@ QWidget *InfoIconWidget::addHoveringInfoToWidget(QWidget *w, QString infoMessage
return hover;
}

QLabel *InfoIconWidget::infoIcon() const { return m_infoIcon; }

#include "moc_infoiconwidget.cpp"
134 changes: 134 additions & 0 deletions iio-widgets/include/iio-widgets/guistrategy/temperatureguistrategy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Copyright (c) 2025 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef SCOPY_TEMPERATUREGUISTRATEGY_H
#define SCOPY_TEMPERATUREGUISTRATEGY_H

#include "scopy-iio-widgets_export.h"
#include <QWidget>
#include <QLabel>
#include <QComboBox>
#include <QTimer>
#include <QHBoxLayout>
#include <guistrategy/guistrategyinterface.h>
#include <infoiconwidget.h>

namespace scopy {

enum class TemperatureUnit
{
Celsius,
Fahrenheit,
Kelvin
};

enum class WarningState
{
Normal,
Approaching,
Critical
};

class SCOPY_IIO_WIDGETS_EXPORT TemperatureGuiStrategy : public QObject, public GuiStrategyInterface
{
Q_OBJECT
Q_INTERFACES(scopy::GuiStrategyInterface)

public:
explicit TemperatureGuiStrategy(IIOWidgetFactoryRecipe recipe, bool isCompact = false,
QWidget *parent = nullptr);
~TemperatureGuiStrategy();

// GuiStrategyInterface implementation
QWidget *ui() override;
bool isValid() override;
void setCustomTitle(QString title) override;
void setInfoMessage(QString infoMessage) override;

// Simple API - Basic temperature monitoring
void enableMonitoring(bool enabled = true);

// Advanced configuration API - Fine-grained control
void setCriticalTemperature(double tempCelsius, const QString &message = "Critical temperature reached!");
void setWarningOffset(double offsetCelsius = 5.0);
void setPeriodicUpdates(bool enabled, int intervalSeconds = 5);
void clearWarning();

Q_SIGNALS:
// GuiStrategyInterface signals
void displayedNewData(QString data, QString optionalData) override;
void emitData(QString data) override;
void requestData() override;

// Temperature-specific signals
void approachingCriticalTemperature(double temperature, double warningThreshold, double criticalThreshold);
void criticalTemperatureReached(double temperature, const QString &message);
void temperatureUpdated(double temperature, TemperatureUnit unit);

public Q_SLOTS:
// GuiStrategyInterface slots
void receiveData(QString currentData, QString optionalData) override;

private Q_SLOTS:
void onUnitChanged();
void onPeriodicUpdate();
void updateWarningState(double celsius);

private:
// UI widget
QWidget *m_ui;

// GuiStrategyInterface recipe
IIOWidgetFactoryRecipe m_recipe;

// UI components
QLabel *m_titleLabel;
QLabel *m_temperatureLabel;
QComboBox *m_unitCombo;
InfoIconWidget *m_infoIcon;
QHBoxLayout *m_mainLayout;

// Update timer
QTimer *m_updateTimer;

// Warning system state
bool m_warningEnabled;
WarningState m_warningState;
double m_criticalTempCelsius;
double m_warningOffsetCelsius;
QString m_warningMessage;
void updateInfoIconForWarning();

// Current state
double m_lastTemperatureCelsius;
TemperatureUnit m_currentUnit;

// Helper functions
void setupUI();
void updateUI();
double convertTemperature(double celsius, TemperatureUnit toUnit) const;

// Data parsing
double parseTemperatureData(const QString &data);
};

} // namespace scopy

#endif // SCOPY_TEMPERATUREGUISTRATEGY_H
3 changes: 2 additions & 1 deletion iio-widgets/include/iio-widgets/iiowidgetbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class SCOPY_IIO_WIDGETS_EXPORT IIOWidgetBuilder : public QObject
ComboUi,
SwitchUi,
RangeUi,
CheckBoxUi
CheckBoxUi,
TemperatureUi
};

explicit IIOWidgetBuilder(QWidget *parent = nullptr);
Expand Down
1 change: 0 additions & 1 deletion iio-widgets/src/datastrategy/channelattrdatastrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ QPair<QString, QString> ChannelAttrDataStrategy::read()
}

// the members that contain data need to be refreshed before the signals are emitted
QString oldData = m_data;
m_data = currentValue;
m_optionalData = options;

Expand Down
Loading
Loading