Fix memory leaks
This commit is contained in:
parent
2df21081a1
commit
bd78e8c275
@ -112,6 +112,7 @@ set(SOURCES
|
|||||||
core/windows7thumbbar.cpp
|
core/windows7thumbbar.cpp
|
||||||
core/screensaver.cpp
|
core/screensaver.cpp
|
||||||
core/scopedtransaction.cpp
|
core/scopedtransaction.cpp
|
||||||
|
core/translations.cpp
|
||||||
|
|
||||||
engine/enginetype.cpp
|
engine/enginetype.cpp
|
||||||
engine/enginebase.cpp
|
engine/enginebase.cpp
|
||||||
|
@ -68,6 +68,7 @@ SCollection::~SCollection() {
|
|||||||
watcher_->deleteLater();
|
watcher_->deleteLater();
|
||||||
watcher_thread_->exit();
|
watcher_thread_->exit();
|
||||||
watcher_thread_->wait(5000 /* five seconds */);
|
watcher_thread_->wait(5000 /* five seconds */);
|
||||||
|
backend_->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SCollection::Init() {
|
void SCollection::Init() {
|
||||||
|
@ -210,6 +210,7 @@ int Database::FTSNext(sqlite3_tokenizer_cursor *cursor, const char* *token, int
|
|||||||
|
|
||||||
void Database::StaticInit() {
|
void Database::StaticInit() {
|
||||||
|
|
||||||
|
if (sFTSTokenizer) return;
|
||||||
sFTSTokenizer = new sqlite3_tokenizer_module;
|
sFTSTokenizer = new sqlite3_tokenizer_module;
|
||||||
sFTSTokenizer->iVersion = 0;
|
sFTSTokenizer->iVersion = 0;
|
||||||
sFTSTokenizer->xCreate = &Database::FTSCreate;
|
sFTSTokenizer->xCreate = &Database::FTSCreate;
|
||||||
@ -241,6 +242,8 @@ Database::Database(Application *app, QObject *parent, const QString &database_na
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Database::~Database() {}
|
||||||
|
|
||||||
QSqlDatabase Database::Connect() {
|
QSqlDatabase Database::Connect() {
|
||||||
|
|
||||||
QMutexLocker l(&connect_mutex_);
|
QMutexLocker l(&connect_mutex_);
|
||||||
@ -273,7 +276,7 @@ QSqlDatabase Database::Connect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find Sqlite3 functions in the Qt plugin.
|
// Find Sqlite3 functions in the Qt plugin.
|
||||||
StaticInit();
|
if (!sFTSTokenizer) StaticInit();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ class Database : public QObject {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Database(Application *app, QObject *parent = nullptr, const QString &database_name = QString());
|
Database(Application *app, QObject *parent = nullptr, const QString &database_name = QString());
|
||||||
|
~Database();
|
||||||
|
|
||||||
struct AttachedDatabase {
|
struct AttachedDatabase {
|
||||||
AttachedDatabase() {}
|
AttachedDatabase() {}
|
||||||
|
@ -1799,7 +1799,7 @@ void MainWindow::SongSaveComplete(TagReaderReply *reply, const QPersistentModelI
|
|||||||
if (reply->is_successful() && index.isValid()) {
|
if (reply->is_successful() && index.isValid()) {
|
||||||
app_->playlist_manager()->current()->ReloadItems(QList<int>()<< index.row());
|
app_->playlist_manager()->current()->ReloadItems(QList<int>()<< index.row());
|
||||||
}
|
}
|
||||||
metaObject()->invokeMethod(reply, "deleteLater", Qt::QueuedConnection);
|
reply->deleteLater();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,12 +39,15 @@
|
|||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
|
||||||
QMutex ThreadSafeNetworkDiskCache::sMutex;
|
QMutex ThreadSafeNetworkDiskCache::sMutex;
|
||||||
|
ThreadSafeNetworkDiskCache *ThreadSafeNetworkDiskCache::sInstance = nullptr;
|
||||||
QNetworkDiskCache *ThreadSafeNetworkDiskCache::sCache = nullptr;
|
QNetworkDiskCache *ThreadSafeNetworkDiskCache::sCache = nullptr;
|
||||||
|
|
||||||
ThreadSafeNetworkDiskCache::ThreadSafeNetworkDiskCache(QObject *parent)
|
ThreadSafeNetworkDiskCache::ThreadSafeNetworkDiskCache(QObject *parent)
|
||||||
: QAbstractNetworkCache(parent) {
|
: QAbstractNetworkCache(parent) {
|
||||||
|
|
||||||
QMutexLocker l(&sMutex);
|
QMutexLocker l(&sMutex);
|
||||||
if (!sCache) {
|
if (!sCache) {
|
||||||
|
sInstance = this;
|
||||||
sCache = new QNetworkDiskCache;
|
sCache = new QNetworkDiskCache;
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
sCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/strawberry/networkcache");
|
sCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/strawberry/networkcache");
|
||||||
@ -52,6 +55,11 @@ ThreadSafeNetworkDiskCache::ThreadSafeNetworkDiskCache(QObject *parent)
|
|||||||
sCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/networkcache");
|
sCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/networkcache");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadSafeNetworkDiskCache::~ThreadSafeNetworkDiskCache() {
|
||||||
|
if (this == sInstance) delete sCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 ThreadSafeNetworkDiskCache::cacheSize() const {
|
qint64 ThreadSafeNetworkDiskCache::cacheSize() const {
|
||||||
|
@ -47,6 +47,7 @@ class QTimerEvent;
|
|||||||
class ThreadSafeNetworkDiskCache : public QAbstractNetworkCache {
|
class ThreadSafeNetworkDiskCache : public QAbstractNetworkCache {
|
||||||
public:
|
public:
|
||||||
explicit ThreadSafeNetworkDiskCache(QObject *parent);
|
explicit ThreadSafeNetworkDiskCache(QObject *parent);
|
||||||
|
~ThreadSafeNetworkDiskCache();
|
||||||
|
|
||||||
qint64 cacheSize() const;
|
qint64 cacheSize() const;
|
||||||
QIODevice *data(const QUrl &url);
|
QIODevice *data(const QUrl &url);
|
||||||
@ -60,6 +61,7 @@ class ThreadSafeNetworkDiskCache : public QAbstractNetworkCache {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static QMutex sMutex;
|
static QMutex sMutex;
|
||||||
|
static ThreadSafeNetworkDiskCache *sInstance;
|
||||||
static QNetworkDiskCache *sCache;
|
static QNetworkDiskCache *sCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,8 +20,11 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QFileSystemWatcher>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
#include "core/logging.h"
|
||||||
|
|
||||||
#include "filesystemwatcherinterface.h"
|
#include "filesystemwatcherinterface.h"
|
||||||
#include "qtfslistener.h"
|
#include "qtfslistener.h"
|
||||||
|
|
||||||
@ -33,9 +36,7 @@ QtFSListener::QtFSListener(QObject *parent) : FileSystemWatcherInterface(parent)
|
|||||||
|
|
||||||
void QtFSListener::AddPath(const QString &path) { watcher_.addPath(path); }
|
void QtFSListener::AddPath(const QString &path) { watcher_.addPath(path); }
|
||||||
|
|
||||||
void QtFSListener::RemovePath(const QString &path) {
|
void QtFSListener::RemovePath(const QString &path) { watcher_.removePath(path); }
|
||||||
watcher_.removePath(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtFSListener::Clear() {
|
void QtFSListener::Clear() {
|
||||||
watcher_.removePaths(watcher_.directories());
|
watcher_.removePaths(watcher_.directories());
|
||||||
|
50
src/core/translations.cpp
Normal file
50
src/core/translations.cpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2019, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QTranslator>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include "translations.h"
|
||||||
|
#include "core/potranslator.h"
|
||||||
|
|
||||||
|
Translations::Translations() {}
|
||||||
|
Translations::~Translations() {
|
||||||
|
|
||||||
|
for (QTranslator *t : translations_) {
|
||||||
|
QCoreApplication::removeTranslator(t);
|
||||||
|
delete t;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Translations::LoadTranslation(const QString &prefix, const QString &path, const QString &language) {
|
||||||
|
|
||||||
|
QTranslator *t = new PoTranslator;
|
||||||
|
if (t->load(prefix + "_" + language, path)) {
|
||||||
|
QCoreApplication::installTranslator(t);
|
||||||
|
translations_ << t;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
delete t;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
src/core/translations.h
Normal file
36
src/core/translations.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Strawberry Music Player
|
||||||
|
* Copyright 2019, Jonas Kvinge <jonas@jkvinge.net>
|
||||||
|
*
|
||||||
|
* Strawberry is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Strawberry is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTranslator>
|
||||||
|
#include <QList>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class Translations : public QObject {
|
||||||
|
public:
|
||||||
|
Translations();
|
||||||
|
~Translations();
|
||||||
|
void LoadTranslation(const QString &prefix, const QString &path, const QString &language);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<QTranslator*> translations_;
|
||||||
|
|
||||||
|
};
|
@ -60,9 +60,6 @@
|
|||||||
#include <QtEvents>
|
#include <QtEvents>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#ifdef HAVE_TRANSLATIONS
|
|
||||||
# include <QTranslator>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
@ -101,10 +98,6 @@
|
|||||||
# include "scoped_cftyperef.h"
|
# include "scoped_cftyperef.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_TRANSLATIONS
|
|
||||||
# include "potranslator.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace Utilities {
|
namespace Utilities {
|
||||||
|
|
||||||
static QString tr(const char *str) {
|
static QString tr(const char *str) {
|
||||||
@ -821,29 +814,6 @@ QString UnicodeToAscii(const QString &unicode) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_TRANSLATIONS
|
|
||||||
|
|
||||||
QString SystemLanguageName() {
|
|
||||||
|
|
||||||
QString system_language = QLocale::system().uiLanguages().empty() ? QLocale::system().name() : QLocale::system().uiLanguages().first();
|
|
||||||
// uiLanguages returns strings with "-" as separators for language/region; however QTranslator needs "_" separators
|
|
||||||
system_language.replace("-", "_");
|
|
||||||
|
|
||||||
return system_language;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadTranslation(const QString &prefix, const QString &path, const QString &language) {
|
|
||||||
|
|
||||||
QTranslator *t = new PoTranslator;
|
|
||||||
if (t->load(prefix + "_" + language, path))
|
|
||||||
QCoreApplication::installTranslator(t);
|
|
||||||
else
|
|
||||||
delete t;
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace Utilities
|
} // namespace Utilities
|
||||||
|
|
||||||
ScopedWCharArray::ScopedWCharArray(const QString &str)
|
ScopedWCharArray::ScopedWCharArray(const QString &str)
|
||||||
|
@ -157,11 +157,6 @@ QString DesktopEnvironment();
|
|||||||
|
|
||||||
QString UnicodeToAscii(const QString &unicode);
|
QString UnicodeToAscii(const QString &unicode);
|
||||||
|
|
||||||
#ifdef HAVE_TRANSLATIONS
|
|
||||||
QString SystemLanguageName();
|
|
||||||
void LoadTranslation(const QString &prefix, const QString &path, const QString &language);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class ScopedWCharArray {
|
class ScopedWCharArray {
|
||||||
|
@ -31,6 +31,14 @@
|
|||||||
|
|
||||||
CoverProviders::CoverProviders(QObject *parent) : QObject(parent) {}
|
CoverProviders::CoverProviders(QObject *parent) : QObject(parent) {}
|
||||||
|
|
||||||
|
CoverProviders::~CoverProviders() {
|
||||||
|
|
||||||
|
while (!cover_providers_.isEmpty()) {
|
||||||
|
delete cover_providers_.firstKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CoverProviders::AddProvider(CoverProvider *provider) {
|
void CoverProviders::AddProvider(CoverProvider *provider) {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,7 @@ class CoverProviders : public QObject {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CoverProviders(QObject *parent = nullptr);
|
explicit CoverProviders(QObject *parent = nullptr);
|
||||||
|
~CoverProviders();
|
||||||
|
|
||||||
// Lets a cover provider register itself in the repository.
|
// Lets a cover provider register itself in the repository.
|
||||||
void AddProvider(CoverProvider *provider);
|
void AddProvider(CoverProvider *provider);
|
||||||
|
@ -46,6 +46,7 @@ DeviceLister::~DeviceLister() {
|
|||||||
if (thread_) {
|
if (thread_) {
|
||||||
thread_->quit();
|
thread_->quit();
|
||||||
thread_->wait(1000);
|
thread_->wait(1000);
|
||||||
|
thread_->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -910,6 +910,6 @@ void EditTagDialog::SongSaveComplete(TagReaderReply *reply, const QString &filen
|
|||||||
|
|
||||||
if (pending_ <= 0) AcceptFinished();
|
if (pending_ <= 0) AcceptFinished();
|
||||||
|
|
||||||
metaObject()->invokeMethod(reply, "deleteLater", Qt::QueuedConnection);
|
reply->deleteLater();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ GstStartup::GstStartup(QObject *parent) : QObject(parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GstStartup::~GstStartup() {
|
GstStartup::~GstStartup() {
|
||||||
|
//gst_deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GstStartup::InitialiseGStreamer() {
|
void GstStartup::InitialiseGStreamer() {
|
||||||
|
@ -31,12 +31,18 @@
|
|||||||
#include "internetservice.h"
|
#include "internetservice.h"
|
||||||
|
|
||||||
InternetServices::InternetServices(QObject *parent) : QObject(parent) {}
|
InternetServices::InternetServices(QObject *parent) : QObject(parent) {}
|
||||||
InternetServices::~InternetServices() {}
|
|
||||||
|
InternetServices::~InternetServices() {
|
||||||
|
|
||||||
|
while (!services_.isEmpty()) {
|
||||||
|
delete services_.take(services_.firstKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void InternetServices::AddService(InternetService *service) {
|
void InternetServices::AddService(InternetService *service) {
|
||||||
|
|
||||||
services_.insert(service->source(), service);
|
services_.insert(service->source(), service);
|
||||||
connect(service, SIGNAL(destroyed()), SLOT(ServiceDeleted()));
|
|
||||||
if (service->has_initial_load_settings()) service->InitialLoadSettings();
|
if (service->has_initial_load_settings()) service->InitialLoadSettings();
|
||||||
else service->ReloadSettings();
|
else service->ReloadSettings();
|
||||||
|
|
||||||
@ -50,12 +56,7 @@ void InternetServices::RemoveService(InternetService *service) {
|
|||||||
services_.remove(service->source());
|
services_.remove(service->source());
|
||||||
disconnect(service, 0, this, 0);
|
disconnect(service, 0, this, 0);
|
||||||
|
|
||||||
}
|
qLog(Debug) << "Removed internet service" << service->name();
|
||||||
|
|
||||||
void InternetServices::ServiceDeleted() {
|
|
||||||
|
|
||||||
InternetService *service = qobject_cast<InternetService*>(sender());
|
|
||||||
if (service) RemoveService(service);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,6 @@ class InternetServices : public QObject {
|
|||||||
void RemoveService(InternetService *service);
|
void RemoveService(InternetService *service);
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void ServiceDeleted();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<Song::Source, InternetService*> services_;
|
QMap<Song::Source, InternetService*> services_;
|
||||||
|
|
||||||
|
@ -32,6 +32,14 @@
|
|||||||
|
|
||||||
LyricsProviders::LyricsProviders(QObject *parent) : QObject(parent) {}
|
LyricsProviders::LyricsProviders(QObject *parent) : QObject(parent) {}
|
||||||
|
|
||||||
|
LyricsProviders::~LyricsProviders() {
|
||||||
|
|
||||||
|
while (!lyrics_providers_.isEmpty()) {
|
||||||
|
delete lyrics_providers_.firstKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void LyricsProviders::AddProvider(LyricsProvider *provider) {
|
void LyricsProviders::AddProvider(LyricsProvider *provider) {
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,8 @@ class LyricsProviders : public QObject {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit LyricsProviders(QObject *parent = nullptr);
|
explicit LyricsProviders(QObject *parent = nullptr);
|
||||||
|
~LyricsProviders();
|
||||||
|
|
||||||
void AddProvider(LyricsProvider *provider);
|
void AddProvider(LyricsProvider *provider);
|
||||||
void RemoveProvider(LyricsProvider *provider);
|
void RemoveProvider(LyricsProvider *provider);
|
||||||
QList<LyricsProvider*> List() const { return lyrics_providers_.keys(); }
|
QList<LyricsProvider*> List() const { return lyrics_providers_.keys(); }
|
||||||
|
18
src/main.cpp
18
src/main.cpp
@ -90,7 +90,7 @@
|
|||||||
#include "core/networkproxyfactory.h"
|
#include "core/networkproxyfactory.h"
|
||||||
#include "core/scangiomodulepath.h"
|
#include "core/scangiomodulepath.h"
|
||||||
#ifdef HAVE_TRANSLATIONS
|
#ifdef HAVE_TRANSLATIONS
|
||||||
# include "core/potranslator.h"
|
# include "core/translations.h"
|
||||||
#endif
|
#endif
|
||||||
#include "settings/behavioursettingspage.h"
|
#include "settings/behavioursettingspage.h"
|
||||||
|
|
||||||
@ -228,12 +228,18 @@ int main(int argc, char* argv[]) {
|
|||||||
s.endGroup();
|
s.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString language = override_language.isEmpty() ? Utilities::SystemLanguageName() : override_language;
|
QString system_language = QLocale::system().uiLanguages().empty() ? QLocale::system().name() : QLocale::system().uiLanguages().first();
|
||||||
|
// uiLanguages returns strings with "-" as separators for language/region; however QTranslator needs "_" separators
|
||||||
|
system_language.replace("-", "_");
|
||||||
|
|
||||||
Utilities::LoadTranslation("qt", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language);
|
const QString language = override_language.isEmpty() ? system_language : override_language;
|
||||||
Utilities::LoadTranslation("strawberry", ":/translations", language);
|
|
||||||
Utilities::LoadTranslation("strawberry", a.applicationDirPath(), language);
|
std::unique_ptr<Translations> translations(new Translations);
|
||||||
Utilities::LoadTranslation("strawberry", QDir::currentPath(), language);
|
|
||||||
|
translations->LoadTranslation("qt", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language);
|
||||||
|
translations->LoadTranslation("strawberry", ":/translations", language);
|
||||||
|
translations->LoadTranslation("strawberry", a.applicationDirPath(), language);
|
||||||
|
translations->LoadTranslation("strawberry", QDir::currentPath(), language);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Application app;
|
Application app;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <QStyleOptionComplex>
|
#include <QStyleOptionComplex>
|
||||||
#include <QStyleOptionSlider>
|
#include <QStyleOptionSlider>
|
||||||
#include <QTimeLine>
|
#include <QTimeLine>
|
||||||
|
#include <QStyle>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
|
|
||||||
@ -59,8 +60,11 @@ MoodbarProxyStyle::MoodbarProxyStyle(Application* app, QSlider* slider)
|
|||||||
|
|
||||||
connect(app, SIGNAL(SettingsChanged()), SLOT(ReloadSettings()));
|
connect(app, SIGNAL(SettingsChanged()), SLOT(ReloadSettings()));
|
||||||
ReloadSettings();
|
ReloadSettings();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MoodbarProxyStyle::~MoodbarProxyStyle() {}
|
||||||
|
|
||||||
void MoodbarProxyStyle::ReloadSettings() {
|
void MoodbarProxyStyle::ReloadSettings() {
|
||||||
|
|
||||||
QSettings s;
|
QSettings s;
|
||||||
|
@ -38,6 +38,7 @@ class MoodbarProxyStyle : public QProxyStyle {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MoodbarProxyStyle(Application* app, QSlider* slider);
|
MoodbarProxyStyle(Application* app, QSlider* slider);
|
||||||
|
~MoodbarProxyStyle();
|
||||||
|
|
||||||
// QProxyStyle
|
// QProxyStyle
|
||||||
void drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget) const;
|
void drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget) const;
|
||||||
|
@ -399,8 +399,7 @@ void Playlist::SongSaveComplete(TagReaderReply *reply, const QPersistentModelInd
|
|||||||
emit Error(tr("An error occurred writing metadata to '%1'").arg(QString::fromStdString(reply->request_message().save_file_request().filename())));
|
emit Error(tr("An error occurred writing metadata to '%1'").arg(QString::fromStdString(reply->request_message().save_file_request().filename())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
reply->deleteLater();
|
||||||
metaObject()->invokeMethod(reply, "deleteLater", Qt::QueuedConnection);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,12 +395,17 @@ TagCompleter::TagCompleter(CollectionBackend *backend, Playlist::Column column,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TagCompleter::~TagCompleter() {
|
||||||
|
delete model();
|
||||||
|
}
|
||||||
|
|
||||||
void TagCompleter::ModelReady(QFuture<TagCompletionModel*> future) {
|
void TagCompleter::ModelReady(QFuture<TagCompletionModel*> future) {
|
||||||
|
|
||||||
TagCompletionModel *model = future.result();
|
TagCompletionModel *model = future.result();
|
||||||
setModel(model);
|
setModel(model);
|
||||||
setCaseSensitivity(Qt::CaseInsensitive);
|
setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
editor_->setCompleter(this);
|
editor_->setCompleter(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *TagCompletionItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem&, const QModelIndex&) const {
|
QWidget *TagCompletionItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem&, const QModelIndex&) const {
|
||||||
@ -409,6 +414,7 @@ QWidget *TagCompletionItemDelegate::createEditor(QWidget *parent, const QStyleOp
|
|||||||
new TagCompleter(backend_, column_, editor);
|
new TagCompleter(backend_, column_, editor);
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NativeSeparatorsDelegate::displayText(const QVariant &value, const QLocale&) const {
|
QString NativeSeparatorsDelegate::displayText(const QVariant &value, const QLocale&) const {
|
||||||
|
@ -144,6 +144,7 @@ class TagCompleter : public QCompleter {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
TagCompleter(CollectionBackend *backend, Playlist::Column column, QLineEdit *editor);
|
TagCompleter(CollectionBackend *backend, Playlist::Column column, QLineEdit *editor);
|
||||||
|
~TagCompleter();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ModelReady(QFuture<TagCompletionModel*> future);
|
void ModelReady(QFuture<TagCompletionModel*> future);
|
||||||
|
@ -180,6 +180,10 @@ QobuzService::~QobuzService() {
|
|||||||
stream_url_req->deleteLater();
|
stream_url_req->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
artists_collection_backend_->deleteLater();
|
||||||
|
albums_collection_backend_->deleteLater();
|
||||||
|
songs_collection_backend_->deleteLater();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QobuzService::ShowConfig() {
|
void QobuzService::ShowConfig() {
|
||||||
|
@ -32,14 +32,19 @@
|
|||||||
|
|
||||||
ScrobblerServices::ScrobblerServices(QObject *parent) : QObject(parent) {}
|
ScrobblerServices::ScrobblerServices(QObject *parent) : QObject(parent) {}
|
||||||
|
|
||||||
ScrobblerServices::~ScrobblerServices() {}
|
ScrobblerServices::~ScrobblerServices() {
|
||||||
|
|
||||||
|
while (!scrobbler_services_.isEmpty()) {
|
||||||
|
delete scrobbler_services_.take(scrobbler_services_.firstKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void ScrobblerServices::AddService(ScrobblerService *service) {
|
void ScrobblerServices::AddService(ScrobblerService *service) {
|
||||||
|
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex_);
|
QMutexLocker locker(&mutex_);
|
||||||
scrobbler_services_.insert(service->name(), service);
|
scrobbler_services_.insert(service->name(), service);
|
||||||
connect(service, SIGNAL(destroyed()), SLOT(ServiceDestroyed()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qLog(Debug) << "Registered scrobbler service" << service->name();
|
qLog(Debug) << "Registered scrobbler service" << service->name();
|
||||||
@ -60,13 +65,6 @@ void ScrobblerServices::RemoveService(ScrobblerService *service) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScrobblerServices::ServiceDestroyed() {
|
|
||||||
|
|
||||||
ScrobblerService *service = static_cast<ScrobblerService*>(sender());
|
|
||||||
RemoveService(service);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int ScrobblerServices::NextId() { return next_id_.fetchAndAddRelaxed(1); }
|
int ScrobblerServices::NextId() { return next_id_.fetchAndAddRelaxed(1); }
|
||||||
|
|
||||||
ScrobblerService *ScrobblerServices::ServiceByName(const QString &name) {
|
ScrobblerService *ScrobblerServices::ServiceByName(const QString &name) {
|
||||||
|
@ -53,9 +53,6 @@ class ScrobblerServices : public QObject {
|
|||||||
return static_cast<T*>(this->ServiceByName(T::kName));
|
return static_cast<T*>(this->ServiceByName(T::kName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private slots:
|
|
||||||
void ServiceDestroyed();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(ScrobblerServices);
|
Q_DISABLE_COPY(ScrobblerServices);
|
||||||
|
|
||||||
|
@ -94,7 +94,9 @@ SubsonicService::SubsonicService(Application *app, QObject *parent)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SubsonicService::~SubsonicService() {}
|
SubsonicService::~SubsonicService() {
|
||||||
|
collection_backend_->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
void SubsonicService::ShowConfig() {
|
void SubsonicService::ShowConfig() {
|
||||||
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Subsonic);
|
app_->OpenSettingsDialogAtPage(SettingsDialog::Page_Subsonic);
|
||||||
|
@ -186,6 +186,10 @@ TidalService::~TidalService() {
|
|||||||
stream_url_req->deleteLater();
|
stream_url_req->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
artists_collection_backend_->deleteLater();
|
||||||
|
albums_collection_backend_->deleteLater();
|
||||||
|
songs_collection_backend_->deleteLater();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TidalService::ShowConfig() {
|
void TidalService::ShowConfig() {
|
||||||
|
@ -72,11 +72,14 @@ TrackSlider::TrackSlider(QWidget* parent)
|
|||||||
|
|
||||||
TrackSlider::~TrackSlider() {
|
TrackSlider::~TrackSlider() {
|
||||||
delete ui_;
|
delete ui_;
|
||||||
|
#ifdef HAVE_MOODBAR
|
||||||
|
if (moodbar_style_) moodbar_style_->deleteLater();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackSlider::SetApplication(Application* app) {
|
void TrackSlider::SetApplication(Application* app) {
|
||||||
#ifdef HAVE_MOODBAR
|
#ifdef HAVE_MOODBAR
|
||||||
moodbar_style_ = new MoodbarProxyStyle(app, ui_->slider);
|
if (!moodbar_style_) moodbar_style_ = new MoodbarProxyStyle(app, ui_->slider);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user