allowing editing the timestamp freely

This commit is contained in:
fourtf 2018-10-31 21:13:01 +01:00
parent 246f999a40
commit 7b06405a1c
2 changed files with 8 additions and 4 deletions

View file

@ -77,10 +77,13 @@ ComboBox *SettingsLayout::addDropdown(const QString &text,
ComboBox *SettingsLayout::addDropdown(
const QString &text, const QStringList &items,
pajlada::Settings::Setting<QString> &setting)
pajlada::Settings::Setting<QString> &setting, bool editable)
{
auto combo = this->addDropdown(text, items);
if (editable)
combo->setEditable(true);
// update when setting changes
setting.connect(
[combo](const QString &value, auto) { combo->setCurrentText(value); },
@ -185,8 +188,8 @@ void GeneralPage::initLayout(SettingsLayout &layout)
layout.addTitle("Messages");
layout.addCheckbox("Timestamps", s.showTimestamps);
layout.addDropdown("Timestamp format",
{"hh:mm", "h:mm", "hh:mm a", "h:mm a"},
s.timestampFormat);
{"h:mm", "hh:mm", "h:mm a", "hh:mm a"},
s.timestampFormat, true);
layout.addDropdown<int>(
"Collapse messages",
{"Never", "Longer than 2 lines", "Longer than 3 lines",

View file

@ -75,7 +75,8 @@ public:
QCheckBox *addCheckbox(const QString &text, BoolSetting &setting);
ComboBox *addDropdown(const QString &text, const QStringList &items);
ComboBox *addDropdown(const QString &text, const QStringList &items,
pajlada::Settings::Setting<QString> &setting);
pajlada::Settings::Setting<QString> &setting,
bool editable = false);
template <typename T>
ComboBox *addDropdown(