change: change code style to Linux style except indent.

This commit is contained in:
Mike Solar
2025-08-03 03:09:40 +08:00
parent 65ab76edc8
commit 74f73ab3be
789 changed files with 77113 additions and 68888 deletions
+71 -61
View File
@@ -27,116 +27,126 @@
#include "window/mainwindow/mainwindow.h"
namespace olive {
namespace olive
{
#define super QDialog
ProgressDialog::ProgressDialog(const QString& message, const QString& title, QWidget *parent) :
super(parent),
show_progress_(true),
first_show_(true)
ProgressDialog::ProgressDialog(const QString &message, const QString &title,
QWidget *parent)
: super(parent)
, show_progress_(true)
, first_show_(true)
{
if (!title.isEmpty()) {
setWindowTitle(title);
}
if (!title.isEmpty()) {
setWindowTitle(title);
}
QVBoxLayout* layout = new QVBoxLayout(this);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(new QLabel(message));
layout->addWidget(new QLabel(message));
bar_ = new QProgressBar();
bar_->setMinimum(0);
bar_->setValue(0);
bar_->setMaximum(100);
layout->addWidget(bar_);
bar_ = new QProgressBar();
bar_->setMinimum(0);
bar_->setValue(0);
bar_->setMaximum(100);
layout->addWidget(bar_);
elapsed_timer_lbl_ = new ElapsedCounterWidget();
layout->addWidget(elapsed_timer_lbl_);
elapsed_timer_lbl_ = new ElapsedCounterWidget();
layout->addWidget(elapsed_timer_lbl_);
QHBoxLayout* cancel_layout = new QHBoxLayout();
layout->addLayout(cancel_layout);
cancel_layout->setContentsMargins(0, 0, 0, 0);
cancel_layout->setSpacing(0);
cancel_layout->addStretch();
QHBoxLayout *cancel_layout = new QHBoxLayout();
layout->addLayout(cancel_layout);
cancel_layout->setContentsMargins(0, 0, 0, 0);
cancel_layout->setSpacing(0);
cancel_layout->addStretch();
QPushButton* cancel_btn = new QPushButton(tr("Cancel"));
QPushButton *cancel_btn = new QPushButton(tr("Cancel"));
// Signal that derivatives can connect to
connect(cancel_btn, &QPushButton::clicked, this, &ProgressDialog::Cancelled, Qt::DirectConnection);
// Signal that derivatives can connect to
connect(cancel_btn, &QPushButton::clicked, this, &ProgressDialog::Cancelled,
Qt::DirectConnection);
// Stop updating the elapsed/remaining timers
connect(cancel_btn, &QPushButton::clicked, elapsed_timer_lbl_, &ElapsedCounterWidget::Stop);
// Stop updating the elapsed/remaining timers
connect(cancel_btn, &QPushButton::clicked, elapsed_timer_lbl_,
&ElapsedCounterWidget::Stop);
// Disable the button so that users know they don't need to keep clicking it
connect(cancel_btn, &QPushButton::clicked, this, &ProgressDialog::DisableSenderWidget);
// Disable the button so that users know they don't need to keep clicking it
connect(cancel_btn, &QPushButton::clicked, this,
&ProgressDialog::DisableSenderWidget);
// Prevent the progress bar from continuing to move
connect(cancel_btn, &QPushButton::clicked, this, &ProgressDialog::DisableProgressWidgets);
// Prevent the progress bar from continuing to move
connect(cancel_btn, &QPushButton::clicked, this,
&ProgressDialog::DisableProgressWidgets);
cancel_layout->addWidget(cancel_btn);
cancel_layout->addWidget(cancel_btn);
cancel_layout->addStretch();
cancel_layout->addStretch();
}
void ProgressDialog::showEvent(QShowEvent *e)
{
super::showEvent(e);
super::showEvent(e);
if (first_show_) {
elapsed_timer_lbl_->Start();
if (first_show_) {
elapsed_timer_lbl_->Start();
Core::instance()->main_window()->SetApplicationProgressStatus(MainWindow::kProgressShow);
Core::instance()->main_window()->SetApplicationProgressStatus(
MainWindow::kProgressShow);
first_show_ = false;
}
first_show_ = false;
}
}
void ProgressDialog::closeEvent(QCloseEvent *e)
{
super::closeEvent(e);
super::closeEvent(e);
Core::instance()->main_window()->SetApplicationProgressStatus(MainWindow::kProgressNone);
Core::instance()->main_window()->SetApplicationProgressStatus(
MainWindow::kProgressNone);
elapsed_timer_lbl_->Stop();
elapsed_timer_lbl_->Stop();
first_show_ = true;
first_show_ = true;
}
void ProgressDialog::SetProgress(double value)
{
if (!show_progress_) {
return;
}
if (!show_progress_) {
return;
}
int percent = qRound(100.0 * value);
int percent = qRound(100.0 * value);
bar_->setValue(percent);
elapsed_timer_lbl_->SetProgress(value);
bar_->setValue(percent);
elapsed_timer_lbl_->SetProgress(value);
Core::instance()->main_window()->SetApplicationProgressValue(percent);
Core::instance()->main_window()->SetApplicationProgressValue(percent);
}
void ProgressDialog::ShowErrorMessage(const QString &title, const QString &message)
void ProgressDialog::ShowErrorMessage(const QString &title,
const QString &message)
{
Core::instance()->main_window()->SetApplicationProgressStatus(MainWindow::kProgressError);
Core::instance()->main_window()->SetApplicationProgressStatus(
MainWindow::kProgressError);
QMessageBox b(this);
b.setIcon(QMessageBox::Critical);
b.setWindowModality(Qt::WindowModal);
b.setWindowTitle(title);
b.setText(message);
b.addButton(QMessageBox::Ok);
b.exec();
QMessageBox b(this);
b.setIcon(QMessageBox::Critical);
b.setWindowModality(Qt::WindowModal);
b.setWindowTitle(title);
b.setText(message);
b.addButton(QMessageBox::Ok);
b.exec();
}
void ProgressDialog::DisableSenderWidget()
{
static_cast<QWidget*>(sender())->setEnabled(false);
static_cast<QWidget *>(sender())->setEnabled(false);
}
void ProgressDialog::DisableProgressWidgets()
{
show_progress_ = false;
show_progress_ = false;
}
}