remove magic numbers

This commit is contained in:
narunlifescience 2016-02-11 04:41:37 -06:00
parent 29b8d308b3
commit b6bf54be6c
11 changed files with 51 additions and 36 deletions

View File

@ -35,9 +35,9 @@ CurrentArtLoader::CurrentArtLoader(Application* app, QObject* parent)
id_(0) {
options_.scale_output_image_ = false;
options_.pad_output_image_ = false;
options_.default_output_image_ = IconLoader::Load("nocover",
IconLoader::Other)
.pixmap(300).toImage();
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)));

View File

@ -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(IconLoader::Load("nocover", IconLoader::Other)
.pixmap(300)).scaled(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);
}

View File

@ -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(IconLoader::Load("nocover", IconLoader::Other)
.pixmap(300)).scaled(kPrettyCoverSize,
kPrettyCoverSize, Qt::KeepAspectRatio,
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)),

View File

@ -173,10 +173,10 @@ LibraryView::LibraryView(QWidget* parent)
app_(nullptr),
filter_(nullptr),
total_song_count_(-1),
nomusic_(IconLoader::Load("nocover",
IconLoader::Other).pixmap(300)),
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);

View File

@ -128,10 +128,6 @@ PlaylistView::PlaylistView(QWidget* parent)
inhibit_autoscroll_(false),
currently_autoscrolling_(false),
row_height_(-1),
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),
@ -141,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)),

View File

@ -89,8 +89,10 @@ AlbumCoverManager::AlbumCoverManager(Application* app,
album_cover_choice_controller_->SetApplication(app_);
// Get a square version of nocover.png
QImage nocover(IconLoader::Load("nocover", IconLoader::Other).pixmap(300)
.toImage());
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);
@ -100,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);
@ -601,8 +602,7 @@ void AlbumCoverManager::SaveCoverToFile() {
// load the image from disk
if (song.has_manually_unset_cover()) {
image = IconLoader::Load("nocover", IconLoader::Other).pixmap(300)
.toImage();
image = no_cover_image_;
} else {
if (!song.art_manual().isEmpty() && QFile::exists(song.art_manual())) {
image = QImage(song.art_manual());
@ -610,8 +610,7 @@ void AlbumCoverManager::SaveCoverToFile() {
QFile::exists(song.art_automatic())) {
image = QImage(song.art_automatic());
} else {
image = IconLoader::Load("nocover", IconLoader::Other).pixmap(300)
.toImage();
image = no_cover_image_;
}
}

View File

@ -61,11 +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_,
IconLoader::Load("nocover",
IconLoader::Other).pixmap(300)
.toImage());
nocover.pixmap(nocover.availableSizes().last())
.toImage());
connect(app_->album_cover_loader(),
SIGNAL(ImageLoaded(quint64, QImage, QImage)),

View File

@ -34,9 +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"),
IconLoader::Load("nocover", IconLoader::Other)
.pixmap(300).toImage());
nocover.pixmap(nocover.availableSizes().last())
.toImage());
ui_->notifications_bg_preset->setItemData(0, QColor(OSDPretty::kPresetBlue),
Qt::DecorationRole);

View File

@ -32,11 +32,12 @@
SystemTrayIcon::SystemTrayIcon(QObject* parent)
: QObject(parent),
percentage_(0),
playing_icon_(IconLoader::Load("tiny-start",
IconLoader::Other).pixmap(64)),
paused_icon_(IconLoader::Load("tiny-pause",
IconLoader::Other).pixmap(64)) {}
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) {

View File

@ -32,9 +32,12 @@ const int FavoriteWidget::kStarSize = 16;
FavoriteWidget::FavoriteWidget(int tab_index, bool favorite, QWidget* parent)
: QWidget(parent),
tab_index_(tab_index),
favorite_(favorite),
on_(IconLoader::Load("star-on", IconLoader::Other).pixmap(16)),
off_(IconLoader::Load("star-off", IconLoader::Other).pixmap(16)) {}
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) {

View File

@ -29,8 +29,10 @@ const int RatingPainter::kStarSize;
RatingPainter::RatingPainter() {
// Load the base pixmaps
QPixmap on(IconLoader::Load("star-on", IconLoader::Other).pixmap(16));
QPixmap off(IconLoader::Load("star-off", IconLoader::Other).pixmap(16));
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) {