From 312af10f4f7aae13d953141ad9e2fb0180aebbef Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Wed, 29 Apr 2020 16:49:12 +0200 Subject: Allow coloring notes field. --- src/mainwindow.cpp | 19 +++++++++---------- src/modlist.cpp | 6 ++++-- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 01d3e62c..8393d314 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3649,11 +3649,7 @@ void MainWindow::setColor_clicked() if (selection->hasSelection() && selection->selectedRows().count() > 1) { for (QModelIndex idx : selection->selectedRows()) { ModInfo::Ptr info = ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt()); - auto flags = info->getFlags(); - if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_SEPARATOR) != flags.end()) - { - info->setColor(currentColor); - } + info->setColor(currentColor); } } else { @@ -3669,11 +3665,7 @@ void MainWindow::resetColor_clicked() if (selection->hasSelection() && selection->selectedRows().count() > 1) { for (QModelIndex idx : selection->selectedRows()) { ModInfo::Ptr info = ModInfo::getByIndex(idx.data(Qt::UserRole + 1).toInt()); - auto flags = info->getFlags(); - if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_SEPARATOR) != flags.end()) - { - info->setColor(color); - } + info->setColor(color); } } else { @@ -4774,6 +4766,13 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos) menu.addSeparator(); + menu.addAction(tr("Select Color..."), this, SLOT(setColor_clicked())); + + if (info->getColor().isValid()) + menu.addAction(tr("Reset Color"), this, SLOT(resetColor_clicked())); + + menu.addSeparator(); + if (info->getNexusID() > 0 && Settings::instance().nexus().endorsementIntegration()) { switch (info->endorsedState()) { case ModInfo::ENDORSED_TRUE: { diff --git a/src/modlist.cpp b/src/modlist.cpp index fb3dde13..4afd2a25 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -404,7 +404,7 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const } return QVariant(); } else if (role == Qt::ForegroundRole) { - if (modInfo->hasFlag(ModInfo::FLAG_SEPARATOR) && modInfo->getColor().isValid()) { + if (modInfo->hasFlag(ModInfo::FLAG_SEPARATOR) || (column == COL_NOTES) && modInfo->getColor().isValid()) { return ColorSettings::idealTextColor(modInfo->getColor()); } else if (column == COL_NAME) { int highlight = modInfo->getHighlight(); @@ -430,7 +430,9 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const bool overwritten = m_Overwritten.find(modIndex) != m_Overwritten.end(); bool archiveOverwritten = m_ArchiveOverwritten.find(modIndex) != m_ArchiveOverwritten.end(); bool archiveLooseOverwritten = m_ArchiveLooseOverwritten.find(modIndex) != m_ArchiveLooseOverwritten.end(); - if (modInfo->getHighlight() & ModInfo::HIGHLIGHT_PLUGIN) { + if (column == COL_NOTES && modInfo->getColor().isValid()) { + return modInfo->getColor(); + } else if (modInfo->getHighlight() & ModInfo::HIGHLIGHT_PLUGIN) { return Settings::instance().colors().modlistContainsPlugin(); } else if (overwritten || archiveLooseOverwritten) { return Settings::instance().colors().modlistOverwritingLoose(); -- cgit v1.3.1 From 4d67365600383d739df5288612a347948d5506b3 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Wed, 29 Apr 2020 17:04:25 +0200 Subject: Only show color context menu for mods when right clicking on Notes column. --- src/mainwindow.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8393d314..b5beb229 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4644,6 +4644,7 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos) m_ContextIdx = mapToModel(m_OrganizerCore.modList(), modList->indexAt(pos)); m_ContextRow = m_ContextIdx.row(); + int contextColumn = m_ContextIdx.column(); if (m_ContextRow == -1) { // no selection @@ -4766,12 +4767,14 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos) menu.addSeparator(); - menu.addAction(tr("Select Color..."), this, SLOT(setColor_clicked())); + if (contextColumn == ModList::COL_NOTES) { + menu.addAction(tr("Select Color..."), this, SLOT(setColor_clicked())); - if (info->getColor().isValid()) - menu.addAction(tr("Reset Color"), this, SLOT(resetColor_clicked())); + if (info->getColor().isValid()) + menu.addAction(tr("Reset Color"), this, SLOT(resetColor_clicked())); - menu.addSeparator(); + menu.addSeparator(); + } if (info->getNexusID() > 0 && Settings::instance().nexus().endorsementIntegration()) { switch (info->endorsedState()) { -- cgit v1.3.1 From bdd1e97d4f3a8b294a0691a7631c60cf24fffa90 Mon Sep 17 00:00:00 2001 From: AL <26797547+Al12rs@users.noreply.github.com> Date: Wed, 29 Apr 2020 22:13:09 +0200 Subject: Add modinfodialog Notes Tab color selector. --- src/modinfodialog.ui | 40 ++++++++++++++++++++++++++---------- src/modinfodialogtab.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++++++- src/modinfodialogtab.h | 9 +++++--- 3 files changed, 87 insertions(+), 15 deletions(-) (limited to 'src') 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; } - - - Enter comments about the mod here. These are displayed in the notes column of the mod list. - - - Enter comments about the mod here. These are displayed in the notes column of the mod list. - - - Enter comments about the mod here. These are displayed in the notes column of the mod list. - - + + + + + Enter comments about the mod here. These are displayed in the notes column of the mod list. + + + Enter comments about the mod here. These are displayed in the notes column of the mod list. + + + Enter comments about the mod here. These are displayed in the notes column of the mod list. + + + + + + + Set Color + + + + + + + Reset Color + + + + 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(); }; -- cgit v1.3.1