Skip to content

Commit

Permalink
improved format settings layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolcha committed Sep 7, 2024
1 parent 8283ce6 commit 3fc6cc5
Show file tree
Hide file tree
Showing 3 changed files with 329 additions and 197 deletions.
15 changes: 10 additions & 5 deletions app/gui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ void SettingsDialog::on_use_custom_format_clicked(bool checked)
if (!checked) updateTimeFormat();
}

void SettingsDialog::on_format_edit_textChanged(const QString& arg1)
void SettingsDialog::on_format_edit_currentTextChanged(const QString& arg1)
{
bool is_multiline = arg1.contains("\\n");
ui->layout_cfg_label->setEnabled(is_multiline);
ui->layout_cfg_edit->setEnabled(is_multiline);
ui->layout_cfg_help_btn->setEnabled(is_multiline);
}

void SettingsDialog::on_format_edit_textEdited(const QString& arg1)
void SettingsDialog::on_format_edit_editTextChanged(const QString& arg1)
{
ui->format_apply_btn->setEnabled(!arg1.isEmpty());
}
Expand All @@ -245,7 +245,7 @@ void SettingsDialog::on_format_help_btn_clicked()

void SettingsDialog::on_format_apply_btn_clicked()
{
auto time_format = ui->format_edit->text();
auto time_format = ui->format_edit->currentText();
applyClockOption(&GraphicsDateTimeWidget::setFormat, time_format);
app->config().window(_curr_idx).appearance().setTimeFormat(time_format);
}
Expand Down Expand Up @@ -296,7 +296,7 @@ void SettingsDialog::updateTimeFormat()
time_format += ui->rb_ucase_apm->isChecked() ? 'A' : 'a';
}

ui->format_edit->setText(time_format);
ui->format_edit->setCurrentText(time_format);
on_format_apply_btn_clicked();
}

Expand All @@ -312,6 +312,11 @@ void SettingsDialog::on_time_zone_edit_activated(int index)
applyTimeZoneSettings();
}

void SettingsDialog::on_multi_timezone_help_btn_clicked()
{
QDesktopServices::openUrl(QUrl("https://github.com/Kolcha/DigitalClock5/wiki/Multiple-timezones"));
}

void SettingsDialog::on_font_rbtn_clicked()
{
SectionAppearance& acfg = app->config().window(_curr_idx).appearance();
Expand Down Expand Up @@ -757,7 +762,7 @@ void SettingsDialog::initGeneralTab(int idx)
ui->seconds_scale_factor_edit->setValue(acfg.getSecondsScaleFactor());

ui->use_custom_format->setChecked(!standard_formats.contains(time_format));
ui->format_edit->setText(time_format);
ui->format_edit->setCurrentText(time_format);

if (!ui->use_custom_format->isChecked()) {
ui->rb_12h->setChecked(time_format.contains('h'));
Expand Down
5 changes: 3 additions & 2 deletions app/gui/settings_dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ private slots:
void on_seconds_scale_factor_edit_valueChanged(int arg1);
void on_use_custom_format_toggled(bool checked);
void on_use_custom_format_clicked(bool checked);
void on_format_edit_textChanged(const QString& arg1);
void on_format_edit_textEdited(const QString& arg1);
void on_format_edit_currentTextChanged(const QString& arg1);
void on_format_edit_editTextChanged(const QString& arg1);
void on_format_help_btn_clicked();
void on_format_apply_btn_clicked();
void on_layout_cfg_edit_textEdited(const QString& arg1);
Expand All @@ -69,6 +69,7 @@ private slots:

void on_use_time_zone_clicked(bool checked);
void on_time_zone_edit_activated(int index);
void on_multi_timezone_help_btn_clicked();

// appearance
void on_font_rbtn_clicked();
Expand Down
Loading

0 comments on commit 3fc6cc5

Please sign in to comment.