Fix paths

- Use QStandardPaths
- Load settings in StatusView widget
- Update about
- Remove redundant code
- Temporary hide missing audiopanorama error as workaround for windows build
This commit is contained in:
Jonas Kvinge
2018-04-06 22:13:11 +02:00
parent 43bf7e3ca8
commit 917b9c39b8
21 changed files with 88 additions and 167 deletions

View File

@@ -97,7 +97,7 @@ QList<QAction*> AlbumCoverChoiceController::GetAllActions() {
}
QString AlbumCoverChoiceController::LoadCoverFromFile(Song *song) {
QString cover = QFileDialog::getOpenFileName(this, tr("Load cover from disk"), GetInitialPathForFileDialog(*song, QString()), tr(kLoadImageFileFilter) + ";;" + tr(kAllFilesFilter));
if (cover.isNull()) return QString();
@@ -211,8 +211,7 @@ void AlbumCoverChoiceController::ShowCover(const Song &song) {
// add (WxHpx) to the title before possibly resizing
title_text += " (" + QString::number(label->pixmap()->width()) + "x" + QString::number(label->pixmap()->height()) + "px)";
// if the cover is larger than the screen, resize the window
// 85% seems to be enough to account for title bar and taskbar etc.
// if the cover is larger than the screen, resize the window 85% seems to be enough to account for title bar and taskbar etc.
QDesktopWidget desktop;
int current_screen = desktop.screenNumber(this);
int desktop_height = desktop.screenGeometry(current_screen).height();
@@ -222,15 +221,13 @@ void AlbumCoverChoiceController::ShowCover(const Song &song) {
if (desktop_width < desktop_height) {
const int new_width = (double)desktop_width * 0.95;
if (new_width < label->pixmap()->width()) {
label->setPixmap(
label->pixmap()->scaledToWidth(new_width, Qt::SmoothTransformation));
label->setPixmap(label->pixmap()->scaledToWidth(new_width, Qt::SmoothTransformation));
}
}
else {
const int new_height = (double)desktop_height * 0.85;
if (new_height < label->pixmap()->height()) {
label->setPixmap(label->pixmap()->scaledToHeight(
new_height, Qt::SmoothTransformation));
label->setPixmap(label->pixmap()->scaledToHeight(new_height, Qt::SmoothTransformation));
}
}

View File

@@ -22,18 +22,22 @@
#include "albumcoverloader.h"
#include <QPainter>
#include <QDir>
#include <QCoreApplication>
#include <QStandardPaths>
#include <QString>
#include <QDir>
#include <QUrl>
#include <QNetworkReply>
#include <QImage>
#include <QPixmap>
#include <QPainter>
#include <QMutexLocker>
#include "config.h"
#include "core/closure.h"
#include "core/logging.h"
#include "core/network.h"
#include "core/tagreaderclient.h"
#include "core/utilities.h"
AlbumCoverLoader::AlbumCoverLoader(QObject *parent)
: QObject(parent),
@@ -42,7 +46,7 @@ AlbumCoverLoader::AlbumCoverLoader(QObject *parent)
network_(new NetworkAccessManager(this)){}
QString AlbumCoverLoader::ImageCacheDir() {
return Utilities::GetConfigPath(Utilities::Path_AlbumCovers);
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/albumcovers";
}
void AlbumCoverLoader::CancelTask(quint64 id) {
@@ -128,7 +132,7 @@ void AlbumCoverLoader::ProcessTask(Task *task) {
}
void AlbumCoverLoader::NextState(Task *task) {
if (task->state == State_TryingManual) {
// Try the automatic one next
task->state = State_TryingAuto;
@@ -139,6 +143,7 @@ void AlbumCoverLoader::NextState(Task *task) {
emit ImageLoaded(task->id, task->options.default_output_image_);
emit ImageLoaded(task->id, task->options.default_output_image_, task->options.default_output_image_);
}
}
AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(const Task &task) {
@@ -179,7 +184,7 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(const Task &task)
QImage image(filename);
return TryLoadResult(false, !image.isNull(), image.isNull() ? task.options.default_output_image_ : image);
}
void AlbumCoverLoader::RemoteFetchFinished(QNetworkReply *reply) {
@@ -241,6 +246,7 @@ QImage AlbumCoverLoader::ScaleAndPad(const AlbumCoverLoaderOptions &options, con
p.end();
return padded_image;
}
QPixmap AlbumCoverLoader::TryLoadPixmap(const QString &automatic, const QString &manual, const QString &filename) {
@@ -255,4 +261,5 @@ QPixmap AlbumCoverLoader::TryLoadPixmap(const QString &automatic, const QString
ret.load(automatic);
}
return ret;
}

View File

@@ -772,6 +772,7 @@ void AlbumCoverManager::SaveAndSetCover(QListWidgetItem *item, const QImage &ima
quint64 id = app_->album_cover_loader()->LoadImageAsync(cover_loader_options_, QString(), path);
item->setData(Role_PathManual, path);
cover_loading_tasks_[id] = item;
}
void AlbumCoverManager::ExportCovers() {