增加段注释
This commit is contained in:
parent
ae6fd93653
commit
522da385d1
|
@ -179,9 +179,40 @@ void MainWindow::on_action_aboutQt_triggered()
|
|||
QMessageBox::aboutQt(nullptr, "关于 Qt");
|
||||
}
|
||||
|
||||
void MainWindow::on_action_help_triggered()
|
||||
{
|
||||
QString s = "<h3 align='center'>快捷键</h3>"
|
||||
"<table align='center'>"
|
||||
"<tr><td>Ctrl + /</td><td>行注释</td></tr>"
|
||||
"<tr><td>Ctrl + *</td><td>段注释</td></tr>"
|
||||
"<tr><td>Ctrl + 鼠标滚轮</td><td>改变线粗或字体大小</td></tr>"
|
||||
"<table>";
|
||||
QDialog *dialog = new QDialog;
|
||||
dialog->setWindowTitle("帮助");
|
||||
dialog->setWindowIcon(QIcon(":/HTYEdit.png"));
|
||||
dialog->setFixedSize(400,300);
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
QTextBrowser *textBrowser = new QTextBrowser;
|
||||
textBrowser->setHtml(s);
|
||||
textBrowser->zoomIn();
|
||||
vbox->addWidget(textBrowser);
|
||||
QHBoxLayout *hbox = new QHBoxLayout;
|
||||
QPushButton *pushButton_confirm = new QPushButton("确定");
|
||||
hbox->addStretch();
|
||||
hbox->addWidget(pushButton_confirm);
|
||||
hbox->addStretch();
|
||||
vbox->addLayout(hbox);
|
||||
dialog->setLayout(vbox);
|
||||
dialog->show();
|
||||
connect(pushButton_confirm, SIGNAL(clicked()), dialog, SLOT(accept()));
|
||||
if (dialog->exec() == QDialog::Accepted) {
|
||||
dialog->close();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_about_triggered()
|
||||
{
|
||||
QMessageBox MB(QMessageBox::NoIcon, "关于", "海天鹰编辑器 1.14\n\n一款基于 Qt 的文本编辑程序。\n作者:海天鹰\nE-mail: sonichy@163.com\n主页:https://github.com/sonichy\n参考文献:\n多文档编辑器:http://www.qter.org/?page_id=161\nQMdiArea基本用法:http://www.mamicode.com/info-detail-1607476.html\n保存文本:http://blog.csdn.net/neicole/article/details/7330234\n语法高亮:http://www.cnblogs.com/lenxvp/p/5475931.html\n拖放打开文件:http://blog.csdn.net/rl529014/article/details/53057577\n行号:http://doc.qt.io/qt-5/qtwidgets-widgets-codeeditor-example.html");
|
||||
QMessageBox MB(QMessageBox::NoIcon, "关于", "海天鹰编辑器 1.15\n\n一款基于 Qt 的文本编辑程序。\n作者:海天鹰\nE-mail: sonichy@163.com\n主页:https://github.com/sonichy\n参考文献:\n多文档编辑器:http://www.qter.org/?page_id=161\nQMdiArea基本用法:http://www.mamicode.com/info-detail-1607476.html\n保存文本:http://blog.csdn.net/neicole/article/details/7330234\n语法高亮:http://www.cnblogs.com/lenxvp/p/5475931.html\n拖放打开文件:http://blog.csdn.net/rl529014/article/details/53057577\n行号:http://doc.qt.io/qt-5/qtwidgets-widgets-codeeditor-example.html");
|
||||
MB.setIconPixmap(QPixmap(":/HTYEdit.png"));
|
||||
MB.setWindowIcon(QIcon(":/HTYEdit.png"));
|
||||
MB.exec();
|
||||
|
@ -189,9 +220,10 @@ void MainWindow::on_action_about_triggered()
|
|||
|
||||
void MainWindow::on_action_changelog_triggered()
|
||||
{
|
||||
QString s = "1.14\n2025-06\n增加导出HTML。\n\n1.13\n2025-03\n修复 file:\\\\ 协议打不开问题。\n修改log路径。\n\n1.12\n2021-01\n修复img去属性,增加删除标签、删除换行。\n\n1.11\n2019-12\n优化排版,增加选中多行Tab缩进。\n\n1.10\n2019-08\n增加:字符数统计。\nHTML排版,增加选中文本分行插入td、tr、p、h1~h6的工具。\n\n1.9\n2019-04\n便签右键菜单增加打开文件路径。\n换行自动缩进。\n快捷键 Ctrl+/ 注释、取消注释选中行。\n保存窗口大小,保存字体设置,设置是否显示输出窗口。\n\n1.8\n2018-11\n使用系统主题图标代替Qt内置图标。\n\n1.7\n2018-10\n支持拖放打开多个文件。\n增加打开文件log。\n打开方式文件路径兼容深度文管和其他文管。\n\n1.6\n2018-09\n标签右键增加只读菜单。\n优化括号补全。\n\n1.5\n2018-08\n增加行号\n增加java文件编译命令\n\n1.4\n2018-07\n设置QTextEdit的Tab跳过的空格数为4个空格\n\n1.3\n2018-06\n增加调试窗口。\n\n1.2\n2018-05\n增加c、cpp的OpenGL编译命令。\n2018-05\n解决右键打开方式无法打开文件问题。\n增加运行python。\n2018-04\n增加打印功能。\n\n1.1\n2017-10\n增加获取文本编码(使用 file --mime-encoding 命令返回),但是没有解决乱码问题。\n排版实验。\n用文本框代替消息框显示更新日志。\n2017-07\n增加拖放打开文件。\n2017-06\n增加语法高亮。\n提取打开文件的相对路径,使Markdown预览能够载入相对路径图片。\n\n1.0\n2017-03\n支持命令行打开文件和打开方式打开文件。\n查找窗口填入选中文本。\n2017-02\n根据文件扩展名选择语法高亮方案。\nJS语法高亮实验成功!\nHTML语法高亮实验成功!\n增加设置字体。\n设置状态栏左右边距。\n2017-01\n实现全部替换。\n设置循环查找。\n增加查找替换窗体和功能。\n根据文件扩展名决定是否使用默认程序打开,如htm。\n优化保存、另存为和文本修动标题标记逻辑。\n增加撤销,重做,子窗标题文本改动标识。\n增加子窗体类,实现Ctrl+滚轮缩放和保存打开文件的路径。\n增加使用默认程序预览文件。\n把上一个打开或保存的路径设置为打开或保存对话框的默认路径和文件名。\n增加放大、缩小。\n增加文本光标变化信号,光标所在行列显示在状态栏第二栏。\n状态栏分为2栏\n修复没有子窗口时预览引起的崩溃。\n增加预览功能。\n保存成功。\n修改字体颜色,背景色成功。\n新建文件成功,打开文件载入成功。\n选用QMdiArea作为主控件,增加窗口标签、平铺、层叠菜单。 \n制作主要菜单。";
|
||||
QString s = "1.15\n2025-08\n增加段注释。\n\n1.14\n2025-06\n增加导出HTML。\n\n1.13\n2025-03\n修复 file:\\\\ 协议打不开问题。\n修改log路径。\n\n1.12\n2021-01\n修复img去属性,增加删除标签、删除换行。\n\n1.11\n2019-12\n优化排版,增加选中多行Tab缩进。\n\n1.10\n2019-08\n增加:字符数统计。\nHTML排版,增加选中文本分行插入td、tr、p、h1~h6的工具。\n\n1.9\n2019-04\n便签右键菜单增加打开文件路径。\n换行自动缩进。\n快捷键 Ctrl+/ 注释、取消注释选中行。\n保存窗口大小,保存字体设置,设置是否显示输出窗口。\n\n1.8\n2018-11\n使用系统主题图标代替Qt内置图标。\n\n1.7\n2018-10\n支持拖放打开多个文件。\n增加打开文件log。\n打开方式文件路径兼容深度文管和其他文管。\n\n1.6\n2018-09\n标签右键增加只读菜单。\n优化括号补全。\n\n1.5\n2018-08\n增加行号\n增加java文件编译命令\n\n1.4\n2018-07\n设置QTextEdit的Tab跳过的空格数为4个空格\n\n1.3\n2018-06\n增加调试窗口。\n\n1.2\n2018-05\n增加c、cpp的OpenGL编译命令。\n2018-05\n解决右键打开方式无法打开文件问题。\n增加运行python。\n2018-04\n增加打印功能。\n\n1.1\n2017-10\n增加获取文本编码(使用 file --mime-encoding 命令返回),但是没有解决乱码问题。\n排版实验。\n用文本框代替消息框显示更新日志。\n2017-07\n增加拖放打开文件。\n2017-06\n增加语法高亮。\n提取打开文件的相对路径,使Markdown预览能够载入相对路径图片。\n\n1.0\n2017-03\n支持命令行打开文件和打开方式打开文件。\n查找窗口填入选中文本。\n2017-02\n根据文件扩展名选择语法高亮方案。\nJS语法高亮实验成功!\nHTML语法高亮实验成功!\n增加设置字体。\n设置状态栏左右边距。\n2017-01\n实现全部替换。\n设置循环查找。\n增加查找替换窗体和功能。\n根据文件扩展名决定是否使用默认程序打开,如htm。\n优化保存、另存为和文本修动标题标记逻辑。\n增加撤销,重做,子窗标题文本改动标识。\n增加子窗体类,实现Ctrl+滚轮缩放和保存打开文件的路径。\n增加使用默认程序预览文件。\n把上一个打开或保存的路径设置为打开或保存对话框的默认路径和文件名。\n增加放大、缩小。\n增加文本光标变化信号,光标所在行列显示在状态栏第二栏。\n状态栏分为2栏\n修复没有子窗口时预览引起的崩溃。\n增加预览功能。\n保存成功。\n修改字体颜色,背景色成功。\n新建文件成功,打开文件载入成功。\n选用QMdiArea作为主控件,增加窗口标签、平铺、层叠菜单。 \n制作主要菜单。";
|
||||
QDialog *dialog = new QDialog;
|
||||
dialog->setWindowTitle("更新历史");
|
||||
dialog->setWindowIcon(QIcon(":/HTYEdit.png"));
|
||||
dialog->setFixedSize(400, 300);
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
QTextBrowser *textBrowser = new QTextBrowser;
|
||||
|
|
|
@ -50,6 +50,7 @@ private slots:
|
|||
void on_action_printPreview_triggered();
|
||||
void on_action_theme_triggered();
|
||||
void on_action_changelog_triggered();
|
||||
void on_action_help_triggered();
|
||||
void on_action_aboutQt_triggered();
|
||||
void on_action_about_triggered();
|
||||
void on_action_subWindowView_triggered();
|
||||
|
|
|
@ -108,6 +108,7 @@
|
|||
<property name="title">
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
<addaction name="action_help"/>
|
||||
<addaction name="action_changelog"/>
|
||||
<addaction name="action_aboutQt"/>
|
||||
<addaction name="action_about"/>
|
||||
|
@ -332,8 +333,7 @@
|
|||
</action>
|
||||
<action name="action_aboutQt">
|
||||
<property name="icon">
|
||||
<iconset theme="help-faq">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
<iconset theme="help-about"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>关于Qt</string>
|
||||
|
@ -578,6 +578,14 @@
|
|||
<string>b</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_help">
|
||||
<property name="icon">
|
||||
<iconset theme="help-faq"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>帮助</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
|
18
mdichild.cpp
18
mdichild.cpp
|
@ -147,6 +147,7 @@ void MdiChild::wheelEvent(QWheelEvent *e)
|
|||
|
||||
void MdiChild::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
//qDebug() << e;
|
||||
// 自动补全
|
||||
if (e->key() == Qt::Key_ParenLeft) {
|
||||
insertPlainText("()");
|
||||
|
@ -157,7 +158,7 @@ void MdiChild::keyPressEvent(QKeyEvent *e)
|
|||
} else if (e->key() == Qt::Key_BracketLeft) {
|
||||
insertPlainText("[]");
|
||||
moveCursor(QTextCursor::Left, QTextCursor::MoveAnchor);
|
||||
} else if ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_Slash) {// Ctrl+/ 注释选中行
|
||||
} else if ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_Slash) { // Ctrl+/ 注释选中行
|
||||
QString s = textCursor().selection().toPlainText();
|
||||
QStringList SL = s.split("\n");
|
||||
for (int i=0; i<SL.length(); i++) {
|
||||
|
@ -170,14 +171,25 @@ void MdiChild::keyPressEvent(QKeyEvent *e)
|
|||
if (i<SL.length()-1) s.append("\n");
|
||||
textCursor().insertText(s);
|
||||
}
|
||||
} else if ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_Asterisk) { // Ctrl+* 注释选中段
|
||||
QString s = textCursor().selection().toPlainText();
|
||||
if (s.startsWith(QString("/*").trimmed()) && s.endsWith(QString("*/").trimmed())) {
|
||||
s = s.replace("/*", "").replace("*/", "");
|
||||
} else {
|
||||
if (s.contains("\n"))
|
||||
s = "/*\n" + s + "\n*/";
|
||||
else
|
||||
s = "/* " + s + " */";
|
||||
}
|
||||
textCursor().insertText(s);
|
||||
} else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {//auto indent
|
||||
QString s = textCursor().block().text(); //当前行字符串
|
||||
QString st = s.trimmed(); //去首尾空格后的字符串
|
||||
QString ws = s.mid(0, s.indexOf(st)); //字符串前面的空白
|
||||
qDebug() << ws;
|
||||
if(st.endsWith("{")){
|
||||
if (st.endsWith("{")) {
|
||||
textCursor().insertText("\n\t" + ws); //插入换行 + tab + 行首空白字符(缩进)
|
||||
}else{
|
||||
} else {
|
||||
textCursor().insertText("\n" + ws); //插入换行 + 行首空白字符(不缩进)
|
||||
}
|
||||
} else if (e->key() == Qt::Key_Tab) { //选中每行前插入一个tab
|
||||
|
|
Loading…
Reference in New Issue