Skip to content

Commit

Permalink
compelete project.
Browse files Browse the repository at this point in the history
  • Loading branch information
parisa-hr committed Nov 17, 2021
1 parent 34c91e0 commit 88a76fc
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 32 deletions.
31 changes: 30 additions & 1 deletion mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,35 @@ MainWindow::MainWindow(QWidget *parent):
_settingPage = new Settings(this);
_settingPage->hide();

connect(_settingPage, &Settings::changingTextColor, this, [this](QColor color)
{
ui->textEdit->setTextColor(color);
});
connect(_settingPage, &Settings::changingTextFont, this, [this](QFont font)
{
ui->textEdit->setFontFamily(font.family());
qDebug() << "fontFamily = " << ui->textEdit->fontFamily();
});
connect(_settingPage, &Settings::changingFontSize, this, [this](int w)
{
ui->textEdit->setFontPointSize(w);
});


auto _windowPos = getSettings("windowPose").toPoint();
move(_windowPos);

auto _fontColor = getSettings("fontColor").toString();
ui->textEdit->setTextColor(_fontColor);

auto _fontFamily = getSettings("fontFamily").toString();
ui->textEdit->setFontFamily(_fontFamily);

auto _fontSize = getSettings("fontSize").toInt();
ui->textEdit->setFontPointSize(_fontSize);


_settingPage->initialSetting(_fontColor, _fontFamily, _fontSize);
}

MainWindow::~MainWindow()
Expand Down Expand Up @@ -56,6 +82,9 @@ void MainWindow::on_pb_close_clicked()
close();

setSettings("windowPose", pos());
setSettings("fontColor", ui->textEdit->textColor());
setSettings("fontFamily", ui->textEdit->currentFont().family());
setSettings("fontSize", ui->textEdit->fontPointSize());
}

void MainWindow::on_pb_minimize_clicked()
Expand All @@ -81,7 +110,7 @@ void MainWindow::on_tb_underline_clicked(bool underline)

void MainWindow::on_tb_StrikeOut_clicked(bool checked)
{
_font = ui->textEdit->font();
_font = ui->textEdit->currentFont();

_font.setStrikeOut(checked);

Expand Down
58 changes: 29 additions & 29 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,35 @@
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">QWidget#wgt_base
<string notr="true"/>
</property>
<widget class="QWidget" name="centralwidget">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="wgt_base" native="true">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true">QWidget#wgt_base
{
border-image: url(:/images/images/Note.png) 0 0 0 0 stretch stretch;
}
Expand Down Expand Up @@ -55,34 +83,6 @@ border:1px solid rgb(164, 0, 0);
border-radius: 5px;
}
</string>
</property>
<widget class="QWidget" name="centralwidget">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="wgt_base" native="true">
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
Expand Down
26 changes: 25 additions & 1 deletion settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,41 @@ Settings::Settings(QWidget *parent):
ui->setupUi(this);
setAttribute(Qt::WA_AlwaysStackOnTop, true);
setAutoFillBackground(true);
ui->spinBox->setValue(9);
}

Settings::~Settings()
{
delete ui;
}

void Settings::initialSetting(QColor c, QString fontFamily, int size)
{
ui->pb_changeColor->setStyleSheet(QString("* {background-color:rgba(%1,%2,%3,%4);}").arg(c.red()).arg(
c.green()).arg(c.blue()).arg(c.alpha()));
QFont f;
f.setFamily(fontFamily);
ui->fontComboBox->setCurrentFont(f);

ui->spinBox->setValue(size);
}

void Settings::on_pb_changeColor_clicked()
{
QColor color = QColorDialog::getColor(Qt::black, this);
color = QColorDialog::getColor(Qt::black, this);

ui->pb_changeColor->setStyleSheet(QString("* {background-color:rgba(%1,%2,%3,%4);}").arg(color.red()).arg(
color.green()).arg(color.blue()).arg(color.alpha()));

emit changingTextColor(color);
}

void Settings::on_spinBox_valueChanged(int arg1)
{
emit changingFontSize(arg1);
}

void Settings::on_fontComboBox_currentFontChanged(const QFont &f)
{
emit changingTextFont(f);
}
13 changes: 12 additions & 1 deletion settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,25 @@ class Settings: public QDialog

~Settings();

void initialSetting(QColor c, QString fontFamily, int size);

signals:
void changingTextColor();
void changingTextColor(QColor color);

void changingTextFont(QFont font);

void changingFontSize(int size);

private slots:
void on_pb_changeColor_clicked();

void on_spinBox_valueChanged(int arg1);

void on_fontComboBox_currentFontChanged(const QFont &f);

private:
Ui::Settings *ui;
QColor color = Qt::black;
};

#endif // SETTINGS_H

0 comments on commit 88a76fc

Please sign in to comment.