fix: 修复一些问题;移除有缺陷的组件;更新打包脚本;

This commit is contained in:
寂静的羽夏 2025-03-02 13:39:07 +08:00
parent 606e55c057
commit a55888b0eb
20 changed files with 941 additions and 948 deletions

View File

@ -235,8 +235,6 @@ set(CLASS_SRC
src/class/languagemanager.cpp src/class/languagemanager.cpp
src/class/settingmanager.h src/class/settingmanager.h
src/class/settingmanager.cpp src/class/settingmanager.cpp
src/class/wingprogressdialog.h
src/class/wingprogressdialog.cpp
src/class/asdebugger.h src/class/asdebugger.h
src/class/asdebugger.cpp src/class/asdebugger.cpp
src/class/scriptconsolemachine.h src/class/scriptconsolemachine.h
@ -284,7 +282,9 @@ set(CLASS_SRC
src/class/crashhandler.h src/class/crashhandler.h
src/class/crashhandler.cpp src/class/crashhandler.cpp
src/class/pluginsystem.h src/class/pluginsystem.h
src/class/pluginsystem.cpp) src/class/pluginsystem.cpp
src/class/inspectqtloghelper.h
src/class/inspectqtloghelper.cpp)
set(INTERNAL_PLG_SRC set(INTERNAL_PLG_SRC
src/class/wingangelapi.h src/class/wingangelapi.cpp src/class/wingangelapi.h src/class/wingangelapi.cpp

BIN
images/qtloginspect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -187,6 +187,8 @@ Homepage: https://www.cnblogs.com/wingsummer/
os.mkdir(os.path.join(exeBasePath, "aslib")) os.mkdir(os.path.join(exeBasePath, "aslib"))
shutil.copy2(exemain_src, os.path.join(exeBasePath, package_name)) shutil.copy2(exemain_src, os.path.join(exeBasePath, package_name))
shutil.copy2(os.path.join(projectdeb, "WingPlugin", "libWingPlugin.so"),
os.path.join(exeBasePath, "libWingPlugin.so"))
desktopPath = os.path.join(exeDebPath, "usr", "share", "applications") desktopPath = os.path.join(exeDebPath, "usr", "share", "applications")
os.makedirs(desktopPath) os.makedirs(desktopPath)

View File

@ -13,6 +13,7 @@ import platform
from colorama import Fore, Style from colorama import Fore, Style
def run_command_interactive(command): def run_command_interactive(command):
""" """
Run a command interactively, printing its stdout in real-time. Run a command interactively, printing its stdout in real-time.
@ -21,8 +22,8 @@ def run_command_interactive(command):
:return: The return code of the command :return: The return code of the command
""" """
process = subprocess.Popen( process = subprocess.Popen(
command, command,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, # Capture both stdout and stderr stderr=subprocess.STDOUT, # Capture both stdout and stderr
text=True # Ensure the output is in text mode text=True # Ensure the output is in text mode
) )
@ -32,15 +33,16 @@ def run_command_interactive(command):
if output == "" and process.poll() is not None: if output == "" and process.poll() is not None:
break break
if output: if output:
print(Fore.GREEN + output.strip() + Style.RESET_ALL) print(Fore.GREEN + output.strip() + Style.RESET_ALL)
return_code = process.wait() return_code = process.wait()
return return_code return return_code
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
prog="mkdeb.py", description="A deb installer maker for WingHexExplorer2") prog="mkdeb.py", description="A deb installer maker for WingHexExplorer2")
parser.add_argument( parser.add_argument(
"folder", help="A folder that has contained the binary build", type=str "folder", help="A folder that has contained the binary build", type=str
) )
@ -57,7 +59,7 @@ def main():
"--no-build", dest="build", action="store_false", help="Skip building the installer" "--no-build", dest="build", action="store_false", help="Skip building the installer"
) )
parser.set_defaults(build=True) parser.set_defaults(build=True)
args = parser.parse_args() args = parser.parse_args()
# checking build toolkits # checking build toolkits
@ -81,15 +83,15 @@ def main():
print( print(
Fore.RED + "[Error] This is not a CMake build directory!" + Style.RESET_ALL) Fore.RED + "[Error] This is not a CMake build directory!" + Style.RESET_ALL)
exit(-1) exit(-1)
deploy_exec = "" deploy_exec = ""
with open(cmake_cache, 'r') as cmake_config: with open(cmake_cache, 'r') as cmake_config:
while(True): while (True):
line = cmake_config.readline() line = cmake_config.readline()
if not line: if not line:
break break
if(line.startswith("WINDEPLOYQT_EXECUTABLE:FILEPATH")): if (line.startswith("WINDEPLOYQT_EXECUTABLE:FILEPATH")):
set = line.split('=', 1) set = line.split('=', 1)
deploy_exec = set[1].strip('\n') deploy_exec = set[1].strip('\n')
pass pass
@ -124,20 +126,24 @@ def main():
# check # check
exemain_src = "" exemain_src = ""
exesym_src = "" exesym_src = ""
exeplg_src = ""
if(os.path.exists(os.path.join(projectdeb, "WingHexExplorer2.sln"))):
exemain_src = os.path.join(projectdeb, "RelWithDebInfo", exe_name) if (os.path.exists(os.path.join(projectdeb, "WingHexExplorer2.sln"))):
exemain_src = os.path.join(projectdeb, "RelWithDebInfo", exe_name)
exesym_src = os.path.join(projectdeb, "RelWithDebInfo", sym_name) exesym_src = os.path.join(projectdeb, "RelWithDebInfo", sym_name)
exeplg_src = os.path.join(
projectdeb, "WingPlugin", "RelWithDebInfo", "WingPlugin.dll")
else: else:
exemain_src = os.path.join(projectdeb, exe_name) exemain_src = os.path.join(projectdeb, exe_name)
exesym_src = os.path.join(projectdeb, sym_name) exesym_src = os.path.join(projectdeb, sym_name)
exeplg_src = os.path.join(projectdeb, "WingPlugin", "WingPlugin.dll")
if (os.path.exists(exemain_src) == False): if (os.path.exists(exemain_src) == False):
print( print(
Fore.RED + "[Error] WingHexExplorer2.exe is not found!" + Style.RESET_ALL) Fore.RED + "[Error] WingHexExplorer2.exe is not found!" + Style.RESET_ALL)
exit(-3) exit(-3)
# calculate the md5 checksum # calculate the md5 checksum
with open(exemain_src, 'rb') as file_to_check: with open(exemain_src, 'rb') as file_to_check:
data = file_to_check.read() data = file_to_check.read()
@ -155,6 +161,8 @@ def main():
shutil.copy2(exemain_src, os.path.join(exeDebPath, exe_name)) shutil.copy2(exemain_src, os.path.join(exeDebPath, exe_name))
shutil.copy2(exesym_src, os.path.join(exeDebPath, sym_name)) shutil.copy2(exesym_src, os.path.join(exeDebPath, sym_name))
shutil.copy2(exeplg_src,
os.path.join(exeDebPath, "WingPlugin.dll"))
shutil.copytree(os.path.join(buildinstaller, "share"), shutil.copytree(os.path.join(buildinstaller, "share"),
os.path.join(exeDebPath, "share")) os.path.join(exeDebPath, "share"))
@ -173,23 +181,24 @@ def main():
shutil.copyfile(os.path.join(projectbase, "images", "author.jpg"), shutil.copyfile(os.path.join(projectbase, "images", "author.jpg"),
os.path.join(exeDebPath, "author.jpg")) os.path.join(exeDebPath, "author.jpg"))
# deploy the software # deploy the software
print(Fore.GREEN + ">> Copying finished, deploying the software..." + Style.RESET_ALL) print(Fore.GREEN + ">> Copying finished, deploying the software..." + Style.RESET_ALL)
try: try:
subprocess.run([deploy_exec, os.path.join(exeDebPath, exe_name) ], check=True, subprocess.run([deploy_exec, os.path.join(exeDebPath, exe_name)], check=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print(Fore.RED + f"[Error] deploy package error: \n{e.stderr.decode('utf-8')}" + Style.RESET_ALL) print(
Fore.RED + f"[Error] deploy package error: \n{e.stderr.decode('utf-8')}" + Style.RESET_ALL)
exit(-4) exit(-4)
except FileNotFoundError: except FileNotFoundError:
exit(-4) exit(-4)
# generate iss file # generate iss file
print(Fore.GREEN + ">> Copying finished, generate ISCC script..." + Style.RESET_ALL) print(Fore.GREEN + ">> Copying finished, generate ISCC script..." + Style.RESET_ALL)
iss_content = fr""" iss_content = fr"""
; Script generated by the mkinnopak.py by wingsummer. ; Script generated by the mkinnopak.py by wingsummer.
@ -243,8 +252,10 @@ Source: {#MyAppExePath}; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
""" """
iss_content += fr'Source: "{exeDebPath}\*"; ' + r'DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "*.iss,{#MyOutputBaseFilename}.exe,README.md"' + '\n' iss_content += fr'Source: "{exeDebPath}\*"; ' + \
iss_content += fr'Source: "{exeDebPath}\README.md"; ' + r'DestDir: "{app}"; Flags: isreadme' r'DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "*.iss,{#MyOutputBaseFilename}.exe,README.md"' + '\n'
iss_content += fr'Source: "{exeDebPath}\README.md"; ' + \
r'DestDir: "{app}"; Flags: isreadme'
iss_content += """ iss_content += """
[Registry] [Registry]
@ -271,21 +282,21 @@ Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChang
""" """
script_src = os.path.join(exeDebPath, "mkiss.iss") script_src = os.path.join(exeDebPath, "mkiss.iss")
with codecs.open(script_src,'w', "utf-8-sig") as iss: with codecs.open(script_src, 'w', "utf-8-sig") as iss:
iss.write(iss_content) iss.write(iss_content)
if args.build == False: if args.build == False:
exit(0) exit(0)
print(Fore.GREEN + ">> Copying finished, running ISCC building..." + Style.RESET_ALL) print(Fore.GREEN + ">> Copying finished, running ISCC building..." + Style.RESET_ALL)
pak_out = "" pak_out = ""
if args.output is None: if args.output is None:
pak_out = os.path.join(exeDebPath,"..") pak_out = os.path.join(exeDebPath, "..")
else: else:
pak_out = args.output pak_out = args.output
ret = run_command_interactive([args.cc, f'/O{pak_out}', script_src]) ret = run_command_interactive([args.cc, f'/O{pak_out}', script_src])
exit(ret) exit(ret)

View File

@ -161,6 +161,9 @@ def main():
for item in deploy_files: for item in deploy_files:
shutil.copy2(os.path.join(installer_path, item), shutil.copy2(os.path.join(installer_path, item),
os.path.join(installer_path_exec, item)) os.path.join(installer_path_exec, item))
shutil.copy2(os.path.join(build_path, "WingPlugin", "libWingPlugin.so"),
os.path.join(installer_path_exec, "lib" , "libWingPlugin.so"))
# finally, copy other files # finally, copy other files
print(Fore.GREEN + ">> Copying License and other materials..." + Style.RESET_ALL) print(Fore.GREEN + ">> Copying License and other materials..." + Style.RESET_ALL)

View File

@ -117,6 +117,8 @@ def update(build_path):
print(Fore.GREEN + ">> Installing..." + Style.RESET_ALL) print(Fore.GREEN + ">> Installing..." + Style.RESET_ALL)
shutil.copy2(exemain_src, os.path.join(INSTALL_PATH, PACKAGE_NAME)) shutil.copy2(exemain_src, os.path.join(INSTALL_PATH, PACKAGE_NAME))
shutil.copy2(os.path.join(build_path, "WingPlugin", "libWingPlugin.so"),
os.path.join(INSTALL_PATH, "libWingPlugin.so"))
create_dir(os.path.join(INSTALL_PATH, "plugin")) create_dir(os.path.join(INSTALL_PATH, "plugin"))
create_dir(os.path.join(INSTALL_PATH, "scripts")) create_dir(os.path.join(INSTALL_PATH, "scripts"))

View File

@ -69,6 +69,7 @@
<file>images/plugin.png</file> <file>images/plugin.png</file>
<file>images/pro.png</file> <file>images/pro.png</file>
<file>images/qt.png</file> <file>images/qt.png</file>
<file>images/qtloginspect.png</file>
<file>images/readonly.png</file> <file>images/readonly.png</file>
<file>images/recent.png</file> <file>images/recent.png</file>
<file>images/redo.png</file> <file>images/redo.png</file>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

@ -29,6 +29,7 @@
#include "define.h" #include "define.h"
#include "dialog/mainwindow.h" #include "dialog/mainwindow.h"
#include "dialog/splashdialog.h" #include "dialog/splashdialog.h"
#include "inspectqtloghelper.h"
#include "languagemanager.h" #include "languagemanager.h"
#include "logger.h" #include "logger.h"
#include "settingmanager.h" #include "settingmanager.h"
@ -42,6 +43,8 @@ AppManager::AppManager(int &argc, char *argv[])
: QtSingleApplication(argc, argv) { : QtSingleApplication(argc, argv) {
ASSERT_SINGLETON; ASSERT_SINGLETON;
LanguageManager::instance();
InspectQtLogHelper::instance().init();
CrashHandler::instance().init(); CrashHandler::instance().init();
auto args = arguments(); auto args = arguments();
@ -77,7 +80,6 @@ AppManager::AppManager(int &argc, char *argv[])
setFont(font); setFont(font);
SkinManager::instance(); SkinManager::instance();
LanguageManager::instance();
auto dontSplash = set.dontUseSplash(); auto dontSplash = set.dontUseSplash();
@ -123,6 +125,8 @@ AppManager::AppManager(int &argc, char *argv[])
} }
} }
connect(_w, &MainWindow::closed, this,
[]() { AppManager::instance()->exit(); });
_instance = this; _instance = this;
if (splash) if (splash)
@ -130,6 +134,7 @@ AppManager::AppManager(int &argc, char *argv[])
} }
AppManager::~AppManager() { AppManager::~AppManager() {
InspectQtLogHelper::instance().destory();
ClangFormatManager::instance().save(); ClangFormatManager::instance().save();
CommandHistoryManager::save(QConsoleWidget::history().strings_); CommandHistoryManager::save(QConsoleWidget::history().strings_);

View File

@ -0,0 +1,96 @@
#include "inspectqtloghelper.h"
#include "utilities.h"
#include <iostream>
#define INFOLOG(msg) "<font color=\"green\">" + msg + "</font>"
#define ERRLOG(msg) "<font color=\"red\">" + msg + "</font>"
#define WARNLOG(msg) "<font color=\"gold\">" + msg + "</font>"
InspectQtLogHelper &InspectQtLogHelper::instance() {
static InspectQtLogHelper ins;
return ins;
}
void InspectQtLogHelper::init() {
_logger = new FramelessDialogBase;
_ctx = new QTextBrowser(_logger);
_ctx->setContextMenuPolicy(Qt::CustomContextMenu);
_ctx->setUndoRedoEnabled(false);
_ctx->setOpenExternalLinks(true);
auto menu = _ctx->createStandardContextMenu();
auto ma = menu->actions();
menu->addSeparator();
auto a = new QAction(tr("Clear"), menu);
connect(a, &QAction::triggered, this, [this]() { _ctx->clear(); });
menu->addAction(a);
auto af = ma.at(0);
af = menu->insertSeparator(af);
a = new QAction(tr("TopMost"), menu);
a->setCheckable(true);
connect(a, &QAction::toggled, this, [this](bool b) {
_logger->setWindowFlag(Qt::WindowStaysOnTopHint, b);
if (!_logger->isVisible()) {
_logger->setVisible(true);
}
});
menu->insertAction(af, a);
connect(_ctx, &QTextBrowser::customContextMenuRequested, this,
[menu, this](const QPoint &pos) {
menu->popup(_ctx->mapToGlobal(pos));
});
_logger->buildUpContent(_ctx);
_logger->setWindowTitle(tr("Inspect"));
_logger->setWindowIcon(ICONRES("qtloginspect"));
qSetMessagePattern(QStringLiteral("%{if-debug}[Debug]%{endif}"
"%{if-warning}[Warn]%{endif}"
"%{if-info}[Info]%{endif}"
"%{if-critical}[Error]%{endif}"
"%{if-fatal}[Fatal]%{endif}"
" %{message}"));
qInstallMessageHandler(messageHandler);
}
void InspectQtLogHelper::destory() {
qInstallMessageHandler(nullptr);
delete _logger;
}
void InspectQtLogHelper::showLogWidget() { _logger->show(); }
InspectQtLogHelper::InspectQtLogHelper() {}
InspectQtLogHelper::~InspectQtLogHelper() {}
void InspectQtLogHelper::messageHandler(QtMsgType type,
const QMessageLogContext &context,
const QString &message) {
auto logger = InspectQtLogHelper::instance()._ctx;
auto msg = qFormatLogMessage(type, context, message);
Q_ASSERT(logger);
switch (type) {
case QtDebugMsg:
logger->append(msg);
std::cout << qUtf8Printable(msg) << std::endl;
break;
case QtWarningMsg:
logger->append(INFOLOG(msg));
std::cout << qUtf8Printable(msg) << std::endl;
break;
case QtCriticalMsg:
case QtFatalMsg:
logger->append(ERRLOG(msg));
std::cerr << qUtf8Printable(msg) << std::endl;
break;
case QtInfoMsg:
logger->append(INFOLOG(msg));
std::cout << qUtf8Printable(msg) << std::endl;
break;
}
}

View File

@ -0,0 +1,35 @@
#ifndef INSPECTQTLOGHELPER_H
#define INSPECTQTLOGHELPER_H
#include "dialog/framelessdialogbase.h"
#include <QObject>
#include <QTextBrowser>
class InspectQtLogHelper : public QObject {
Q_OBJECT
public:
static InspectQtLogHelper &instance();
void init();
void destory();
void showLogWidget();
private:
InspectQtLogHelper();
~InspectQtLogHelper();
Q_DISABLE_COPY_MOVE(InspectQtLogHelper)
private:
static void messageHandler(QtMsgType type,
const QMessageLogContext &context,
const QString &message);
private:
FramelessDialogBase *_logger;
QTextBrowser *_ctx;
};
#endif // INSPECTQTLOGHELPER_H

View File

@ -1,124 +0,0 @@
/*==============================================================================
** Copyright (C) 2024-2027 WingSummer
**
** This program is free software: you can redistribute it and/or modify it under
** the terms of the GNU Affero General Public License as published by the Free
** Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
** FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
** details.
**
** You should have received a copy of the GNU Affero General Public License
** along with this program. If not, see <https://www.gnu.org/licenses/>.
** =============================================================================
*/
#include "wingprogressdialog.h"
#include <QProgressBar>
WingProgressDialog::WingProgressDialog(QWidget *parent) {
m_dialog = new QProgressDialog(parent, Qt::Widget);
auto pb = new QProgressBar(this);
pb->setTextVisible(false);
m_dialog->setBar(pb);
buildUpContent(m_dialog);
connect(m_dialog, &QProgressDialog::canceled, this,
&WingProgressDialog::canceled);
connect(m_dialog, &QProgressDialog::finished, this,
&FramelessDialogBase::done);
}
WingProgressDialog::WingProgressDialog(const QString &labelText,
const QString &cancelButtonText,
int minimum, int maximum,
QWidget *parent) {
m_dialog = new QProgressDialog(labelText, cancelButtonText, minimum,
maximum, this);
m_dialog->setWindowFlag(Qt::Widget);
auto pb = new QProgressBar(this);
pb->setTextVisible(false);
m_dialog->setBar(pb);
buildUpContent(m_dialog);
connect(m_dialog, &QProgressDialog::canceled, this,
&WingProgressDialog::cancel);
connect(m_dialog, &QProgressDialog::finished, this,
&FramelessDialogBase::done);
}
WingProgressDialog::~WingProgressDialog() {}
void WingProgressDialog::setLabel(QLabel *label) { m_dialog->setLabel(label); }
void WingProgressDialog::setCancelButton(QPushButton *button) {
m_dialog->setCancelButton(button);
}
void WingProgressDialog::setBar(QProgressBar *bar) { m_dialog->setBar(bar); }
bool WingProgressDialog::wasCanceled() const { return m_dialog->wasCanceled(); }
int WingProgressDialog::minimum() const { return m_dialog->minimum(); }
int WingProgressDialog::maximum() const { return m_dialog->maximum(); }
int WingProgressDialog::value() const { return m_dialog->value(); }
QString WingProgressDialog::labelText() const { return m_dialog->labelText(); }
int WingProgressDialog::minimumDuration() const {
return m_dialog->minimumDuration();
}
void WingProgressDialog::setAutoReset(bool reset) {
m_dialog->setAutoReset(reset);
}
bool WingProgressDialog::autoReset() const { return m_dialog->autoReset(); }
void WingProgressDialog::setAutoClose(bool close) {
m_dialog->setAutoClose(close);
}
bool WingProgressDialog::autoClose() const { return m_dialog->autoClose(); }
void WingProgressDialog::open(QObject *receiver, const char *member) {
m_dialog->open(receiver, member);
}
void WingProgressDialog::cancel() { m_dialog->cancel(); }
void WingProgressDialog::reset() { m_dialog->reset(); }
void WingProgressDialog::setMaximum(int maximum) {
m_dialog->setMaximum(maximum);
}
void WingProgressDialog::setMinimum(int minimum) {
m_dialog->setMinimum(minimum);
}
void WingProgressDialog::setRange(int minimum, int maximum) {
m_dialog->setRange(minimum, maximum);
}
void WingProgressDialog::setValue(int progress) {
m_dialog->setValue(progress);
}
void WingProgressDialog::setLabelText(const QString &text) {
m_dialog->setLabelText(text);
}
void WingProgressDialog::setCancelButtonText(const QString &text) {
m_dialog->setCancelButtonText(text);
}
void WingProgressDialog::setMinimumDuration(int ms) {
m_dialog->setMinimumDuration(ms);
}

View File

@ -1,78 +0,0 @@
/*==============================================================================
** Copyright (C) 2024-2027 WingSummer
**
** This program is free software: you can redistribute it and/or modify it under
** the terms of the GNU Affero General Public License as published by the Free
** Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
** FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
** details.
**
** You should have received a copy of the GNU Affero General Public License
** along with this program. If not, see <https://www.gnu.org/licenses/>.
** =============================================================================
*/
#ifndef WINGPROGRESSDIALOG_H
#define WINGPROGRESSDIALOG_H
#include <QProgressDialog>
#include "dialog/framelessdialogbase.h"
class WingProgressDialog : public FramelessDialogBase {
Q_OBJECT
public:
explicit WingProgressDialog(QWidget *parent = nullptr);
WingProgressDialog(const QString &labelText,
const QString &cancelButtonText, int minimum,
int maximum, QWidget *parent = nullptr);
~WingProgressDialog();
public:
void setLabel(QLabel *label);
void setCancelButton(QPushButton *button);
void setBar(QProgressBar *bar);
bool wasCanceled() const;
int minimum() const;
int maximum() const;
int value() const;
QString labelText() const;
int minimumDuration() const;
void setAutoReset(bool reset);
bool autoReset() const;
void setAutoClose(bool close);
bool autoClose() const;
using FramelessDialogBase::open;
void open(QObject *receiver, const char *member);
public Q_SLOTS:
void cancel();
void reset();
void setMaximum(int maximum);
void setMinimum(int minimum);
void setRange(int minimum, int maximum);
void setValue(int progress);
void setLabelText(const QString &text);
void setCancelButtonText(const QString &text);
void setMinimumDuration(int ms);
Q_SIGNALS:
void canceled();
private:
QProgressDialog *m_dialog;
};
#endif // WINGPROGRESSDIALOG_H

View File

@ -510,7 +510,9 @@ ErrFile EditorView::save(const QString &workSpaceName, const QString &path,
convertTabW(this); convertTabW(this);
for (auto &c : m_cloneChildren) { for (auto &c : m_cloneChildren) {
convertTabW(c); if (c) {
convertTabW(c);
}
} }
} }
} }

