summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAl12rs <gabriel.cortesi@outlook.com>2018-10-28 17:27:34 +0100
committerAl12rs <gabriel.cortesi@outlook.com>2018-10-28 17:27:34 +0100
commitab95f78689e159722b79f991c7ef07c31cb3f958 (patch)
tree157abb49863528e7f307b588b5fc96cc3a63aebf /src
parent9e66799abf1e99cb507966e1780dd25fd7887df4 (diff)
Added Reset color option for separators and changed the bahavior of "cancel" of the color selector dialog to keep previous color.
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp26
-rw-r--r--src/mainwindow.h1
2 files changed, 26 insertions, 1 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 3b2dfbb2..74eecf06 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2873,7 +2873,29 @@ void MainWindow::createSeparator_clicked()
void MainWindow::setColor_clicked()
{
ModInfo::Ptr modInfo = ModInfo::getByIndex(m_ContextRow);
- QColor color = QColorDialog::getColor(modInfo->getColor(),this);
+ QColor color = QColorDialog::getColor(modInfo->getColor(), this);
+ if (!color.isValid())
+ return;
+ QItemSelectionModel *selection = ui->modList->selectionModel();
+ 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);
+ }
+ }
+ }
+ else {
+ modInfo->setColor(color);
+ }
+}
+
+void MainWindow::resetColor_clicked()
+{
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(m_ContextRow);
+ QColor color = QColor();
QItemSelectionModel *selection = ui->modList->selectionModel();
if (selection->hasSelection() && selection->selectedRows().count() > 1) {
for (QModelIndex idx : selection->selectedRows()) {
@@ -3682,6 +3704,8 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos)
menu->addAction(tr("Remove Separator..."), this, SLOT(removeMod_clicked()));
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();
} else if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_FOREIGN) != flags.end()) {
// nop, nothing to do with this mod
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 02e368d7..53db447a 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -409,6 +409,7 @@ private slots:
void renameMod_clicked();
void removeMod_clicked();
void setColor_clicked();
+ void resetColor_clicked();
void backupMod_clicked();
void reinstallMod_clicked();
void endorse_clicked();