Merge pull request #5210 from narunlifescience/patch-2
Use icon loader for remaining icons
This commit is contained in:
commit
0ea84e129e
@ -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");
|
||||
QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
|
||||
options_.default_output_image_ = nocover.pixmap(nocover.availableSizes()
|
||||
.last()).toImage();
|
||||
|
||||
connect(app_->album_cover_loader(), SIGNAL(ImageLoaded(quint64, QImage)),
|
||||
SLOT(TempArtLoaded(quint64, QImage)));
|
||||
|
@ -33,8 +33,10 @@ 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,
|
||||
QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
|
||||
no_cover_icon_ = nocover.pixmap(nocover.availableSizes().last()).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,11 @@ 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);
|
||||
QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
|
||||
no_cover_icon_ = nocover.pixmap(nocover.availableSizes().last()).scaled(
|
||||
kPrettyCoverSize, kPrettyCoverSize,
|
||||
Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
|
||||
connect(backend_, SIGNAL(SongsDiscovered(SongList)),
|
||||
SLOT(SongsDiscovered(SongList)));
|
||||
|
@ -173,9 +173,10 @@ LibraryView::LibraryView(QWidget* parent)
|
||||
app_(nullptr),
|
||||
filter_(nullptr),
|
||||
total_song_count_(-1),
|
||||
nomusic_(":nomusic.png"),
|
||||
context_menu_(nullptr),
|
||||
is_in_keyboard_search_(false) {
|
||||
QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
|
||||
nomusic_ = nocover.pixmap(nocover.availableSizes().last());
|
||||
setItemDelegate(new LibraryItemDelegate(this));
|
||||
setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
setHeaderHidden(true);
|
||||
|
@ -227,11 +227,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,6 @@ PlaylistView::PlaylistView(QWidget* parent)
|
||||
inhibit_autoscroll_(false),
|
||||
currently_autoscrolling_(false),
|
||||
row_height_(-1),
|
||||
currenttrack_play_(":currenttrack_play.png"),
|
||||
currenttrack_pause_(":currenttrack_pause.png"),
|
||||
cached_current_row_row_(-1),
|
||||
drop_indicator_row_(-1),
|
||||
drag_over_(false),
|
||||
@ -138,6 +137,17 @@ PlaylistView::PlaylistView(QWidget* parent)
|
||||
setStyle(style_);
|
||||
setMouseTracking(true);
|
||||
|
||||
QIcon currenttrack_play = IconLoader::Load("currenttrack_play",
|
||||
IconLoader::Other);
|
||||
currenttrack_play_ = currenttrack_play.pixmap(currenttrack_play
|
||||
.availableSizes()
|
||||
.last());
|
||||
QIcon currenttrack_pause = IconLoader::Load("currenttrack_pause",
|
||||
IconLoader::Other);
|
||||
currenttrack_pause_ = currenttrack_pause.pixmap(currenttrack_pause
|
||||
.availableSizes()
|
||||
.last());
|
||||
|
||||
connect(header_, SIGNAL(sectionResized(int, int, int)), SLOT(SaveGeometry()));
|
||||
connect(header_, SIGNAL(sectionMoved(int, int, int)), SLOT(SaveGeometry()));
|
||||
connect(header_, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
|
||||
|
@ -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,10 @@ AlbumCoverManager::AlbumCoverManager(Application* app,
|
||||
album_cover_choice_controller_->SetApplication(app_);
|
||||
|
||||
// Get a square version of nocover.png
|
||||
QImage nocover(":/nocover.png");
|
||||
no_cover_icon_ = IconLoader::Load("nocover", IconLoader::Other);
|
||||
no_cover_image_ = no_cover_icon_.pixmap(no_cover_icon_.availableSizes()
|
||||
.last()).toImage();
|
||||
QImage nocover(no_cover_image_);
|
||||
nocover =
|
||||
nocover.scaled(120, 120, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
QImage square_nocover(120, 120, QImage::Format_ARGB32);
|
||||
@ -98,7 +102,6 @@ AlbumCoverManager::AlbumCoverManager(Application* app,
|
||||
p.drawImage((120 - nocover.width()) / 2, (120 - nocover.height()) / 2,
|
||||
nocover);
|
||||
p.end();
|
||||
no_cover_icon_ = QPixmap::fromImage(square_nocover);
|
||||
|
||||
cover_searcher_ = new AlbumCoverSearcher(no_cover_icon_, app_, this);
|
||||
cover_export_ = new AlbumCoverExport(this);
|
||||
@ -599,7 +602,7 @@ void AlbumCoverManager::SaveCoverToFile() {
|
||||
|
||||
// load the image from disk
|
||||
if (song.has_manually_unset_cover()) {
|
||||
image = QImage(":/nocover.png");
|
||||
image = no_cover_image_;
|
||||
} else {
|
||||
if (!song.art_manual().isEmpty() && QFile::exists(song.art_manual())) {
|
||||
image = QImage(song.art_manual());
|
||||
@ -607,7 +610,7 @@ void AlbumCoverManager::SaveCoverToFile() {
|
||||
QFile::exists(song.art_automatic())) {
|
||||
image = QImage(song.art_automatic());
|
||||
} else {
|
||||
image = QImage(":/nocover.png");
|
||||
image = no_cover_image_;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,11 @@ EditTagDialog::EditTagDialog(Application* app, QWidget* parent)
|
||||
cover_art_id_(0),
|
||||
cover_art_is_set_(false),
|
||||
results_dialog_(new TrackSelectionDialog(this)) {
|
||||
QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
|
||||
cover_options_.default_output_image_ =
|
||||
AlbumCoverLoader::ScaleAndPad(cover_options_, QImage(":nocover.png"));
|
||||
AlbumCoverLoader::ScaleAndPad(cover_options_,
|
||||
nocover.pixmap(nocover.availableSizes().last())
|
||||
.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>
|
||||
@ -33,8 +34,10 @@ NotificationsSettingsPage::NotificationsSettingsPage(SettingsDialog* dialog)
|
||||
ui_->setupUi(this);
|
||||
setWindowIcon(IconLoader::Load("help-hint", IconLoader::Base));
|
||||
|
||||
QIcon nocover = IconLoader::Load("nocover", IconLoader::Other);
|
||||
pretty_popup_->SetMessage(tr("OSD Preview"), tr("Drag to reposition"),
|
||||
QImage(":nocover.png"));
|
||||
nocover.pixmap(nocover.availableSizes().last())
|
||||
.toImage());
|
||||
|
||||
ui_->notifications_bg_preset->setItemData(0, QColor(OSDPretty::kPresetBlue),
|
||||
Qt::DecorationRole);
|
||||
|
@ -28,11 +28,16 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
SystemTrayIcon::SystemTrayIcon(QObject* parent)
|
||||
: QObject(parent),
|
||||
percentage_(0),
|
||||
playing_icon_(":/tiny-start.png"),
|
||||
paused_icon_(":/tiny-pause.png") {}
|
||||
percentage_(0) {
|
||||
QIcon tiny_start = IconLoader::Load("tiny-start", IconLoader::Other);
|
||||
playing_icon_ = tiny_start.pixmap(tiny_start.availableSizes().last());
|
||||
QIcon tiny_pause = IconLoader::Load("tiny-pause", IconLoader::Other);
|
||||
paused_icon_ = tiny_pause.pixmap(tiny_pause.availableSizes().last());
|
||||
}
|
||||
|
||||
QPixmap SystemTrayIcon::CreateIcon(const QPixmap& icon,
|
||||
const QPixmap& grey_icon) {
|
||||
|
@ -25,15 +25,19 @@
|
||||
#include <QFontMetrics>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
const int FavoriteWidget::kStarSize = 16;
|
||||
|
||||
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") {}
|
||||
favorite_(favorite) {
|
||||
QIcon star_on = IconLoader::Load("star-on", IconLoader::Other);
|
||||
on_ = star_on.pixmap(star_on.availableSizes().last());
|
||||
QIcon star_off = IconLoader::Load("star-off", IconLoader::Other);
|
||||
off_ = star_off.pixmap(star_off.availableSizes().last());
|
||||
}
|
||||
|
||||
void FavoriteWidget::SetFavorite(bool favorite) {
|
||||
if (favorite_ != favorite) {
|
||||
|
@ -22,13 +22,17 @@
|
||||
#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");
|
||||
QIcon star_on = IconLoader::Load("star-on", IconLoader::Other);
|
||||
QPixmap on(star_on.pixmap(star_on.availableSizes().last()));
|
||||
QIcon star_off = IconLoader::Load("star-off", IconLoader::Other);
|
||||
QPixmap off(star_off.pixmap(star_off.availableSizes().last()));
|
||||
|
||||
// Generate the 10 states, better to do it now than on the fly
|
||||
for (int i = 0; i < kStarCount * 2 + 1; ++i) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user