Compare commits

...

4 Commits

Author SHA1 Message Date
x-tools-author
393da176ca chore: update the file
Some checks failed
build-qt5 / Build with Qt5(linux) (5.12.12) (push) Has been cancelled
build-qt5 / Build with Qt5(linux) (5.13.2) (push) Has been cancelled
build-qt5 / Build with Qt5(linux) (5.14.2) (push) Has been cancelled
build-qt5 / Build with Qt5(linux) (5.15.2) (push) Has been cancelled
build-qt5 / Build with Qt5(linux) (5.9.9) (push) Has been cancelled
build-qt5 / Build with Qt5(macos) (macos-14, 5.10.1) (push) Has been cancelled
build-qt5 / Build with Qt5(macos) (macos-14, 5.11.3) (push) Has been cancelled
build-qt5 / Build with Qt5(macos) (macos-14, 5.12.12) (push) Has been cancelled
build-qt5 / Build with Qt5(macos) (macos-14, 5.13.2) (push) Has been cancelled
build-qt5 / Build with Qt5(macos) (macos-14, 5.14.2) (push) Has been cancelled
build-qt5 / Build with Qt5(macos) (macos-14, 5.15.2) (push) Has been cancelled
build-qt5 / Build with Qt5(macos) (macos-14, 5.9.9) (push) Has been cancelled
build-macos / Build (macos-14, 6.2.4) (push) Has been cancelled
build-macos / Build (macos-14, 6.5.3) (push) Has been cancelled
build-macos / Build (macos-14, 6.8.3) (push) Has been cancelled
build-macos / Build (macos-14, 6.9.1) (push) Has been cancelled
build-daily / update-tag (push) Has been cancelled
build-apps / Build with Qt6 (xAssistant, win64_msvc2022_64, 6.8.3) (push) Has been cancelled
build-apps / Build with Qt6 (xCode, win64_msvc2022_64, 6.8.3) (push) Has been cancelled
build-apps / Build with Qt6 (xHash, win64_msvc2022_64, 6.8.3) (push) Has been cancelled
build-apps / Build with Qt6 (xOscilloscope, win64_msvc2022_64, 6.8.3) (push) Has been cancelled
build-apps / Build with Qt6 (xPing, win64_msvc2022_64, 6.8.3) (push) Has been cancelled
build-android / Build for Android(docker) (push) Has been cancelled
build-android / Build for Android(windows) (windows-2022, 6.8.3) (push) Has been cancelled
build-daily / update-release (push) Has been cancelled
build-daily / release-for-windows (push) Has been cancelled
build-daily / release-for-windows7 (push) Has been cancelled
build-daily / release-for-linux (push) Has been cancelled
build-daily / release-for-macos (push) Has been cancelled
build-daily / release-for-android (push) Has been cancelled
2025-09-14 21:20:03 +08:00
x-tools-author
4b8409ce7a chore: update the file 2025-09-14 21:19:40 +08:00
x-tools-author
c316fb2c93 chore: update the file 2025-09-14 20:34:16 +08:00
x-tools-author
56e8355c5f chore: rename the file 2025-09-14 17:56:43 +08:00
8 changed files with 170 additions and 5 deletions

View File

@ -51,5 +51,5 @@ set_property(TARGET SingleApplication PROPERTY FOLDER "3rd")
set_target_properties(SingleApplication PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${sapp_lib_dir})
list(APPEND X_LIBS SingleApplication)
add_compile_definitions(X_ENABLE_SINGLEAPPLICATION)
set(X_ENABLE_SINGLEAPPLICATION ON)
add_compile_definitions(X_ENABLE_SINGLE_APPLICATION)
set(X_ENABLE_SINGLE_APPLICATION ON)

View File

