add of fontSize and font functions
This commit is contained in:
parent
0b4f2a172c
commit
2f6b7d44d8
1
data.qrc
1
data.qrc
@ -21,5 +21,6 @@
|
|||||||
<file>data/images/add.png</file>
|
<file>data/images/add.png</file>
|
||||||
<file>data/images/font-color.png</file>
|
<file>data/images/font-color.png</file>
|
||||||
<file>data/images/overline.png</file>
|
<file>data/images/overline.png</file>
|
||||||
|
<file>data/images/font-size.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
BIN
data/images/font-size.png
Normal file
BIN
data/images/font-size.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@ -9,6 +9,8 @@
|
|||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include <QFontDialog>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
@ -325,3 +327,50 @@ void MainWindow::on_actionOverline_triggered()
|
|||||||
this->setOverline();
|
this->setOverline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::setSize(){
|
||||||
|
QWidget *focused = QApplication::focusWidget();
|
||||||
|
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
|
||||||
|
|
||||||
|
if (plainTextEdit) {
|
||||||
|
QTextCursor cursor = plainTextEdit->textCursor();
|
||||||
|
if (cursor.hasSelection()) {
|
||||||
|
bool ok;
|
||||||
|
int size = QInputDialog::getInt(this, "Taille de la police", "Entrez la taille de la police:", cursor.charFormat().font().pointSize(), 1, 100, 1, &ok);
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
QTextCharFormat format;
|
||||||
|
QFont font = cursor.charFormat().font();
|
||||||
|
font.setPointSize(size);
|
||||||
|
format.setFont(font);
|
||||||
|
cursor.mergeCharFormat(format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void MainWindow::on_actionSize_triggered()
|
||||||
|
{
|
||||||
|
this->setSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setFont(){
|
||||||
|
QWidget *focused = QApplication::focusWidget();
|
||||||
|
QPlainTextEdit* plainTextEdit = qobject_cast<QPlainTextEdit*>(focused);
|
||||||
|
|
||||||
|
if (plainTextEdit) {
|
||||||
|
QTextCursor cursor = plainTextEdit->textCursor();
|
||||||
|
if (cursor.hasSelection()) {
|
||||||
|
bool ok;
|
||||||
|
QFont font = QFontDialog::getFont(&ok, cursor.charFormat().font(), this, "Choisir une police");
|
||||||
|
if (ok) {
|
||||||
|
QTextCharFormat format;
|
||||||
|
format.setFont(font);
|
||||||
|
cursor.mergeCharFormat(format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void MainWindow::on_actionFont_triggered()
|
||||||
|
{
|
||||||
|
this->setFont();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,6 +31,8 @@ public:
|
|||||||
void setUnderline();
|
void setUnderline();
|
||||||
void setColor();
|
void setColor();
|
||||||
void setOverline();
|
void setOverline();
|
||||||
|
void setSize();
|
||||||
|
void setFont();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
@ -58,6 +60,10 @@ private slots:
|
|||||||
|
|
||||||
void on_actionOverline_triggered();
|
void on_actionOverline_triggered();
|
||||||
|
|
||||||
|
void on_actionSize_triggered();
|
||||||
|
|
||||||
|
void on_actionFont_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
QString currentFile;
|
QString currentFile;
|
||||||
|
|||||||
@ -343,6 +343,8 @@
|
|||||||
<addaction name="actionEditRedo"/>
|
<addaction name="actionEditRedo"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionColor"/>
|
<addaction name="actionColor"/>
|
||||||
|
<addaction name="actionFont"/>
|
||||||
|
<addaction name="actionSize"/>
|
||||||
<addaction name="actionBold"/>
|
<addaction name="actionBold"/>
|
||||||
<addaction name="actionItalic"/>
|
<addaction name="actionItalic"/>
|
||||||
<addaction name="actionUnderline"/>
|
<addaction name="actionUnderline"/>
|
||||||
@ -537,6 +539,24 @@
|
|||||||
<string>Overline</string>
|
<string>Overline</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionFont">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="data.qrc">
|
||||||
|
<normaloff>:/data/images/data/images/font.png</normaloff>:/data/images/data/images/font.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Font</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionSize">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="data.qrc">
|
||||||
|
<normaloff>:/data/images/data/images/font-size.png</normaloff>:/data/images/data/images/font-size.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Size</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="data.qrc"/>
|
<include location="data.qrc"/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user