Skip to content

Commit

Permalink
Merge branch 'highlight_color' into 'master'
Browse files Browse the repository at this point in the history
Highlight new items in launcher by text formatting, not by color

See merge request OpenMW/openmw!3625
  • Loading branch information
Capostrophic committed Dec 3, 2023
2 parents 98dfb68 + 5e96825 commit 53f5e4d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
15 changes: 10 additions & 5 deletions apps/launcher/datafilespage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,14 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
auto row = ui.directoryListWidget->count() - 1;
auto* item = ui.directoryListWidget->item(row);

// Display new content with green background
// Display new content with custom formatting
if (mNewDataDirs.contains(canonicalDirPath))
{
tooltip += "Will be added to the current profile\n";
item->setBackground(Qt::green);
item->setForeground(Qt::black);
QFont font = item->font();
font.setBold(true);
font.setItalic(true);
item->setFont(font);
}

// deactivate data-local and global data directory: they are always included
Expand Down Expand Up @@ -737,8 +739,11 @@ void Launcher::DataFilesPage::addArchive(const QString& name, Qt::CheckState sel
ui.archiveListWidget->item(row)->setCheckState(selected);
if (mKnownArchives.filter(name).isEmpty()) // XXX why contains doesn't work here ???
{
ui.archiveListWidget->item(row)->setBackground(Qt::green);
ui.archiveListWidget->item(row)->setForeground(Qt::black);
auto item = ui.archiveListWidget->item(row);
QFont font = item->font();
font.setBold(true);
font.setItalic(true);
item->setFont(font);
}
}

Expand Down
17 changes: 6 additions & 11 deletions components/contentselector/model/contentmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <QDebug>
#include <QDir>
#include <QFont>

#include <components/esm/format.hpp>
#include <components/esm3/esmreader.hpp>
Expand Down Expand Up @@ -164,20 +165,14 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex& index, int
return isLoadOrderError(file) ? mWarningIcon : QVariant();
}

case Qt::BackgroundRole:
case Qt::FontRole:
{
if (isNew(file->fileName()))
{
return QVariant(QColor(Qt::green));
}
return QVariant();
}

case Qt::ForegroundRole:
{
if (isNew(file->fileName()))
{
return QVariant(QColor(Qt::black));
auto font = QFont();
font.setBold(true);
font.setItalic(true);
return font;
}
return QVariant();
}
Expand Down
8 changes: 4 additions & 4 deletions files/ui/datafilespage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>571</width>
<width>573</width>
<height>384</height>
</rect>
</property>
Expand All @@ -30,7 +30,7 @@
<item row="1" column="0">
<widget class="QLabel" name="dataNoteLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;note: content files that are not part of current Content List are &lt;/span&gt;&lt;span style=&quot; font-style:italic; background-color:#00ff00;&quot;&gt;highlighted&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;note: content files that are not part of current Content List are &lt;span style=&quot; font-style:italic;font-weight: bold&quot;&gt;highlighted&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand All @@ -57,7 +57,7 @@
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;note: directories that are not part of current Content List are &lt;/span&gt;&lt;span style=&quot; font-style:italic; background-color:#00ff00;&quot;&gt;highlighted&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;note: directories that are not part of current Content List are &lt;span style=&quot; font-style:italic;font-weight: bold&quot;&gt;highlighted&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -210,7 +210,7 @@
<item row="27" column="0" colspan="2">
<widget class="QLabel" name="archiveNoteLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;note: archives that are not part of current Content List are &lt;/span&gt;&lt;span style=&quot; font-style:italic; background-color:#00ff00;&quot;&gt;highlighted&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;note: archives that are not part of current Content List are &lt;span style=&quot; font-style:italic;font-weight: bold&quot;&gt;highlighted&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit 53f5e4d

Please sign in to comment.