fix GTK client message log window does not restore level selection (#4242)
* fix: save log level, encryption mod, preallocation mode as ints * fix: ensure log level is saved in tr_sessionGetSettings() * fix: ensure the right verbosity row is selected
This commit is contained in:
parent
feeea2649e
commit
ec6cb67c5c
|
@ -141,13 +141,19 @@ void MessageLogWindow::Impl::scroll_to_bottom()
|
|||
|
||||
void MessageLogWindow::Impl::level_combo_init(Gtk::ComboBox* level_combo) const
|
||||
{
|
||||
auto const pref_level = static_cast<tr_log_level>(gtr_pref_int_get(TR_KEY_message_level));
|
||||
auto const default_level = TR_LOG_INFO;
|
||||
|
||||
auto has_pref_level = false;
|
||||
auto items = std::vector<std::pair<Glib::ustring, int>>{};
|
||||
for (auto const& [level, name] : level_names_)
|
||||
{
|
||||
items.emplace_back(name, level);
|
||||
has_pref_level |= level == pref_level;
|
||||
}
|
||||
|
||||
gtr_combo_box_set_enum(*level_combo, items);
|
||||
gtr_combo_box_set_active_enum(*level_combo, gtr_pref_int_get(TR_KEY_message_level));
|
||||
gtr_combo_box_set_active_enum(*level_combo, has_pref_level ? pref_level : default_level);
|
||||
}
|
||||
|
||||
void MessageLogWindow::Impl::level_combo_changed_cb(Gtk::ComboBox* combo_box)
|
||||
|
@ -461,7 +467,6 @@ MessageLogWindow::Impl::Impl(
|
|||
{ TR_LOG_WARN, C_("Logging level", "Warning") },
|
||||
{ TR_LOG_INFO, C_("Logging level", "Information") },
|
||||
{ TR_LOG_DEBUG, C_("Logging level", "Debug") },
|
||||
{ TR_LOG_TRACE, C_("Logging level", "Trace") },
|
||||
} }
|
||||
{
|
||||
/**
|
||||
|
@ -508,5 +513,7 @@ MessageLogWindow::Impl::Impl(
|
|||
appendColumn(view_, message_log_cols.name);
|
||||
appendColumn(view_, message_log_cols.message);
|
||||
|
||||
level_combo_changed_cb(level_combo);
|
||||
|
||||
scroll_to_bottom();
|
||||
}
|
||||
|
|
|
@ -369,6 +369,9 @@ void tr_sessionGetSettings(tr_session const* session, tr_variant* setme_dictiona
|
|||
session->settings_.save(setme_dictionary);
|
||||
session->alt_speeds_.save(setme_dictionary);
|
||||
session->rpc_server_->save(setme_dictionary);
|
||||
|
||||
tr_variantDictRemove(setme_dictionary, TR_KEY_message_level);
|
||||
tr_variantDictAddInt(setme_dictionary, TR_KEY_message_level, tr_logGetLevel());
|
||||
}
|
||||
|
||||
static void getSettingsFilename(tr_pathbuf& setme, char const* config_dir, char const* appname)
|
||||
|
|
|
@ -101,16 +101,7 @@ std::optional<tr_encryption_mode> VariantConverter::load<tr_encryption_mode>(tr_
|
|||
template<>
|
||||
void VariantConverter::save<tr_encryption_mode>(tr_variant* tgt, tr_encryption_mode const& val)
|
||||
{
|
||||
using namespace EncryptionHelpers;
|
||||
|
||||
for (auto const& [key, value] : Keys)
|
||||
{
|
||||
if (value == val)
|
||||
{
|
||||
tr_variantInitStrView(tgt, key);
|
||||
return;
|
||||
}
|
||||
}
|
||||
tr_variantInitInt(tgt, val);
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -165,16 +156,7 @@ std::optional<tr_log_level> VariantConverter::load<tr_log_level>(tr_variant* src
|
|||
template<>
|
||||
void VariantConverter::save<tr_log_level>(tr_variant* tgt, tr_log_level const& val)
|
||||
{
|
||||
using namespace LogLevelHelpers;
|
||||
|
||||
for (auto const& [key, value] : Keys)
|
||||
{
|
||||
if (value == val)
|
||||
{
|
||||
tr_variantInitStrView(tgt, key);
|
||||
return;
|
||||
}
|
||||
}
|
||||
tr_variantInitInt(tgt, val);
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -273,16 +255,7 @@ std::optional<tr_preallocation_mode> VariantConverter::load<tr_preallocation_mod
|
|||
template<>
|
||||
void VariantConverter::save<tr_preallocation_mode>(tr_variant* tgt, tr_preallocation_mode const& val)
|
||||
{
|
||||
using namespace PreallocationModeHelpers;
|
||||
|
||||
for (auto const& [key, value] : Keys)
|
||||
{
|
||||
if (value == val)
|
||||
{
|
||||
tr_variantInitStrView(tgt, key);
|
||||
return;
|
||||
}
|
||||
}
|
||||
tr_variantInitInt(tgt, val);
|
||||
}
|
||||
|
||||
///
|
||||
|
|
|
@ -128,9 +128,9 @@ TEST_F(SettingsTest, canSaveEncryptionMode)
|
|||
auto dict = tr_variant{};
|
||||
tr_variantInitDict(&dict, 100);
|
||||
settings.save(&dict);
|
||||
auto val = std::string_view{};
|
||||
EXPECT_TRUE(tr_variantDictFindStrView(&dict, Key, &val));
|
||||
EXPECT_EQ("required"sv, val);
|
||||
auto val = int64_t{};
|
||||
EXPECT_TRUE(tr_variantDictFindInt(&dict, Key, &val));
|
||||
EXPECT_EQ(ExpectedValue, val);
|
||||
tr_variantClear(&dict);
|
||||
}
|
||||
|
||||
|
@ -171,9 +171,9 @@ TEST_F(SettingsTest, canSaveLogLevel)
|
|||
tr_variantInitDict(&dict, 100);
|
||||
settings.log_level = ExpectedValue;
|
||||
settings.save(&dict);
|
||||
auto val = std::string_view{};
|
||||
EXPECT_TRUE(tr_variantDictFindStrView(&dict, Key, &val));
|
||||
EXPECT_EQ("debug", val);
|
||||
auto val = int64_t{};
|
||||
EXPECT_TRUE(tr_variantDictFindInt(&dict, Key, &val));
|
||||
EXPECT_EQ(ExpectedValue, val);
|
||||
tr_variantClear(&dict);
|
||||
}
|
||||
|
||||
|
@ -293,9 +293,9 @@ TEST_F(SettingsTest, canSavePreallocation)
|
|||
tr_variantInitDict(&dict, 100);
|
||||
settings.preallocation_mode = ExpectedValue;
|
||||
settings.save(&dict);
|
||||
auto val = std::string_view{};
|
||||
EXPECT_TRUE(tr_variantDictFindStrView(&dict, Key, &val));
|
||||
EXPECT_EQ("full", val);
|
||||
auto val = int64_t{};
|
||||
EXPECT_TRUE(tr_variantDictFindInt(&dict, Key, &val));
|
||||
EXPECT_EQ(ExpectedValue, val);
|
||||
tr_variantClear(&dict);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue