mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-15 10:48:33 +01:00
plugin that lets you grey out deleted songs on demand ("main menu / playlist") - available by default
also: this action will "ungrey" songs that were deleted but got restored SIPs
This commit is contained in:
parent
823f798451
commit
3db00fc339
@ -8,3 +8,4 @@ endfunction(install_script_files)
|
||||
|
||||
add_subdirectory(digitallyimported-radio)
|
||||
add_subdirectory(remove-duplicates)
|
||||
add_subdirectory(invalidate-deleted)
|
||||
|
5
scripts/invalidate-deleted/CMakeLists.txt
Normal file
5
scripts/invalidate-deleted/CMakeLists.txt
Normal file
@ -0,0 +1,5 @@
|
||||
install_script_files(invalidate-deleted
|
||||
icon.png
|
||||
invalidate_deleted.py
|
||||
script.ini
|
||||
)
|
BIN
scripts/invalidate-deleted/icon.png
Normal file
BIN
scripts/invalidate-deleted/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
22
scripts/invalidate-deleted/invalidate_deleted.py
Normal file
22
scripts/invalidate-deleted/invalidate_deleted.py
Normal file
@ -0,0 +1,22 @@
|
||||
import clementine
|
||||
|
||||
from PyQt4.QtCore import QObject
|
||||
from PyQt4.QtCore import SIGNAL
|
||||
from PyQt4.QtGui import QAction
|
||||
|
||||
class InvalidateDeleted(QObject):
|
||||
|
||||
def __init__(self):
|
||||
QObject.__init__(self)
|
||||
|
||||
self.action = QAction("invalidate_deleted", self)
|
||||
self.action.setText("Grey out deleted songs")
|
||||
self.connect(self.action, SIGNAL("activated()"), self.grey_out_activated)
|
||||
|
||||
clementine.ui.AddAction('playlist_menu', self.action)
|
||||
|
||||
def grey_out_activated(self):
|
||||
clementine.playlists.InvalidateDeletedSongs()
|
||||
|
||||
|
||||
script = InvalidateDeleted()
|
9
scripts/invalidate-deleted/script.ini
Normal file
9
scripts/invalidate-deleted/script.ini
Normal file
@ -0,0 +1,9 @@
|
||||
[Script]
|
||||
name=Deleted songs invalidator
|
||||
description=This script will add a menu item for playlist's main menu which will grey out all non existent songs in all of your playlists.
|
||||
author=Pawel Bara <keirangtp ( at ) gmail.com>
|
||||
url=http://www.clementine-player.org
|
||||
icon=icon.png
|
||||
|
||||
language=python
|
||||
script_file=invalidate_deleted.py
|
@ -1580,10 +1580,17 @@ void Playlist::InvalidateDeletedSongs() {
|
||||
PlaylistItemPtr item = items_[row];
|
||||
Song song = item->Metadata();
|
||||
|
||||
if(song.filetype() != Song::Type_Stream && !QFile::exists(song.filename())) {
|
||||
// gray out the song if it's not there
|
||||
item->SetForegroundColor(kInvalidSongPriority, kInvalidSongColor);
|
||||
invalidated_rows.append(row);
|
||||
if(song.filetype() != Song::Type_Stream) {
|
||||
bool exists = QFile::exists(song.filename());
|
||||
|
||||
if(!exists && !item->HasForegroundColor(kInvalidSongPriority)) {
|
||||
// gray out the song if it's not there
|
||||
item->SetForegroundColor(kInvalidSongPriority, kInvalidSongColor);
|
||||
invalidated_rows.append(row);
|
||||
} else if(exists && item->HasForegroundColor(kInvalidSongPriority)) {
|
||||
item->RemoveForegroundColor(kInvalidSongPriority);
|
||||
invalidated_rows.append(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,9 @@ QFuture<void> PlaylistItem::BackgroundReload() {
|
||||
void PlaylistItem::SetBackgroundColor(short priority, const QColor& color) {
|
||||
background_colors_[priority] = color;
|
||||
}
|
||||
bool PlaylistItem::HasBackgroundColor(short priority) const {
|
||||
return background_colors_.contains(priority);
|
||||
}
|
||||
void PlaylistItem::RemoveBackgroundColor(short priority) {
|
||||
background_colors_.remove(priority);
|
||||
}
|
||||
@ -110,6 +113,9 @@ bool PlaylistItem::HasCurrentBackgroundColor() const {
|
||||
void PlaylistItem::SetForegroundColor(short priority, const QColor& color) {
|
||||
foreground_colors_[priority] = color;
|
||||
}
|
||||
bool PlaylistItem::HasForegroundColor(short priority) const {
|
||||
return foreground_colors_.contains(priority);
|
||||
}
|
||||
void PlaylistItem::RemoveForegroundColor(short priority) {
|
||||
foreground_colors_.remove(priority);
|
||||
}
|
||||
|
@ -116,12 +116,14 @@ class PlaylistItem : public boost::enable_shared_from_this<PlaylistItem> {
|
||||
|
||||
// Background colors.
|
||||
void SetBackgroundColor(short priority, const QColor& color);
|
||||
bool HasBackgroundColor(short priority) const;
|
||||
void RemoveBackgroundColor(short priority);
|
||||
QColor GetCurrentBackgroundColor() const;
|
||||
bool HasCurrentBackgroundColor() const;
|
||||
|
||||
// Foreground colors.
|
||||
void SetForegroundColor(short priority, const QColor& color);
|
||||
bool HasForegroundColor(short priority) const;
|
||||
void RemoveForegroundColor(short priority);
|
||||
QColor GetCurrentForegroundColor() const;
|
||||
bool HasCurrentForegroundColor() const;
|
||||
|
@ -111,6 +111,9 @@ public:
|
||||
void InsertUrls (const QList<QUrl>& urls, int pos = -1, bool play_now = false, bool enqueue = false);
|
||||
void RemoveItemsWithoutUndo (const QList<int>& indicesIn);
|
||||
|
||||
// Grays out and reloads all deleted songs in this playlist.
|
||||
void InvalidateDeletedSongs();
|
||||
|
||||
void StopAfter(int row);
|
||||
void ReloadItems(const QList<int>& rows);
|
||||
|
||||
|
@ -199,6 +199,14 @@ Below we list all the currently taken background priorities:
|
||||
|
||||
If it makes sense, one functionality (one plugin) can use many background
|
||||
priorities at the same time.
|
||||
%End
|
||||
|
||||
bool HasBackgroundColor(short priority) const;
|
||||
%Docstring
|
||||
HasBackgroundColor(priority) -> bool
|
||||
Checks if this PlaylistItem has a background color with this priority set.
|
||||
It doesn't need to be the current color, it just needs to exist in the colors
|
||||
list.
|
||||
%End
|
||||
|
||||
void RemoveBackgroundColor(short priority);
|
||||
@ -231,14 +239,22 @@ If it makes sense, one functionality (one plugin) can use many foreground
|
||||
priorities at the same time.
|
||||
%End
|
||||
|
||||
bool HasForegroundColor(short priority) const;
|
||||
%Docstring
|
||||
HasForegroundColor(priority) -> bool
|
||||
Checks if this PlaylistItem has a foreground color with this priority set.
|
||||
It doesn't need to be the current color, it just needs to exist in the colors
|
||||
list.
|
||||
%End
|
||||
|
||||
void RemoveForegroundColor(short priority);
|
||||
%Docstring
|
||||
%Docstring
|
||||
RemoveForegroundColor(priority)
|
||||
Removes a foreground color with the given priority from this PlaylistItem's
|
||||
foreground. If there's no such color, this call will be ignored.
|
||||
|
||||
@see: L{SetForegroundColor()}
|
||||
%End
|
||||
%End
|
||||
|
||||
~PlaylistItem();
|
||||
%MethodCode
|
||||
|
@ -85,6 +85,13 @@ Equivalent to C{playlist(active_id())}.
|
||||
%Docstring
|
||||
GetAllPlaylists() -> list of L{Playlist}s
|
||||
Returns a list containing all the playlists.
|
||||
%End
|
||||
|
||||
void InvalidateDeletedSongs();
|
||||
%Docstring
|
||||
InvalidateDeletedSongs()
|
||||
Grays out and reloads all deleted songs in all playlists. Also, "ungreys"
|
||||
those songs which were once deleted but now got restored somehow.
|
||||
%End
|
||||
|
||||
const QItemSelection& selection(int id) const;
|
||||
|
@ -390,7 +390,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1131</width>
|
||||
<height>23</height>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_music">
|
||||
@ -429,6 +429,7 @@
|
||||
<addaction name="action_jump"/>
|
||||
<addaction name="action_clear_playlist"/>
|
||||
<addaction name="action_shuffle"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_help">
|
||||
<property name="title">
|
||||
|
Loading…
Reference in New Issue
Block a user