Dark mode support

Centralized all colors, tweaked application paletter in darkmode to make it darker.
This commit is contained in:
eelke 2025-02-23 08:32:15 +01:00
parent aac55b0ed1
commit 86a9a0d709
19 changed files with 335 additions and 73 deletions

View file

@ -30,6 +30,13 @@ namespace {
}
ColumnTableModel::ColumnTableModel(QObject *parent)
: BaseTableModel(parent)
, theme(GetColorTheme())
{
}
void ColumnTableModel::setData(std::shared_ptr<const PgDatabaseCatalog> cat, const std::optional<PgClass> &table)
{
if (cat != m_catalog) {
@ -285,22 +292,19 @@ QVariant ColumnTableModel::data(const QModelIndex &index, int role) const
QVariant v;
const auto &t = m_columns[index.row()];
if (t.typid == InvalidOid)
v = QBrush(Qt::black);
v = QBrush(theme.defaultTextColor);
else {
auto c = m_catalog->types()->getByKey(t.typid);
switch (c->category) {
case TypCategory::Boolean:
v = QBrush(Qt::darkGreen);
break;
case TypCategory::Numeric:
v = QBrush(Qt::darkBlue);
v = QBrush(theme.numericTypeColor);
break;
case TypCategory::DateTime:
case TypCategory::Timespan:
v = QBrush(Qt::darkMagenta);
v = QBrush(theme.dateTimeTypeColor);
break;
case TypCategory::String:
v = QBrush(Qt::darkYellow);
v = QBrush(theme.stringTypeColor);
break;
case TypCategory::Array:
case TypCategory::Composite:
@ -313,7 +317,8 @@ QVariant ColumnTableModel::data(const QModelIndex &index, int role) const
case TypCategory::BitString:
case TypCategory::Unknown:
default:
v = QBrush(Qt::black);
v = QBrush(theme.defaultTextColor);
break;
}
}
return v;

View file

@ -1,6 +1,7 @@
#ifndef COLUMNTABLEMODEL_H
#define COLUMNTABLEMODEL_H
#include "util/Colors.h"
#include "catalog/models/BaseTableModel.h"
#include "catalog/PgAttribute.h"
#include "catalog/PgDatabaseCatalog.h"
@ -29,7 +30,8 @@ public:
colCount };
using BaseTableModel::BaseTableModel;
explicit ColumnTableModel(QObject *parent = nullptr);
void setData(std::shared_ptr<const PgDatabaseCatalog> cat, const std::optional<PgClass> &table);
// Header:
@ -57,6 +59,9 @@ protected:
QString getFKey(const PgAttribute &column) const;
QString getDefaultString(const PgAttribute &column) const;
private:
const ColorTheme &theme;
private slots:
/// Retrieves required data from catalog, called everytime it might have changed
void refresh();