diff --git a/CMakeLists.txt b/CMakeLists.txt index ab660383..cc82669f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -352,6 +352,7 @@ set(DSView_SOURCES DSView/pv/ui/uimanager.cpp DSView/pv/ui/popupdlglist.cpp DSView/pv/ui/xspinbox.cpp + DSView/pv/ui/xprogressbar.cpp DSView/pv/utility/formatting.cpp ) diff --git a/DSView/pv/dialogs/storeprogress.cpp b/DSView/pv/dialogs/storeprogress.cpp index f7fc1a3d..bb2685a2 100644 --- a/DSView/pv/dialogs/storeprogress.cpp +++ b/DSView/pv/dialogs/storeprogress.cpp @@ -37,6 +37,7 @@ #include "../view/cursor.h" #include "../ui/langresource.h" #include "../ui/dscombobox.h" +#include "../ui/xprogressbar.h" namespace pv { namespace dialogs { @@ -48,12 +49,13 @@ StoreProgress::StoreProgress(SigSession *session, QWidget *parent) : _ckOrigin = NULL; _store_session = new StoreSession(session); + _progress = new XProgressBar(this); this->setMinimumSize(550, 220); this->setModal(true); - _progress.setValue(0); - _progress.setMaximum(100); + _progress->setValue(0); + _progress->setMaximum(100); _isExport = false; _is_done = false; @@ -83,7 +85,7 @@ StoreProgress::StoreProgress(SigSession *session, QWidget *parent) : _space->setMinimumHeight(80); _space->setVisible(false); - grid->addWidget(&_progress, 0, 0, 1, 4); + grid->addWidget(_progress, 0, 0, 1, 4); grid->addWidget(_fileLab, 1, 0, 1, 3); grid->addWidget(_openButton, 1, 3, 1, 1); grid->addWidget(_space); @@ -102,7 +104,7 @@ StoreProgress::StoreProgress(SigSession *session, QWidget *parent) : connect(_openButton, SIGNAL(clicked()),this, SLOT(on_change_file())); - _progress.setVisible(false); + _progress->setVisible(false); connect(&m_timer, &QTimer::timeout, this, &StoreProgress::on_timeout); m_timer.setInterval(100); @@ -222,7 +224,7 @@ void StoreProgress::accept() _store_session->SetDataRange(start_index, end_index); } - _progress.setVisible(true); + _progress->setVisible(true); _fileLab->setVisible(false); _fileLab->setVisible(false); _openButton->setVisible(false); @@ -370,10 +372,10 @@ void StoreProgress::on_progress_updated() if (writed < total){ int percent = writed * 1.0 / total * 100.0; - _progress.setValue(percent); + _progress->setValue(percent); } else{ - _progress.setValue(100); + _progress->setValue(100); } const QString err = _store_session->error(); diff --git a/DSView/pv/dialogs/storeprogress.h b/DSView/pv/dialogs/storeprogress.h index 974039ef..600b57fe 100644 --- a/DSView/pv/dialogs/storeprogress.h +++ b/DSView/pv/dialogs/storeprogress.h @@ -23,7 +23,6 @@ #ifndef DSVIEW_PV_DIALOGS_SAVEPROGRESS_H #define DSVIEW_PV_DIALOGS_SAVEPROGRESS_H -#include #include #include "../storesession.h" #include "../dialogs/dsdialog.h" @@ -35,6 +34,7 @@ class QGridLayout; class QPushButton; class QWidget; class QComboBox; +class QProgressBar; namespace pv { namespace view { @@ -81,7 +81,7 @@ private slots: private: pv::StoreSession *_store_session; - QProgressBar _progress; + QProgressBar *_progress; bool _isExport; QTextEdit *_fileLab; QRadioButton *_ckOrigin; diff --git a/DSView/pv/ui/xprogressbar.cpp b/DSView/pv/ui/xprogressbar.cpp new file mode 100644 index 00000000..bcbbefd2 --- /dev/null +++ b/DSView/pv/ui/xprogressbar.cpp @@ -0,0 +1,38 @@ +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2024 DreamSourceLab + * + * 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 "xprogressbar.h" + +XProgressBar::XProgressBar(QWidget *parent) + :QProgressBar(parent) +{ + +} + +XProgressBar::~XProgressBar() +{ + +} + +QString XProgressBar::text() const +{ + return QString::number(value()) + "%"; +} \ No newline at end of file diff --git a/DSView/pv/ui/xprogressbar.h b/DSView/pv/ui/xprogressbar.h new file mode 100644 index 00000000..930f8aa6 --- /dev/null +++ b/DSView/pv/ui/xprogressbar.h @@ -0,0 +1,37 @@ +/* + * This file is part of the DSView project. + * DSView is based on PulseView. + * + * Copyright (C) 2024 DreamSourceLab + * + * 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 + */ + +#ifndef XPROGRESS_H +#define XPROGRESS_H + +#include +#include + +class XProgressBar : public QProgressBar +{ +public: + XProgressBar(QWidget *parent); + ~XProgressBar(); + + QString text() const override; +}; + +#endif diff --git a/DSView/pv/ui/xspinbox.h b/DSView/pv/ui/xspinbox.h index 42aeeca5..7b205d94 100644 --- a/DSView/pv/ui/xspinbox.h +++ b/DSView/pv/ui/xspinbox.h @@ -19,6 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef XSPINBOX_H +#define XSPINBOX_H + #include #include @@ -40,4 +43,6 @@ public: protected: QString textFromValue(double val) const override; -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/DSView/pv/utility/formatting.h b/DSView/pv/utility/formatting.h index f936c4cc..d32bb764 100644 --- a/DSView/pv/utility/formatting.h +++ b/DSView/pv/utility/formatting.h @@ -19,6 +19,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef FORMATTING_H +#define FORMATTING_H + class QDateTime; class QString; @@ -33,4 +36,6 @@ class Formatting { public: static QString DateTimeToString(QDateTime tm, TimeStrigFormatType format); -}; \ No newline at end of file +}; + +#endif \ No newline at end of file