mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-17 11:28:16 +00:00
gui2/tgame_cache_options: Disable Clean/Purge buttons if cache is empty
This commit is contained in:
parent
f5ba6a0e9e
commit
85688780c5
@ -76,13 +76,18 @@ REGISTER_DIALOG(game_cache_options)
|
|||||||
|
|
||||||
tgame_cache_options::tgame_cache_options()
|
tgame_cache_options::tgame_cache_options()
|
||||||
: cache_path_(filesystem::get_cache_dir())
|
: cache_path_(filesystem::get_cache_dir())
|
||||||
|
, clean_button_(NULL)
|
||||||
|
, purge_button_(NULL)
|
||||||
, size_label_(NULL)
|
, size_label_(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void tgame_cache_options::pre_show(CVideo& video, twindow& window)
|
void tgame_cache_options::pre_show(CVideo& video, twindow& window)
|
||||||
{
|
{
|
||||||
|
clean_button_ = &find_widget<tbutton>(&window, "clean", false);
|
||||||
|
purge_button_ = &find_widget<tbutton>(&window, "purge", false);
|
||||||
size_label_ = &find_widget<tlabel>(&window, "size", false);
|
size_label_ = &find_widget<tlabel>(&window, "size", false);
|
||||||
|
|
||||||
update_cache_size_display();
|
update_cache_size_display();
|
||||||
|
|
||||||
ttext_& path_box = find_widget<ttext_>(&window, "path", false);
|
ttext_& path_box = find_widget<ttext_>(&window, "path", false);
|
||||||
@ -103,14 +108,12 @@ void tgame_cache_options::pre_show(CVideo& video, twindow& window)
|
|||||||
boost::bind(&tgame_cache_options::browse_cache_callback,
|
boost::bind(&tgame_cache_options::browse_cache_callback,
|
||||||
this));
|
this));
|
||||||
|
|
||||||
tbutton& clean = find_widget<tbutton>(&window, "clean", false);
|
connect_signal_mouse_left_click(*clean_button_,
|
||||||
connect_signal_mouse_left_click(clean,
|
|
||||||
boost::bind(&tgame_cache_options::clean_cache_callback,
|
boost::bind(&tgame_cache_options::clean_cache_callback,
|
||||||
this,
|
this,
|
||||||
boost::ref(video)));
|
boost::ref(video)));
|
||||||
|
|
||||||
tbutton& purge = find_widget<tbutton>(&window, "purge", false);
|
connect_signal_mouse_left_click(*purge_button_,
|
||||||
connect_signal_mouse_left_click(purge,
|
|
||||||
boost::bind(&tgame_cache_options::purge_cache_callback,
|
boost::bind(&tgame_cache_options::purge_cache_callback,
|
||||||
this,
|
this,
|
||||||
boost::ref(video)));
|
boost::ref(video)));
|
||||||
@ -134,6 +137,11 @@ void tgame_cache_options::update_cache_size_display()
|
|||||||
} else {
|
} else {
|
||||||
size_label_->set_label(utils::si_string(size, true, _("unit_byte^B")));
|
size_label_->set_label(utils::si_string(size, true, _("unit_byte^B")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(size == 0) {
|
||||||
|
clean_button_->set_active(false);
|
||||||
|
purge_button_->set_active(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tgame_cache_options::copy_to_clipboard_callback()
|
void tgame_cache_options::copy_to_clipboard_callback()
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
namespace gui2
|
namespace gui2
|
||||||
{
|
{
|
||||||
class tlabel;
|
class tlabel;
|
||||||
|
class tbutton;
|
||||||
|
|
||||||
class tgame_cache_options : public tdialog
|
class tgame_cache_options : public tdialog
|
||||||
{
|
{
|
||||||
@ -39,6 +40,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string cache_path_;
|
std::string cache_path_;
|
||||||
|
|
||||||
|
tbutton* clean_button_;
|
||||||
|
tbutton* purge_button_;
|
||||||
tlabel* size_label_;
|
tlabel* size_label_;
|
||||||
|
|
||||||
void clean_cache_callback(CVideo& video);
|
void clean_cache_callback(CVideo& video);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user