add of setbold, setItalic, setUnderlined and setFontColor functions
This commit is contained in:
parent
f8cac1aeff
commit
65e391412e
1
data.qrc
1
data.qrc
@ -19,5 +19,6 @@
|
|||||||
<file>data/images/save_as.png</file>
|
<file>data/images/save_as.png</file>
|
||||||
<file>data/images/underline.png</file>
|
<file>data/images/underline.png</file>
|
||||||
<file>data/images/add.png</file>
|
<file>data/images/add.png</file>
|
||||||
|
<file>data/images/font-color.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
BIN
data/images/font-color.png
Normal file
BIN
data/images/font-color.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
@ -6,6 +6,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QTextEdit>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
@ -212,3 +213,91 @@ void MainWindow::on_actionEditCut_triggered()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setBold(){
|
||||||
|
QWidget *focused = QApplication::focusWidget();
|
||||||
|
QTextEdit* textEdit = qobject_cast<QTextEdit*>(focused);
|
||||||
|
|
||||||
|
if (textEdit) {
|
||||||
|
QTextCursor cursor = textEdit->textCursor();
|
||||||
|
if (cursor.hasSelection()) {
|
||||||
|
QTextCharFormat format;
|
||||||
|
QFont font = textEdit->currentFont();
|
||||||
|
font.setBold(!font.bold());
|
||||||
|
format.setFont(font);
|
||||||
|
cursor.mergeCharFormat(format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionBold_triggered()
|
||||||
|
{
|
||||||
|
this->setBold();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::setItalic(){
|
||||||
|
QWidget *focused = QApplication::focusWidget();
|
||||||
|
QTextEdit* textEdit = qobject_cast<QTextEdit*>(focused);
|
||||||
|
|
||||||
|
if (textEdit) {
|
||||||
|
QTextCursor cursor = textEdit->textCursor();
|
||||||
|
if (cursor.hasSelection()) {
|
||||||
|
QTextCharFormat format;
|
||||||
|
QFont font = textEdit->currentFont();
|
||||||
|
font.setItalic(!font.italic());
|
||||||
|
format.setFont(font);
|
||||||
|
cursor.mergeCharFormat(format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionItalic_triggered()
|
||||||
|
{
|
||||||
|
this->setItalic();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::setUnderline(){
|
||||||
|
QWidget *focused = QApplication::focusWidget();
|
||||||
|
QTextEdit* textEdit = qobject_cast<QTextEdit*>(focused);
|
||||||
|
|
||||||
|
if (textEdit) {
|
||||||
|
QTextCursor cursor = textEdit->textCursor();
|
||||||
|
if (cursor.hasSelection()) {
|
||||||
|
QTextCharFormat format;
|
||||||
|
QFont font = textEdit->currentFont();
|
||||||
|
font.setUnderline(!font.underline());
|
||||||
|
format.setFont(font);
|
||||||
|
cursor.mergeCharFormat(format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionUnderline_triggered()
|
||||||
|
{
|
||||||
|
this->setUnderline();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::setColor(){
|
||||||
|
QWidget *focused = QApplication::focusWidget();
|
||||||
|
QTextEdit* textEdit = qobject_cast<QTextEdit*>(focused);
|
||||||
|
|
||||||
|
if (textEdit) {
|
||||||
|
QTextCursor cursor = textEdit->textCursor();
|
||||||
|
if (cursor.hasSelection()) {
|
||||||
|
QTextCharFormat format;
|
||||||
|
format.setForeground(QBrush(QColor(255,0,0)));
|
||||||
|
cursor.mergeCharFormat(format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionColor_triggered()
|
||||||
|
{
|
||||||
|
this->setColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
12
mainwindow.h
12
mainwindow.h
@ -26,6 +26,10 @@ public:
|
|||||||
void addNewPath();
|
void addNewPath();
|
||||||
void addNewStep();
|
void addNewStep();
|
||||||
void exportHTMLMap();
|
void exportHTMLMap();
|
||||||
|
void setBold();
|
||||||
|
void setItalic();
|
||||||
|
void setUnderline();
|
||||||
|
void setColor();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
@ -43,6 +47,14 @@ private slots:
|
|||||||
|
|
||||||
void on_actionEditCut_triggered();
|
void on_actionEditCut_triggered();
|
||||||
|
|
||||||
|
void on_actionBold_triggered();
|
||||||
|
|
||||||
|
void on_actionItalic_triggered();
|
||||||
|
|
||||||
|
void on_actionUnderline_triggered();
|
||||||
|
|
||||||
|
void on_actionColor_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QString currentFile;
|
QString currentFile;
|
||||||
|
|||||||
@ -38,9 +38,6 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Path information</string>
|
<string>Path information</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -52,10 +49,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::Shape::StyledPanel</enum>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Shadow::Raised</enum>
|
|
||||||
</property>
|
</property>
|
||||||
<widget class="QSpinBox" name="spinBox">
|
<widget class="QSpinBox" name="spinBox">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@ -279,19 +273,23 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Step information</string>
|
<string>Step information</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="frame_2">
|
<widget class="QFrame" name="frame_2">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::Shape::StyledPanel</enum>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Shadow::Raised</enum>
|
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QTextEdit" name="textEdit">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>250</x>
|
||||||
|
<y>100</y>
|
||||||
|
<width>391</width>
|
||||||
|
<height>121</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -302,7 +300,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>800</width>
|
||||||
<height>23</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
@ -344,6 +342,10 @@
|
|||||||
<addaction name="actionEditUndo"/>
|
<addaction name="actionEditUndo"/>
|
||||||
<addaction name="actionEditRedo"/>
|
<addaction name="actionEditRedo"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionColor"/>
|
||||||
|
<addaction name="actionBold"/>
|
||||||
|
<addaction name="actionItalic"/>
|
||||||
|
<addaction name="actionUnderline"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionOpen">
|
<action name="actionOpen">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -378,7 +380,7 @@
|
|||||||
<string>New File</string>
|
<string>New File</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSaveFile">
|
<action name="actionSaveFile">
|
||||||
@ -390,7 +392,7 @@
|
|||||||
<string>Save</string>
|
<string>Save</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSaveAsFile">
|
<action name="actionSaveAsFile">
|
||||||
@ -402,7 +404,7 @@
|
|||||||
<string>Save as</string>
|
<string>Save as</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionPrintFile">
|
<action name="actionPrintFile">
|
||||||
@ -414,7 +416,7 @@
|
|||||||
<string>Print</string>
|
<string>Print</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionEditCopy">
|
<action name="actionEditCopy">
|
||||||
@ -426,7 +428,7 @@
|
|||||||
<string>Copy</string>
|
<string>Copy</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionEditPaste">
|
<action name="actionEditPaste">
|
||||||
@ -438,7 +440,7 @@
|
|||||||
<string>Paste</string>
|
<string>Paste</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionEditCut">
|
<action name="actionEditCut">
|
||||||
@ -450,7 +452,7 @@
|
|||||||
<string>Cut</string>
|
<string>Cut</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionEditUndo">
|
<action name="actionEditUndo">
|
||||||
@ -462,7 +464,7 @@
|
|||||||
<string>Undo</string>
|
<string>Undo</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionEditRedo">
|
<action name="actionEditRedo">
|
||||||
@ -474,7 +476,7 @@
|
|||||||
<string>Redo</string>
|
<string>Redo</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionopenFile">
|
<action name="actionopenFile">
|
||||||
@ -486,7 +488,43 @@
|
|||||||
<string>Open file</string>
|
<string>Open file</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="menuRole">
|
<property name="menuRole">
|
||||||
<enum>QAction::MenuRole::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionBold">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="data.qrc">
|
||||||
|
<normaloff>:/data/images/data/images/bold.png</normaloff>:/data/images/data/images/bold.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Bold</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionItalic">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="data.qrc">
|
||||||
|
<normaloff>:/data/images/data/images/italic.png</normaloff>:/data/images/data/images/italic.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Italic</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionUnderline">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="data.qrc">
|
||||||
|
<normaloff>:/data/images/data/images/underline.png</normaloff>:/data/images/data/images/underline.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Underline</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionColor">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="data.qrc">
|
||||||
|
<normaloff>:/data/images/data/images/font-color.png</normaloff>:/data/images/data/images/font-color.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Color</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
2
path.cpp
2
path.cpp
@ -75,7 +75,7 @@ Path::Path(QFile *file){
|
|||||||
QJsonArray stepsArray = json["steps"].toArray();
|
QJsonArray stepsArray = json["steps"].toArray();
|
||||||
for (const QJsonValue &stepValue : stepsArray) {
|
for (const QJsonValue &stepValue : stepsArray) {
|
||||||
QJsonObject stepObj = stepValue.toObject();
|
QJsonObject stepObj = stepValue.toObject();
|
||||||
//step.append(Step(stepObj));
|
step.append(Step(stepObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user