Files
Cmake 7ee2826040 dogprotect: VMProtect → DogProtect 全量改名 + VM 节名改 .dog
与 dogprotect / linux-build 分支同一次改名,等价内容:
- 产品名/展示串、SDK 与运行时导出 API、.NET 命名空间全部换为 DogProtect
- 文件名与目录改名(dogprotect.sln / DogProtect/ / DogProtectCon/ / sdk/DogProtect.SDK/ /
  sdk/DogProtectSDK.{h,pas,bas,inc} / runtime/DogProtect.Runtime/ / core/dogprotect.rc /
  app/dogprotect_gui.app)
- 项目文件扩展名 .vmp → .dog;VM 代码节名默认 .dog(产物节 .dog0/.dog1/...)
- 授权数据/配置: DogProtect.dat、DogProtectLicense.ini、Global\\DogProtect.dat
- 域名占位 dogprotect.example、bundle id com.dogprotect.dogprotect
- 保留 VMP_* 内部宏与 third-party/
2026-11-23 16:16:12 +08:00

133 lines
3.1 KiB
C++

#include "../core/objects.h"
#include "../core/files.h"
#include "../core/lang.h"
#include "wait_cursor.h"
#include "progress_dialog.h"
#include "moc/moc_progress_dialog.cc"
#include "message_dialog.h"
/**
* ProgressDialog
*/
ProgressDialog::ProgressDialog(QWidget *parent)
: QDialog(parent, Qt::Dialog | Qt::FramelessWindowHint | Qt::CustomizeWindowHint)
{
progressBar = new QProgressBar(this);
progressBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
QFontMetrics fontMetrics = progressBar->fontMetrics();
QString spaces;
while (fontMetrics.width(spaces) < 58)
spaces += QLatin1Char(' ');
progressBar->setFormat(progressBar->format() + spaces);
label = new QLabel(this);
QToolButton *button = new QToolButton(this);
button->setObjectName("cancel");
button->setToolTip(QString::fromUtf8(language[lsCancel].c_str()));
QHBoxLayout *layout = new QHBoxLayout;
layout->setContentsMargins(20, 0, 20, 0);
layout->setSpacing(0);
layout->addWidget(label, 1);
layout->addWidget(button, 0, Qt::AlignRight);
progressBar->setLayout(layout);
layout = new QHBoxLayout();
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(progressBar);
setLayout(layout);
setModal(true);
connect(button, SIGNAL(clicked()), this, SLOT(cancelClicked()));
resize(320, 60);
}
void ProgressDialog::cancelClicked()
{
if(!wait_cursor_.get())
wait_cursor_.reset(new WaitCursor());
this->setDisabled(true);
emit cancel();
}
void ProgressDialog::startProgress(const QString &caption, unsigned long long max)
{
label->setText(caption);
progressBar->setValue(0);
progressBar->setMaximum(max);
}
void ProgressDialog::stepProgress(unsigned long long value)
{
progressBar->setValue(progressBar->value() + value);
}
void ProgressDialog::closeEvent(QCloseEvent *event)
{
event->ignore();
}
void ProgressDialog::notify(MessageType type, IObject * /*sender*/, const QString &message)
{
wait_cursor_.reset();
switch (type) {
case mtError:
MessageDialog::critical(this, message, QMessageBox::Ok);
break;
case mtWarning:
MessageDialog::warning(this, message, QMessageBox::Ok);
break;
case mtInformation:
MessageDialog::information(this, message, QMessageBox::Ok);
break;
}
}
/**
* GUILog
*/
GUILog::GUILog(QObject *parent)
: QObject(parent), is_canceled_(false)
{
qRegisterMetaType<MessageType>("MessageType");
}
void GUILog::Notify(MessageType type, IObject *sender, const std::string &message)
{
emit notify(type, sender, QString::fromUtf8(message.c_str()));
}
void GUILog::StartProgress(const std::string &caption, unsigned long long max)
{
checkCanceled();
emit startProgress(QString::fromUtf8(caption.c_str()), max);
}
void GUILog::StepProgress(unsigned long long value, bool /*is_project*/)
{
checkCanceled();
emit stepProgress(value);
}
void GUILog::EndProgress()
{
checkCanceled();
emit endProgress();
}
void GUILog::cancel()
{
is_canceled_ = true;
}
void GUILog::checkCanceled()
{
if (is_canceled_)
throw canceled_error(language[lsOperationCanceledByUser]);
}