diff --git a/ToolUIInterface.pro b/ToolUIInterface.pro new file mode 100644 index 0000000..7c29b58 --- /dev/null +++ b/ToolUIInterface.pro @@ -0,0 +1,16 @@ +FORMS += \ + about.ui \ + fontch.ui \ + information.ui \ + mainwindow.ui + +SOURCES += \ + main.cpp + mainwindow.ui + +QT += core widgets + +RESOURCES += \ + main.qrc + +RC_ICONS = favicon.ico diff --git a/ToolUIInterface.pro.user b/ToolUIInterface.pro.user new file mode 100644 index 0000000..dff227c --- /dev/null +++ b/ToolUIInterface.pro.user @@ -0,0 +1,437 @@ + + + + + + EnvironmentId + {f2d23c01-5cb6-43a6-ae4c-c40810fd5ec8} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + true + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 0 + 80 + true + true + 1 + 0 + false + true + false + 2 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + false + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 8 + true + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + Desktop Qt 6.9.0 MinGW 64-bit + Desktop Qt 6.9.0 MinGW 64-bit + qt.qt6.690.win64_mingw_kit + 1 + 0 + 0 + + 0 + C:\Users\huaji\Desktop\code\ProjectQt\ToolUI\ToolUIInterface\build\Desktop_Qt_6_9_0_MinGW_64_bit-Debug + C:/Users/huaji/Desktop/code/ProjectQt/ToolUI/ToolUIInterface/build/Desktop_Qt_6_9_0_MinGW_64_bit-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + C:\Users\huaji\Desktop\code\ProjectQt\ToolUI\ToolUIInterface\build\Desktop_Qt_6_9_0_MinGW_64_bit-Release + C:/Users/huaji/Desktop/code/ProjectQt/ToolUI/ToolUIInterface/build/Desktop_Qt_6_9_0_MinGW_64_bit-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + C:\Users\huaji\Desktop\code\ProjectQt\ToolUI\ToolUIInterface\build\Desktop_Qt_6_9_0_MinGW_64_bit-Profile + C:/Users/huaji/Desktop/code/ProjectQt/ToolUI/ToolUIInterface/build/Desktop_Qt_6_9_0_MinGW_64_bit-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + 部署 + 部署 + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph "dwarf,4096" -F 250 + + Qt4ProjectManager.Qt4RunConfiguration: + C:/Users/huaji/Desktop/code/ProjectQt/ToolUI/ToolUIInterface/ToolUIInterface.pro + false + true + true + true + C:/Users/huaji/Desktop/code/ProjectQt/ToolUI/ToolUIInterface/build/Desktop_Qt_6_9_0_MinGW_64_bit-Release + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop + 桌面 + 桌面 + {750dc322-d5fd-4302-92cb-98de32b9798e} + 0 + 0 + 0 + + 0 + C:\Users\huaji\Desktop\code\ProjectQt\ToolUI\ToolUIInterface\build\unknown-Debug + C:/Users/huaji/Desktop/code/ProjectQt/ToolUI/ToolUIInterface/build/unknown-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + C:\Users\huaji\Desktop\code\ProjectQt\ToolUI\ToolUIInterface\build\unknown-Release + C:/Users/huaji/Desktop/code/ProjectQt/ToolUI/ToolUIInterface/build/unknown-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + C:\Users\huaji\Desktop\code\ProjectQt\ToolUI\ToolUIInterface\build\unknown-Profile + C:/Users/huaji/Desktop/code/ProjectQt/ToolUI/ToolUIInterface/build/unknown-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + 构建 + 构建 + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + 清除 + 清除 + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + 部署 + 部署 + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + 0 + true + + 2 + + false + -e cpu-cycles --call-graph "dwarf,4096" -F 250 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/about.ui b/about.ui new file mode 100644 index 0000000..a8d582c --- /dev/null +++ b/about.ui @@ -0,0 +1,86 @@ + + + about + + + + 0 + 0 + 439 + 329 + + + + Form + + + + + 10 + 40 + 421 + 241 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><title>免责声明</title><style type="text/css"> +p, li { white-space: pre-wrap; } +hr { height: 1px; border-width: 0; } +li.unchecked::marker { content: "\2610"; } +li.checked::marker { content: "\2612"; } +</style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;"> +<h2 style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="cn"></a><span style=" font-size:x-large; font-weight:700;">在</span><span style=" font-size:x-large; font-weight:700;">您使用本程序前,请仔细阅读以下信息。除本协议中明确赋予用户的权利、其它权利均保留。 </span></h2> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="#cn"><span style=" text-decoration: underline; color:#003e92;">中文版</span></a> </p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="#eng"><span style=" text-decoration: underline; color:#003e92;">English</span></a> </p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:700; color:#ff0000;">如果您不同意以下使用许可协议,请停止访问和使用本程序。以下“本人”均指站长</span> </p> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">1、本人</span><span style=" font-size:large; font-weight:700; color:#ff0000;">不提供任何形式的商业服务</span><span style=" font-size:large; font-weight:700;">,包括但不限于:技术支持,二次开发,源码出售,付费使用。请用户勿将本网站用于商业目的,违者自负责任。 </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">2、本站资源库及接口解析出的资源均来自网络,本站及本站所有者及管理员</span><span style=" font-size:large; font-weight:700; color:#ff0000;">不做任何视频存储工作</span><span style=" font-size:large; font-weight:700;">,所有行为均用户自行负责,如有疑问请联系底部邮箱。 </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">3、作为使用者,您拥有使用程序的权利,如需使用本程序你必须</span><span style=" font-size:large; font-weight:700; color:#ff0000;">独立承担这些内容的法律义务</span><span style=" font-size:large; font-weight:700;">。本人不对本程序的任何信息内容以及导致的任何版权纠纷和法律争议承担责任。 </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">4、本程序尚未发现重大问题,但风险评估较高。若您出于自愿而使用本网页,您必须了解使用风险,本人不提供任何形式的使用担保,也</span><span style=" font-size:large; font-weight:700; color:#ff0000;">不承担任何的相关责任</span><span style=" font-size:large; font-weight:700;">。 </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">5、用户使用本网页时,</span><span style=" font-size:large; font-weight:700; color:#ff0000;">不得用于从事违反中国人民共和国相关法律的活动</span><span style=" font-size:large; font-weight:700;">,本人对于用户擅自使用本程序从事违法活动不承担任何责任,包括但不限于刑事责任、行政责任、民事责任等。 </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">6、以上声明解释权、修改权均归站长本人所有 </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">一旦您使用本网页,</span><span style=" font-size:large; font-weight:700; color:#ff0000;">即默认</span><span style=" font-size:large; font-weight:700;">您已同意并接受本声明 </span></h3> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /><br /><br /><br /><br /><br /></p> +<h2 style=" margin-top:16px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a name="eng"></a><span style=" font-size:x-large; font-weight:700;">B</span><span style=" font-size:x-large; font-weight:700;">efore you use this website, please read the following information carefully. Except for the rights explicitly given to users in this agreement, other rights are reserved. </span></h2> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:700; color:#ff0000;">If you do not agree to the following license agreement, please stop visiting and using this website. The following &quot;I&quot; refer to the Administrator</span> </p> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">1. I </span><span style=" font-size:large; font-weight:700; color:#ff0000;">do not provide any form of commercial services</span><span style=" font-size:large; font-weight:700;">,including but not limited to: technical support, secondary development, source code sales, paid use. Please do not use this website for commercial purposes. Violators are responsible. </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">2. The resources resolved by the resource library and interface of our website are all from the network. Our website and the Administrator &amp;nbsp</span><span style=" font-size:large; font-weight:700; color:#ff0000;">do not do any video storage work</span><span style=" font-size:large; font-weight:700;">. All behaviors are the responsibility of the user. If you have any questions, please contact the mailbox at the bottom. </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">3. As a user, you have the right to use the website. If you need to use the website ,</span><span style=" font-size:large; font-weight:700; color:#ff0000;"> you must bear the legal obligations of these contents independently </span><span style=" font-size:large; font-weight:700;">. I am not responsible for any information content of the website and any copyright disputes and legal disputes caused by it. </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">4. This website has not found any major problems, but the risk assessment is high. If you use this website for your own free will, you must be aware of the risks. I do not provide any form of warranty or </span><span style=" font-size:large; font-weight:700; color:#ff0000;">assume any responsibility.</span><span style=" font-size:large; font-weight:700;">。 </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">5. When users use this webpage, </span><span style=" font-size:large; font-weight:700; color:#ff0000;">they are not allowed to engage in activities in violation of the relevant laws of the People's Republic of China.</span><span style=" font-size:large; font-weight:700;">I do not bear any responsibility for users' unauthorized use of this webpage to engage in illegal activities, including but not limited to criminal liability, administrative liability, civil liability, etc </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">6. The right to interpret and modify the above statement belongs to the web Administrator himself </span></h3> +<h3 style=" margin-top:14px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:large; font-weight:700;">Once you use this webpage, </span><span style=" font-size:large; font-weight:700; color:#ff0000;">it is deemed that</span><span style=" font-size:large; font-weight:700;">, you have agreed and accepted this statement </span></h3> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">如有任何问题请联系站长。站长邮箱:huajishe@gmail.com</p></body></html> + + + + + + 330 + 290 + 75 + 24 + + + + 我已阅读 + + + + + + 10 + 10 + 331 + 16 + + + + + + + + + + diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000..3d357d5 Binary files /dev/null and b/favicon.ico differ diff --git a/fontch.ui b/fontch.ui new file mode 100644 index 0000000..8391c08 --- /dev/null +++ b/fontch.ui @@ -0,0 +1,19 @@ + + + Fontch + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + diff --git a/information.ui b/information.ui new file mode 100644 index 0000000..448ddf5 --- /dev/null +++ b/information.ui @@ -0,0 +1,80 @@ + + + information + + + + 0 + 0 + 439 + 329 + + + + Form + + + + + 330 + 290 + 75 + 24 + + + + 我已阅读 + + + + + + 10 + 10 + 331 + 16 + + + + + + + + + + 20 + 20 + 381 + 201 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><meta charset="utf-8" /><style type="text/css"> +p, li { white-space: pre-wrap; } +hr { height: 1px; border-width: 0; } +li.unchecked::marker { content: "\2610"; } +li.checked::marker { content: "\2612"; } +</style></head><body style=" font-family:'Microsoft YaHei UI'; font-size:9pt; font-weight:400; font-style:normal;"> +<h2 style=" margin-top:16px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:120%; background-color:#ffffff;"><a name="滑稽社介绍"></a><span style=" font-family:'Helvetica Neue','Helvetica','Segoe UI','Arial','freesans','sans-serif'; font-size:x-large; font-weight:600; color:#000000; background-color:#ffffff;">滑</span><span style=" font-family:'Helvetica Neue','Helvetica','Segoe UI','Arial','freesans','sans-serif'; font-size:8pt; font-weight:600; color:#000000; background-color:#ffffff;">稽社介绍</span></h2> +<p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; background-color:#ffffff;"><span style=" font-family:'Helvetica Neue','Helvetica','Segoe UI','Arial','freesans','sans-serif'; font-size:10pt; font-weight:700; color:#000000;">滑稽社</span><span style=" font-family:'Helvetica Neue','Helvetica','Segoe UI','Arial','freesans','sans-serif'; font-size:8pt; color:#333333;">(Huaji Club)创立于2018年,是一个起源于“整活”精神、发展于技术热情的高校科技创业社团。我们以“自由探索、滑稽创新”为核心理念,致力于打造一个属于技术爱好者、开源精神拥护者和数字创客的乐园。</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Release Version: V1.0</p></body></html> + + + + + + 30 + 250 + 351 + 16 + + + + Copyright © 2018–2025 滑稽社 Huaji Club. All rights reserved. + + + + + + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..00bac14 --- /dev/null +++ b/main.cpp @@ -0,0 +1,509 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ui_mainwindow.h" +#include "ui_about.h" +#include "ui_information.h" +//#include "ui_fontch.h" + +int main(int argc, char* argv[]){ + QApplication app(argc, argv); + QIcon icon(":/favicon.ico"); + QMainWindow* M; + M = new QMainWindow(); + M->setWindowIcon(icon); + Ui::MainWindow* uu; + uu = new Ui::MainWindow(); + uu->setupUi(M); + uu->actionSave->setShortcut(QKeySequence::Save); + uu->actionOpen->setShortcut(QKeySequence::Open); + uu->actionNewFile->setShortcut(QKeySequence::New); + uu->actionDelete->setShortcut(QKeySequence::Delete); + QString dir; + +//左侧树状图 + QTreeView* tree = new QTreeView(M); + tree->resize(50,M->height()); + +//设置文件路径 + QFileSystemModel* model = new QFileSystemModel(M); + model->setRootPath(QDir::homePath()); + tree->setModel(model); + QString path = QDir::homePath(); + +//右侧的代码区 + QTextEdit* editor = new QTextEdit; + QFont codeFont("JetBrains Mono"); + codeFont.setPointSize(11); + editor->setFont(codeFont); + //editor->setText("

