-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.cpp
More file actions
97 lines (55 loc) · 2.33 KB
/
edit.cpp
File metadata and controls
97 lines (55 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QPalette>
void MainWindow::findtext()
{
this->wfind = new FindWindow;
connect(this->wfind, &FindWindow::Send_findInfo, this, &MainWindow::findintext);
wfind->show();
}
void MainWindow::findintext(const QString & exp, unsigned char rule)
{
if(rule == 0)
{
if(!this->ui->textEdit->find(exp, QTextDocument::FindBackward))
{
QMessageBox::information(this, tr("查找"), tr("已查找全部:") + exp, QMessageBox::Ok, QMessageBox::Ok);
wfind->raise();
}
else
{
QPalette palette = ui->textEdit->palette();
palette.setColor(QPalette::Highlight,palette.color(QPalette::Active,QPalette::Highlight));
ui->textEdit->setPalette(palette);
}
}
}
void MainWindow::autoCheckLine(bool checked)
{
if(checked)
{
ui->textEdit->setLineWrapMode(QTextEdit::WidgetWidth);
}
else
{
ui->textEdit->setLineWrapMode(QTextEdit::NoWrap);
}
}
void MainWindow::edit_init()
{
this->ui->actionUndo_U->setEnabled(false);
this->ui->actionReundo_R->setEnabled(false);
this->ui->actionCopy_C->setEnabled(false);
connect(this->ui->actionclear, &QAction::triggered, this->ui->textEdit, &QTextEdit::clear);
connect(this->ui->actionUndo_U, &QAction::triggered, this->ui->textEdit, &QTextEdit::undo);
connect(this->ui->actionReundo_R, &QAction::triggered, this->ui->textEdit, &QTextEdit::redo);
connect(this->ui->actionCopy_C, &QAction::triggered, this->ui->textEdit, &QTextEdit::copy);
connect(this->ui->action_Paste_V, &QAction::triggered, this->ui->textEdit, &QTextEdit::paste);
connect(this->ui->actionselectall, &QAction::triggered, this->ui->textEdit, &QTextEdit::selectAll);
connect(this->ui->action_Cut_X, &QAction::triggered, this->ui->textEdit, &QTextEdit::cut);
connect(this->ui->textEdit, &QTextEdit::undoAvailable, this->ui->actionUndo_U, &QAction::setEnabled);
connect(this->ui->textEdit, &QTextEdit::redoAvailable, this->ui->actionReundo_R, &QAction::setEnabled);
connect(this->ui->textEdit,&QTextEdit::copyAvailable, this->ui->actionCopy_C, &QAction::setEnabled);
connect(this->ui->textEdit, &QTextEdit::cursorPositionChanged, this, &MainWindow::get_cursor);
}