View File

@ -33,12 +33,6 @@ ColorPickerDialog::ColorPickerDialog(QWidget *parent)
{240.0 / 360.0, Qt::blue}, {240.0 / 360.0, Qt::blue},
{300.0 / 360.0, Qt::magenta}, {300.0 / 360.0, Qt::magenta},
{359.0 / 360.0, Qt::red}}); {359.0 / 360.0, Qt::red}});
ui->saturationSlider->setGradientStops(
{{0.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 0, 255)},
{255.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 255, 255)}});
ui->brightnessSlider->setGradientStops(
{{0.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 255, 0)},
{255.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 255, 255)}});
_oldColor.setHsv(180, 255, 255); _oldColor.setHsv(180, 255, 255);
updateColor(_oldColor); updateColor(_oldColor);
@ -74,8 +68,23 @@ void ColorPickerDialog::updateColor() {
updateColor(_color); updateColor(_color);
} }
void ColorPickerDialog::updateHueSlider() {
ui->saturationSlider->setGradientStops(
{{0.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 0, 255)},
{255.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 255, 255)}});
ui->brightnessSlider->setGradientStops(
{{0.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 255, 0)},
{255.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 255, 255)}});
}
void ColorPickerDialog::updateColor(QColor color) { void ColorPickerDialog::updateColor(QColor color) {
ui->hueSlider->setValue(color.hsvHue()); ui->hueSlider->setValue(color.hsvHue());
ui->saturationSlider->setGradientStops(
{{0.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 0, 255)},
{255.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 255, 255)}});
ui->brightnessSlider->setGradientStops(
{{0.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 255, 0)},
{255.0 / 255.0, QColor::fromHsv(ui->hueSlider->value(), 255, 255)}});
ui->saturationSlider->setValue(color.hsvSaturation()); ui->saturationSlider->setValue(color.hsvSaturation());
ui->brightnessSlider->setValue(color.value()); ui->brightnessSlider->setValue(color.value());
ui->leColor->setText(color.name()); ui->leColor->setText(color.name());

