增加插入a元素,优化插入p元素
This commit is contained in:
parent
d6968574ba
commit
e3b37a61b2
|
@ -1,3 +1,3 @@
|
|||
s="[Desktop Entry]\nName=海天鹰编辑器\nComment=Text Editor\nExec=`pwd`/HTYEdit %u\nIcon=`pwd`/HTYEdit.png\nPath=`pwd`\nTerminal=false\nType=Application\nMimeType=text/plain;text/html;image/svg+xml;\nCategories=TextEditor;"
|
||||
s="[Desktop Entry]\nName=海天鹰编辑器\nComment=Text Editor\nExec=`pwd`/HTYEdit %u\nIcon=`pwd`/HTYEdit.png\nPath=`pwd`\nTerminal=false\nType=Application\nMimeType=text/plain;text/html;image/svg+xml;\nCategories=TextEditor;Utility;"
|
||||
echo -e $s > HTYEdit.desktop
|
||||
cp `pwd`/HTYEdit.desktop ~/.local/share/applications/HTYEdit.desktop
|
|
@ -114,7 +114,7 @@ void MainWindow::on_action_aboutQt_triggered()
|
|||
|
||||
void MainWindow::on_action_about_triggered()
|
||||
{
|
||||
QMessageBox aboutMB(QMessageBox::NoIcon, "关于", "海天鹰编辑器 1.10\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 aboutMB(QMessageBox::NoIcon, "关于", "海天鹰编辑器 1.10\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");
|
||||
aboutMB.setIconPixmap(QPixmap(":/HTYEdit.png"));
|
||||
aboutMB.setWindowIcon(QIcon(":/HTYEdit.png"));
|
||||
aboutMB.exec();
|
||||
|
@ -676,8 +676,8 @@ void MainWindow::updateCommand()
|
|||
} else if (suffix == "sh") {
|
||||
lineEdit_command->setText("./%1");
|
||||
} else {
|
||||
lineEdit_command->setText("");
|
||||
ui->textBrowser->hide();
|
||||
//lineEdit_command->setText("");
|
||||
//ui->textBrowser->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -762,6 +762,24 @@ void MainWindow::on_action_p_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_div_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if(window != 0){
|
||||
MdiChild *child = (MdiChild*)(window->widget());
|
||||
child->insertDIV(lineEdit_command->text());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_a_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if(window != 0){
|
||||
MdiChild *child = (MdiChild*)(window->widget());
|
||||
child->insertA(lineEdit_command->text());
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::comboBoxHChanged(QString s)
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
|
|
|
@ -64,6 +64,8 @@ private slots:
|
|||
void on_action_tr_triggered();
|
||||
void on_action_td_triggered();
|
||||
void on_action_p_triggered();
|
||||
void on_action_div_triggered();
|
||||
void on_action_a_triggered();
|
||||
void find();
|
||||
void replace();
|
||||
void replaceAll();
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>28</height>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu">
|
||||
|
@ -149,6 +149,8 @@
|
|||
<addaction name="action_tr"/>
|
||||
<addaction name="action_td"/>
|
||||
<addaction name="action_p"/>
|
||||
<addaction name="action_div"/>
|
||||
<addaction name="action_a"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="action_new">
|
||||
|
@ -484,6 +486,31 @@
|
|||
<string>Ctrl+Alt+P</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_div">
|
||||
<property name="text">
|
||||
<string>div</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Ctrl+Alt+D</string>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font/>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Alt+D</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_a">
|
||||
<property name="text">
|
||||
<string>a</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Ctrl+Shift+A</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Shift+A</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
|
32
mdichild.cpp
32
mdichild.cpp
|
@ -286,6 +286,7 @@ void MdiChild::insertTD()
|
|||
void MdiChild::insertP()
|
||||
{
|
||||
QString s = textCursor().selection().toPlainText();
|
||||
s = s.replace("<br>", "\n");
|
||||
QStringList SL = s.split("\n");
|
||||
s = "";
|
||||
for (int i=0; i<SL.length(); i++) {
|
||||
|
@ -296,4 +297,35 @@ void MdiChild::insertP()
|
|||
}
|
||||
}
|
||||
textCursor().insertText(s);
|
||||
}
|
||||
|
||||
void MdiChild::insertDIV(QString s1)
|
||||
{
|
||||
QString s = textCursor().selection().toPlainText();
|
||||
QStringList SL = s.split("\n");
|
||||
s = "";
|
||||
for (int i=0; i<SL.length(); i++) {
|
||||
if (SL.at(i) != "") {
|
||||
s += "<div" + s1 + ">" + SL.at(i) + "</div>";
|
||||
if (i < SL.length()-1)
|
||||
s += "\n";
|
||||
}
|
||||
}
|
||||
textCursor().insertText(s);
|
||||
}
|
||||
|
||||
void MdiChild::insertA(QString s1)
|
||||
{
|
||||
//正则去链接("/<a[^>]*>(.*?)<\/a>/is", "$1")
|
||||
QString s = textCursor().selection().toPlainText();
|
||||
QStringList SL = s.split("\n");
|
||||
s = "";
|
||||
for (int i=0; i<SL.length(); i++) {
|
||||
if (SL.at(i) != "") {
|
||||
s += "<a " + s1 + ">" + SL.at(i) + "</a>";
|
||||
if (i < SL.length()-1)
|
||||
s += "\n";
|
||||
}
|
||||
}
|
||||
textCursor().insertText(s);
|
||||
}
|
|
@ -20,6 +20,8 @@ public:
|
|||
void insertTR();
|
||||
void insertTD();
|
||||
void insertP();
|
||||
void insertDIV(QString s1);
|
||||
void insertA(QString s1);
|
||||
|
||||
private:
|
||||
QSettings settings;
|
||||
|
|
Loading…
Reference in New Issue