src: split indexing dialog to multiple classes
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
#include "QtProgressBarDialog.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
#include "QtProgressBar.h"
|
||||
|
||||
QtProgressBarDialog::QtProgressBarDialog(float topRatio, bool hideable, QWidget* parent)
|
||||
: QtIndexingDialog(true, parent)
|
||||
, m_title(nullptr)
|
||||
, m_topRatio(topRatio)
|
||||
{
|
||||
m_top = new QWidget(m_window);
|
||||
m_top->setObjectName("topHalf");
|
||||
m_top->setGeometry(0, 0, 0, 0);
|
||||
m_top->show();
|
||||
m_top->lower();
|
||||
|
||||
m_progressBar = new QtProgressBar(m_window);
|
||||
m_progressBar->setGeometry(0, 0, 0, 0);
|
||||
|
||||
m_title = new QLabel("", this);
|
||||
m_title->setObjectName("title");
|
||||
m_title->setAlignment(Qt::AlignRight | Qt::AlignBottom);
|
||||
m_title->show();
|
||||
|
||||
m_percentLabel = new QLabel("0% Progress");
|
||||
m_percentLabel->setObjectName("percent");
|
||||
m_layout->addWidget(m_percentLabel, 0, Qt::AlignRight);
|
||||
|
||||
m_messageLabel = QtIndexingDialog::createMessageLabel(m_layout);
|
||||
}
|
||||
|
||||
void QtProgressBarDialog::updateTitle(const QString& title)
|
||||
{
|
||||
if (m_title)
|
||||
{
|
||||
m_title->setText(title);
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring QtProgressBarDialog::getTitle() const
|
||||
{
|
||||
if (m_title)
|
||||
{
|
||||
return m_title->text().toStdWString();
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
void QtProgressBarDialog::updateMessage(const QString& message)
|
||||
{
|
||||
if (m_messageLabel)
|
||||
{
|
||||
m_messageLabel->setText(message);
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring QtProgressBarDialog::getMessage() const
|
||||
{
|
||||
if (m_messageLabel)
|
||||
{
|
||||
return m_messageLabel->text().toStdWString();
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
void QtProgressBarDialog::setUnknownProgress()
|
||||
{
|
||||
m_progressBar->showUnknownProgressAnimated();
|
||||
m_percentLabel->hide();
|
||||
}
|
||||
|
||||
void QtProgressBarDialog::updateProgress(size_t progress)
|
||||
{
|
||||
size_t percent = std::min<size_t>(std::max<size_t>(progress, 0), 100);
|
||||
|
||||
m_progressBar->showProgress(percent);
|
||||
m_percentLabel->setText(QString::number(percent) + "% Progress");
|
||||
m_percentLabel->show();
|
||||
setGeometries();
|
||||
}
|
||||
|
||||
size_t QtProgressBarDialog::getProgress() const
|
||||
{
|
||||
return m_progressBar->getProgress();
|
||||
}
|
||||
|
||||
void QtProgressBarDialog::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QtIndexingDialog::resizeEvent(event);
|
||||
setGeometries();
|
||||
}
|
||||
|
||||
void QtProgressBarDialog::setGeometries()
|
||||
{
|
||||
if (m_top)
|
||||
{
|
||||
QMargins margins = m_content->layout()->contentsMargins();
|
||||
margins.setTop(m_window->size().height() * m_topRatio + 10);
|
||||
m_content->layout()->setContentsMargins(margins);
|
||||
|
||||
m_top->setGeometry(0, 0, m_window->size().width(), m_window->size().height() * m_topRatio);
|
||||
|
||||
m_title->setGeometry(
|
||||
45,
|
||||
m_window->size().height() * m_topRatio - 50,
|
||||
m_window->size().width() - 60,
|
||||
40
|
||||
);
|
||||
}
|
||||
|
||||
if (m_progressBar)
|
||||
{
|
||||
m_progressBar->setGeometry(0, m_window->size().height() * m_topRatio - 5, m_window->size().width(), 10);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user