View File

@ -56,7 +56,7 @@ private slots:
private: private:
void updateColor(); void updateColor();
void updateHueSlider();
void updateColor(QColor color); void updateColor(QColor color);
private: private:

View File

@ -26,6 +26,7 @@
#include "class/appmanager.h" #include "class/appmanager.h"
#include "class/dockcomponentsfactory.h" #include "class/dockcomponentsfactory.h"
#include "class/eventfilter.h" #include "class/eventfilter.h"
#include "class/inspectqtloghelper.h"
#include "class/langservice.h" #include "class/langservice.h"
#include "class/languagemanager.h" #include "class/languagemanager.h"
#include "class/layoutmanager.h" #include "class/layoutmanager.h"
@ -1674,6 +1675,8 @@ RibbonTabContent *MainWindow::buildViewPage(RibbonTabContent *tab) {
&MainWindow::on_exportlog); &MainWindow::on_exportlog);
addPannelAction(pannel, QStringLiteral("clearhis"), tr("ClearLog"), addPannelAction(pannel, QStringLiteral("clearhis"), tr("ClearLog"),
&MainWindow::on_clslog); &MainWindow::on_clslog);
addPannelAction(pannel, QStringLiteral("qtloginspect"), tr("InsepctQt"),
&MainWindow::on_inspectQt);
} }
return tab; return tab;
@ -2296,10 +2299,11 @@ void MainWindow::on_findfile() {
info.encoding = r.encoding; info.encoding = r.encoding;
info.str = r.str; info.str = r.str;
showStatus(tr("Finding..."));
ExecAsync<EditorView::FindError>( ExecAsync<EditorView::FindError>(
[this, r]() -> EditorView::FindError { [this, r]() -> EditorView::FindError {
m_isfinding = true; m_isfinding = true;
this->showStatus(tr("Finding..."));
return currentEditor()->find(r); return currentEditor()->find(r);
}, },
[this](EditorView::FindError err) { [this](EditorView::FindError err) {
@ -3040,6 +3044,10 @@ void MainWindow::on_clslog() {
tr("ClearLogSuccess")); tr("ClearLogSuccess"));
} }
void MainWindow::on_inspectQt() {
InspectQtLogHelper::instance().showLogWidget();
}
void MainWindow::on_scriptwindow() { void MainWindow::on_scriptwindow() {
Q_ASSERT(m_scriptDialog); Q_ASSERT(m_scriptDialog);
m_scriptDialog->show(); m_scriptDialog->show();
@ -3081,6 +3089,7 @@ void MainWindow::on_wiki() {
} }
void MainWindow::on_update() { void MainWindow::on_update() {
showStatus(tr("CheckingUpdate"));
ExecAsync<int>( ExecAsync<int>(
[]() -> int { []() -> int {
bool ok = false; bool ok = false;
@ -3100,8 +3109,8 @@ void MainWindow::on_update() {
WingMessageBox::information(this, qAppName(), WingMessageBox::information(this, qAppName(),
tr("NewestVersion")); tr("NewestVersion"));
} }
}, this->showStatus({});
tr("CheckingUpdate")); });
} }
QString MainWindow::saveLog() { QString MainWindow::saveLog() {
@ -3989,6 +3998,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
PluginSystem::instance().destory(); PluginSystem::instance().destory();
FramelessMainWindow::closeEvent(event); FramelessMainWindow::closeEvent(event);
emit closed();
} }
bool MainWindow::eventFilter(QObject *watched, QEvent *event) { bool MainWindow::eventFilter(QObject *watched, QEvent *event) {

View File

@ -45,7 +45,6 @@
#include "class/clickcallback.h" #include "class/clickcallback.h"
#include "class/recentfilemanager.h" #include "class/recentfilemanager.h"
#include "class/scriptmanager.h" #include "class/scriptmanager.h"
#include "class/wingprogressdialog.h"
#include "control/editorview.h" #include "control/editorview.h"
#include "control/qtableviewext.h" #include "control/qtableviewext.h"
#include "control/scriptingconsole.h" #include "control/scriptingconsole.h"
@ -201,6 +200,7 @@ private slots:
void on_saveLayout(); void on_saveLayout();
void on_exportlog(); void on_exportlog();
void on_clslog(); void on_clslog();
void on_inspectQt();
void on_scriptwindow(); void on_scriptwindow();
void on_setting_general(); void on_setting_general();
@ -438,8 +438,7 @@ private:
/* =============== some templates for async execution ===============*/ /* =============== some templates for async execution ===============*/
template <typename ReturnType, typename ExecFunc, typename FinishFunc> template <typename ReturnType, typename ExecFunc, typename FinishFunc>
void ExecAsync(ExecFunc &&execFunc, FinishFunc &&finishFunc, void ExecAsync(ExecFunc &&execFunc, FinishFunc &&finishFunc) {
const QString &tip = QString()) {
QFutureWatcher<ReturnType> *watcher = new QFutureWatcher<ReturnType>(); QFutureWatcher<ReturnType> *watcher = new QFutureWatcher<ReturnType>();
QObject::connect(watcher, &QFutureWatcher<ReturnType>::finished, this, QObject::connect(watcher, &QFutureWatcher<ReturnType>::finished, this,
@ -451,25 +450,10 @@ private:
auto fu = QtConcurrent::run([=]() -> ReturnType { return execFunc(); }); auto fu = QtConcurrent::run([=]() -> ReturnType { return execFunc(); });
watcher->setFuture(fu); watcher->setFuture(fu);
if (!tip.isEmpty()) {
auto pdialog = new WingProgressDialog(tip, QString(), 0, 0);
pdialog->setModal(true);
pdialog->setValue(0);
QObject::connect(watcher, &QFutureWatcher<ReturnType>::finished,
this, [pdialog]() mutable {
pdialog->cancel();
pdialog->deleteLater();
});
pdialog->exec();
}
} }
template <typename ExecFunc, typename FinishFunc> template <typename ExecFunc, typename FinishFunc>
void ExecAsync_VOID(ExecFunc &&execFunc, FinishFunc &&finishFunc, void ExecAsync_VOID(ExecFunc &&execFunc, FinishFunc &&finishFunc) {
const QString &tip = QString()) {
QFutureWatcher<void> *watcher = new QFutureWatcher<void>(); QFutureWatcher<void> *watcher = new QFutureWatcher<void>();
QObject::connect(watcher, &QFutureWatcher<void>::finished, this, QObject::connect(watcher, &QFutureWatcher<void>::finished, this,
@ -480,22 +464,11 @@ private:
auto fu = QtConcurrent::run([=]() -> void { return execFunc(); }); auto fu = QtConcurrent::run([=]() -> void { return execFunc(); });
watcher->setFuture(fu); watcher->setFuture(fu);
if (!tip.isEmpty()) {
auto pdialog = new WingProgressDialog(tip, QString(), 0, 0);
pdialog->setModal(true);
pdialog->setValue(0);
QObject::connect(watcher, &QFutureWatcher<void>::finished, this,
[pdialog]() mutable {
pdialog->cancel();
pdialog->deleteLater();
});
pdialog->exec();
}
} }
signals:
void closed();
private: private:
Ribbon *m_ribbon = nullptr; Ribbon *m_ribbon = nullptr;
ads::CDockManager *m_dock = nullptr; ads::CDockManager *m_dock = nullptr;