actions: toggle screen lock: check if screen is lockable before asking for width
This commit is contained in:
@@ -1564,14 +1564,18 @@ void ToggleScreenLock::run()
|
||||
{
|
||||
using Global::wFooter;
|
||||
using Global::myLockedScreen;
|
||||
// FIXME: check if screen can be locked before prompting for width
|
||||
if (myLockedScreen != 0)
|
||||
const char *msg_unlockable_screen = "Current screen can't be locked";
|
||||
if (myLockedScreen != nullptr)
|
||||
{
|
||||
BaseScreen::unlock();
|
||||
Actions::setResizeFlags();
|
||||
myScreen->resize();
|
||||
Statusbar::print("Screen unlocked");
|
||||
}
|
||||
else if (!myScreen->isLockable())
|
||||
{
|
||||
Statusbar::print(msg_unlockable_screen);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned part = Config.locked_screen_width_part*100;
|
||||
@@ -1586,7 +1590,7 @@ void ToggleScreenLock::run()
|
||||
if (myScreen->lock())
|
||||
Statusbar::printf("Screen locked (with %1%%% width)", part);
|
||||
else
|
||||
Statusbar::print("Current screen can't be locked");
|
||||
Statusbar::print(msg_unlockable_screen);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ struct Browser: Screen<NC::Menu<MPD::Item>>, HasSongs, Searchable, Tabbable
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Searchable implementation
|
||||
@@ -73,9 +74,6 @@ struct Browser: Screen<NC::Menu<MPD::Item>>, HasSongs, Searchable, Tabbable
|
||||
|
||||
static void fetchSupportedExtensions();
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
bool m_update_request;
|
||||
bool m_local_browser;
|
||||
|
||||
@@ -46,10 +46,8 @@ struct Clock: Screen<NC::Window>, Tabbable
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
||||
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
NC::Window m_pane;
|
||||
|
||||
@@ -40,10 +40,8 @@ struct Help: Screen<NC::Scrollpad>, Tabbable
|
||||
virtual void enterPressed() OVERRIDE { }
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
};
|
||||
|
||||
extern Help *myHelp;
|
||||
|
||||
@@ -48,6 +48,7 @@ struct Lastfm: Screen<NC::Scrollpad>, Tabbable
|
||||
virtual void enterPressed() OVERRIDE { }
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
template <typename ServiceT>
|
||||
@@ -69,9 +70,6 @@ struct Lastfm: Screen<NC::Scrollpad>, Tabbable
|
||||
m_title = ToWString(m_service->name());
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
void getResult();
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ struct Lyrics: Screen<NC::Scrollpad>, Tabbable
|
||||
virtual void enterPressed() OVERRIDE { }
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// private members
|
||||
@@ -60,9 +61,6 @@ struct Lyrics: Screen<NC::Scrollpad>, Tabbable
|
||||
|
||||
bool Reload;
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
void Load();
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ struct MediaLibrary: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tab
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Searchable implementation
|
||||
@@ -135,9 +136,6 @@ struct MediaLibrary: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tab
|
||||
NC::Menu<AlbumEntry> Albums;
|
||||
NC::Menu<MPD::Song> Songs;
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
void AddToPlaylist(bool);
|
||||
|
||||
|
||||
@@ -47,13 +47,11 @@ struct Outputs: Screen<NC::Menu<MPD::Output>>, Tabbable
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// private members
|
||||
void FetchList();
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
};
|
||||
|
||||
extern Outputs *myOutputs;
|
||||
|
||||
@@ -46,6 +46,7 @@ struct Playlist: Screen<NC::Menu<MPD::Song>>, HasSongs, Searchable, Tabbable
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Searchable implementation
|
||||
@@ -77,9 +78,6 @@ struct Playlist: Screen<NC::Menu<MPD::Song>>, HasSongs, Searchable, Tabbable
|
||||
void reloadTotalLength() { m_reload_total_length = true; }
|
||||
void reloadRemaining() { m_reload_remaining = true; }
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
std::string getTotalLength();
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ struct PlaylistEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, T
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Searchable implementation
|
||||
@@ -80,9 +81,6 @@ struct PlaylistEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, T
|
||||
NC::Menu<MPD::Playlist> Playlists;
|
||||
NC::Menu<MPD::Song> Content;
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
void AddToPlaylist(bool);
|
||||
|
||||
|
||||
@@ -98,8 +98,7 @@ void BaseScreen::getWindowResizeParams(size_t &x_offset, size_t &width, bool adj
|
||||
|
||||
bool BaseScreen::lock()
|
||||
{
|
||||
if (myLockedScreen)
|
||||
return false;
|
||||
assert(myLockedScreen == nullptr);
|
||||
if (isLockable())
|
||||
{
|
||||
myLockedScreen = this;
|
||||
|
||||
12
src/screen.h
12
src/screen.h
@@ -81,6 +81,12 @@ struct BaseScreen
|
||||
/// @see Screen::mouseButtonPressed()
|
||||
virtual void mouseButtonPressed(MEVENT me) = 0;
|
||||
|
||||
/// @return true if screen can be locked. Note that returning
|
||||
/// false here doesn't neccesarily mean that screen is also not
|
||||
/// mergable (eg. lyrics screen is not lockable since that wouldn't
|
||||
/// make much sense, but it's perfectly fine to merge it).
|
||||
virtual bool isLockable() = 0;
|
||||
|
||||
/// @return true if screen is mergable, ie. can be "proper" subwindow
|
||||
/// if one of the screens is locked. Screens that somehow resemble popups
|
||||
/// will want to return false here.
|
||||
@@ -98,12 +104,6 @@ struct BaseScreen
|
||||
static void unlock();
|
||||
|
||||
protected:
|
||||
/// @return true if screen can be locked. Note that returning
|
||||
/// false here doesn't neccesarily mean that screen is also not
|
||||
/// mergable (eg. lyrics screen is not lockable since that wouldn't
|
||||
/// make much sense, but it's perfectly fine to merge it).
|
||||
virtual bool isLockable() = 0;
|
||||
|
||||
/// Gets X offset and width of current screen to be used eg. in resize() function.
|
||||
/// @param adjust_locked_screen indicates whether this function should
|
||||
/// automatically adjust locked screen's dimensions (if there is one set)
|
||||
|
||||
@@ -91,6 +91,7 @@ struct SearchEngine: Screen<NC::Menu<SEItem>>, HasSongs, Searchable, Tabbable
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Searchable implementation
|
||||
@@ -113,9 +114,6 @@ struct SearchEngine: Screen<NC::Menu<SEItem>>, HasSongs, Searchable, Tabbable
|
||||
static size_t SearchButton;
|
||||
static size_t ResetButton;
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
void Prepare();
|
||||
void Search();
|
||||
|
||||
@@ -47,10 +47,8 @@ struct SelectedItemsAdder: Screen<NC::Menu<RunnableItem<std::string, void()>> *>
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isMergable() OVERRIDE { return false; }
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
virtual bool isMergable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
void populatePlaylistSelector(BaseScreen *screen);
|
||||
|
||||
@@ -42,10 +42,8 @@ struct ServerInfo: Screen<NC::Scrollpad>, Tabbable
|
||||
virtual void enterPressed() OVERRIDE { }
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
|
||||
virtual bool isMergable() OVERRIDE { return false; }
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
virtual bool isMergable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
void SetDimensions();
|
||||
|
||||
@@ -48,14 +48,12 @@ struct SongInfo: Screen<NC::Scrollpad>, Tabbable
|
||||
virtual void enterPressed() OVERRIDE { }
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// private members
|
||||
static const Metadata Tags[];
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
void PrepareSong(MPD::Song &);
|
||||
};
|
||||
|
||||
@@ -45,15 +45,13 @@ struct SortPlaylistDialog
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
virtual bool isMergable() OVERRIDE { return false; }
|
||||
|
||||
// private members
|
||||
void moveSortOrderUp();
|
||||
void moveSortOrderDown();
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
void moveSortOrderHint() const;
|
||||
void sort() const;
|
||||
|
||||
@@ -49,6 +49,7 @@ struct TagEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tabbab
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// Searchable implementation
|
||||
@@ -79,9 +80,6 @@ struct TagEditor: Screen<NC::Window *>, HasColumns, HasSongs, Searchable, Tabbab
|
||||
NC::Menu<std::string> *TagTypes;
|
||||
NC::Menu<MPD::MutableSong> *Tags;
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
void SetDimensions(size_t, size_t);
|
||||
|
||||
|
||||
@@ -46,14 +46,12 @@ struct TinyTagEditor: Screen<NC::Menu<NC::Buffer>>
|
||||
virtual void spacePressed() OVERRIDE { }
|
||||
virtual void mouseButtonPressed(MEVENT me) OVERRIDE;
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// private members
|
||||
void SetEdited(const MPD::Song &);
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return false; }
|
||||
|
||||
private:
|
||||
bool getTags();
|
||||
MPD::MutableSong itsEdited;
|
||||
|
||||
@@ -53,6 +53,7 @@ struct Visualizer: Screen<NC::Window>, Tabbable
|
||||
virtual void spacePressed() OVERRIDE;
|
||||
virtual void mouseButtonPressed(MEVENT) OVERRIDE { }
|
||||
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
virtual bool isMergable() OVERRIDE { return true; }
|
||||
|
||||
// private members
|
||||
@@ -60,9 +61,6 @@ struct Visualizer: Screen<NC::Window>, Tabbable
|
||||
void ResetFD();
|
||||
void FindOutputID();
|
||||
|
||||
protected:
|
||||
virtual bool isLockable() OVERRIDE { return true; }
|
||||
|
||||
private:
|
||||
void DrawSoundWave(int16_t *, ssize_t, size_t, size_t);
|
||||
void DrawSoundWaveStereo(int16_t *, int16_t *, ssize_t, size_t);
|
||||
|
||||
Reference in New Issue
Block a user