Use icon loader for remaining icons
This commit is contained in:
parent
8579cce85c
commit
29b8d308b3
|
@ -26,6 +26,7 @@
|
|||
#include "core/application.h"
|
||||
#include "covers/albumcoverloader.h"
|
||||
#include "playlist/playlistmanager.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
CurrentArtLoader::CurrentArtLoader(Application* app, QObject* parent)
|
||||
: QObject(parent),
|
||||
|
@ -34,7 +35,9 @@ CurrentArtLoader::CurrentArtLoader(Application* app, QObject* parent)
|
|||
id_(0) {
|
||||
options_.scale_output_image_ = false;
|
||||
options_.pad_output_image_ = false;
|
||||
options_.default_output_image_ = QImage(":nocover.png");
|
||||
options_.default_output_image_ = IconLoader::Load("nocover",
|
||||
IconLoader::Other)
|
||||
.pixmap(300).toImage();
|
||||
|
||||
connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64, QImage)),
|
||||
SLOT(TempArtLoaded(quint64, QImage)));
|
||||
|
|
|
@ -33,8 +33,9 @@ GlobalSearchModel::GlobalSearchModel(GlobalSearch* engine, QObject* parent)
|
|||
group_by_[1] = LibraryModel::GroupBy_Album;
|
||||
group_by_[2] = LibraryModel::GroupBy_None;
|
||||
|
||||
no_cover_icon_ = QPixmap(":nocover.png").scaled(
|
||||
LibraryModel::kPrettyCoverSize, LibraryModel::kPrettyCoverSize,
|
||||
no_cover_icon_ = QPixmap(IconLoader::Load("nocover", IconLoader::Other)
|
||||
.pixmap(300)).scaled(LibraryModel::kPrettyCoverSize,
|
||||
LibraryModel::kPrettyCoverSize,
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
|
|
|
@ -413,7 +413,8 @@ void SpotifyService::PlaylistsUpdated(const pb::spotify::Playlists& response) {
|
|||
search_->setData(InternetModel::PlayBehaviour_MultipleItems,
|
||||
InternetModel::Role_PlayBehaviour);
|
||||
|
||||
starred_ = new QStandardItem(QIcon(":/star-on.png"), tr("Starred"));
|
||||
starred_ = new QStandardItem(IconLoader::Load("star-on", IconLoader::Other),
|
||||
tr("Starred"));
|
||||
starred_->setData(Type_StarredPlaylist, InternetModel::Role_Type);
|
||||
starred_->setData(true, InternetModel::Role_CanLazyLoad);
|
||||
starred_->setData(InternetModel::PlayBehaviour_MultipleItems,
|
||||
|
@ -610,7 +611,8 @@ QList<QAction*> SpotifyService::playlistitem_actions(const Song& song) {
|
|||
}
|
||||
|
||||
QAction* add_to_starred =
|
||||
new QAction(QIcon(":/star-on.png"), tr("Add to Spotify starred"), this);
|
||||
new QAction(IconLoader::Load("star-on", IconLoader::Other),
|
||||
tr("Add to Spotify starred"), this);
|
||||
connect(add_to_starred, SIGNAL(triggered()),
|
||||
SLOT(AddCurrentSongToStarredPlaylist()));
|
||||
playlistitem_actions_.append(add_to_starred);
|
||||
|
|
|
@ -107,9 +107,10 @@ LibraryModel::LibraryModel(LibraryBackend* backend, Application* app,
|
|||
Utilities::GetConfigPath(Utilities::Path_CacheRoot) + "/pixmapcache");
|
||||
icon_cache_->setMaximumCacheSize(LibraryModel::kIconCacheSize);
|
||||
|
||||
no_cover_icon_ = QPixmap(":nocover.png")
|
||||
.scaled(kPrettyCoverSize, kPrettyCoverSize,
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
no_cover_icon_ = QPixmap(IconLoader::Load("nocover", IconLoader::Other)
|
||||
.pixmap(300)).scaled(kPrettyCoverSize,
|
||||
kPrettyCoverSize, Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
|
||||
connect(backend_, SIGNAL(SongsDiscovered(SongList)),
|
||||
SLOT(SongsDiscovered(SongList)));
|
||||
|
|
|
@ -173,7 +173,8 @@ LibraryView::LibraryView(QWidget* parent)
|
|||
app_(nullptr),
|
||||
filter_(nullptr),
|
||||
total_song_count_(-1),
|
||||
nomusic_(":nomusic.png"),
|
||||
nomusic_(IconLoader::Load("nocover",
|
||||
IconLoader::Other).pixmap(300)),
|
||||
context_menu_(nullptr),
|
||||
is_in_keyboard_search_(false) {
|
||||
setItemDelegate(new LibraryItemDelegate(this));
|
||||
|
|
|
@ -224,11 +224,11 @@ void PlaylistContainer::SetViewModel(Playlist* playlist) {
|
|||
}
|
||||
|
||||
void PlaylistContainer::ActivePlaying() {
|
||||
UpdateActiveIcon(QIcon(":tiny-start.png"));
|
||||
UpdateActiveIcon(IconLoader::Load("tiny-start", IconLoader::Other));
|
||||
}
|
||||
|
||||
void PlaylistContainer::ActivePaused() {
|
||||
UpdateActiveIcon(QIcon(":tiny-pause.png"));
|
||||
UpdateActiveIcon(IconLoader::Load("tiny-pause", IconLoader::Other));
|
||||
}
|
||||
|
||||
void PlaylistContainer::ActiveStopped() { UpdateActiveIcon(QIcon()); }
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "core/player.h"
|
||||
#include "covers/currentartloader.h"
|
||||
#include "ui/qt_blurimage.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
#include <QCleanlooksStyle>
|
||||
#include <QClipboard>
|
||||
|
@ -127,8 +128,10 @@ PlaylistView::PlaylistView(QWidget* parent)
|
|||
inhibit_autoscroll_(false),
|
||||
currently_autoscrolling_(false),
|
||||
row_height_(-1),
|
||||
currenttrack_play_(":currenttrack_play.png"),
|
||||
currenttrack_pause_(":currenttrack_pause.png"),
|
||||
currenttrack_play_(IconLoader::Load("currenttrack_play",
|
||||
IconLoader::Other).pixmap(16)),
|
||||
currenttrack_pause_(IconLoader::Load("currenttrack_pause",
|
||||
IconLoader::Other).pixmap(16)),
|
||||
cached_current_row_row_(-1),
|
||||
drop_indicator_row_(-1),
|
||||
drag_over_(false),
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "widgets/forcescrollperpixel.h"
|
||||
#include "ui/albumcoverchoicecontroller.h"
|
||||
#include "ui/albumcoverexport.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
#include <QActionGroup>
|
||||
#include <QPushButton>
|
||||
|
@ -88,7 +89,8 @@ AlbumCoverManager::AlbumCoverManager(Application* app,
|
|||
album_cover_choice_controller_->SetApplication(app_);
|
||||
|
||||
// Get a square version of nocover.png
|
||||
QImage nocover(":/nocover.png");
|
||||
QImage nocover(IconLoader::Load("nocover", IconLoader::Other).pixmap(300)
|
||||
.toImage());
|
||||
nocover =
|
||||
nocover.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
QImage square_nocover(120, 120, QImage::Format_ARGB32);
|
||||
|
@ -599,7 +601,8 @@ void AlbumCoverManager::SaveCoverToFile() {
|
|||
|
||||
// load the image from disk
|
||||
if (song.has_manually_unset_cover()) {
|
||||
image = QImage(":/nocover.png");
|
||||
image = IconLoader::Load("nocover", IconLoader::Other).pixmap(300)
|
||||
.toImage();
|
||||
} else {
|
||||
if (!song.art_manual().isEmpty() && QFile::exists(song.art_manual())) {
|
||||
image = QImage(song.art_manual());
|
||||
|
@ -607,7 +610,8 @@ void AlbumCoverManager::SaveCoverToFile() {
|
|||
QFile::exists(song.art_automatic())) {
|
||||
image = QImage(song.art_automatic());
|
||||
} else {
|
||||
image = QImage(":/nocover.png");
|
||||
image = IconLoader::Load("nocover", IconLoader::Other).pixmap(300)
|
||||
.toImage();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,10 @@ EditTagDialog::EditTagDialog(Application* app, QWidget* parent)
|
|||
cover_art_is_set_(false),
|
||||
results_dialog_(new TrackSelectionDialog(this)) {
|
||||
cover_options_.default_output_image_ =
|
||||
AlbumCoverLoader::ScaleAndPad(cover_options_, QImage(":nocover.png"));
|
||||
AlbumCoverLoader::ScaleAndPad(cover_options_,
|
||||
IconLoader::Load("nocover",
|
||||
IconLoader::Other).pixmap(300)
|
||||
.toImage());
|
||||
|
||||
connect(app_->album_cover_loader(),
|
||||
SIGNAL(ImageLoaded(quint64, QImage, QImage)),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* This file is part of Clementine.
|
||||
Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
Copyright 2015 - 2016, Arun Narayanankutty <n.arun.lifescience@gmail.com>
|
||||
|
||||
Clementine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -31,7 +32,7 @@ void IconLoader::Init() {
|
|||
sizes_ << 22 << 32 << 48;
|
||||
custom_icon_path_ = Utilities::GetConfigPath(Utilities::Path_Icons);
|
||||
icon_sub_path_.clear();
|
||||
icon_sub_path_ << "/icons" << "/providers" << "/last.fm";
|
||||
icon_sub_path_ << "/icons" << "/providers" << "/last.fm" << "";
|
||||
}
|
||||
|
||||
QIcon IconLoader::Load(const QString& name, const IconType& icontype) {
|
||||
|
@ -48,22 +49,30 @@ QIcon IconLoader::Load(const QString& name, const IconType& icontype) {
|
|||
case Base: case Provider:
|
||||
break;
|
||||
|
||||
case Lastfm: {
|
||||
case Lastfm: case Other: {
|
||||
// lastfm icons location
|
||||
const QString custom_lastfm_icon_location = custom_icon_path_ + "/last.fm";
|
||||
if (QDir(custom_lastfm_icon_location).exists()) {
|
||||
const QString custom_fm_other_icon_location = custom_icon_path_
|
||||
+ icon_sub_path_.at(icontype);
|
||||
if (QDir(custom_fm_other_icon_location).exists()) {
|
||||
// Try to load icons from the custom icon location initially
|
||||
const QString locate_file(
|
||||
custom_lastfm_icon_location + "/" + name + ".png");
|
||||
custom_fm_other_icon_location + "/" + name + ".png");
|
||||
|
||||
if (QFile::exists(locate_file)) ret.addFile(locate_file);
|
||||
if (!ret.isNull()) return ret;
|
||||
}
|
||||
|
||||
// Otherwise use our fallback theme
|
||||
const QString lastfm_path_file(":/last.fm/" + name + ".png");
|
||||
#if QT_VERSION >= 0x040600
|
||||
// Then try to load it from the system theme
|
||||
ret = QIcon::fromTheme(name);
|
||||
if (!ret.isNull()) return ret;
|
||||
#endif
|
||||
|
||||
if (QFile::exists(lastfm_path_file)) ret.addFile(lastfm_path_file);
|
||||
// Otherwise use our fallback theme
|
||||
const QString path_file(":" + icon_sub_path_.at(icontype)
|
||||
+ "/" + name + ".png");
|
||||
|
||||
if (QFile::exists(path_file)) ret.addFile(path_file);
|
||||
if (ret.isNull()) qLog(Warning) << "Couldn't load icon" << name;
|
||||
return ret;
|
||||
}
|
||||
|
@ -74,14 +83,16 @@ QIcon IconLoader::Load(const QString& name, const IconType& icontype) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
const QString custom_icon_location = custom_icon_path_ + icon_sub_path_.at(icontype);
|
||||
const QString custom_icon_location = custom_icon_path_
|
||||
+ icon_sub_path_.at(icontype);
|
||||
if (QDir(custom_icon_location).exists()) {
|
||||
// Try to load icons from the custom icon location initially
|
||||
const QString locate(custom_icon_location + "/%1x%2/%3.png");
|
||||
for (int size : sizes_) {
|
||||
QString filename_custom(locate.arg(size).arg(size).arg(name));
|
||||
|
||||
if (QFile::exists(filename_custom)) ret.addFile(filename_custom, QSize(size, size));
|
||||
if (QFile::exists(filename_custom)) ret.addFile(filename_custom,
|
||||
QSize(size, size));
|
||||
}
|
||||
if (!ret.isNull()) return ret;
|
||||
}
|
||||
|
@ -103,4 +114,3 @@ QIcon IconLoader::Load(const QString& name, const IconType& icontype) {
|
|||
if (ret.isNull()) qLog(Warning) << "Couldn't load icon" << name;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* This file is part of Clementine.
|
||||
Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
Copyright 2015 - 2016, Arun Narayanankutty <n.arun.lifescience@gmail.com>
|
||||
|
||||
Clementine is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -25,7 +26,8 @@ class IconLoader {
|
|||
enum IconType {
|
||||
Base = 0,
|
||||
Provider = 1,
|
||||
Lastfm = 2
|
||||
Lastfm = 2,
|
||||
Other = 3
|
||||
};
|
||||
|
||||
static void Init();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "notificationssettingspage.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "ui_notificationssettingspage.h"
|
||||
#include "ui/iconloader.h"
|
||||
#include "widgets/osdpretty.h"
|
||||
|
||||
#include <QColorDialog>
|
||||
|
@ -34,7 +35,8 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog* dialog)
|
|||
setWindowIcon(IconLoader::Load("help-hint", IconLoader::Base));
|
||||
|
||||
pretty_popup_->SetMessage(tr("OSD Preview"), tr("Drag to reposition"),
|
||||
QImage(":nocover.png"));
|
||||
IconLoader::Load("nocover", IconLoader::Other)
|
||||
.pixmap(300).toImage());
|
||||
|
||||
ui_->notifications_bg_preset->setItemData(0, QColor(OSDPretty::kPresetBlue),
|
||||
Qt::DecorationRole);
|
||||
|
|
|
@ -28,11 +28,15 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
SystemTrayIcon::SystemTrayIcon(QObject* parent)
|
||||
: QObject(parent),
|
||||
percentage_(0),
|
||||
playing_icon_(":/tiny-start.png"),
|
||||
paused_icon_(":/tiny-pause.png") {}
|
||||
playing_icon_(IconLoader::Load("tiny-start",
|
||||
IconLoader::Other).pixmap(64)),
|
||||
paused_icon_(IconLoader::Load("tiny-pause",
|
||||
IconLoader::Other).pixmap(64)) {}
|
||||
|
||||
QPixmap SystemTrayIcon::CreateIcon(const QPixmap& icon,
|
||||
const QPixmap& grey_icon) {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QFontMetrics>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
const int FavoriteWidget::kStarSize = 16;
|
||||
|
||||
|
@ -32,8 +33,8 @@ FavoriteWidget::FavoriteWidget(int tab_index, bool favorite, QWidget* parent)
|
|||
: QWidget(parent),
|
||||
tab_index_(tab_index),
|
||||
favorite_(favorite),
|
||||
on_(":/star-on.png"),
|
||||
off_(":/star-off.png") {}
|
||||
on_(IconLoader::Load("star-on", IconLoader::Other).pixmap(16)),
|
||||
off_(IconLoader::Load("star-off", IconLoader::Other).pixmap(16)) {}
|
||||
|
||||
void FavoriteWidget::SetFavorite(bool favorite) {
|
||||
if (favorite_ != favorite) {
|
||||
|
|
|
@ -22,13 +22,15 @@
|
|||
#include <QStylePainter>
|
||||
#include <QtDebug>
|
||||
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
const int RatingPainter::kStarCount;
|
||||
const int RatingPainter::kStarSize;
|
||||
|
||||
RatingPainter::RatingPainter() {
|
||||
// Load the base pixmaps
|
||||
QPixmap on(":/star-on.png");
|
||||
QPixmap off(":/star-off.png");
|
||||
QPixmap on(IconLoader::Load("star-on", IconLoader::Other).pixmap(16));
|
||||
QPixmap off(IconLoader::Load("star-off", IconLoader::Other).pixmap(16));
|
||||
|
||||
// Generate the 10 states, better to do it now than on the fly
|
||||
for (int i = 0; i < kStarCount * 2 + 1; ++i) {
|
||||
|
|
Loading…
Reference in New Issue