diff options
| author | Al12rs <gabriel.cortesi@outlook.com> | 2018-10-28 15:04:50 +0100 |
|---|---|---|
| committer | Al12rs <gabriel.cortesi@outlook.com> | 2018-10-28 15:04:50 +0100 |
| commit | dce6507dad1ff7d76a5c0497d516c79bacd08477 (patch) | |
| tree | 3ee70b476b0d5f1016a0348839ef696e25b86f40 /src | |
| parent | 42d2344f0b81cb1cf8dbe83e8f480b84ed0c3114 (diff) | |
Added Color costumization for Separators.
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 28 | ||||
| -rw-r--r-- | src/mainwindow.h | 1 | ||||
| -rw-r--r-- | src/modinfo.h | 11 | ||||
| -rw-r--r-- | src/modinforegular.cpp | 13 | ||||
| -rw-r--r-- | src/modinforegular.h | 7 | ||||
| -rw-r--r-- | src/modlist.cpp | 6 |
6 files changed, 64 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bc25ab70..438ba037 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -154,6 +154,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <QWidgetAction>
#include <QWebEngineProfile>
#include <QShortcut>
+#include <QColorDialog>
+#include <QColor>
#include <QDebug>
#include <QtGlobal>
@@ -2868,6 +2870,26 @@ void MainWindow::createSeparator_clicked() m_OrganizerCore.refreshModList();
}
+void MainWindow::setColor_clicked()
+{
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(m_ContextRow);
+ QColor color = QColorDialog::getColor(modInfo->getColor(),this);
+ 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::createModFromOverwrite()
{
GuessedValue<QString> name;
@@ -3608,7 +3630,7 @@ QMenu *MainWindow::modListContextMenu() menu->addAction(tr("Create empty mod"), this, SLOT(createEmptyMod_clicked()));
- menu->addAction(tr("Create separator"), this, SLOT(createSeparator_clicked()));
+ menu->addAction(tr("Create Separator"), this, SLOT(createSeparator_clicked()));
menu->addSeparator();
@@ -3655,8 +3677,12 @@ void MainWindow::on_modList_customContextMenuRequested(const QPoint &pos) menu->addAction(tr("Restore Backup"), this, SLOT(restoreBackup_clicked()));
menu->addAction(tr("Remove Backup..."), this, SLOT(removeMod_clicked()));
} else if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_SEPARATOR) != flags.end()){
+ menu->addSeparator();
menu->addAction(tr("Rename Separator..."), this, SLOT(renameMod_clicked()));
menu->addAction(tr("Remove Separator..."), this, SLOT(removeMod_clicked()));
+ menu->addSeparator();
+ menu->addAction(tr("Select Color..."), this, SLOT(setColor_clicked()));
+ menu->addSeparator();
} else if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_FOREIGN) != flags.end()) {
// nop, nothing to do with this mod
} else {
diff --git a/src/mainwindow.h b/src/mainwindow.h index 78d374e6..02e368d7 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -408,6 +408,7 @@ private slots: void restoreBackup_clicked();
void renameMod_clicked();
void removeMod_clicked();
+ void setColor_clicked();
void backupMod_clicked();
void reinstallMod_clicked();
void endorse_clicked();
diff --git a/src/modinfo.h b/src/modinfo.h index 9f6c2fbc..235fb50c 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -31,6 +31,7 @@ class QDir; #include <QSharedPointer>
#include <QString>
#include <QStringList>
+#include <QColor>
#include <boost/function.hpp>
@@ -524,6 +525,16 @@ public: */
virtual QStringList archives() const = 0;
+ /*
+ *@return the color choosen by the user for the mod/separator
+ */
+ virtual QColor getColor() { return QColor(); }
+
+ /*
+ *@return true if the color has been set successfully.
+ */
+ virtual void setColor(QColor color) { }
+
/**
* @brief adds the information that a file has been installed into this mod
* @param modId id of the mod installed
diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index 1d84e2c8..d0f56a52 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -90,6 +90,7 @@ void ModInfoRegular::readMeta() m_Validated = metaFile.value("validated", false).toBool(); m_URL = metaFile.value("url", "").toString(); m_LastNexusQuery = QDateTime::fromString(metaFile.value("lastNexusQuery", "").toString(), Qt::ISODate); + m_Color = metaFile.value("color",QColor()).value<QColor>(); if (metaFile.contains("endorsed")) { if (metaFile.value("endorsed").canConvert<int>()) { switch (metaFile.value("endorsed").toInt()) { @@ -153,6 +154,7 @@ void ModInfoRegular::saveMeta() metaFile.setValue("lastNexusQuery", m_LastNexusQuery.toString(Qt::ISODate)); metaFile.setValue("converted", m_Converted); metaFile.setValue("validated", m_Validated); + metaFile.setValue("color", m_Color); if (m_EndorsedState != ENDORSED_UNKNOWN) { metaFile.setValue("endorsed", m_EndorsedState); } @@ -397,6 +399,17 @@ void ModInfoRegular::setNeverEndorse() } +void ModInfoRegular::setColor(QColor color) +{ + m_Color = color; + m_MetaInfoChanged = true; +} + +QColor ModInfoRegular::getColor() +{ + return m_Color; +} + bool ModInfoRegular::remove() { m_MetaInfoChanged = false; diff --git a/src/modinforegular.h b/src/modinforegular.h index 2f3eb941..78a6e58a 100644 --- a/src/modinforegular.h +++ b/src/modinforegular.h @@ -311,6 +311,10 @@ public: virtual QStringList archives() const; + virtual void setColor(QColor color); + + virtual QColor getColor(); + virtual void addInstalledFile(int modId, int fileId); /** @@ -355,9 +359,12 @@ private: QString m_URL; QString m_GameName; + QDateTime m_CreationTime; QDateTime m_LastNexusQuery; + QColor m_Color; + int m_NexusID; std::set<std::pair<int, int>> m_InstalledFileIDs; diff --git a/src/modlist.cpp b/src/modlist.cpp index 31ef9ddc..6caafeb2 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -383,12 +383,16 @@ QVariant ModList::data(const QModelIndex &modelIndex, int role) const return QVariant();
} else if ((role == Qt::BackgroundRole)
|| (role == ViewMarkingScrollBar::DEFAULT_ROLE)) {
+ auto flags = modInfo->getFlags();
if (modInfo->getHighlight() & ModInfo::HIGHLIGHT_PLUGIN) {
return QColor(0, 0, 255, 64);
} else if (m_Overwrite.find(modIndex) != m_Overwrite.end()) {
return QColor(0, 255, 0, 64);
- } else if (m_Overwritten.find(modIndex) != m_Overwritten.end()) {
+ }
+ else if (m_Overwritten.find(modIndex) != m_Overwritten.end()) {
return QColor(255, 0, 0, 64);
+ } else if (std::find(flags.begin(), flags.end(), ModInfo::FLAG_SEPARATOR) != flags.end() && modInfo->getColor().isValid()) {
+ return modInfo->getColor();
} else {
return QVariant();
}
|
