mirror of
https://github.com/x-tools-author/x-tools.git
synced 2025-09-15 15:28:40 +08:00
chore: update the file
This commit is contained in:
parent
c316fb2c93
commit
4b8409ce7a
@ -9,6 +9,10 @@
|
||||
#include "scriptbase.h"
|
||||
#include "ui_scriptbase.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include "scriptrunner.h"
|
||||
|
||||
ScriptBase::ScriptBase(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::ScriptBase)
|
||||
@ -32,8 +36,14 @@ ScriptRunner *ScriptBase::newRunner()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QString ScriptBase::helpUrl() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
void ScriptBase::onRunButtonClicked(bool checked)
|
||||
{
|
||||
ui->toolButtonOpen->setEnabled(false);
|
||||
if (checked) {
|
||||
startRunner();
|
||||
} else {
|
||||
@ -47,11 +57,37 @@ void ScriptBase::onOpenButtonClicked() {}
|
||||
|
||||
void ScriptBase::onRefreshButtonClicked() {}
|
||||
|
||||
void ScriptBase::onHelpButtonClicked() {}
|
||||
void ScriptBase::onHelpButtonClicked()
|
||||
{
|
||||
QString url = helpUrl();
|
||||
if (url.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QDesktopServices::openUrl(QUrl(url));
|
||||
}
|
||||
|
||||
void ScriptBase::startRunner()
|
||||
{
|
||||
stopRunner();
|
||||
|
||||
m_runner = newRunner();
|
||||
if (!m_runner) {
|
||||
return;
|
||||
}
|
||||
|
||||
connect(m_runner, &QThread::finished, this, [this]() { ui->toolButtonOpen->setEnabled(true); });
|
||||
connect(m_runner, &QThread::started, this, [this]() { ui->toolButtonOpen->setEnabled(true); });
|
||||
m_runner->start();
|
||||
}
|
||||
|
||||
void ScriptBase::stopRunner() {}
|
||||
void ScriptBase::stopRunner()
|
||||
{
|
||||
if (m_runner) {
|
||||
m_runner->requestInterruption();
|
||||
m_runner->exit();
|
||||
m_runner->wait();
|
||||
m_runner->deleteLater();
|
||||
m_runner = nullptr;
|
||||
}
|
||||
}
|
||||
@ -24,6 +24,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual ScriptRunner *newRunner();
|
||||
virtual QString helpUrl() const;
|
||||
|
||||
private:
|
||||
void onRunButtonClicked(bool checked);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user