kopia lustrzana https://github.com/dgatf/Oscilloscope
Improve gui
rodzic
87d4df5d67
commit
860f1a3016
Plik binarny nie jest wyświetlany.
|
@ -21,16 +21,14 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow),
|
||||
m_serial(new QSerialPort(this)),
|
||||
m_pixmap(new QPixmap(500, 400)),
|
||||
m_pixmap(new QPixmap(520, 250)),
|
||||
m_paint(new QPainter(m_pixmap)),
|
||||
m_ui_settings(new SettingsDialog()),
|
||||
m_statusLabel(new QLabel())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->lbPic->setMinimumSize(1, 1);
|
||||
//ui->lbPic->adjustSize();
|
||||
drawBackground();
|
||||
ui->lbPic->setMinimumSize(50, 50);
|
||||
ui->lbPic->setPixmap(*m_pixmap);
|
||||
statusBar()->addWidget(m_statusLabel);
|
||||
m_statusLabel->setText("Disconnected");
|
||||
|
@ -52,7 +50,7 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
ui->cbHdiv->addItem("100us/d");
|
||||
ui->cbHdiv->setItemData(0, 10000);
|
||||
ui->cbHdiv->setItemData(1, 5000);
|
||||
ui->cbHdiv->setItemData(2, 100);
|
||||
ui->cbHdiv->setItemData(2, 1000);
|
||||
ui->cbHdiv->setItemData(3, 500);
|
||||
ui->cbHdiv->setItemData(4, 100);
|
||||
ui->cbHdiv->setCurrentIndex(2);
|
||||
|
@ -64,21 +62,20 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
|
||||
QMenu *menu = menuBar()->addMenu(tr("&Menu"));
|
||||
|
||||
const QIcon connectIcon = QIcon::fromTheme("connect", QIcon("connect.png"));
|
||||
const QIcon connectIcon = QIcon(":/connect.png");
|
||||
connectAct = new QAction(connectIcon, tr("&Connect"), this);
|
||||
menu->addAction(connectAct);
|
||||
|
||||
|
||||
const QIcon disconnectIcon = QIcon::fromTheme("disconnect", QIcon("disconnect.png"));
|
||||
const QIcon disconnectIcon = QIcon(":/disconnect.png");
|
||||
disconnectAct = new QAction(disconnectIcon, tr("&Disconnect"), this);
|
||||
menu->addAction(disconnectAct);
|
||||
menu->addSeparator();
|
||||
|
||||
const QIcon exportIcon = QIcon::fromTheme("export", QIcon("save.png"));
|
||||
const QIcon exportIcon = QIcon(":/save.png");
|
||||
QAction *exportAct = new QAction(exportIcon, tr("&Export..."), this);
|
||||
menu->addAction(exportAct);
|
||||
|
||||
const QIcon settingsIcon = QIcon::fromTheme("settings", QIcon("settings.png"));
|
||||
const QIcon settingsIcon = QIcon(":/settings.png");
|
||||
QAction *settingsAct = new QAction(settingsIcon, tr("&Settings..."), this);
|
||||
menu->addAction(settingsAct);
|
||||
menu->addSeparator();
|
||||
|
@ -86,7 +83,7 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
QAction *aboutAct = new QAction(tr("&About"), this);
|
||||
menu->addAction(aboutAct);
|
||||
|
||||
const QIcon exitIcon = QIcon::fromTheme("exit", QIcon("application-exit.png"));
|
||||
const QIcon exitIcon = QIcon(":/application-exit.png");
|
||||
QAction *exitAct = new QAction(exitIcon, tr("&Exit"), this);
|
||||
menu->addAction(exitAct);
|
||||
|
||||
|
@ -100,8 +97,10 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
toolBar->addSeparator();
|
||||
toolBar->addAction(exitAct);
|
||||
#endif
|
||||
|
||||
disconnectAct->setEnabled(false);
|
||||
|
||||
|
||||
connect(m_serial, &QSerialPort::readyRead, this, &MainWindow::readData);
|
||||
connect(connectAct, &QAction::triggered, this, &MainWindow::openSerialPort);
|
||||
connect(disconnectAct, &QAction::triggered, this, &MainWindow::closeSerialPort);
|
||||
|
@ -109,13 +108,15 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
connect(exportAct, &QAction::triggered, this, &MainWindow::exportData);
|
||||
connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
|
||||
connect(exitAct, &QAction::triggered, this, &MainWindow::exitApp);
|
||||
connect(ui->cbHdiv, &QComboBox::currentIndexChanged, this, &MainWindow::updateHdiv);
|
||||
connect(ui->cbVdiv, &QComboBox::currentIndexChanged, this, &MainWindow::updateVdiv);
|
||||
connect(ui->cbTriggerType, &QComboBox::currentIndexChanged, this, &MainWindow::updateTriggerType);
|
||||
connect(ui->sbTriggerValue, &QDoubleSpinBox::valueChanged, this, &MainWindow::updateTrigger);
|
||||
|
||||
connect(ui->cbHdiv, &QComboBox::currentTextChanged, this, &MainWindow::updateHdiv);
|
||||
connect(ui->cbVdiv, &QComboBox::currentTextChanged, this, &MainWindow::updateVdiv);
|
||||
connect(ui->cbTriggerType, &QComboBox::currentTextChanged, this, &MainWindow::updateTriggerType);
|
||||
connect(ui->sbTriggerValue, &QDoubleSpinBox::textChanged, this, &MainWindow::updateTrigger);
|
||||
connect(m_ui_settings, &SettingsDialog::accepted, this, &MainWindow::refresh);
|
||||
|
||||
qInfo() << QString::number(ui->lbPic->height()) + " " + QString::number(ui->lbPic->width());
|
||||
ui->lbPic->adjustSize();
|
||||
drawBackground();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -242,7 +243,6 @@ void MainWindow::drawBackground()
|
|||
float voltPos = (float)ui->slVolt->value() / (ui->slVolt->maximum() - ui->slVolt->minimum());
|
||||
uint16_t yPos = m_pixmap->height() * (5 / volt + (6 - 5 / vDiv) / 6 / 2);
|
||||
m_paint->drawLine(0, yPos + m_pixmap->height() * voltPos, m_pixmap->width(), yPos + m_pixmap->height() * voltPos);
|
||||
//m_paint->setPen(QColor(0, 0, 0, 123));
|
||||
m_paint->setPen(QColor(m_ui_settings->m_currentSettings.gridcolor));
|
||||
|
||||
for (uint8_t i = 0; i < 6; i++) { // horizontal lines
|
||||
|
@ -257,7 +257,6 @@ void MainWindow::drawBackground()
|
|||
font.setPixelSize(14);
|
||||
//font.setBold(true);
|
||||
m_paint->setFont(font);
|
||||
//m_paint->setPen(QColor(0, 0, 100, 255));
|
||||
m_paint->setPen(QColor(m_ui_settings->m_currentSettings.textcolor));
|
||||
m_paint->drawText(5, height - 5, QString::number(vDiv * 1000) + "mV/d " + QString::number((float)timeLenght / 10 * 1000) + "μs/d Vmax=" + QString::number((float)maxValue / 0xFF * 5, 'f',
|
||||
3) + " Vmin=" + QString::number((float)minValue / 0xFF * 5, 'f', 3));
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
#include <QSerialPort>
|
||||
#include <QSerialPortInfo>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QFileDialog>
|
||||
|
@ -61,12 +60,12 @@ private:
|
|||
float trigger = 1;
|
||||
enum Edge { min, max };
|
||||
enum TriggerType { none, rising, falling };
|
||||
TriggerType triggerType = none;
|
||||
TriggerType triggerType = rising;
|
||||
|
||||
uint8_t maxValue = 0;
|
||||
uint8_t minValue = 0;
|
||||
uint16_t rawFreq;
|
||||
uint16_t rawDuty;
|
||||
uint16_t rawFreq = 0;
|
||||
uint16_t rawDuty = 0;
|
||||
bool pendingExport = false;
|
||||
QString fileName;
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1009</width>
|
||||
<height>766</height>
|
||||
<width>565</width>
|
||||
<height>428</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
|
@ -100,6 +100,12 @@ selection-background-color: rgb(192, 191, 188);</string>
|
|||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
|
@ -164,7 +170,7 @@ selection-background-color: rgb(192, 191, 188);</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1009</width>
|
||||
<width>565</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
|
|
@ -21,6 +21,12 @@ FORMS += \
|
|||
mainwindow.ui \
|
||||
settingsdialog.ui
|
||||
|
||||
CONFIG(win) {
|
||||
TARGET = oscilloscope_win
|
||||
} else {
|
||||
TARGET = oscilloscope_linux
|
||||
}
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
|
@ -29,6 +35,3 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin
|
|||
RESOURCES += \
|
||||
resources.qrc
|
||||
|
||||
DISTFILES += \
|
||||
../../README.md \
|
||||
connect.png
|
||||
|
|
|
@ -3,5 +3,7 @@
|
|||
<file>oscilloscope.bmp</file>
|
||||
<file>connect.png</file>
|
||||
<file>disconnect.png</file>
|
||||
<file>save.png</file>
|
||||
<file>settings.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include <QSerialPort>
|
||||
#include <QSettings>
|
||||
#include <QDebug>
|
||||
#include <QIntValidator>
|
||||
#include <QLineEdit>
|
||||
#include <QSerialPortInfo>
|
||||
#include <QColorDialog>
|
||||
|
|
Ładowanie…
Reference in New Issue