htm文件增加插入<b>标签
This commit is contained in:
parent
c75a0f9a5e
commit
ae6fd93653
|
@ -4,7 +4,7 @@
|
|||
install.sh 可以生成 desktop,并发送到系统开始菜单。
|
||||

|
||||
### 已知问题
|
||||
从打开方式打开文件,文件只读无法保存。
|
||||
从打开方式打开文件,文件只读无法保存,需要新建一个标签再关闭才能够保存。
|
||||
### 参考:
|
||||
多文档编辑器:http://www.qter.org/portal.php?mod=view&aid=10
|
||||
编译、运行输出:https://github.com/m-iDev-0792/HJ-Editor
|
||||
|
|
|
@ -824,19 +824,38 @@ void MainWindow::anchorClick(QUrl url)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_action_p_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if (window != nullptr) {
|
||||
MdiChild *child = (MdiChild*)(window->widget());
|
||||
child->insertP();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_br_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if(window != nullptr){
|
||||
if (window != nullptr) {
|
||||
MdiChild *child = static_cast<MdiChild*>(window->widget());
|
||||
child->insertBR();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_b_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if (window != nullptr) {
|
||||
MdiChild *child = static_cast<MdiChild*>(window->widget());
|
||||
child->insertB();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_tr_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if(window != nullptr){
|
||||
if (window != nullptr) {
|
||||
MdiChild *child = (MdiChild*)(window->widget());
|
||||
child->insertTR();
|
||||
}
|
||||
|
@ -845,25 +864,16 @@ void MainWindow::on_action_tr_triggered()
|
|||
void MainWindow::on_action_td_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if(window != nullptr){
|
||||
if (window != nullptr) {
|
||||
MdiChild *child = (MdiChild*)(window->widget());
|
||||
child->insertTD();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_p_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if(window != nullptr){
|
||||
MdiChild *child = (MdiChild*)(window->widget());
|
||||
child->insertP();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_action_div_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if(window != nullptr){
|
||||
if (window != nullptr) {
|
||||
MdiChild *child = (MdiChild*)(window->widget());
|
||||
child->insertDIV(lineEdit_command->text());
|
||||
}
|
||||
|
@ -872,7 +882,7 @@ void MainWindow::on_action_div_triggered()
|
|||
void MainWindow::on_action_a_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if(window != nullptr){
|
||||
if (window != nullptr) {
|
||||
MdiChild *child = (MdiChild*)(window->widget());
|
||||
child->insertA(lineEdit_command->text());
|
||||
}
|
||||
|
@ -881,7 +891,7 @@ void MainWindow::on_action_a_triggered()
|
|||
void MainWindow::on_action_img_triggered()
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if(window != nullptr){
|
||||
if (window != nullptr) {
|
||||
MdiChild *child = (MdiChild*)(window->widget());
|
||||
child->insertImg(lineEdit_command->text());
|
||||
}
|
||||
|
@ -908,7 +918,7 @@ void MainWindow::on_action_deleteBR_triggered()
|
|||
void MainWindow::comboBoxHChanged(QString s)
|
||||
{
|
||||
QMdiSubWindow *window = ui->mdiArea->currentSubWindow();
|
||||
if(window != nullptr){
|
||||
if (window != nullptr) {
|
||||
MdiChild *child = (MdiChild*)(window->widget());
|
||||
child->insertH(s);
|
||||
}
|
||||
|
|
|
@ -64,10 +64,11 @@ private slots:
|
|||
void on_action_find_triggered();
|
||||
void on_action_indent_triggered();
|
||||
void on_action_font_triggered();
|
||||
void on_action_br_triggered();
|
||||
void on_action_tr_triggered();
|
||||
void on_action_td_triggered();
|
||||
void on_action_p_triggered();
|
||||
void on_action_br_triggered();
|
||||
void on_action_b_triggered();
|
||||
void on_action_tr_triggered();
|
||||
void on_action_td_triggered();
|
||||
void on_action_div_triggered();
|
||||
void on_action_a_triggered();
|
||||
void on_action_img_triggered();
|
||||
|
|
|
@ -154,10 +154,11 @@
|
|||
</attribute>
|
||||
<addaction name="action_font"/>
|
||||
<addaction name="action_run"/>
|
||||
<addaction name="action_p"/>
|
||||
<addaction name="action_br"/>
|
||||
<addaction name="action_b"/>
|
||||
<addaction name="action_tr"/>
|
||||
<addaction name="action_td"/>
|
||||
<addaction name="action_p"/>
|
||||
<addaction name="action_div"/>
|
||||
<addaction name="action_a"/>
|
||||
<addaction name="action_img"/>
|
||||
|
@ -565,12 +566,18 @@
|
|||
</action>
|
||||
<action name="action_exportHTML">
|
||||
<property name="icon">
|
||||
<iconset theme="text-html"/>
|
||||
<iconset theme="text-html">
|
||||
<normaloff>.</normaloff>.</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>导出HTML</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_b">
|
||||
<property name="text">
|
||||
<string>b</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
|
39
mdichild.cpp
39
mdichild.cpp
|
@ -262,11 +262,34 @@ void MdiChild::setReadOnlyA(bool b)
|
|||
setReadOnly(b);
|
||||
}
|
||||
|
||||
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++) {
|
||||
if (SL.at(i) != "") {
|
||||
s += "<p>" + SL.at(i) + "</p>";
|
||||
if (i < SL.length()-1)
|
||||
s += "\n";
|
||||
}
|
||||
}
|
||||
textCursor().insertText(s);
|
||||
}
|
||||
|
||||
void MdiChild::insertBR()
|
||||
{
|
||||
textCursor().insertText("<br>");
|
||||
}
|
||||
|
||||
void MdiChild::insertB()
|
||||
{
|
||||
QString s = textCursor().selection().toPlainText();
|
||||
s = "<b>" + s + "</b>";
|
||||
textCursor().insertText(s);
|
||||
}
|
||||
|
||||
void MdiChild::insertH(QString h)
|
||||
{
|
||||
QString s = textCursor().selection().toPlainText(); //可以显示换行符
|
||||
|
@ -312,22 +335,6 @@ void MdiChild::insertTD()
|
|||
textCursor().insertText(s);
|
||||
}
|
||||
|
||||
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++) {
|
||||
if (SL.at(i) != "") {
|
||||
s += "<p>" + SL.at(i) + "</p>";
|
||||
if (i < SL.length()-1)
|
||||
s += "\n";
|
||||
}
|
||||
}
|
||||
textCursor().insertText(s);
|
||||
}
|
||||
|
||||
void MdiChild::insertDIV(QString se)
|
||||
{
|
||||
QString s = textCursor().selection().toPlainText();
|
||||
|
|
|
@ -18,11 +18,12 @@ public:
|
|||
bool saveHTML(QString);
|
||||
void lineNumberAreaPaintEvent(QPaintEvent *event);
|
||||
int lineNumberAreaWidth();
|
||||
void insertH(QString h);
|
||||
void insertTR();
|
||||
void insertTD();
|
||||
void insertP();
|
||||
void insertBR();
|
||||
void insertB();
|
||||
void insertH(QString h);
|
||||
void insertTR();
|
||||
void insertTD();
|
||||
void insertDIV(QString se);
|
||||
void insertA(QString se);
|
||||
void insertImg(QString se);
|
||||
|
|
Loading…
Reference in New Issue