@ -12,7 +12,7 @@
#include "application.h"
#include "mainwindow.h"
#if defined(X_ENABLE_SINGLEAPPLICATION)
#if defined(X_ENABLE_SINGLE_APPLICATION)
#include "singleapplication.h"
#endif
@ -24,7 +24,7 @@ int main(int argc, char *argv[])
Application::setupHdpi();
Application app(argc, argv);
#if defined(X_ENABLE_SINGLEAPPLICATION)
#if defined(X_ENABLE_SINGLE_APPLICATION)
SingleApplication sApp(argc, argv);
if (sApp.isSecondary()) {
return 0;
@ -44,7 +44,7 @@ int main(int argc, char *argv[])
window.load();
window.moveToCenter();
#if defined(X_ENABLE_SINGLEAPPLICATION)
#if defined(X_ENABLE_SINGLE_APPLICATION)
QObject::connect(&sApp, &SingleApplication::instanceStarted, &window, [&window]() {
window.show();
window.raise();

View File

@ -9,14 +9,85 @@
#include "scriptbase.h"
#include "ui_scriptbase.h"
#include <QDesktopServices>
#include "scriptrunner.h"
ScriptBase::ScriptBase(QWidget *parent)
: QWidget(parent)
, ui(new Ui::ScriptBase)
{
ui->setupUi(this);
connect(ui->toolButtonOpen, &QToolButton::clicked, this, &ScriptBase::onRunButtonClicked);
connect(ui->toolButtonNew, &QToolButton::clicked, this, &ScriptBase::onNewButtonClicked);
connect(ui->toolButtonOpen, &QToolButton::clicked, this, &ScriptBase::onOpenButtonClicked);
connect(ui->toolButtonRefresh, &QToolButton::clicked, this, &ScriptBase::onRefreshButtonClicked);
connect(ui->toolButtonHelp, &QToolButton::clicked, this, &ScriptBase::onHelpButtonClicked);
}
ScriptBase::~ScriptBase()
{
delete ui;
}
ScriptRunner *ScriptBase::newRunner()
{
return nullptr;
}
QString ScriptBase::helpUrl() const
{
return QString();
}
void ScriptBase::onRunButtonClicked(bool checked)
{
ui->toolButtonOpen->setEnabled(false);
if (checked) {
startRunner();
} else {
stopRunner();
}
}
void ScriptBase::onNewButtonClicked() {}
void ScriptBase::onOpenButtonClicked() {}
void ScriptBase::onRefreshButtonClicked() {}
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()
{
if (m_runner) {
m_runner->requestInterruption();
m_runner->exit();
m_runner->wait();
m_runner->deleteLater();
m_runner = nullptr;
}
}

View File

@ -14,6 +14,7 @@ namespace Ui {
class ScriptBase;
}
class ScriptRunner;
class ScriptBase : public QWidget
{
Q_OBJECT
@ -21,6 +22,21 @@ public:
explicit ScriptBase(QWidget *parent = nullptr);
~ScriptBase() override;
protected:
virtual ScriptRunner *newRunner();
virtual QString helpUrl() const;
private:
void onRunButtonClicked(bool checked);
void onNewButtonClicked();
void onOpenButtonClicked();
void onRefreshButtonClicked();
void onHelpButtonClicked();
void startRunner();
void stopRunner();
private:
Ui::ScriptBase *ui = nullptr;
ScriptRunner *m_runner = nullptr;
};

View File

@ -0,0 +1,17 @@
/***************************************************************************************************
* Copyright 2025-2025 x-tools-author(x-tools@outlook.com). All rights reserved.
*
* The file is encoded using "utf8 with bom", it is a part of eTools project.
*
* eTools is licensed according to the terms in the file LICENCE(GPL V3) in the root of the source
* code directory.
**************************************************************************************************/
#include "scriptrunnerjs.h"
ScriptRunnerJs::ScriptRunnerJs(QObject *parent)
: ScriptRunner(parent)
{}
ScriptRunnerJs::~ScriptRunnerJs() {}
void ScriptRunnerJs::run() {}

View File

@ -0,0 +1,22 @@
/***************************************************************************************************
* Copyright 2025-2025 x-tools-author(x-tools@outlook.com). All rights reserved.
*
* The file is encoded using "utf8 with bom", it is a part of eTools project.
*
* eTools is licensed according to the terms in the file LICENCE(GPL V3) in the root of the source
* code directory.
**************************************************************************************************/
#pragma once
#include "scriptrunner.h"
class ScriptRunnerJs : public ScriptRunner
{
Q_OBJECT
public:
explicit ScriptRunnerJs(QObject *parent = nullptr);
~ScriptRunnerJs();
protected:
void run() override;
};

View File

@ -0,0 +1,17 @@
/***************************************************************************************************
* Copyright 2025-2025 x-tools-author(x-tools@outlook.com). All rights reserved.
*
* The file is encoded using "utf8 with bom", it is a part of eTools project.
*
* eTools is licensed according to the terms in the file LICENCE(GPL V3) in the root of the source
* code directory.
**************************************************************************************************/
#include "scriptrunnerlua.h"
ScriptRunnerLua::ScriptRunnerLua(QObject *parent)
: ScriptRunner(parent)
{}
ScriptRunnerLua::~ScriptRunnerLua() {}
void ScriptRunnerLua::run() {}

View File

@ -0,0 +1,22 @@
/***************************************************************************************************
* Copyright 2025-2025 x-tools-author(x-tools@outlook.com). All rights reserved.
*
* The file is encoded using "utf8 with bom", it is a part of eTools project.
*
* eTools is licensed according to the terms in the file LICENCE(GPL V3) in the root of the source
* code directory.
**************************************************************************************************/
#pragma once
#include "scriptrunner.h"
class ScriptRunnerLua : public ScriptRunner
{
Q_OBJECT
public:
explicit ScriptRunnerLua(QObject *parent = nullptr);
~ScriptRunnerLua();
protected:
void run() override;
};