Resolve the issue of UI garbled formatting in certain regions.

This commit is contained in:
dreamsource-tai 2024-07-26 11:32:46 +08:00
parent a716beeef8
commit 47125dc1ee
21 changed files with 219 additions and 36 deletions

View File

@ -351,6 +351,8 @@ set(DSView_SOURCES
DSView/pv/ui/xtoolbutton.cpp
DSView/pv/ui/uimanager.cpp
DSView/pv/ui/popupdlglist.cpp
DSView/pv/ui/xspinbox.cpp
DSView/pv/utility/formatting.cpp
)
set(DSView_HEADERS

View File

@ -23,8 +23,6 @@
#include "deviceoptions.h"
#include <QListWidget>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QGuiApplication>
#include <QScreen>
#include <QScrollArea>

View File

@ -20,10 +20,9 @@
*/
#include "interval.h"
#include <QGridLayout>
#include "../ui/langresource.h"
#include "../ui/xspinbox.h"
namespace pv {
namespace dialogs {
@ -41,7 +40,7 @@ Interval::Interval(QWidget *parent) :
setMinimumWidth(300);
_interval_label = new QLabel(L_S(STR_PAGE_DLG, S_ID(IDS_DLG_INTERVAL_S), "Interval(s): "), this);
_interval_spinBox = new QDoubleSpinBox(this);
_interval_spinBox = new XDoubleSpinBox(this);
_interval_spinBox->setRange(0.1, 10);
_interval_spinBox->setDecimals(1);
_interval_spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);

View File

@ -24,7 +24,6 @@
#define DSVIEW_PV_INTERVAL_H
#include <QLabel>
#include <QDoubleSpinBox>
#include <QSlider>
#include <QDialogButtonBox>
@ -32,6 +31,8 @@
#include "../toolbars/titlebar.h"
#include "dsdialog.h"
class QDoubleSpinBox;
namespace pv {
namespace dialogs {

View File

@ -44,6 +44,7 @@
#include "../log.h"
#include "../ui/langresource.h"
#include "../ui/msgbox.h"
#include "../utility/formatting.h"
#define EXPORT_DEC_ROW_COUNT_MAX 20
@ -166,7 +167,9 @@ void ProtocolExp::onAccept()
AppConfig &app = AppConfig::Instance();
QString default_filter = _format_combobox->currentText();
QString default_name = app.userHistory.protocolExportPath + "/" + "decoder-";
default_name += _session->get_session_time().toString("-yyMMdd-hhmmss");
QString dateTimeString = Formatting::DateTimeToString(_session->get_session_time(), TimeStrigFormatType::TIME_STR_FORMAT_SHORT2);
default_name += "-" + dateTimeString;
QString file_name = QFileDialog::getSaveFileName(
this,

View File

@ -24,7 +24,6 @@
#include <QDockWidget>
#include <QSlider>
#include <QSpinBox>
#include <QButtonGroup>
#include <QScrollArea>
#include <QLabel>

View File

@ -22,6 +22,7 @@
#include "keywordlineedit.h"
#include <QHBoxLayout>
#include <QTimer>
#include <QSpinBox>
#include "../config/appconfig.h"
#include "../ui/langresource.h"
#include "../log.h"

View File

@ -27,7 +27,6 @@
#include <QMouseEvent>
#include <QWidget>
#include <QDialog>
#include <QSpinBox>
#include <QWheelEvent>
class IKeywordActive{

View File

@ -27,7 +27,6 @@
#include <QLabel>
#include <QRadioButton>
#include <QSlider>
#include <QSpinBox>
#include <QGroupBox>
#include <QTableWidget>
#include <QCheckBox>

View File

@ -29,7 +29,6 @@
#include <QRadioButton>
#include <QSlider>
#include <QLineEdit>
#include <QSpinBox>
#include <QTableWidget>
#include <QCheckBox>

View File

@ -28,7 +28,6 @@
#include <QLabel>
#include <QRadioButton>
#include <QSlider>
#include <QSpinBox>
#include <QGroupBox>
#include <QCheckBox>
#include <QTableWidget>

View File

@ -43,6 +43,7 @@
#include <QJsonValue>
#include <QJsonArray>
#include <functional>
#include "utility/formatting.h"
//include with qt5
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
@ -525,7 +526,8 @@ namespace pv
void MainWindow::on_screenShot()
{
AppConfig &app = AppConfig::Instance();
QString default_name = app.userHistory.screenShotPath + "/" + APP_NAME + QDateTime::currentDateTime().toString("-yyMMdd-hhmmss");
QString dateTimeString = Formatting::DateTimeToString(QDateTime::currentDateTime(), TimeStrigFormatType::TIME_STR_FORMAT_SHORT2);
QString default_name = app.userHistory.screenShotPath + "/" + APP_NAME + "-" + dateTimeString;
int x = parentWidget()->pos().x();
int y = parentWidget()->pos().y();

View File

@ -20,11 +20,10 @@
*/
#include <assert.h>
#include <QDoubleSpinBox>
#include "double.h"
#include <assert.h>
#include "../ui/xspinbox.h"
using namespace std;
using namespace boost;
@ -57,7 +56,7 @@ QWidget* Double::get_widget(QWidget *parent, bool auto_commit)
if (_spin_box)
return _spin_box;
_spin_box = new QDoubleSpinBox(parent);
_spin_box = new XDoubleSpinBox(parent);
_spin_box->setDecimals(_decimals);
_spin_box->setSuffix(_suffix);
if (_range)

View File

@ -20,13 +20,11 @@
*/
#include "int.h"
#include <stdint.h>
#include <assert.h>
#include <math.h>
#include <QSpinBox>
#include "int.h"
#include "../ui/xspinbox.h"
using boost::optional;
using namespace std;
@ -82,7 +80,7 @@ QWidget* Int::get_widget(QWidget *parent, bool auto_commit)
if (!_value)
return NULL;
_spin_box = new QSpinBox(parent);
_spin_box = new XSpinBox(parent);
_spin_box->setSuffix(_suffix);
const GVariantType *const type = g_variant_get_type(_value);

View File

@ -19,12 +19,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <assert.h>
#include <QLineEdit>
#include <QSpinBox>
#include "string.h"
#include <assert.h>
#include <QLineEdit>
namespace pv {
namespace prop {

View File

@ -60,8 +60,8 @@
#include "utility/encoding.h"
#include "utility/path.h"
#include "log.h"
#include "ui/langresource.h"
#include "utility/formatting.h"
#define DEOCDER_CONFIG_VERSION 2
@ -922,8 +922,8 @@ void StoreSession::export_exec(data::Snapshot *snapshot)
}
}
QString sessionTime = _session->get_session_time().toString("yyyy-MM-dd HH:mm:ss");
strcpy(output.time_string, sessionTime.toStdString().c_str());
QString dateTimeString = Formatting::DateTimeToString(_session->get_session_time(), TimeStrigFormatType::TIME_STR_FORMAT_ALL);
strcpy(output.time_string, dateTimeString.toStdString().c_str());
QFile file(_file_name);
file.open(QIODevice::WriteOnly | QIODevice::Text);
@ -1649,7 +1649,8 @@ QString StoreSession::MakeSaveFile(bool bDlg)
}
}
default_name += _session->get_session_time().toString("-yyMMdd-hhmmss");
QString dateTimeString = Formatting::DateTimeToString(_session->get_session_time(), TimeStrigFormatType::TIME_STR_FORMAT_SHORT2);
default_name += "-" + dateTimeString;
// Show the dialog
if (bDlg)
@ -1707,7 +1708,9 @@ QString StoreSession::MakeExportFile(bool bDlg)
break;
}
}
default_name += _session->get_session_time().toString("-yyMMdd-hhmmss");
QString dateTimeString = Formatting::DateTimeToString(_session->get_session_time(), TimeStrigFormatType::TIME_STR_FORMAT_SHORT2);
default_name += "-" + dateTimeString;
//ext name
QList<QString> supportedFormats = getSuportedExportFormats();

56
DSView/pv/ui/xspinbox.cpp Normal file
View File

@ -0,0 +1,56 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2024 DreamSourceLab <support@dreamsourcelab.com>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "xspinbox.h"
XSpinBox::XSpinBox(QWidget *parent)
: QSpinBox(parent)
{
}
XSpinBox::~XSpinBox()
{
}
QString XSpinBox::textFromValue(int val) const
{
return QString::number(val);
}
//-------------------XDoubleSpinBox
XDoubleSpinBox::XDoubleSpinBox(QWidget *parent)
: QDoubleSpinBox(parent)
{
}
XDoubleSpinBox::~XDoubleSpinBox()
{
}
QString XDoubleSpinBox::textFromValue(double val) const
{
int digit = decimals();
return QString::number(val, 'f', digit);
}

43
DSView/pv/ui/xspinbox.h Normal file
View File

@ -0,0 +1,43 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2024 DreamSourceLab <support@dreamsourcelab.com>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <QSpinBox>
#include <QWidget>
class XSpinBox : public QSpinBox
{
public:
XSpinBox(QWidget *parent);
~XSpinBox();
protected:
QString textFromValue(int val) const override;
};
class XDoubleSpinBox : public QDoubleSpinBox
{
public:
XDoubleSpinBox(QWidget *parent);
~XDoubleSpinBox();
protected:
QString textFromValue(double val) const override;
};

View File

@ -0,0 +1,49 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2024 DreamSourceLab <support@dreamsourcelab.com>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "formatting.h"
#include <QDateTime>
#include <QString>
#include <stdlib.h>
QString Formatting::DateTimeToString(QDateTime tm, TimeStrigFormatType format)
{
int year = tm.date().year();
int month = tm.date().month();
int day = tm.date().day();
int hour = tm.time().hour();
int minute = tm.time().minute();
int second = tm.time().second();
char buffer[20];
switch (format)
{
case TimeStrigFormatType::TIME_STR_FORMAT_SHORT2: //"yyMMdd-hhmmss"
sprintf(buffer, "%02d%02d%02d-%02d%02d%02d", year%100, month, day, hour, minute, second);
break;
default: //yyyy-MM-dd hh:mm:ss
sprintf(buffer, "%04d-%02d-%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
break;
}
return QString(buffer);
}

View File

@ -0,0 +1,36 @@
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2024 DreamSourceLab <support@dreamsourcelab.com>
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class QDateTime;
class QString;
enum TimeStrigFormatType
{
TIME_STR_FORMAT_ALL = 0, //"yyyy-MM-dd hh:mm:ss"
TIME_STR_FORMAT_SHORT2, //"yyMMdd-hhmmss"
};
class Formatting
{
public:
static QString DateTimeToString(QDateTime tm, TimeStrigFormatType format);
};

View File

@ -40,6 +40,7 @@
#include "../config/appconfig.h"
#include "../appcontrol.h"
#include "../ui/fn.h"
#include "../utility/formatting.h"
using namespace std;
@ -188,9 +189,9 @@ void ViewStatus::repeat_unshow()
}
void ViewStatus::set_trig_time(QDateTime time)
{
_trig_time = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_TRIGGER_TIME), "Trigger Time: ") + time.toString("yyyy-MM-dd hh:mm:ss");
// assert(0);
{
QString dateTimeString = Formatting::DateTimeToString(time, TimeStrigFormatType::TIME_STR_FORMAT_ALL);
_trig_time = L_S(STR_PAGE_DLG, S_ID(IDS_DLG_TRIGGER_TIME), "Trigger Time: ") + dateTimeString;
}
void ViewStatus::set_rle_depth(uint64_t depth)