display more readable strings in custom skin colors

This commit is contained in:
Martin Rotter 2021-11-26 07:56:47 +01:00
parent efe3c3f8db
commit a03df018bb
5 changed files with 42 additions and 2 deletions

View File

@ -243,8 +243,14 @@ void SettingsGui::loadSettings() {
lay->addWidget(clr_btn);
lay->addWidget(rst_btn);
m_ui->m_layoutCustomColors->setWidget(row, QFormLayout::ItemRole::LabelRole, new QLabel(enumer.key(i), this));
m_ui->m_layoutCustomColors->setLayout(row, QFormLayout::ItemRole::FieldRole, lay);
m_ui->m_layoutCustomColors->setWidget(row,
QFormLayout::ItemRole::LabelRole,
new QLabel(
TextFactory::capitalizeFirstLetter(SkinEnums::palleteColorText(SkinEnums::PaletteColors(enumer.value(i)))),
this));
m_ui->m_layoutCustomColors->setLayout(row,
QFormLayout::ItemRole::FieldRole,
lay);
}

View File

@ -348,3 +348,25 @@ QVariant Skin::colorForModel(SkinEnums::PaletteColors type, bool ignore_custom_c
? m_colorPalette[type]
: QVariant();
}
QString SkinEnums::palleteColorText(PaletteColors col) {
switch (col) {
case SkinEnums::PaletteColors::FgInteresting:
return QObject::tr("interesting stuff");
case SkinEnums::PaletteColors::FgSelectedInteresting:
return QObject::tr("interesting stuff (highlighted)");;
case SkinEnums::PaletteColors::FgError:
return QObject::tr("errored items");
case SkinEnums::PaletteColors::FgSelectedError:
return QObject::tr("errored items (highlighted)");
case SkinEnums::PaletteColors::Allright:
return QObject::tr("OK-ish color");
default:
return {};
}
}

View File

@ -32,6 +32,8 @@ class SkinEnums : public QObject {
Allright = 16
};
static QString palleteColorText(PaletteColors col);
Q_ENUM(PaletteColors)
};

View File

@ -151,6 +151,15 @@ QString TextFactory::newline() {
#endif
}
QString TextFactory::capitalizeFirstLetter(const QString& sts) {
if (sts.isEmpty()) {
return sts;
}
else {
return sts[0].toUpper() + sts.mid(1);
}
}
QString TextFactory::shorten(const QString& input, int text_length_limit) {
if (input.size() > text_length_limit) {
return input.left(text_length_limit - ELLIPSIS_LENGTH) + QString(ELLIPSIS_LENGTH, QL1C('.'));

View File

@ -31,6 +31,7 @@ class TextFactory {
static QString encrypt(const QString& text, quint64 key = 0);
static QString decrypt(const QString& text, quint64 key = 0);
static QString newline();
static QString capitalizeFirstLetter(const QString& sts);
// Shortens input string according to given length limit.
static QString shorten(const QString& input, int text_length_limit = TEXT_TITLE_LIMIT);