Skip to content

Commit

Permalink
Improve UI so undo limit = 0 means "no limit" (#1127)
Browse files Browse the repository at this point in the history
By default we'll have "no undo limit".
  • Loading branch information
dacap committed Oct 25, 2017
1 parent f0c11ef commit 5cd3687
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion data/pref.xml
Expand Up @@ -113,7 +113,7 @@
<option id="show_menu_bar" type="bool" default="true" />
</section>
<section id="undo" text="Undo">
<option id="size_limit" type="int" default="64" />
<option id="size_limit" type="int" default="0" />
<option id="goto_modified" type="bool" default="true" />
<option id="allow_nonlinear_history" type="bool" default="false" />
</section>
Expand Down
4 changes: 2 additions & 2 deletions data/widgets/options.xml
Expand Up @@ -249,8 +249,8 @@
<vbox id="section_undo">
<separator text="@.section_undo" horizontal="true" />
<hbox>
<label text="@.undo_size_limit" />
<entry id="undo_size_limit" maxsize="4" tooltip="@.undo_size_limit_tooltip" />
<check id="limit_undo" text="@.undo_size_limit" />
<entry id="undo_size_limit" maxsize="6" tooltip="@.undo_size_limit_tooltip" />
<label text="@.undo_mb" />
</hbox>

Expand Down
20 changes: 18 additions & 2 deletions src/app/commands/cmd_options.cpp
Expand Up @@ -44,6 +44,8 @@ static const char* kSectionGridId = "section_grid";
static const char* kSectionThemeId = "section_theme";
static const char* kSectionExtensionsId = "section_extensions";

static const char* kInfiniteSymbol = "\xE2\x88\x9E"; // Infinite symbol (UTF-8)

using namespace ui;

class OptionsWindow : public app::gen::Options {
Expand Down Expand Up @@ -321,7 +323,10 @@ class OptionsWindow : public app::gen::Options {
#endif

// Undo preferences
undoSizeLimit()->setTextf("%d", m_pref.undo.sizeLimit());
limitUndo()->Click.connect(base::Bind<void>(&OptionsWindow::onLimitUndoCheck, this));
limitUndo()->setSelected(m_pref.undo.sizeLimit() != 0);
onLimitUndoCheck();

undoGotoModified()->setSelected(m_pref.undo.gotoModified());
undoAllowNonlinearHistory()->setSelected(m_pref.undo.allowNonlinearHistory());

Expand Down Expand Up @@ -418,7 +423,7 @@ class OptionsWindow : public app::gen::Options {

int undo_size_limit_value;
undo_size_limit_value = undoSizeLimit()->textInt();
undo_size_limit_value = MID(1, undo_size_limit_value, 9999);
undo_size_limit_value = MID(0, undo_size_limit_value, 999999);

m_pref.undo.sizeLimit(undo_size_limit_value);
m_pref.undo.gotoModified(undoGotoModified()->isSelected());
Expand Down Expand Up @@ -655,6 +660,17 @@ class OptionsWindow : public app::gen::Options {
app::launcher::open_folder(app::main_config_filename());
}

void onLimitUndoCheck() {
if (limitUndo()->isSelected()) {
undoSizeLimit()->setEnabled(true);
undoSizeLimit()->setTextf("%d", m_pref.undo.sizeLimit());
}
else {
undoSizeLimit()->setEnabled(false);
undoSizeLimit()->setText(kInfiniteSymbol);
}
}

void reloadThemes() {
while (themeList()->firstChild())
delete themeList()->lastChild();
Expand Down

0 comments on commit 5cd3687

Please sign in to comment.