settings: add option to disable data fetching delay in media library and playlist editor

This commit is contained in:
Andrzej Rybczak
2014-09-14 13:32:40 +02:00
parent 0efe79b475
commit 67f2903c42
8 changed files with 24 additions and 11 deletions

View File

@@ -48,9 +48,6 @@ MediaLibrary *myLibrary;
namespace {
const auto ml_wtimeout = 250;
const auto fetch_delay = boost::posix_time::milliseconds(ml_wtimeout);
bool hasTwoColumns;
size_t itsLeftColStartX;
size_t itsLeftColWidth;
@@ -149,6 +146,8 @@ public:
MediaLibrary::MediaLibrary()
: m_timer(boost::posix_time::from_time_t(0))
, m_window_timeout(Config.data_fetching_delay ? 250 : 500)
, m_fetching_delay(boost::posix_time::milliseconds(Config.data_fetching_delay ? 250 : -1))
{
hasTwoColumns = 0;
itsLeftColWidth = COLS/3-1;
@@ -342,7 +341,7 @@ void MediaLibrary::update()
}
if (!Tags.empty()
&& ((Albums.reallyEmpty() && Global::Timer - m_timer > fetch_delay) || m_albums_update_request)
&& ((Albums.reallyEmpty() && Global::Timer - m_timer > m_fetching_delay) || m_albums_update_request)
)
{
Albums.clearSearchResults();
@@ -390,7 +389,7 @@ void MediaLibrary::update()
}
if (!Albums.empty()
&& ((Songs.reallyEmpty() && Global::Timer - m_timer > fetch_delay) || m_songs_update_request)
&& ((Songs.reallyEmpty() && Global::Timer - m_timer > m_fetching_delay) || m_songs_update_request)
)
{
Songs.clearSearchResults();
@@ -427,7 +426,7 @@ void MediaLibrary::update()
int MediaLibrary::windowTimeout()
{
if (Albums.reallyEmpty() || Songs.reallyEmpty())
return ml_wtimeout;
return m_window_timeout;
else
return Screen<WindowType>::windowTimeout();
}

View File

@@ -150,6 +150,9 @@ private:
bool m_songs_update_request;
boost::posix_time::ptime m_timer;
const int m_window_timeout;
const boost::posix_time::time_duration m_fetching_delay;
};
extern MediaLibrary *myLibrary;

View File

@@ -45,9 +45,6 @@ PlaylistEditor *myPlaylistEditor;
namespace {
const int pe_timeout = 250;
const auto fetch_delay = boost::posix_time::milliseconds(pe_timeout);
size_t LeftColumnStartX;
size_t LeftColumnWidth;
size_t RightColumnStartX;
@@ -61,6 +58,8 @@ bool SongEntryMatcher(const boost::regex &rx, const MPD::Song &s);
PlaylistEditor::PlaylistEditor()
: m_timer(boost::posix_time::from_time_t(0))
, m_window_timeout(Config.data_fetching_delay ? 250 : 500)
, m_fetching_delay(boost::posix_time::milliseconds(Config.data_fetching_delay ? 250 : -1))
{
LeftColumnWidth = COLS/3-1;
RightColumnStartX = LeftColumnWidth+1;
@@ -158,7 +157,7 @@ void PlaylistEditor::update()
}
if (!Playlists.empty()
&& ((Content.reallyEmpty() && Global::Timer - m_timer > fetch_delay) || m_content_update_requested)
&& ((Content.reallyEmpty() && Global::Timer - m_timer > m_fetching_delay) || m_content_update_requested)
)
{
m_content_update_requested = false;
@@ -212,7 +211,7 @@ void PlaylistEditor::update()
int PlaylistEditor::windowTimeout()
{
if (Content.reallyEmpty())
return pe_timeout;
return m_window_timeout;
else
return Screen<WindowType>::windowTimeout();
}

View File

@@ -95,6 +95,9 @@ private:
bool m_content_update_requested;
boost::posix_time::ptime m_timer;
const int m_window_timeout;
const boost::posix_time::time_duration m_fetching_delay;
};
extern PlaylistEditor *myPlaylistEditor;

View File

@@ -400,6 +400,9 @@ bool Configuration::read(const std::string &config_path)
p.add("user_interface", assign_default(
design, Design::Classic
));
p.add("data_fetching_delay", yes_no(
data_fetching_delay, true
));
p.add("media_library_primary_tag", option_parser::worker([this](std::string &&v) {
if (v == "artist")
media_lib_primary_tag = MPD_TAG_ARTIST;

View File

@@ -153,6 +153,7 @@ struct Configuration
bool mouse_list_scroll_whole_page;
bool visualizer_use_wave;
bool visualizer_in_stereo;
bool data_fetching_delay;
bool media_library_sort_by_mtime;
bool tag_editor_extended_numeration;
bool discard_colors_if_item_is_selected;