diff options
| author | Al12rs <gabriel.cortesi@outlook.com> | 2018-10-28 17:27:34 +0100 |
|---|---|---|
| committer | Al12rs <gabriel.cortesi@outlook.com> | 2018-10-28 17:27:34 +0100 |
| commit | ab95f78689e159722b79f991c7ef07c31cb3f958 (patch) | |
| tree | 157abb49863528e7f307b588b5fc96cc3a63aebf /src/mainwindow.cpp | |
| parent | 9e66799abf1e99cb507966e1780dd25fd7887df4 (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/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 26 |
1 files changed, 25 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
|
