diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/modinfodialog.ui | 40 | ||||
| -rw-r--r-- | src/modinfodialogtab.cpp | 53 | ||||
| -rw-r--r-- | src/modinfodialogtab.h | 9 |
3 files changed, 87 insertions, 15 deletions
diff --git a/src/modinfodialog.ui b/src/modinfodialog.ui index 869ae04e..f035d93b 100644 --- a/src/modinfodialog.ui +++ b/src/modinfodialog.ui @@ -1204,17 +1204,35 @@ p, li { white-space: pre-wrap; } </attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
- <widget class="QLineEdit" name="comments">
- <property name="toolTip">
- <string>Enter comments about the mod here. These are displayed in the notes column of the mod list.</string>
- </property>
- <property name="whatsThis">
- <string>Enter comments about the mod here. These are displayed in the notes column of the mod list.</string>
- </property>
- <property name="placeholderText">
- <string>Enter comments about the mod here. These are displayed in the notes column of the mod list.</string>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
+ <item>
+ <widget class="QLineEdit" name="comments">
+ <property name="toolTip">
+ <string>Enter comments about the mod here. These are displayed in the notes column of the mod list.</string>
+ </property>
+ <property name="whatsThis">
+ <string>Enter comments about the mod here. These are displayed in the notes column of the mod list.</string>
+ </property>
+ <property name="placeholderText">
+ <string>Enter comments about the mod here. These are displayed in the notes column of the mod list.</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="setColorButton">
+ <property name="text">
+ <string>Set Color</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="resetColorButton">
+ <property name="text">
+ <string>Reset Color</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
<item>
<widget class="HTMLEditor" name="notes">
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()); } diff --git a/src/modinfodialogtab.h b/src/modinfodialogtab.h index d0a58574..7a42bf7e 100644 --- a/src/modinfodialogtab.h +++ b/src/modinfodialogtab.h @@ -253,6 +253,9 @@ protected: // void setFocus(); + // parent widget, used to display modal dialogs + QWidget* m_parent; + private: // core OrganizerCore& m_core; @@ -260,9 +263,6 @@ private: // plugin PluginContainer& m_plugin; - // parent widget, used to display modal dialogs - QWidget* m_parent; - // current mod, never null ModInfoPtr m_mod; @@ -299,8 +299,11 @@ public: bool usesOriginFiles() const override; private: + void updateCommentsColor(bool clear = false); void onComments(); void onNotes(); + void onSetColor(); + void onResetColor(); void checkHasData(); }; |
