From ab95f78689e159722b79f991c7ef07c31cb3f958 Mon Sep 17 00:00:00 2001 From: Al12rs Date: Sun, 28 Oct 2018 17:27:34 +0100 Subject: Added Reset color option for separators and changed the bahavior of "cancel" of the color selector dialog to keep previous color. --- src/mainwindow.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/mainwindow.cpp') 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 -- cgit v1.3.1