mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-23 13:42:55 +08:00
custom progressbar
This commit is contained in:
parent
47125dc1ee
commit
a4db63b4e4
@ -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
|
||||
)
|
||||
|
||||
|
@ -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();
|
||||
|
@ -23,7 +23,6 @@
|
||||
#ifndef DSVIEW_PV_DIALOGS_SAVEPROGRESS_H
|
||||
#define DSVIEW_PV_DIALOGS_SAVEPROGRESS_H
|
||||
|
||||
#include <QProgressBar>
|
||||
#include <QTimer>
|
||||
#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;
|
||||
|
38
DSView/pv/ui/xprogressbar.cpp
Normal file
38
DSView/pv/ui/xprogressbar.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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 "xprogressbar.h"
|
||||
|
||||
XProgressBar::XProgressBar(QWidget *parent)
|
||||
:QProgressBar(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
XProgressBar::~XProgressBar()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString XProgressBar::text() const
|
||||
{
|
||||
return QString::number(value()) + "%";
|
||||
}
|
37
DSView/pv/ui/xprogressbar.h
Normal file
37
DSView/pv/ui/xprogressbar.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef XPROGRESS_H
|
||||
#define XPROGRESS_H
|
||||
|
||||
#include <QProgressBar>
|
||||
#include <QWidget>
|
||||
|
||||
class XProgressBar : public QProgressBar
|
||||
{
|
||||
public:
|
||||
XProgressBar(QWidget *parent);
|
||||
~XProgressBar();
|
||||
|
||||
QString text() const override;
|
||||
};
|
||||
|
||||
#endif
|
@ -19,6 +19,9 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef XSPINBOX_H
|
||||
#define XSPINBOX_H
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QWidget>
|
||||
|
||||
@ -41,3 +44,5 @@ public:
|
||||
protected:
|
||||
QString textFromValue(double val) const override;
|
||||
};
|
||||
|
||||
#endif
|
@ -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;
|
||||
|
||||
@ -34,3 +37,5 @@ class Formatting
|
||||
public:
|
||||
static QString DateTimeToString(QDateTime tm, TimeStrigFormatType format);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user