这里是右侧编辑器区域

"); + + // 在构造函数中添加 + QString placeholder = "这里是右侧编辑器区域"; + + editor->setTextColor(Qt::gray); + editor->setPlainText(placeholder); + + // 是否在显示提示文本 + bool showingPlaceholder = true; + + // 当文本编辑框获得焦点 + QObject::connect(editor, &QTextEdit::textChanged, M, [=]() mutable { + if (showingPlaceholder && editor->toPlainText() != placeholder && showingPlaceholder == true) { + showingPlaceholder = false; + editor->setTextColor(Qt::black); + editor->clear(); + + } + }); + + // 如果不想在 textChanged 中重复 setPlainText,可在 focusInEvent/focusOutEvent 中更优雅地控制(进阶可加) + +//NewFile的时候 + QObject::connect( + uu->actionNewFile, + &QAction::triggered, + M, + [&](){ + QString fileName = QFileDialog::getSaveFileName(M, "新建文件", QDir::homePath(), "所有文件 (*.*)"); + + if (!fileName.isEmpty()) { + QFile file(fileName); + QFileInfo fileinfo(fileName); + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { + file.close(); // 创建空文件(也可以先写入一些内容) + editor->clear(); + editor->setReadOnly(false); + path = fileinfo.absolutePath(); + //qDebug() << path << Qt::endl; + QMessageBox::information(M, "成功", "文件已创建: " + fileName); + model->setRootPath(path); + tree->setRootIndex(model->index(path)); + } else { + QMessageBox::warning(M, "失败", "无法创建文件: " + fileName); + } + + } + } + ); + +//Open的时候 + QObject::connect( + uu->actionOpen, + &QAction::triggered, + M, + [&](){ + dir = QFileDialog::getExistingDirectory(M, "选择一个目录", QDir::homePath()); + model->setRootPath(dir); + tree->setRootIndex(model->index(dir)); + } + ); + +//Delete的时候 + QObject::connect( + uu->actionDelete, + &QAction::triggered, + M, + [&]() + { + QModelIndex index = tree->currentIndex(); // 获取当前选中的项 + if (!index.isValid()) { + QMessageBox::warning(M, "未选择", "请先选中要删除的文件或目录。"); + return; + } + + QString paths = model->filePath(index); + QFileInfo info(paths); + + // 弹出确认对话框 + if (QMessageBox::question(M, "确认删除", "确定要删除吗?\n" + paths) + != QMessageBox::Yes) { + return; + } + + bool success = false; + if (info.isDir()) { + QDir dir(paths); + success = dir.removeRecursively(); // 删除整个目录 + } else { + QFile file(paths); + success = file.remove(); // 删除单个文件 + } + + if (success) { + QMessageBox::information(M, "删除成功", "已删除: " + paths); + // 刷新当前目录 + QString parentPath = info.absolutePath(); + model->setRootPath(""); + model->setRootPath(parentPath); + tree->setRootIndex(model->index(parentPath)); + editor->clear(); + } else { + QMessageBox::warning(M, "删除失败", "无法删除文件或目录。"); + } + } + ); + +//Save的时候 + QObject::connect( + uu->actionSave, + &QAction::triggered, + M, + [&](){ + //save + if (path.isEmpty()) { + QMessageBox::warning(M, "错误", "没有打开任何文件!"); + return; + } + + QFile file(path); + QFileInfo fileinfo(path); + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QString content = editor->toPlainText(); + file.write(content.toUtf8()); + file.close(); + QMessageBox::information(M, "保存成功", "文件已保存到:" + path); + QString w = fileinfo.absolutePath(); + model->setRootPath(""); + model->setRootPath(w); + tree->setRootIndex(model->index(w)); + } else { + QMessageBox::warning(M, "保存失败", "无法写入文件:" + path); + } + } + ); + +//SaveAs的时候 + QObject::connect( + uu->actionSaveas, + &QAction::triggered, + M, + [&](){ + QString saveas = QFileDialog::getSaveFileName(M, "另存为", path); + if (!saveas.isEmpty()) { + QFile file(saveas); + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { + QString content = editor->toPlainText(); + file.write(content.toUtf8()); + file.close(); + QMessageBox::information(M, "另存为成功", "文件已保存到:" + saveas); + } else { + QMessageBox::warning(M, "另存为失败", "无法写入文件:" + saveas); + } + } + else{ + QMessageBox::warning(M, "错误", "文件名称路径设置有误!"); + return; + } + } + ); + +//tree视图中打开代码 + QObject::connect( + tree, + &QTreeView::clicked, + M, + [&](const QModelIndex& index){ + path = model->filePath(index); + + QFileInfo info(path); + if (info.isFile()) { + QFile file(path); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QString content = file.readAll(); + editor->setPlainText(content); // 显示到右侧编辑器 + editor->setReadOnly(false); // 可编辑 + file.close(); + } else { + editor->setPlainText("无法打开文件:" + dir); + } + } else { + // 如果是目录可以忽略或清空右侧 + editor->clear(); + } + } + ); + + //把字体做了---------------------------------------------------------------------------- +//字体大小 + QObject::connect( + uu->actionSize, + &QAction::triggered, + M, + [&](){ + QDialog* dFont = new QDialog(M); + dFont->setWindowTitle("设置字体大小"); + dFont->resize(200,100); + + QLabel *label = new QLabel("请输入字体大小(px):", dFont); + QLineEdit* input = new QLineEdit(M); + input->setPlaceholderText("例如:16"); + + QPushButton *okButton = new QPushButton("确定", dFont); + QPushButton *cancelButton = new QPushButton("取消", dFont); + + QHBoxLayout *btnLayout = new QHBoxLayout(); + btnLayout->addWidget(okButton); + btnLayout->addWidget(cancelButton); + + QVBoxLayout *mainLayout = new QVBoxLayout(dFont); + mainLayout->addWidget(label); + mainLayout->addWidget(input); + mainLayout->addLayout(btnLayout); + + QObject::connect(okButton, &QPushButton::clicked, dFont, [&](){ + bool ok; + int fontSize = input->text().toInt(&ok); + if (ok && fontSize > 0) { + // 在这里添加设置字体大小的逻辑 + codeFont.setPointSize(fontSize); + editor->setFont(codeFont); + dFont->close(); + } else { + QMessageBox::warning(dFont, "错误", "请输入有效的字体大小"); + } + }); + QObject::connect(cancelButton, &QPushButton::clicked, dFont, [=](){ + dFont->close(); + }); + + dFont->exec(); + //exec是动态模,比较好,close可以关闭 + + } + ); + + +//字体设置(新窗口通过转盘选择) 大项目,把颜色,大小,字体等相关操作都融入进去 + //Ui::Fontch* fontch = new Ui::Fontch(); + //QWidget* fontset = new QWidget(); + //不能多次删改一个Widget + //fontch->setupUi(fontset); + QObject::connect(uu->actionFont,&QAction::triggered,M,[&](){ + QDialog* fontset = new QDialog(); + // 字体选择 + QFontComboBox *fontCombo = new QFontComboBox(fontset); + + // 字号选择 + QSpinBox *sizeSpin = new QSpinBox(fontset); + sizeSpin->setRange(6, 72); + sizeSpin->setValue(16); + + // 加粗、斜体 + QCheckBox *boldCheck = new QCheckBox("加粗", fontset); + QCheckBox *italicCheck = new QCheckBox("斜体", fontset); + + // 颜色选择按钮 + QPushButton *colorBtn = new QPushButton("选择颜色", fontset); + QColor currentColor = Qt::black; + + // 示例展示标签 + QLabel *previewLabel = new QLabel("字体预览", fontset); + previewLabel->setMinimumHeight(40); + previewLabel->setAlignment(Qt::AlignCenter); + + // 更新样式的函数 + auto updatePreview = [=, ¤tColor]() mutable { + QFont font(fontCombo->currentFont()); + font.setPointSize(sizeSpin->value()); + font.setBold(boldCheck->isChecked()); + font.setItalic(italicCheck->isChecked()); + previewLabel->setFont(font); + QPalette pal = previewLabel->palette(); + pal.setColor(QPalette::WindowText, currentColor); + previewLabel->setPalette(pal); + qDebug() << "ReNewed" << Qt::endl; + }; + + // 响应颜色按钮点击 + QObject::connect(colorBtn, &QPushButton::clicked, fontset, [=, ¤tColor]() mutable { + QColor color = QColorDialog::getColor(currentColor, fontset, "选择颜色"); + if (color.isValid()) { + currentColor = color; + updatePreview(); + } + }); + + // 连接所有变化信号 + QObject::connect(fontCombo, &QFontComboBox::currentFontChanged, fontset, updatePreview); + QObject::connect(sizeSpin, QOverload::of(&QSpinBox::valueChanged), fontset, updatePreview); + QObject::connect(boldCheck, &QCheckBox::toggled, fontset, updatePreview); + QObject::connect(italicCheck, &QCheckBox::toggled, fontset, updatePreview); + + //确定修改按钮 + QDialogButtonBox *buttonBoxs = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, fontset); + QObject::connect(buttonBoxs, &QDialogButtonBox::accepted, fontset, [=]() { + QFont finalFont = fontCombo->currentFont(); + finalFont.setPointSize(sizeSpin->value()); + finalFont.setBold(boldCheck->isChecked()); + finalFont.setItalic(italicCheck->isChecked()); + editor->setFont(finalFont); + + QPalette pal = editor->palette(); + pal.setColor(QPalette::Text, currentColor); // 注意你用的是 currentColor + editor->setPalette(pal); + + fontset->close(); + }); + + + // 布局整理 + QGridLayout *layout = new QGridLayout; + layout->addWidget(new QLabel("字体:"), 0, 0); + layout->addWidget(fontCombo, 0, 1); + layout->addWidget(new QLabel("大小:"), 1, 0); + layout->addWidget(sizeSpin, 1, 1); + layout->addWidget(new QLabel("颜色:"), 2, 0); + layout->addWidget(colorBtn, 2, 1, 1, 1); + layout->addWidget(boldCheck, 3, 1); + layout->addWidget(italicCheck, 3, 2); + layout->addWidget(previewLabel, 4, 0, 1, 2); + layout->addWidget(buttonBoxs, 5, 0); + // 你可以把 layout 放到设置页或主窗口中的某个容器里,比如: + fontset->setLayout(layout); + fontset->exec(); + }); + +//主页面 + QSplitter* mainsp = new QSplitter(); + mainsp->addWidget(tree); + mainsp->addWidget(editor); + M->setCentralWidget(mainsp); + //qDebug() << "第一处" << mainsp->sizes() << Qt::endl; + //mainsp->setSizes({2,8}); + //↑这里不能设置,窗口还没有初始化 + + +//关于部分的窗口设置 + QWidget* aboutq = new QWidget(); + +//关于-声明 + Ui::about* about; + about = new Ui::about; + about->setupUi(aboutq); + QObject::connect( + uu->actionStatement, + &QAction::triggered, + M, + [&]{ + + about->label->setText("

