Skip to content

Commit

Permalink
Make the launcher dara directory and bsa list play nicer with dark
Browse files Browse the repository at this point in the history
themes.

Known issue: the padding icon for disabled data directories is of wrong
color.
  • Loading branch information
fr3dz10 committed Apr 28, 2022
1 parent 2061a0b commit bab5e56
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
24 changes: 12 additions & 12 deletions apps/launcher/datafilespage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,7 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
// add new achives files presents in current directory
addArchivesFromDir(currentDir);

// Display new content with green background
QColor background;
QString tooltip;
if (mNewDataDirs.contains(currentDir))
{
tooltip += "Will be added to the current profile\n";
background = Qt::green;
}
else
background = Qt::white;

// add content files presents in current directory
mSelector->addFiles(currentDir, mNewDataDirs.contains(currentDir));
Expand All @@ -265,7 +256,14 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
ui.directoryListWidget->addItem(currentDir);
auto row = ui.directoryListWidget->count() - 1;
auto* item = ui.directoryListWidget->item(row);
item->setBackground(background);

// Display new content with green background
if (mNewDataDirs.contains(currentDir))
{
tooltip += "Will be added to the current profile\n";
item->setBackground(Qt::green);
item->setForeground(Qt::black);
}

// deactivate data-local and global data directory: they are always included
if (currentDir == mDataLocal || currentDir == globalDataDir)
Expand All @@ -284,7 +282,7 @@ void Launcher::DataFilesPage::populateFileViews(const QString& contentModelName)
{
// Pad to correct vertical alignment
QPixmap pixmap(QSize(200, 200)); // Arbitrary big number, will be scaled down to widget size
pixmap.fill(background);
pixmap.fill(ui.directoryListWidget->palette().base().color());
auto emptyIcon = QIcon(pixmap);
item->setIcon(emptyIcon);
}
Expand Down Expand Up @@ -447,7 +445,6 @@ void Launcher::DataFilesPage::setProfile (const QString &previous, const QString
{
auto* item = ui.archiveListWidget->item(i);
mKnownArchives.push_back(item->text());
item->setBackground(Qt::white);
}

checkForDefaultProfile();
Expand Down Expand Up @@ -704,7 +701,10 @@ void Launcher::DataFilesPage::addArchive(const QString& name, Qt::CheckState sel
ui.archiveListWidget->insertItem(row, name);
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);
}
}

void Launcher::DataFilesPage::addArchivesFromDir(const QString& path)
Expand Down
9 changes: 9 additions & 0 deletions components/contentselector/model/contentmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ QVariant ContentSelectorModel::ContentModel::data(const QModelIndex &index, int
return QVariant();
}

case Qt::ForegroundRole:
{
if (isNew(file->fileName()))
{
return QVariant(QColor(Qt::black));
}
return QVariant();
}

case Qt::EditRole:
case Qt::DisplayRole:
{
Expand Down

0 comments on commit bab5e56

Please sign in to comment.