diff options
| author | AL <26797547+Al12rs@users.noreply.github.com> | 2020-04-29 22:13:09 +0200 |
|---|---|---|
| committer | AL <26797547+Al12rs@users.noreply.github.com> | 2020-04-29 22:13:09 +0200 |
| commit | bdd1e97d4f3a8b294a0691a7631c60cf24fffa90 (patch) | |
| tree | c9845642b6f048fa80edbc38285d78ee3bf0c3fa /src/modinfodialogtab.cpp | |
| parent | 4d67365600383d739df5288612a347948d5506b3 (diff) | |
Add modinfodialog Notes Tab color selector.
Diffstat (limited to 'src/modinfodialogtab.cpp')
| -rw-r--r-- | src/modinfodialogtab.cpp | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/modinfodialogtab.cpp b/src/modinfodialogtab.cpp index d662e2b2..f795cdf9 100644 --- a/src/modinfodialogtab.cpp +++ b/src/modinfodialogtab.cpp @@ -154,12 +154,29 @@ NotesTab::NotesTab(ModInfoDialogTabContext cx) { connect(ui->comments, &QLineEdit::editingFinished, [&]{ onComments(); }); connect(ui->notes, &HTMLEditor::editingFinished, [&]{ onNotes(); }); + connect(ui->setColorButton, &QPushButton::clicked, [&] { onSetColor(); }); + connect(ui->resetColorButton, &QPushButton::clicked, [&] { onResetColor(); }); +} + +void NotesTab::updateCommentsColor(bool clear) +{ + QPalette commentPalette = QPalette(); + + if (!clear) { + auto modColor = mod().getColor(); + if (modColor.isValid()) { + commentPalette.setColor(QPalette::Base, modColor); + commentPalette.setColor(QPalette::Text, ColorSettings::idealTextColor(modColor)); + } + } + ui->comments->setPalette(commentPalette); } void NotesTab::clear() { ui->comments->clear(); ui->notes->clear(); + updateCommentsColor(true); setHasData(false); } @@ -170,6 +187,7 @@ void NotesTab::update() ui->comments->setText(comments); ui->notes->setText(notes); + updateCommentsColor(); checkHasData(); } @@ -196,6 +214,38 @@ void NotesTab::onNotes() checkHasData(); } +void NotesTab::onSetColor() +{ + QColorDialog dialog(m_parent); + dialog.setOption(QColorDialog::ShowAlphaChannel); + + QColor currentColor = mod().getColor(); + + if (currentColor.isValid()) { + dialog.setCurrentColor(currentColor); + } + + if (!dialog.exec()) + return; + + currentColor = dialog.currentColor(); + if (!currentColor.isValid()) + return; + + mod().setColor(currentColor); + updateCommentsColor(); + checkHasData(); +} + +void NotesTab::onResetColor() +{ + QColor color = QColor(); + + mod().setColor(color); + updateCommentsColor(); + checkHasData(); +} + bool NotesTab::usesOriginFiles() const { return false; @@ -205,5 +255,6 @@ void NotesTab::checkHasData() { setHasData( !ui->comments->text().isEmpty() || - !ui->notes->toPlainText().isEmpty()); + !ui->notes->toPlainText().isEmpty() || + mod().getColor().isValid()); } |