请认真阅读下列文字,阅读后点击“我已阅读”"); + aboutq->setWindowTitle("声明"); + aboutq->show(); + } + ); + + QObject::connect( + about->button, + &QPushButton::clicked, + M, + [&]{ + aboutq->close(); + } + ); + +//关于-信息 + Ui::information* info = new Ui::information(); + QWidget* abouti = new QWidget(); + info->setupUi(abouti); + QObject::connect( + uu->actionInformation, + &QAction::triggered, + M, + [&]{ + abouti->setWindowTitle("信息-Version1.0"); + abouti->show(); + } + ); + + QObject::connect( + info->button, + &QPushButton::clicked, + M, + [&]{ + abouti->close(); + } + ); +//关于-联系 + QObject::connect( + uu->actionHuajishe, + &QAction::triggered, + M, + [&]{ + QDesktopServices::openUrl(QUrl("https://huajishe.fun")); + } + ); + QObject::connect( + uu->actione2hang, + &QAction::triggered, + M, + [&]{ + QDesktopServices::openUrl(QUrl("https://huajishe.fun/forum")); + } + ); + + +//关于-查看进度 + QObject::connect( + uu->actiontutorial, + &QAction::triggered, + M, + [&]{ + QDesktopServices::openUrl(QUrl("https://huajishe.fun/help")); + } + ); + +//附加参数的启动方式 + + // 默认最大化 + bool modeSet = false; + + // 检查参数 + for (int i = 1; i < argc - 1; ++i) { + QString arg = argv[i]; + if (arg == "-window") { + QString mode = argv[i + 1]; + if (mode == "f") { + M->showFullScreen(); + modeSet = true; + } else if (mode == "m") { + M->showMaximized(); + modeSet = true; + } else if (mode == "s") { + M->show(); // 正常窗口 + modeSet = true; + } + break; // 找到 -window 后只处理一次 + } + } + + if (!modeSet) { + M->showMaximized(); // 默认最大化 + } + //qDebug() << "第二处" << mainsp->sizes() << Qt::endl; + int mwt, mwe; + mwt = M->width() * 0.2; + mwe = M->width() * 0.8; + mainsp->setSizes({ mwt , mwe }); + + qDebug() << "Success" << Qt::endl; + return app.exec(); +} diff --git a/main.qrc b/main.qrc new file mode 100644 index 0000000..5df7c82 --- /dev/null +++ b/main.qrc @@ -0,0 +1,5 @@ + + + favicon.ico + + diff --git a/mainwindow.ui b/mainwindow.ui new file mode 100644 index 0000000..0762a05 --- /dev/null +++ b/mainwindow.ui @@ -0,0 +1,146 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + HuajisheEditTool + + + + + + 0 + 0 + 800 + 22 + + + + false + + + + 帮助 + + + + 联系 + + + + + + + + + + + + + + + 设置 + + + + + + + 文件 + + + + + + + + + + + + + + + 关于 + + + + + 滑稽社官方 + + + + + E2hang + + + + + 打开目录 + + + + + 保存 + + + + + 声明 + + + + + 点击后会直接跳转到相关网页 + + + QAction::MenuRole::NoRole + + + + + 另存为 + + + + + 使用教程 + + + + + 新建文件 + + + + + 删除文件 + + + + + 字体 + + + + + 字体大小 + + + + + Version1.0 + + + + + +