Reformat all C++

This commit is contained in:
John Maguire 2020-09-18 15:15:19 +01:00 committed by John Maguire
parent 18d4057ab7
commit 341dc7326f
612 changed files with 3599 additions and 3527 deletions

View File

@ -18,13 +18,13 @@
// it is used by the Spotify blob which links against libspotify and is not GPL
// compatible.
#include <gst/gst.h>
#include <QCoreApplication>
#include <QStringList>
#include <gst/gst.h>
#include "spotifyclient.h"
#include "core/logging.h"
#include "spotifyclient.h"
int main(int argc, char** argv) {
QCoreApplication a(argc, argv);

View File

@ -19,11 +19,12 @@
// compatible.
#include "mediapipeline.h"
#include "core/logging.h"
#include "core/timeconstants.h"
#include <cstring>
#include "core/logging.h"
#include "core/timeconstants.h"
MediaPipeline::MediaPipeline(int port, quint64 length_msec)
: port_(port),
length_msec_(length_msec),

View File

@ -11,8 +11,7 @@ namespace utilities {
QString GetUserDataDirectory() {
ScopedNSAutoreleasePool pool;
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,
NSUserDomainMask, YES);
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
QString ret;
if ([paths count] > 0) {
NSString* user_path = [paths objectAtIndex:0];
@ -25,8 +24,8 @@ QString GetUserDataDirectory() {
QString GetSettingsDirectory() {
ScopedNSAutoreleasePool pool;
NSArray* paths = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSArray* paths =
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSString* ret;
if ([paths count] > 0) {
ret = [paths objectAtIndex:0];
@ -36,10 +35,7 @@ QString GetSettingsDirectory() {
ret = [ret stringByAppendingString:@"/Clementine/spotify-settings"];
NSFileManager* file_manager = [NSFileManager defaultManager];
[file_manager createDirectoryAtPath:ret
withIntermediateDirectories:YES
attributes:nil
error:nil];
[file_manager createDirectoryAtPath:ret withIntermediateDirectories:YES attributes:nil error:nil];
QString path = QString::fromUtf8([ret UTF8String]);
return path;

View File

@ -20,22 +20,21 @@
#include "spotifyclient.h"
#include <algorithm>
#include <memory>
#include <QCoreApplication>
#include <QDir>
#include <QHostAddress>
#include <QTcpSocket>
#include <QTimer>
#include <algorithm>
#include <memory>
#include "core/arraysize.h"
#include "core/logging.h"
#include "core/timeconstants.h"
#include "mediapipeline.h"
#include "spotify_utilities.h"
#include "spotifykey.h"
#include "spotifymessages.pb.h"
#include "spotify_utilities.h"
const int SpotifyClient::kSpotifyImageIDSize = 20;
const int SpotifyClient::kWaveHeaderSize = 44;
@ -622,8 +621,8 @@ void SpotifyClient::AddTracksToPlaylist(
}
// Get the tracks we want to add
std::unique_ptr<sp_track* []> tracks_array(
new sp_track* [req.track_uri_size()]);
std::unique_ptr<sp_track*[]> tracks_array(
new sp_track*[req.track_uri_size()]);
for (int i = 0; i < req.track_uri_size(); ++i) {
sp_link* track_link = sp_link_create_from_string(req.track_uri(i).c_str());
sp_track* track = sp_link_as_track(track_link);

View File

@ -15,16 +15,16 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tagreaderworker.h"
#include "core/logging.h"
#include <sys/time.h>
#include <QCoreApplication>
#include <QLocalSocket>
#include <QSslSocket>
#include <QStringList>
#include <iostream>
#include <sys/time.h>
#include "core/logging.h"
#include "tagreaderworker.h"
int main(int argc, char** argv) {
QCoreApplication a(argc, argv);

View File

@ -71,12 +71,12 @@ void TagReaderWorker::MessageArrived(const pb::tagreader::Message& message) {
const pb::tagreader::ReadCloudFileRequest& req =
message.read_cloud_file_request();
if (!tag_reader_.ReadCloudFile(
QUrl::fromEncoded(QByteArray(req.download_url().data(),
req.download_url().size())),
QStringFromStdString(req.title()), req.size(),
QStringFromStdString(req.mime_type()),
QStringFromStdString(req.authorisation_header()),
reply.mutable_read_cloud_file_response()->mutable_metadata())) {
QUrl::fromEncoded(QByteArray(req.download_url().data(),
req.download_url().size())),
QStringFromStdString(req.title()), req.size(),
QStringFromStdString(req.mime_type()),
QStringFromStdString(req.authorisation_header()),
reply.mutable_read_cloud_file_response()->mutable_metadata())) {
reply.mutable_read_cloud_file_response()->clear_metadata();
}
#endif

View File

@ -18,24 +18,23 @@
// it is used by the Spotify blob which links against libspotify and is not GPL
// compatible.
#include <QtGlobal>
#include <cxxabi.h>
#include <QtGlobal>
#ifdef Q_OS_UNIX
#include <execinfo.h>
#endif
#include <iostream>
#include <memory>
#include <glib.h>
#include <QBuffer>
#include <QCoreApplication>
#include <QDateTime>
#include <QStringList>
#include <QtMessageHandler>
#include <QTextStream>
#include <glib.h>
#include <QtMessageHandler>
#include <iostream>
#include <memory>
#include "logging.h"
@ -117,9 +116,12 @@ class LoggedDebug : public DebugBase<LoggedDebug> {
LoggedDebug(QtMsgType t) : DebugBase(t) { nospace() << kMessageHandlerMagic; }
};
static void MessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message) {
if (strncmp(kMessageHandlerMagic, message.toLocal8Bit().data(), kMessageHandlerMagicLength) == 0) {
fprintf(stderr, "%s\n", message.toLocal8Bit().data() + kMessageHandlerMagicLength);
static void MessageHandler(QtMsgType type, const QMessageLogContext& context,
const QString& message) {
if (strncmp(kMessageHandlerMagic, message.toLocal8Bit().data(),
kMessageHandlerMagicLength) == 0) {
fprintf(stderr, "%s\n",
message.toLocal8Bit().data() + kMessageHandlerMagicLength);
return;
}

View File

@ -19,11 +19,12 @@
// compatible.
#include "messagehandler.h"
#include "core/logging.h"
#include <QAbstractSocket>
#include <QLocalSocket>
#include <QDataStream>
#include <QLocalSocket>
#include "core/logging.h"
_MessageHandlerBase::_MessageHandlerBase(QIODevice* device, QObject* parent)
: QObject(parent),

View File

@ -11,9 +11,7 @@ ScopedNSAutoreleasePool::ScopedNSAutoreleasePool()
Q_ASSERT(autorelease_pool_);
}
ScopedNSAutoreleasePool::~ScopedNSAutoreleasePool() {
[autorelease_pool_ drain];
}
ScopedNSAutoreleasePool::~ScopedNSAutoreleasePool() { [autorelease_pool_ drain]; }
// Cycle the internal pool, allowing everything there to get cleaned up and
// start anew.

View File

@ -17,20 +17,20 @@
#include "cloudstream.h"
#include <taglib/id3v2framefactory.h>
#include <taglib/mpegfile.h>
#include <QEventLoop>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <taglib/id3v2framefactory.h>
#include <taglib/mpegfile.h>
#include "core/logging.h"
namespace {
static const int kTaglibPrefixCacheBytes = 64 * 1024; // Should be enough.
static const int kTaglibSuffixCacheBytes = 8 * 1024;
}
} // namespace
CloudStream::CloudStream(const QUrl& url, const QString& filename,
const long length, const QString& auth)

View File

@ -17,10 +17,9 @@
#include "fmpsparser.h"
#include <functional>
#include <QStringList>
#include <QtDebug>
#include <functional>
using std::placeholders::_1;
using std::placeholders::_2;

View File

@ -1,10 +1,8 @@
#include "core/logging.h"
#include "core/timeconstants.h"
#include "gmereader.h"
#include "tagreader.h"
#include <apefile.h>
#include <tag.h>
#include <QByteArray>
#include <QChar>
#include <QFile>
@ -12,6 +10,10 @@
#include <QString>
#include <QtEndian>
#include "core/logging.h"
#include "core/timeconstants.h"
#include "tagreader.h"
bool GME::IsSupportedFormat(const QFileInfo& file_info) {
return (file_info.completeSuffix().endsWith("spc") ||
file_info.completeSuffix().endsWith("vgm"));

View File

@ -20,19 +20,18 @@
*/
/* Original Author: Max Howell <max.howell@methylblue.com> 2003
*/
*/
#include "analyzerbase.h"
#include <QEvent>
#include <QPaintEvent>
#include <QPainter>
#include <QtDebug>
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <QEvent>
#include <QPainter>
#include <QPaintEvent>
#include <QtDebug>
#include "core/arraysize.h"
// INSTRUCTIONS Base2D

View File

@ -21,7 +21,7 @@
*/
/* Original Author: Max Howell <max.howell@methylblue.com> 2004
*/
*/
#ifndef ANALYZERS_ANALYZERBASE_H_
#define ANALYZERS_ANALYZERBASE_H_
@ -32,14 +32,15 @@
#include <sys/types.h>
#endif
#include "fht.h"
#include "engines/engine_fwd.h"
#include "engines/enginebase.h"
#include <QPixmap>
#include <QBasicTimer>
#include <QPixmap>
#include <QWidget>
#include <vector>
#include "engines/engine_fwd.h"
#include "engines/enginebase.h"
#include "fht.h"
#ifdef HAVE_OPENGL
#include <QGLWidget>
#ifdef Q_OS_MACX

View File

@ -21,13 +21,6 @@
*/
#include "analyzercontainer.h"
#include "baranalyzer.h"
#include "blockanalyzer.h"
#include "boomanalyzer.h"
#include "sonogram.h"
#include "rainbowanalyzer.h"
#include "turbine.h"
#include "core/logging.h"
#include <QHBoxLayout>
#include <QMouseEvent>
@ -35,6 +28,14 @@
#include <QTimer>
#include <QtDebug>
#include "baranalyzer.h"
#include "blockanalyzer.h"
#include "boomanalyzer.h"
#include "core/logging.h"
#include "rainbowanalyzer.h"
#include "sonogram.h"
#include "turbine.h"
const char* AnalyzerContainer::kSettingsGroup = "Analyzer";
const char* AnalyzerContainer::kSettingsFramerate = "framerate";
@ -155,8 +156,7 @@ void AnalyzerContainer::TogglePsychedelicColors() {
}
void AnalyzerContainer::ChangeAnalyzer(int id) {
QObject* instance =
analyzer_types_[id]->newInstance(Q_ARG(QWidget*, this));
QObject* instance = analyzer_types_[id]->newInstance(Q_ARG(QWidget*, this));
if (!instance) {
qLog(Warning) << "Couldn't initialise a new"
@ -225,7 +225,7 @@ void AnalyzerContainer::Load() {
}
void AnalyzerContainer::SaveFramerate(int framerate) {
// For now, framerate is common for all analyzers.
// For now, framerate is common for all analyzers.
// Maybe each analyzer should have its own framerate?
current_framerate_ = framerate;
QSettings s;

View File

@ -23,8 +23,8 @@
#ifndef ANALYZERS_ANALYZERCONTAINER_H_
#define ANALYZERS_ANALYZERCONTAINER_H_
#include <QWidget>
#include <QMenu>
#include <QWidget>
#include "analyzerbase.h"
#include "engines/engine_fwd.h"
@ -40,7 +40,7 @@ class AnalyzerContainer : public QWidget {
static const char* kSettingsGroup;
static const char* kSettingsFramerate;
signals:
signals:
void WheelEvent(int delta);
protected:

View File

@ -21,12 +21,13 @@
*/
/* Original Author: Mark Kretschmann <markey@web.de> 2003
*/
*/
#include "baranalyzer.h"
#include <cmath>
#include <QtDebug>
#include <QPainter>
#include <QtDebug>
#include <cmath>
using Analyzer::Scope;
@ -158,12 +159,11 @@ void BarAnalyzer::analyze(QPainter& p, const Scope& s, bool new_frame) {
// 3. fall downwards at a constant pace
/*if ( change > max_up_ ) //anything too much greater than 2 gives "jitter"
//add some dynamics - makes the value slightly closer to what it was last time
y2 = ( barVector_[i] + max_up_ );
//add some dynamics - makes the value slightly closer to what it was
last time y2 = ( barVector_[i] + max_up_ );
//y2 = ( barVector_[i] * 2 + y2 ) / 3;
else*/ if (change <
max_down_)
y2 = barVector_[i] + max_down_;
else*/
if (change < max_down_) y2 = barVector_[i] + max_down_;
if (static_cast<int>(y2) > roofVector_[i]) {
roofVector_[i] = static_cast<int>(y2);

View File

@ -22,7 +22,7 @@
/* Original Author: Max Howell <max.howell@methylblue.com> 2003-2005
* Original Author: Mark Kretschmann <markey@web.de> 2005
*/
*/
#ifndef ANALYZERS_BARANALYZER_H_
#define ANALYZERS_BARANALYZER_H_

View File

@ -26,12 +26,11 @@
#include "blockanalyzer.h"
#include <cmath>
#include <QMouseEvent>
#include <QResizeEvent>
#include <cstdlib>
#include <QPainter>
#include <QResizeEvent>
#include <cmath>
#include <cstdlib>
const uint BlockAnalyzer::kHeight = 2;
const uint BlockAnalyzer::kWidth = 4;

View File

@ -25,9 +25,10 @@
#ifndef ANALYZERS_BLOCKANALYZER_H_
#define ANALYZERS_BLOCKANALYZER_H_
#include "analyzerbase.h"
#include <qcolor.h>
#include "analyzerbase.h"
class QResizeEvent;
class QMouseEvent;
class QPalette;

View File

@ -23,8 +23,9 @@
*/
#include "boomanalyzer.h"
#include <cmath>
#include <QPainter>
#include <cmath>
using Analyzer::Scope;

View File

@ -18,10 +18,11 @@
*/
/* Original Author: Melchior FRANZ <mfranz@kde.org> 2004
*/
*/
#include "fht.h"
#include <cmath>
#include "fht.h"
FHT::FHT(int n) : num_((n < 3) ? 0 : 1 << n), exp2_((n < 3) ? -1 : n) {
if (n > 3) {

View File

@ -18,7 +18,7 @@
*/
/* Original Author: Melchior FRANZ <mfranz@kde.org> 2004
*/
*/
#ifndef ANALYZERS_FHT_H_
#define ANALYZERS_FHT_H_
@ -59,10 +59,10 @@ class FHT {
public:
/**
* Prepare transform for data sets with @f$2^n@f$ numbers, whereby @f$n@f$
* should be at least 3. Values of more than 3 need a trigonometry table.
* @see makeCasTable()
*/
* Prepare transform for data sets with @f$2^n@f$ numbers, whereby @f$n@f$
* should be at least 3. Values of more than 3 need a trigonometry table.
* @see makeCasTable()
*/
FHT(int);
~FHT();

View File

@ -25,10 +25,12 @@
#ifdef HAVE_QGLWIDGET
#include <cmath>
#include "glanalyzer.h"
#include <kdebug.h>
#include <cmath>
#include "glanalyzer.h"
GLAnalyzer::GLAnalyzer(QWidget* parent)
: Analyzer::Base3D(parent, 15), m_oldy(32, -10.0f), m_peaks(32) {}
@ -75,8 +77,9 @@ void GLAnalyzer::analyze(const Scope& s) {
// Calculating new vertical position (y) depending on the data passed by
// amarok
y = static_cast<float>(s[i + offset] * mfactor); // This make it kinda dynamically
// resize depending on the data
y = static_cast<float>(s[i + offset] *
mfactor); // This make it kinda dynamically
// resize depending on the data
// Some basic bounds checking
if (y > 30)

View File

@ -25,14 +25,16 @@
#ifdef HAVE_QGLWIDGET
#include <cmath>
#include <cstdlib>
#include "glanalyzer2.h"
#include <kdebug.h>
#include <kstandarddirs.h>
#include <qimage.h>
#include <sys/time.h>
#include <cmath>
#include <cstdlib>
#include "glanalyzer2.h"
GLAnalyzer2::GLAnalyzer2(QWidget* parent) : Analyzer::Base3D(parent, 15) {
// initialize openGL context before managing GL calls
makeCurrent();
@ -77,7 +79,8 @@ void GLAnalyzer2::resizeGL(int w, int h) {
glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, -5.0f, 5.0f);
// Get the aspect ratio of the screen to draw 'cicular' particles
float ratio = static_cast<float>(w) / static_cast<float>(h), eqPixH = 60, eqPixW = 80;
float ratio = static_cast<float>(w) / static_cast<float>(h), eqPixH = 60,
eqPixW = 80;
if (ratio >= (4.0 / 3.0)) {
unitX = 10.0 / (eqPixH * ratio);
unitY = 10.0 / eqPixH;
@ -89,7 +92,8 @@ void GLAnalyzer2::resizeGL(int w, int h) {
// Get current timestamp.
timeval tv;
gettimeofday(&tv, nullptr);
show.timeStamp = static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_usec) / 1000000.0;
show.timeStamp = static_cast<double>(tv.tv_sec) +
static_cast<double>(tv.tv_usec) / 1000000.0;
}
void GLAnalyzer2::paused() { analyze(Scope()); }
@ -133,7 +137,8 @@ void GLAnalyzer2::paintGL() {
// Compute the dT since the last call to paintGL and update timings
timeval tv;
gettimeofday(&tv, nullptr);
double currentTime = static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_usec) / 1000000.0;
double currentTime = static_cast<double>(tv.tv_sec) +
static_cast<double>(tv.tv_usec) / 1000000.0;
show.dT = currentTime - show.timeStamp;
show.timeStamp = currentTime;

View File

@ -27,9 +27,10 @@
#include <config.h>
#ifdef HAVE_QGLWIDGET
#include "analyzerbase.h"
#include <qstring.h>
#include <qptrlist.h>
#include <qstring.h>
#include "analyzerbase.h"
class GLAnalyzer2 : public Analyzer::Base3D {
public:

View File

@ -25,14 +25,16 @@
#ifdef HAVE_QGLWIDGET
#include <cmath>
#include <cstdlib>
#include "glanalyzer3.h"
#include <kdebug.h>
#include <kstandarddirs.h>
#include <qimage.h>
#include <sys/time.h>
#include <cmath>
#include <cstdlib>
#include "glanalyzer3.h"
#ifndef HAVE_FABSF
inline float fabsf(float f) { return f < 0.f ? -f : f; }
#endif
@ -47,7 +49,7 @@ class Ball {
vy(0.0),
vz(0.0),
mass(0.01 + drand48() / 10.0),
color((float[3]) { 0.0, drand48()*0.5, 0.7 + drand48() * 0.3 }) {}
color((float[3]){0.0, drand48() * 0.5, 0.7 + drand48() * 0.3}) {}
float x, y, z, vx, vy, vz, mass;
float color[3];
@ -69,7 +71,7 @@ class Ball {
class Paddle {
public:
explicit Paddle(float xPos)
: onLeft(xPos < 0), mass(1.0), X(xPos), x(xPos), vx(0.0) {}
: onLeft(xPos < 0), mass(1.0), X(xPos), x(xPos), vx(0.0) {}
void updatePhysics(float dT) {
x += vx * dT; // posision
@ -175,7 +177,8 @@ void GLAnalyzer3::resizeGL(int w, int h) {
// Get current timestamp.
timeval tv;
gettimeofday(&tv, nullptr);
show.timeStamp = static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_usec) / 1000000.0;
show.timeStamp = static_cast<double>(tv.tv_sec) +
static_cast<double>(tv.tv_usec) / 1000000.0;
}
void GLAnalyzer3::paused() { analyze(Scope()); }
@ -184,7 +187,8 @@ void GLAnalyzer3::analyze(const Scope& s) {
// compute the dTime since the last call
timeval tv;
gettimeofday(&tv, nullptr);
double currentTime = static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_usec) / 1000000.0;
double currentTime = static_cast<double>(tv.tv_sec) +
static_cast<double>(tv.tv_usec) / 1000000.0;
show.dT = currentTime - show.timeStamp;
show.timeStamp = currentTime;

View File

@ -27,9 +27,10 @@
#ifndef ANALYZERS_GLANALYZER3_H_
#define ANALYZERS_GLANALYZER3_H_
#include "analyzerbase.h"
#include <qstring.h>
#include <qptrlist.h>
#include <qstring.h>
#include "analyzerbase.h"
class QWidget;
class Ball;
@ -68,7 +69,7 @@ class GLAnalyzer3 : public Analyzer::Base3D {
static const int NUMBER_OF_BALLS = 16;
QPtrList<Ball> balls;
Paddle* leftPaddle, *rightPaddle;
Paddle *leftPaddle, *rightPaddle;
float unitX, unitY;
GLuint ballTexture;
GLuint gridTexture;

View File

@ -23,12 +23,11 @@
#include "rainbowanalyzer.h"
#include <cmath>
#include <QBrush>
#include <QPainter>
#include <QPen>
#include <QTimerEvent>
#include <cmath>
#include "core/arraysize.h"
#include "core/logging.h"

View File

@ -24,21 +24,18 @@
#ifndef ANALYZERS_RAINBOWANALYZER_H_
#define ANALYZERS_RAINBOWANALYZER_H_
#include "analyzerbase.h"
#include <QDateTime>
#include <QPainter>
#include <QPen>
#include "analyzerbase.h"
namespace Rainbow {
class RainbowAnalyzer : public Analyzer::Base {
Q_OBJECT
public:
enum RainbowType {
Nyancat = 0,
Dash = 1
};
enum RainbowType { Nyancat = 0, Dash = 1 };
RainbowAnalyzer(const RainbowType& rbtype, QWidget* parent);
@ -66,25 +63,25 @@ class RainbowAnalyzer : public Analyzer::Base {
static RainbowType rainbowtype;
inline QRect SourceRect(RainbowType rainbowtype) const {
return QRect(0, kHeight[rainbowtype] * frame_,
kWidth[rainbowtype], kHeight[rainbowtype]);
return QRect(0, kHeight[rainbowtype] * frame_, kWidth[rainbowtype],
kHeight[rainbowtype]);
}
inline QRect SleepingSourceRect(RainbowType rainbowtype) const {
return QRect(0, kHeight[rainbowtype] * kFrameCount[rainbowtype],
return QRect(0, kHeight[rainbowtype] * kFrameCount[rainbowtype],
kWidth[rainbowtype], kSleepingHeight[rainbowtype]);
}
inline QRect DestRect(RainbowType rainbowtype) const {
return QRect(width() - kWidth[rainbowtype], (height() -
kHeight[rainbowtype]) / 2, kWidth[rainbowtype],
return QRect(width() - kWidth[rainbowtype],
(height() - kHeight[rainbowtype]) / 2, kWidth[rainbowtype],
kHeight[rainbowtype]);
}
inline QRect SleepingDestRect(RainbowType rainbowtype) const {
return QRect(width() - kWidth[rainbowtype], (height() -
kSleepingHeight[rainbowtype]) / 2, kWidth[rainbowtype],
kSleepingHeight[rainbowtype]);
return QRect(width() - kWidth[rainbowtype],
(height() - kSleepingHeight[rainbowtype]) / 2,
kWidth[rainbowtype], kSleepingHeight[rainbowtype]);
}
private:
@ -102,7 +99,7 @@ class RainbowAnalyzer : public Analyzer::Base {
// The y positions of each point on the rainbow.
float history_[kHistorySize * kRainbowBands];
// A cache of the last frame's rainbow,
// A cache of the last frame's rainbow,
// so it can be used in the next frame.
QPixmap buffer_[2];
int current_buffer_;
@ -114,7 +111,7 @@ class RainbowAnalyzer : public Analyzer::Base {
// X spacing between each point in the polyline.
int px_per_frame_;
// Amount the buffer_ is shifted to the left (off the edge of the widget)
// Amount the buffer_ is shifted to the left (off the edge of the widget)
// to make the rainbow extend from 0 to available_rainbow_width_.
int x_offset_;
@ -126,7 +123,7 @@ class NyanCatAnalyzer : public RainbowAnalyzer {
public:
Q_INVOKABLE NyanCatAnalyzer(QWidget* parent);
static const char* kName;
};
@ -138,6 +135,6 @@ class RainbowDashAnalyzer : public RainbowAnalyzer {
static const char* kName;
};
}
} // namespace Rainbow
#endif // ANALYZERS_RAINBOWANALYZER_H_

View File

@ -24,11 +24,11 @@
* Original Author: Max Howell <max.howell@methylblue.com> 2003
*/
#include <cmath>
#include <QPainter>
#include "turbine.h"
#include <QPainter>
#include <cmath>
using Analyzer::Scope;
const char* TurbineAnalyzer::kName =

View File

@ -20,11 +20,11 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "application.h"
#include <QSettings>
#include <QTimer>
#include "application.h"
#include "config.h"
#include "core/appearance.h"
#include "core/database.h"
@ -107,9 +107,9 @@ class ApplicationImpl {
// Initialize the repository of cover providers.
cover_providers->AddProvider(new MusicbrainzCoverProvider);
cover_providers->AddProvider(new DiscogsCoverProvider);
#ifdef HAVE_LIBLASTFM
#ifdef HAVE_LIBLASTFM
cover_providers->AddProvider(new LastFmCoverProvider(app));
#endif
#endif
return cover_providers;
}),
task_manager_([=]() { return new TaskManager(app); }),

View File

@ -22,9 +22,8 @@
#ifndef CORE_APPLICATION_H_
#define CORE_APPLICATION_H_
#include <memory>
#include <QObject>
#include <memory>
#include "ui/settingsdialog.h"
@ -115,7 +114,7 @@ class Application : public QObject {
void ReloadSettings();
void OpenSettingsDialogAtPage(SettingsDialog::Page page);
signals:
signals:
void ErrorAdded(const QString& message);
void SettingsChanged();
void SaveSettings(QSettings* settings);

View File

@ -20,10 +20,9 @@
#ifndef CORE_CACHEDLIST_H_
#define CORE_CACHEDLIST_H_
#include <algorithm>
#include <QDateTime>
#include <QSettings>
#include <algorithm>
template <typename T>
class CachedList {

View File

@ -21,18 +21,19 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "commandlineoptions.h"
#include "version.h"
#include "core/logging.h"
#include <cstdlib>
#include <getopt.h>
#include <iostream>
#include <QBuffer>
#include <QCoreApplication>
#include <QFileInfo>
#include <cstdlib>
#include <iostream>
#include "config.h"
#include "core/logging.h"
#include "version.h"
const char* CommandlineOptions::kHelpText =
"%1: clementine [%2] [%3]\n"
@ -143,7 +144,8 @@ bool CommandlineOptions::Parse() {
// Parse the arguments
bool ok = false;
forever {
int c = getopt_long(argc_, argv_, "xhptusqrfv:c:alk:oyg:", kOptions, nullptr);
int c =
getopt_long(argc_, argv_, "xhptusqrfv:c:alk:oyg:", kOptions, nullptr);
// End of the options
if (c == -1) break;
@ -182,7 +184,7 @@ bool CommandlineOptions::Parse() {
tr("Equivalent to --log-levels *:1"),
tr("Equivalent to --log-levels *:3"),
tr("Comma separated list of class:level, level is 0-3"))
.arg(tr("Print out version information"),
.arg(tr("Print out version information"),
tr("Delete the currently playing song"));
std::cout << translated_help_text.toLocal8Bit().constData();
@ -346,7 +348,7 @@ QString CommandlineOptions::tr(const char* source_text) {
QDataStream& operator<<(QDataStream& s, const CommandlineOptions& a) {
s << qint32(a.player_action_) << qint32(a.url_list_action_) << a.set_volume_
<< a.volume_modifier_ << a.seek_to_ << a.seek_by_ << a.play_track_at_
<< a.show_osd_ << a.urls_ << a.log_levels_ << a.toggle_pretty_osd_
<< a.show_osd_ << a.urls_ << a.log_levels_ << a.toggle_pretty_osd_
<< a.delete_current_track_;
return s;

View File

@ -24,9 +24,9 @@
#ifndef CORE_COMMANDLINEOPTIONS_H_
#define CORE_COMMANDLINEOPTIONS_H_
#include <QDataStream>
#include <QList>
#include <QUrl>
#include <QDataStream>
class CommandlineOptions {
friend QDataStream& operator<<(QDataStream& s, const CommandlineOptions& a);

View File

@ -17,21 +17,22 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "crashreporting.h"
#include "core/logging.h"
#include <QApplication>
#include <QDir>
#include <QFile>
#include <QMessageBox>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QProgressDialog>
#include <QUrl>
#include <QtDebug>
#include "config.h"
#include "core/logging.h"
#if defined(HAVE_BREAKPAD) and defined(Q_OS_LINUX)
#include "client/linux/handler/exception_handler.h"
#include "third_party/lss/linux_syscall_support.h"
@ -111,13 +112,14 @@ bool CrashSender::Start() {
}
// No tr() here.
QMessageBox prompt(QMessageBox::Critical, "Clementine has crashed!",
QString(
"A crash report has been created and saved to '%1'. "
"With your permission "
"it can be automatically sent to our server so the "
"developers can find "
"out what happened.").arg(path_));
QMessageBox prompt(
QMessageBox::Critical, "Clementine has crashed!",
QString("A crash report has been created and saved to '%1'. "
"With your permission "
"it can be automatically sent to our server so the "
"developers can find "
"out what happened.")
.arg(path_));
prompt.addButton("Don't send", QMessageBox::RejectRole);
prompt.addButton("Send crash report", QMessageBox::AcceptRole);
if (prompt.exec() == QDialog::Rejected) {
@ -195,7 +197,7 @@ void CrashSender::UploadProgress(qint64 bytes) { progress_->setValue(bytes); }
namespace google_breakpad {
class ExceptionHandler {};
}
} // namespace google_breakpad
CrashReporting::CrashReporting() {}

View File

@ -20,9 +20,8 @@
#ifndef CORE_CRASHREPORTING_H_
#define CORE_CRASHREPORTING_H_
#include <memory>
#include <QObject>
#include <memory>
class QFile;
class QNetworkAccessManager;

View File

@ -23,15 +23,7 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "database.h"
#include "scopedtransaction.h"
#include "utilities.h"
#include "core/application.h"
#include "core/logging.h"
#include "core/taskmanager.h"
#include <boost/scope_exit.hpp>
#include <sqlite3.h>
@ -41,10 +33,18 @@
#include <QLibraryInfo>
#include <QSqlDriver>
#include <QSqlQuery>
#include <QtDebug>
#include <QThread>
#include <QUrl>
#include <QVariant>
#include <QtDebug>
#include <boost/scope_exit.hpp>
#include "config.h"
#include "core/application.h"
#include "core/logging.h"
#include "core/taskmanager.h"
#include "scopedtransaction.h"
#include "utilities.h"
const char* Database::kDatabaseFilename = "clementine.db";
const int Database::kSchemaVersion = 51;
@ -241,8 +241,10 @@ QSqlDatabase Database::Connect() {
}
}
const QString connection_id = QString("%1_thread_%2").arg(connection_id_).arg(
reinterpret_cast<quint64>(QThread::currentThread()));
const QString connection_id =
QString("%1_thread_%2")
.arg(connection_id_)
.arg(reinterpret_cast<quint64>(QThread::currentThread()));
// Try to find an existing connection for this thread
QSqlDatabase db = QSqlDatabase::database(connection_id);
@ -266,17 +268,20 @@ QSqlDatabase Database::Connect() {
if (!sFTSTokenizer) StaticInit();
{
#ifdef SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER
// In case sqlite>=3.12 is compiled without -DSQLITE_ENABLE_FTS3_TOKENIZER (generally a good idea
// due to security reasons) the fts3 support should be enabled explicitly.
// see https://github.com/clementine-player/Clementine/issues/5297
// In case sqlite>=3.12 is compiled without -DSQLITE_ENABLE_FTS3_TOKENIZER
// (generally a good idea due to security reasons) the fts3 support should
// be enabled explicitly. see
// https://github.com/clementine-player/Clementine/issues/5297
//
// See https://www.sqlite.org/fts3.html#custom_application_defined_tokenizers
// See
// https://www.sqlite.org/fts3.html#custom_application_defined_tokenizers
QVariant v = db.driver()->handle();
if (v.isValid() && qstrcmp(v.typeName(), "sqlite3*") == 0) {
sqlite3* handle = *static_cast<sqlite3**>(v.data());
if (!handle || sqlite3_db_config(handle, SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1, nullptr) != SQLITE_OK) {
if (!handle ||
sqlite3_db_config(handle, SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER, 1,
nullptr) != SQLITE_OK) {
qLog(Fatal) << "Failed to enable FTS3 tokenizer";
}
}
@ -289,7 +294,8 @@ QSqlDatabase Database::Connect() {
":pointer", QByteArray(reinterpret_cast<const char*>(&sFTSTokenizer),
sizeof(&sFTSTokenizer)));
if (!set_fts_tokenizer.exec()) {
qLog(Warning) << "Couldn't register FTS3 tokenizer : " << set_fts_tokenizer.lastError();
qLog(Warning) << "Couldn't register FTS3 tokenizer : "
<< set_fts_tokenizer.lastError();
}
// Implicit invocation of ~QSqlQuery() when leaving the scope
// to release any remaining database locks!
@ -330,9 +336,9 @@ QSqlDatabase Database::Connect() {
continue;
// Find out if there are any tables in this database
QSqlQuery q(db);
q.prepare(QString(
"SELECT ROWID FROM %1.sqlite_master"
" WHERE type='table'").arg(key));
q.prepare(QString("SELECT ROWID FROM %1.sqlite_master"
" WHERE type='table'")
.arg(key));
if (!q.exec() || !q.next()) {
q.finish();
ExecSchemaCommandsFromFile(db, attached_databases_[key].schema_, 0);
@ -473,7 +479,8 @@ void Database::UrlEncodeFilenameColumn(const QString& table, QSqlDatabase& db) {
QSqlQuery select(db);
select.prepare(QString("SELECT ROWID, filename FROM %1").arg(table));
QSqlQuery update(db);
update.prepare(QString("UPDATE %1 SET filename=:filename WHERE ROWID=:id").arg(table));
update.prepare(
QString("UPDATE %1 SET filename=:filename WHERE ROWID=:id").arg(table));
select.exec();
if (CheckErrors(select)) return;
while (select.next()) {
@ -568,9 +575,9 @@ QStringList Database::SongsTables(QSqlDatabase& db, int schema_version) const {
// look for the tables in attached dbs
for (const QString& key : attached_databases_.keys()) {
QSqlQuery q(db);
q.prepare(QString(
"SELECT NAME FROM %1.sqlite_master"
" WHERE type='table' AND name='songs' OR name LIKE '%songs'")
q.prepare(
QString("SELECT NAME FROM %1.sqlite_master"
" WHERE type='table' AND name='songs' OR name LIKE '%songs'")
.arg(key));
if (q.exec()) {
while (q.next()) {

View File

@ -24,6 +24,8 @@
#ifndef CORE_DATABASE_H_
#define CORE_DATABASE_H_
#include <sqlite3.h>
#include <QMap>
#include <QMutex>
#include <QObject>
@ -31,8 +33,6 @@
#include <QSqlError>
#include <QStringList>
#include <sqlite3.h>
#include "gtest/gtest_prod.h"
extern "C" {

View File

@ -20,8 +20,8 @@
#include "deletefiles.h"
#include <QStringList>
#include <QTimer>
#include <QThread>
#include <QTimer>
#include <QUrl>
#include "musicstorage.h"

View File

@ -20,9 +20,8 @@
#ifndef CORE_DELETEFILES_H_
#define CORE_DELETEFILES_H_
#include <memory>
#include <QObject>
#include <memory>
#include "song.h"

View File

@ -21,13 +21,14 @@
*/
#include "filesystemmusicstorage.h"
#include "core/logging.h"
#include "core/utilities.h"
#include <QDir>
#include <QFile>
#include <QUrl>
#include "core/logging.h"
#include "core/utilities.h"
FilesystemMusicStorage::FilesystemMusicStorage(const QString& root)
: root_(root) {}

View File

@ -19,19 +19,19 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "globalshortcuts.h"
#include "gnomeglobalshortcutbackend.h"
#include "kglobalaccelglobalshortcutbackend.h"
#include "macglobalshortcutbackend.h"
#include "qxtglobalshortcutbackend.h"
#include "mac_startup.h"
#include <QAction>
#include <QShortcut>
#include <QtDebug>
#include "config.h"
#include "gnomeglobalshortcutbackend.h"
#include "kglobalaccelglobalshortcutbackend.h"
#include "mac_startup.h"
#include "macglobalshortcutbackend.h"
#include "qxtglobalshortcutbackend.h"
#ifdef HAVE_DBUS
#include <QtDBus>
#endif

View File

@ -59,7 +59,7 @@ class GlobalShortcuts : public QWidget {
void Unregister();
void Register();
signals:
signals:
void Play();
void Pause();
void PlayPause();

View File

@ -17,11 +17,12 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gnomeglobalshortcutbackend.h"
#include "config.h"
#include "core/closure.h"
#include "core/logging.h"
#include "globalshortcuts.h"
#include "gnomeglobalshortcutbackend.h"
#ifdef HAVE_DBUS
#include <dbus/gnomesettingsdaemon.h>
@ -111,7 +112,7 @@ void GnomeGlobalShortcutBackend::DoUnregister() {
#ifdef HAVE_DBUS
// Check if the GSD service is available
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(
kGsdService))
kGsdService))
return;
if (!interface_ || !is_connected_) return;

View File

@ -1,9 +1,10 @@
#include "core/logging.h"
#include "kglobalaccelglobalshortcutbackend.h"
#include <QAction>
#include <QGuiApplication>
#include "core/logging.h"
#ifdef HAVE_DBUS
#include <dbus/kglobalaccel.h>

View File

@ -1,13 +1,13 @@
#ifndef CORE_KGLOBALACCELGLOBALSHORTCUTBACKEND_H_
#define CORE_KGLOBALACCELGLOBALSHORTCUTBACKEND_H_
#include <QSet>
#include <QStringList>
#include "config.h"
#include "globalshortcutbackend.h"
#include "globalshortcuts.h"
#include <QSet>
#include <QStringList>
class QAction;
class OrgKdeKGlobalAccelInterface;

View File

@ -29,7 +29,7 @@
class PlatformInterface;
@class SPMediaKeyTap;
@interface AppDelegate : NSObject<NSApplicationDelegate, NSUserNotificationCenterDelegate> {
@interface AppDelegate : NSObject <NSApplicationDelegate, NSUserNotificationCenterDelegate> {
PlatformInterface* application_handler_;
NSMenu* dock_menu_;
MacGlobalShortcutBackend* shortcut_handler_;
@ -43,20 +43,16 @@ class PlatformInterface;
- (id)initWithHandler:(PlatformInterface*)handler;
// NSApplicationDelegate
- (BOOL)applicationShouldHandleReopen:(NSApplication*)app
hasVisibleWindows:(BOOL)flag;
- (BOOL)applicationShouldHandleReopen:(NSApplication*)app hasVisibleWindows:(BOOL)flag;
- (NSMenu*)applicationDockMenu:(NSApplication*)sender;
- (void)applicationDidFinishLaunching:(NSNotification*)aNotification;
- (NSApplicationTerminateReply)applicationShouldTerminate:
(NSApplication*)sender;
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender;
// NSUserNotificationCenterDelegate
- (BOOL)userNotificationCenter:(id)center
shouldPresentNotification:(id)notification;
- (BOOL)userNotificationCenter:(id)center shouldPresentNotification:(id)notification;
- (void)setDockMenu:(NSMenu*)menu;
- (MacGlobalShortcutBackend*)shortcut_handler;
- (void)setShortcutHandler:(MacGlobalShortcutBackend*)backend;
- (void)mediaKeyTap:(SPMediaKeyTap*)keyTap
receivedMediaKeyEvent:(NSEvent*)event;
- (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
@end

View File

@ -41,15 +41,15 @@
#import "3rdparty/SPMediaKeyTap/SPMediaKeyTap.h"
#include "config.h"
#include "core/logging.h"
#include "core/scoped_cftyperef.h"
#include "core/scoped_nsautorelease_pool.h"
#include "globalshortcuts.h"
#include "mac_delegate.h"
#include "mac_startup.h"
#include "mac_utilities.h"
#include "macglobalshortcutbackend.h"
#include "utilities.h"
#include "core/logging.h"
#include "core/scoped_cftyperef.h"
#include "core/scoped_nsautorelease_pool.h"
#ifdef HAVE_SPARKLE
#import <Sparkle/SUUpdater.h>
@ -127,16 +127,15 @@ static BreakpadRef InitBreakpad() {
// Register defaults for the whitelist of apps that want to use media keys
[[NSUserDefaults standardUserDefaults]
registerDefaults:
[NSDictionary
dictionaryWithObjectsAndKeys:
[SPMediaKeyTap defaultMediaKeyUserBundleIdentifiers],
kMediaKeyUsingBundleIdentifiersDefaultsKey, nil]];
registerDefaults:[NSDictionary
dictionaryWithObjectsAndKeys:[SPMediaKeyTap
defaultMediaKeyUserBundleIdentifiers],
kMediaKeyUsingBundleIdentifiersDefaultsKey,
nil]];
return self;
}
- (BOOL)applicationShouldHandleReopen:(NSApplication*)app
hasVisibleWindows:(BOOL)flag {
- (BOOL)applicationShouldHandleReopen:(NSApplication*)app hasVisibleWindows:(BOOL)flag {
if (application_handler_) {
application_handler_->Activate();
}
@ -163,10 +162,9 @@ static BreakpadRef InitBreakpad() {
key_tap_ = [[SPMediaKeyTap alloc] initWithDelegate:self];
if ([SPMediaKeyTap usesGlobalMediaKeyTap] &&
![[NSProcessInfo processInfo]
isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){
.majorVersion = 10,
.minorVersion = 12,
.patchVersion = 0}]) {
isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){.majorVersion = 10,
.minorVersion = 12,
.patchVersion = 0}]) {
[key_tap_ startWatchingMediaKeys];
} else {
qLog(Warning) << "Media key monitoring disabled";
@ -185,16 +183,13 @@ static BreakpadRef InitBreakpad() {
- (void)application:(NSApplication*)app openFiles:(NSArray*)filenames {
qLog(Debug) << "Wants to open:" << filenames;
[filenames
enumerateObjectsUsingBlock:^(id object, NSUInteger idx, BOOL* stop) {
[self application:app openFile:(NSString*)object];
}];
[filenames enumerateObjectsUsingBlock:^(id object, NSUInteger idx, BOOL* stop) {
[self application:app openFile:(NSString*)object];
}];
}
- (void)mediaKeyTap:(SPMediaKeyTap*)keyTap
receivedMediaKeyEvent:(NSEvent*)event {
NSAssert([event type] == NSSystemDefined &&
[event subtype] == SPSystemDefinedEventMediaKeys,
- (void)mediaKeyTap:(SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event {
NSAssert([event type] == NSSystemDefined && [event subtype] == SPSystemDefinedEventMediaKeys,
@"Unexpected NSEvent in mediaKeyTap:receivedMediaKeyEvent:");
int key_code = (([event data1] & 0xFFFF0000) >> 16);
@ -211,16 +206,14 @@ static BreakpadRef InitBreakpad() {
}
}
- (NSApplicationTerminateReply)applicationShouldTerminate:
(NSApplication*)sender {
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender {
#ifdef HAVE_BREAKPAD
BreakpadRelease(breakpad_);
#endif
return NSTerminateNow;
}
- (BOOL)userNotificationCenter:(id)center
shouldPresentNotification:(id)notification {
- (BOOL)userNotificationCenter:(id)center shouldPresentNotification:(id)notification {
// Always show notifications, even if Clementine is in the foreground.
return YES;
}
@ -257,14 +250,12 @@ static BreakpadRef InitBreakpad() {
[delegate_ setShortcutHandler:shortcut_handler_];
[self setDelegate:delegate_];
[[NSUserNotificationCenter defaultUserNotificationCenter]
setDelegate:delegate_];
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:delegate_];
}
- (void)sendEvent:(NSEvent*)event {
// If event tap is not installed, handle events that reach the app instead
BOOL shouldHandleMediaKeyEventLocally =
![SPMediaKeyTap usesGlobalMediaKeyTap];
BOOL shouldHandleMediaKeyEventLocally = ![SPMediaKeyTap usesGlobalMediaKeyTap];
if (shouldHandleMediaKeyEventLocally && [event type] == NSSystemDefined &&
[event subtype] == SPSystemDefinedEventMediaKeys) {
@ -288,13 +279,9 @@ void MacMain() {
#endif
}
void SetShortcutHandler(MacGlobalShortcutBackend* handler) {
[NSApp SetShortcutHandler:handler];
}
void SetShortcutHandler(MacGlobalShortcutBackend* handler) { [NSApp SetShortcutHandler:handler]; }
void SetApplicationHandler(PlatformInterface* handler) {
[NSApp SetApplicationHandler:handler];
}
void SetApplicationHandler(PlatformInterface* handler) { [NSApp SetApplicationHandler:handler]; }
void CheckForUpdates() {
#ifdef HAVE_SPARKLE
@ -303,12 +290,10 @@ void CheckForUpdates() {
}
QString GetBundlePath() {
ScopedCFTypeRef<CFURLRef> app_url(
CFBundleCopyBundleURL(CFBundleGetMainBundle()));
ScopedCFTypeRef<CFURLRef> app_url(CFBundleCopyBundleURL(CFBundleGetMainBundle()));
ScopedCFTypeRef<CFStringRef> mac_path(
CFURLCopyFileSystemPath(app_url.get(), kCFURLPOSIXPathStyle));
const char* path =
CFStringGetCStringPtr(mac_path.get(), CFStringGetSystemEncoding());
const char* path = CFStringGetCStringPtr(mac_path.get(), CFStringGetSystemEncoding());
QString bundle_path = QString::fromUtf8(path);
return bundle_path;
}
@ -320,8 +305,8 @@ QString GetResourcesPath() {
QString GetApplicationSupportPath() {
ScopedNSAutoreleasePool pool;
NSArray* paths = NSSearchPathForDirectoriesInDomains(
NSApplicationSupportDirectory, NSUserDomainMask, YES);
NSArray* paths =
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
QString ret;
if ([paths count] > 0) {
NSString* user_path = [paths objectAtIndex:0];
@ -334,8 +319,7 @@ QString GetApplicationSupportPath() {
QString GetMusicDirectory() {
ScopedNSAutoreleasePool pool;
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSMusicDirectory,
NSUserDomainMask, YES);
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSMusicDirectory, NSUserDomainMask, YES);
QString ret;
if ([paths count] > 0) {
NSString* user_path = [paths objectAtIndex:0];

View File

@ -16,10 +16,10 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QKeySequence>
#include <CoreFoundation/CFDictionary.h>
#include <QKeySequence>
#ifdef __OBJC__
@class NSEvent;
#else
@ -31,4 +31,4 @@ namespace mac {
QKeySequence KeySequenceFromNSEvent(NSEvent* event);
void DumpDictionary(CFDictionaryRef dict);
float GetDevicePixelRatio(QWidget* widget);
}
} // namespace mac

View File

@ -28,7 +28,10 @@
#include "core/scoped_nsobject.h"
MacFSListener::MacFSListener(QObject* parent)
: FileSystemWatcherInterface(parent), run_loop_(nullptr), stream_(nullptr), update_timer_(new QTimer(this)) {
: FileSystemWatcherInterface(parent),
run_loop_(nullptr),
stream_(nullptr),
update_timer_(new QTimer(this)) {
update_timer_->setSingleShot(true);
update_timer_->setInterval(2000);
connect(update_timer_, SIGNAL(timeout()), SLOT(UpdateStream()));
@ -36,10 +39,10 @@ MacFSListener::MacFSListener(QObject* parent)
void MacFSListener::Init() { run_loop_ = CFRunLoopGetCurrent(); }
void MacFSListener::EventStreamCallback(
ConstFSEventStreamRef stream, void* user_data, size_t num_events,
void* event_paths, const FSEventStreamEventFlags event_flags[],
const FSEventStreamEventId event_ids[]) {
void MacFSListener::EventStreamCallback(ConstFSEventStreamRef stream, void* user_data,
size_t num_events, void* event_paths,
const FSEventStreamEventFlags event_flags[],
const FSEventStreamEventId event_ids[]) {
MacFSListener* me = reinterpret_cast<MacFSListener*>(user_data);
char** paths = reinterpret_cast<char**>(event_paths);
for (int i = 0; i < num_events; ++i) {
@ -97,10 +100,10 @@ void MacFSListener::UpdateStream() {
context.info = this;
CFAbsoluteTime latency = 1.0;
stream_ = FSEventStreamCreate(nullptr, &EventStreamCallback, &context, // Copied
reinterpret_cast<CFArrayRef>(array.get()),
kFSEventStreamEventIdSinceNow, latency,
kFSEventStreamCreateFlagNone);
stream_ =
FSEventStreamCreate(nullptr, &EventStreamCallback, &context, // Copied
reinterpret_cast<CFArrayRef>(array.get()), kFSEventStreamEventIdSinceNow,
latency, kFSEventStreamCreateFlagNone);
FSEventStreamScheduleWithRunLoop(stream_, run_loop_, kCFRunLoopDefaultMode);
FSEventStreamStart(stream_);

View File

@ -20,13 +20,12 @@
#ifndef CORE_MACGLOBALSHORTCUTBACKEND_H_
#define CORE_MACGLOBALSHORTCUTBACKEND_H_
#include <QKeySequence>
#include <QMap>
#include <memory>
#include "globalshortcutbackend.h"
#include <QKeySequence>
#include <QMap>
class MacGlobalShortcutBackendPrivate;
class QAction;

View File

@ -22,9 +22,9 @@
#include <AppKit/NSEvent.h>
#include <AppKit/NSWorkspace.h>
#include <ApplicationServices/ApplicationServices.h>
#include <Foundation/NSString.h>
#include <IOKit/hidsystem/ev_keymap.h>
#include <ApplicationServices/ApplicationServices.h>
#include <QAction>
#include <QList>
@ -47,19 +47,16 @@ class MacGlobalShortcutBackendPrivate : boost::noncopyable {
: global_monitor_(nil), local_monitor_(nil), backend_(backend) {}
bool Register() {
global_monitor_ =
[NSEvent addGlobalMonitorForEventsMatchingMask:NSKeyDownMask
handler:^(NSEvent* event) {
HandleKeyEvent(event);
}];
global_monitor_ = [NSEvent addGlobalMonitorForEventsMatchingMask:NSKeyDownMask
handler:^(NSEvent* event) {
HandleKeyEvent(event);
}];
local_monitor_ =
[NSEvent addLocalMonitorForEventsMatchingMask:NSKeyDownMask
handler:^(NSEvent* event) {
// Filter event if we handle
// it as a global shortcut.
return HandleKeyEvent(event)
? nil
: event;
// Filter event if we handle
// it as a global shortcut.
return HandleKeyEvent(event) ? nil : event;
}];
return true;
}
@ -81,8 +78,7 @@ class MacGlobalShortcutBackendPrivate : boost::noncopyable {
};
MacGlobalShortcutBackend::MacGlobalShortcutBackend(GlobalShortcuts* parent)
: GlobalShortcutBackend(parent),
p_(new MacGlobalShortcutBackendPrivate(this)) {}
: GlobalShortcutBackend(parent), p_(new MacGlobalShortcutBackendPrivate(this)) {}
MacGlobalShortcutBackend::~MacGlobalShortcutBackend() {}
@ -90,8 +86,7 @@ bool MacGlobalShortcutBackend::DoRegister() {
// Always enable media keys.
mac::SetShortcutHandler(this);
for (const GlobalShortcuts::Shortcut& shortcut :
manager_->shortcuts().values()) {
for (const GlobalShortcuts::Shortcut& shortcut : manager_->shortcuts().values()) {
shortcuts_[shortcut.action->shortcut()] = shortcut.action;
}
return p_->Register();
@ -130,21 +125,21 @@ bool MacGlobalShortcutBackend::KeyPressed(const QKeySequence& sequence) {
bool MacGlobalShortcutBackend::IsAccessibilityEnabled() const {
bool accessibilityEnabled;
try{
try {
accessibilityEnabled = AXAPIEnabled();
}catch(...){
NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES};
} catch (...) {
NSDictionary* options = @{(id)kAXTrustedCheckOptionPrompt : @YES};
accessibilityEnabled = AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
}
return accessibilityEnabled;
}
void MacGlobalShortcutBackend::ShowAccessibilityDialog() {
NSArray* paths = NSSearchPathForDirectoriesInDomains(
NSPreferencePanesDirectory, NSSystemDomainMask, YES);
NSArray* paths =
NSSearchPathForDirectoriesInDomains(NSPreferencePanesDirectory, NSSystemDomainMask, YES);
if ([paths count] == 1) {
SBSystemPreferencesApplication* system_prefs = [SBApplication
applicationWithBundleIdentifier:@"com.apple.systempreferences"];
SBSystemPreferencesApplication* system_prefs =
[SBApplication applicationWithBundleIdentifier:@"com.apple.systempreferences"];
[system_prefs activate];
SBElementArray* panes = [system_prefs panes];

View File

@ -19,21 +19,21 @@
*/
#include "mergedproxymodel.h"
#include "core/logging.h"
#include <QStringList>
#include <functional>
#include <limits>
#include "core/logging.h"
// boost::multi_index still relies on these being in the global namespace.
using std::placeholders::_1;
using std::placeholders::_2;
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/multi_index_container.hpp>
using boost::multi_index::hashed_unique;
using boost::multi_index::identity;
@ -48,8 +48,8 @@ std::size_t hash_value(const QModelIndex& index) { return qHash(index); }
namespace {
struct Mapping {
explicit Mapping(const QModelIndex& _source_index) :
source_index(_source_index) {}
explicit Mapping(const QModelIndex& _source_index)
: source_index(_source_index) {}
QModelIndex source_index;
};
@ -65,8 +65,8 @@ class MergedProxyModelPrivate {
Mapping*,
indexed_by<
hashed_unique<tag<tag_by_source>,
member<Mapping, QModelIndex, &Mapping::source_index> >,
ordered_unique<tag<tag_by_pointer>, identity<Mapping*> > > >
member<Mapping, QModelIndex, &Mapping::source_index>>,
ordered_unique<tag<tag_by_pointer>, identity<Mapping*>>>>
MappingContainer;
public:
@ -264,8 +264,8 @@ void MergedProxyModel::RowsRemoved(const QModelIndex&, int, int) {
endRemoveRows();
}
QModelIndex MergedProxyModel::mapToSource(const QModelIndex& proxy_index)
const {
QModelIndex MergedProxyModel::mapToSource(
const QModelIndex& proxy_index) const {
if (!proxy_index.isValid()) return QModelIndex();
Mapping* mapping = static_cast<Mapping*>(proxy_index.internalPointer());
@ -277,8 +277,8 @@ QModelIndex MergedProxyModel::mapToSource(const QModelIndex& proxy_index)
return mapping->source_index;
}
QModelIndex MergedProxyModel::mapFromSource(const QModelIndex& source_index)
const {
QModelIndex MergedProxyModel::mapFromSource(
const QModelIndex& source_index) const {
if (!source_index.isValid()) return QModelIndex();
if (source_index.model() == resetting_model_) return QModelIndex();
@ -376,8 +376,8 @@ QVariant MergedProxyModel::data(const QModelIndex& proxyIndex, int role) const {
return source_index.model()->data(source_index, role);
}
QMap<int, QVariant> MergedProxyModel::itemData(const QModelIndex& proxy_index)
const {
QMap<int, QVariant> MergedProxyModel::itemData(
const QModelIndex& proxy_index) const {
QModelIndex source_index = mapToSource(proxy_index);
if (!source_index.isValid()) return sourceModel()->itemData(QModelIndex());
@ -442,8 +442,8 @@ bool MergedProxyModel::dropMimeData(const QMimeData* data,
return sourceModel()->dropMimeData(data, action, row, column, parent);
}
QModelIndex MergedProxyModel::FindSourceParent(const QModelIndex& proxy_index)
const {
QModelIndex MergedProxyModel::FindSourceParent(
const QModelIndex& proxy_index) const {
if (!proxy_index.isValid()) return QModelIndex();
QModelIndex source_index = mapToSource(proxy_index);
@ -468,8 +468,8 @@ void MergedProxyModel::fetchMore(const QModelIndex& parent) {
GetModel(source_index)->fetchMore(source_index);
}
QAbstractItemModel* MergedProxyModel::GetModel(const QModelIndex& source_index)
const {
QAbstractItemModel* MergedProxyModel::GetModel(
const QModelIndex& source_index) const {
// This is essentially const_cast<QAbstractItemModel*>(source_index.model()),
// but without the const_cast
const QAbstractItemModel* const_model = source_index.model();

View File

@ -20,9 +20,8 @@
#ifndef CORE_MERGEDPROXYMODEL_H_
#define CORE_MERGEDPROXYMODEL_H_
#include <memory>
#include <QAbstractProxyModel>
#include <memory>
std::size_t hash_value(const QModelIndex& index);

View File

@ -45,6 +45,7 @@
#ifdef HAVE_DBUS
#include <QDBusMetaType>
#include "core/mpris2.h"
#include "dbus/metatypes.h"
#endif

View File

@ -18,6 +18,7 @@
*/
#include "mpris.h"
#include "mpris2.h"
namespace mpris {

View File

@ -23,20 +23,19 @@
#include "mpris2.h"
#include <algorithm>
#include <QApplication>
#include <QDBusConnection>
#include <QtConcurrentRun>
#include <algorithm>
#include "config.h"
#include "core/application.h"
#include "core/logging.h"
#include "core/mpris_common.h"
#include "core/mpris2_player.h"
#include "core/mpris2_playlists.h"
#include "core/mpris2_root.h"
#include "core/mpris2_tracklist.h"
#include "core/mpris_common.h"
#include "core/player.h"
#include "core/timeconstants.h"
#include "covers/currentartloader.h"
@ -207,8 +206,9 @@ QString Mpris2::DesktopEntryAbsolutePath() const {
xdg_data_dirs.append("/usr/share/");
for (const QString& directory : xdg_data_dirs) {
QString path = QString("%1/applications/%2.desktop").arg(
directory, QApplication::applicationName().toLower());
QString path =
QString("%1/applications/%2.desktop")
.arg(directory, QApplication::applicationName().toLower());
if (QFile::exists(path)) return path;
}
return QString();
@ -506,7 +506,7 @@ QDBusObjectPath MakePlaylistPath(int id) {
return QDBusObjectPath(
QString("/org/clementineplayer/clementine/PlaylistId/%1").arg(id));
}
}
} // namespace
MaybePlaylist Mpris2::ActivePlaylist() const {
MaybePlaylist maybe_playlist;

View File

@ -177,7 +177,7 @@ class Mpris2 : public QObject {
QList<MprisPlaylist> GetPlaylists(quint32 index, quint32 max_count,
const QString& order, bool reverse_order);
signals:
signals:
// Player
void Seeked(qlonglong position);

View File

@ -18,12 +18,13 @@
*/
#include "multisortfilterproxy.h"
#include "core/logging.h"
#include <QDate>
#include <QDateTime>
#include <QTime>
#include "core/logging.h"
MultiSortFilterProxy::MultiSortFilterProxy(QObject* parent)
: QSortFilterProxyModel(parent) {}

View File

@ -20,12 +20,11 @@
#ifndef CORE_MUSICSTORAGE_H_
#define CORE_MUSICSTORAGE_H_
#include "song.h"
#include <QMetaType>
#include <functional>
#include <memory>
#include <QMetaType>
#include "song.h"
class MusicStorage {
public:

View File

@ -17,7 +17,6 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "core/logging.h"
#include "network.h"
#include <QCoreApplication>
@ -27,6 +26,7 @@
#include <QNetworkReply>
#include "core/closure.h"
#include "core/logging.h"
#include "utilities.h"
QMutex ThreadSafeNetworkDiskCache::sMutex;

View File

@ -17,16 +17,16 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "networkproxyfactory.h"
#include "core/logging.h"
#include <stdlib.h>
#include <QMutexLocker>
#include <QSettings>
#include <QStringList>
#include <QtDebug>
#include <stdlib.h>
#include "core/logging.h"
NetworkProxyFactory* NetworkProxyFactory::sInstance = nullptr;
const char* NetworkProxyFactory::kSettingsGroup = "Proxy";

View File

@ -27,7 +27,11 @@
class NetworkProxyFactory : public QNetworkProxyFactory {
public:
// These values are persisted
enum Mode { Mode_System = 0, Mode_Direct = 1, Mode_Manual = 2, };
enum Mode {
Mode_System = 0,
Mode_Direct = 1,
Mode_Manual = 2,
};
static NetworkProxyFactory* Instance();
static const char* kSettingsGroup;

View File

@ -21,19 +21,18 @@
#include "organise.h"
#include <functional>
#include <QDir>
#include <QFileInfo>
#include <QTimer>
#include <QThread>
#include <QTimer>
#include <QUrl>
#include <functional>
#include "musicstorage.h"
#include "taskmanager.h"
#include "core/logging.h"
#include "core/tagreaderclient.h"
#include "core/utilities.h"
#include "musicstorage.h"
#include "taskmanager.h"
using std::placeholders::_1;
@ -43,8 +42,8 @@ const int Organise::kTranscodeProgressInterval = 500;
Organise::Organise(TaskManager* task_manager,
std::shared_ptr<MusicStorage> destination,
const OrganiseFormat& format, bool copy, bool overwrite,
bool mark_as_listened,
const NewSongInfoList& songs_info, bool eject_after)
bool mark_as_listened, const NewSongInfoList& songs_info,
bool eject_after)
: thread_(nullptr),
task_manager_(task_manager),
transcoder_(new Transcoder(this)),
@ -203,8 +202,8 @@ void Organise::ProcessSomeFiles() {
if (job.remove_original_) {
// Notify other aspects of system that song has been invalidated
QString root = destination_->LocalPath();
QFileInfo new_file = QFileInfo(
root + "/" + task.song_info_.new_filename_);
QFileInfo new_file =
QFileInfo(root + "/" + task.song_info_.new_filename_);
emit SongPathChanged(song, new_file);
}
if (job.mark_as_listened_) {
@ -288,7 +287,8 @@ void Organise::UpdateProgress() {
task_manager_->SetTaskProgress(task_id_, progress, total);
}
void Organise::FileTranscoded(const QString& input, const QString& output, bool success) {
void Organise::FileTranscoded(const QString& input, const QString& output,
bool success) {
qLog(Info) << "File finished" << input << success;
transcode_progress_timer_.stop();

View File

@ -22,12 +22,11 @@
#ifndef CORE_ORGANISE_H_
#define CORE_ORGANISE_H_
#include <memory>
#include <QFileInfo>
#include <QBasicTimer>
#include <QFileInfo>
#include <QObject>
#include <QTemporaryFile>
#include <memory>
#include "organiseformat.h"
#include "transcoder/transcoder.h"
@ -68,7 +67,8 @@ class Organise : public QObject {
private slots:
void ProcessSomeFiles();
void FileTranscoded(const QString& input, const QString& output, bool success);
void FileTranscoded(const QString& input, const QString& output,
bool success);
private:
void SetSongProgress(float progress, bool transcoded = false);

View File

@ -21,8 +21,8 @@
#define CORE_ORGANISEFORMAT_H_
#include <QSyntaxHighlighter>
#include <QValidator>
#include <QTextEdit>
#include <QValidator>
#include "core/song.h"

View File

@ -27,12 +27,11 @@
#include "player.h"
#include <memory>
#include <QSettings>
#include <QSortFilterProxyModel>
#include <QtDebug>
#include <QtConcurrentRun>
#include <QtDebug>
#include <memory>
#include "config.h"
#include "core/application.h"
@ -114,7 +113,8 @@ void Player::ReloadSettings() {
void Player::HandleLoadResult(const UrlHandler::LoadResult& result) {
// Might've been an async load, so check we're still on the same item
shared_ptr<PlaylistItem> item = app_->playlist_manager()->active()->current_item();
shared_ptr<PlaylistItem> item =
app_->playlist_manager()->active()->current_item();
if (!item) {
loading_async_ = QUrl();
return;
@ -624,7 +624,7 @@ void Player::InvalidSongRequested(const QUrl& url) {
emit SongChangeRequestProcessed(url, false);
// ... and now when our listeners have completed their processing of the
// current item we can change the current item by skipping to the next song
QSettings s;
s.beginGroup(kSettingsGroup);

View File

@ -27,11 +27,10 @@
#ifndef CORE_PLAYER_H_
#define CORE_PLAYER_H_
#include <memory>
#include <QDateTime>
#include <QObject>
#include <QSettings>
#include <memory>
#include "config.h"
#include "core/song.h"
@ -92,7 +91,7 @@ class PlayerInterface : public QObject {
virtual void Play() = 0;
virtual void ShowOSD() = 0;
signals:
signals:
void Playing();
void Paused();
void Stopped();

View File

@ -20,10 +20,10 @@
#ifndef CORE_QTFSLISTENER_H_
#define CORE_QTFSLISTENER_H_
#include "filesystemwatcherinterface.h"
#include <QFileSystemWatcher>
#include "filesystemwatcherinterface.h"
class QtFSListener : public FileSystemWatcherInterface {
Q_OBJECT
public:

View File

@ -17,15 +17,16 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "globalshortcuts.h"
#include "qxtglobalshortcutbackend.h"
#include "qxtglobalshortcut.h"
#include "core/logging.h"
#include <QAction>
#include <QGuiApplication>
#include <QtDebug>
#include "core/logging.h"
#include "globalshortcuts.h"
#include "qxtglobalshortcut.h"
QxtGlobalShortcutBackend::QxtGlobalShortcutBackend(GlobalShortcuts* parent)
: GlobalShortcutBackend(parent) {}

View File

@ -18,11 +18,12 @@
*/
#include "scopedtransaction.h"
#include "core/logging.h"
#include <QSqlDatabase>
#include <QtDebug>
#include "core/logging.h"
ScopedTransaction::ScopedTransaction(QSqlDatabase* db)
: db_(db), pending_(true) {
db->transaction();

View File

@ -19,8 +19,8 @@
#ifndef CORE_SETTINGSPROVIDER_H_
#define CORE_SETTINGSPROVIDER_H_
#include <QVariant>
#include <QSettings>
#include <QVariant>
class SettingsProvider {
public:

View File

@ -22,7 +22,7 @@
#include "core/logging.h"
gulong CheckedGConnect(gpointer source, const char* signal, GCallback callback,
gpointer data, const int callback_param_count) {
gpointer data, const int callback_param_count) {
guint signal_id = 0;
GQuark detail = 0;

View File

@ -20,10 +20,10 @@
#ifndef CORE_SIMPLETREEITEM_H_
#define CORE_SIMPLETREEITEM_H_
#include "simpletreemodel.h"
#include <QString>
#include <QList>
#include <QString>
#include "simpletreemodel.h"
template <typename T>
class SimpleTreeItem {

View File

@ -28,8 +28,6 @@
#include "song.h"
#include <algorithm>
#include <QCoreApplication>
#include <QDir>
#include <QFile>
@ -41,6 +39,7 @@
#include <QTime>
#include <QVariant>
#include <QtConcurrentRun>
#include <algorithm>
#ifdef HAVE_LIBLASTFM
#include "internet/lastfm/fixlastfm.h"

View File

@ -22,27 +22,26 @@
#include "songloader.h"
#include <algorithm>
#include <memory>
#include <QBuffer>
#include <QDirIterator>
#include <QFileInfo>
#include <QTimer>
#include <QUrl>
#include <QtDebug>
#include <algorithm>
#include <memory>
#include "config.h"
#include "core/logging.h"
#include "core/player.h"
#include "core/utilities.h"
#include "core/signalchecker.h"
#include "core/song.h"
#include "core/tagreaderclient.h"
#include "core/timeconstants.h"
#include "core/utilities.h"
#include "core/waitforsignal.h"
#include "internet/lastfm/fixlastfm.h"
#include "internet/core/internetmodel.h"
#include "internet/lastfm/fixlastfm.h"
#include "internet/podcasts/podcastparser.h"
#include "internet/podcasts/podcastservice.h"
#include "internet/podcasts/podcasturlloader.h"
@ -55,6 +54,7 @@
#ifdef HAVE_AUDIOCD
#include <gst/audio/gstaudiocdsrc.h>
#include "devices/cddasongloader.h"
#endif
@ -404,8 +404,8 @@ SongLoader::Result SongLoader::LoadRemote() {
// Create the source element automatically based on the URL
GstElement* source = gst_element_make_from_uri(
GST_URI_SRC, Utilities::GetUriForGstreamer(url_).constData(),
nullptr, nullptr);
GST_URI_SRC, Utilities::GetUriForGstreamer(url_).constData(), nullptr,
nullptr);
if (!source) {
qLog(Warning) << "Couldn't create gstreamer source element for"
<< url_.toString();

View File

@ -23,18 +23,17 @@
#ifndef CORE_SONGLOADER_H_
#define CORE_SONGLOADER_H_
#include <functional>
#include <memory>
#include <gst/gst.h>
#include <QObject>
#include <QThreadPool>
#include <QUrl>
#include <functional>
#include <memory>
#include "song.h"
#include "core/tagreaderclient.h"
#include "musicbrainz/musicbrainzclient.h"
#include "song.h"
class CueParser;
class LibraryBackendInterface;
@ -79,7 +78,7 @@ class SongLoader : public QObject {
void LoadMetadataBlocking();
Result LoadAudioCD();
signals:
signals:
void AudioCDTracksLoaded();
void LoadAudioCDFinished(bool success);
void LoadRemoteFinished();

View File

@ -18,10 +18,11 @@
*/
#include "stylesheetloader.h"
#include "core/logging.h"
#include <QFile>
#include <QEvent>
#include <QFile>
#include "core/logging.h"
StyleSheetLoader::StyleSheetLoader(QObject* parent) : QObject(parent) {}

View File

@ -19,10 +19,10 @@
#ifndef CORE_STYLESHEETLOADER_H_
#define CORE_STYLESHEETLOADER_H_
#include <QString>
#include <QPalette>
#include <QWidget>
#include <QMap>
#include <QPalette>
#include <QString>
#include <QWidget>
class StyleSheetLoader : public QObject {
public:

View File

@ -18,7 +18,6 @@
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "player.h"
#include "tagreaderclient.h"
#include <QCoreApplication>
@ -28,6 +27,8 @@
#include <QThread>
#include <QUrl>
#include "player.h"
const char* TagReaderClient::kWorkerExecutableName = "clementine-tagreader";
TagReaderClient* TagReaderClient::sInstance = nullptr;

View File

@ -21,12 +21,12 @@
#ifndef CORE_TAGREADERCLIENT_H_
#define CORE_TAGREADERCLIENT_H_
#include "song.h"
#include "tagreadermessages.pb.h"
#include <QStringList>
#include "core/messagehandler.h"
#include "core/workerpool.h"
#include <QStringList>
#include "song.h"
#include "tagreadermessages.pb.h"
class QLocalServer;
class QProcess;

View File

@ -19,6 +19,7 @@
#define CORE_THREAD_H_
#include <QThread>
#include "core/utilities.h"
// Improve QThread by adding a SetIoPriority function

View File

@ -18,11 +18,12 @@
*/
#include "ubuntuunityhack.h"
#include "core/logging.h"
#include <QFile>
#include <QProcess>
#include "core/logging.h"
const char* UbuntuUnityHack::kGSettingsFileName = "gsettings";
const char* UbuntuUnityHack::kUnityPanel = "com.canonical.Unity.Panel";
const char* UbuntuUnityHack::kUnitySystrayWhitelist = "systray-whitelist";
@ -43,8 +44,8 @@ UbuntuUnityHack::UbuntuUnityHack(QObject* parent) : QObject(parent) {
QProcess* get = new QProcess(this);
connect(get, SIGNAL(finished(int)), SLOT(GetFinished(int)));
connect(get, SIGNAL(error(QProcess::ProcessError)), SLOT(GetError()));
get->start(kGSettingsFileName, QStringList() << "get" << kUnityPanel
<< kUnitySystrayWhitelist);
get->start(kGSettingsFileName,
QStringList() << "get" << kUnityPanel << kUnitySystrayWhitelist);
}
void UbuntuUnityHack::GetError() {
@ -85,9 +86,9 @@ void UbuntuUnityHack::GetFinished(int exit_code) {
QProcess* set = new QProcess(this);
connect(set, SIGNAL(finished(int)), set, SLOT(deleteLater()));
set->start(kGSettingsFileName, QStringList() << "set" << kUnityPanel
<< kUnitySystrayWhitelist
<< whitelist);
set->start(kGSettingsFileName, QStringList()
<< "set" << kUnityPanel
<< kUnitySystrayWhitelist << whitelist);
qLog(Info) << "Clementine has added itself to the Unity system tray"
<< "whitelist, but this won't take effect until the next time"

View File

@ -28,8 +28,6 @@
#include <stdlib.h>
#include <memory>
#include <QApplication>
#include <QDateTime>
#include <QDesktopServices>
@ -40,41 +38,44 @@
#include <QMouseEvent>
#include <QStringList>
#include <QTcpServer>
#include <QtDebug>
#include <QTemporaryFile>
#include <QtGlobal>
#include <QUrl>
#include <QWidget>
#include <QXmlStreamReader>
#include <QtDebug>
#include <QtGlobal>
#include <memory>
#include "config.h"
#include "core/application.h"
#include "core/logging.h"
#include "config.h"
#include "timeconstants.h"
#if defined(Q_OS_UNIX)
#include <sys/statvfs.h>
#elif defined(Q_OS_WIN32)
#include <windows.h>
#include <QProcess>
#endif
#ifdef Q_OS_LINUX
#include <unistd.h>
#include <sys/syscall.h>
#include <unistd.h>
#endif
#ifdef Q_OS_DARWIN
#include <sys/resource.h>
#endif
#ifdef Q_OS_DARWIN
#include <QProcess>
#include "CoreServices/CoreServices.h"
#include "IOKit/ps/IOPSKeys.h"
#include "IOKit/ps/IOPowerSources.h"
#include "core/mac_startup.h"
#include "core/mac_utilities.h"
#include "core/scoped_cftyperef.h"
#include "CoreServices/CoreServices.h"
#include "IOKit/ps/IOPowerSources.h"
#include "IOKit/ps/IOPSKeys.h"
#include <QProcess>
#endif
namespace Utilities {

View File

@ -23,15 +23,14 @@
#ifndef CORE_UTILITIES_H_
#define CORE_UTILITIES_H_
#include <memory>
#include <QColor>
#include <QCryptographicHash>
#include <QFile>
#include <QLocale>
#include <QCryptographicHash>
#include <QSize>
#include <QString>
#include <QUrl>
#include <memory>
class QIODevice;
class QMouseEvent;

View File

@ -22,8 +22,8 @@
#include <QFile>
#include <QThreadPool>
#include "coverexportrunnable.h"
#include "core/song.h"
#include "coverexportrunnable.h"
const int AlbumCoverExporter::kMaxConcurrentRequests = 3;

View File

@ -19,14 +19,14 @@
#ifndef COVERS_ALBUMCOVEREXPORTER_H_
#define COVERS_ALBUMCOVEREXPORTER_H_
#include "coverexportrunnable.h"
#include "core/song.h"
#include "ui/albumcoverexport.h"
#include <QObject>
#include <QQueue>
#include <QTimer>
#include "core/song.h"
#include "coverexportrunnable.h"
#include "ui/albumcoverexport.h"
class QThreadPool;
class AlbumCoverExporter : public QObject {

View File

@ -90,7 +90,8 @@ void AlbumCoverFetcher::StartRequests() {
return;
}
while (!queued_requests_.isEmpty() && active_requests_.size() < kMaxConcurrentRequests) {
while (!queued_requests_.isEmpty() &&
active_requests_.size() < kMaxConcurrentRequests) {
CoverSearchRequest request = queued_requests_.dequeue();
// search objects are this fetcher's children so worst case scenario - they

View File

@ -21,8 +21,6 @@
#ifndef COVERS_ALBUMCOVERFETCHER_H_
#define COVERS_ALBUMCOVERFETCHER_H_
#include "coversearchstatistics.h"
#include <QHash>
#include <QImage>
#include <QList>
@ -32,6 +30,8 @@
#include <QQueue>
#include <QUrl>
#include "coversearchstatistics.h"
class QNetworkReply;
class QString;

View File

@ -20,20 +20,19 @@
#include "albumcoverfetchersearch.h"
#include <algorithm>
#include <cmath>
#include <QMutexLocker>
#include <QNetworkReply>
#include <QTimer>
#include <QtDebug>
#include <algorithm>
#include <cmath>
#include "albumcoverfetcher.h"
#include "coverprovider.h"
#include "coverproviders.h"
#include "core/closure.h"
#include "core/logging.h"
#include "core/network.h"
#include "coverprovider.h"
#include "coverproviders.h"
const int AlbumCoverFetcherSearch::kSearchTimeoutMs = 10000;
const int AlbumCoverFetcherSearch::kImageLoadTimeoutMs = 2500;
@ -224,11 +223,13 @@ float AlbumCoverFetcherSearch::ScoreImage(const QImage& image) const {
// A 500x500px image scores 1.0, bigger scores higher
const float size_score =
std::sqrt(static_cast<float>(image.width() * image.height())) / kTargetSize;
std::sqrt(static_cast<float>(image.width() * image.height())) /
kTargetSize;
// A 1:1 image scores 1.0, anything else scores less
const float aspect_score = 1.0 - static_cast<float>(image.height() - image.width()) /
std::max(image.height(), image.width());
const float aspect_score =
1.0 - static_cast<float>(image.height() - image.width()) /
std::max(image.height(), image.width());
return size_score + aspect_score;
}

View File

@ -21,11 +21,11 @@
#ifndef COVERS_ALBUMCOVERFETCHERSEARCH_H_
#define COVERS_ALBUMCOVERFETCHERSEARCH_H_
#include "albumcoverfetcher.h"
#include <QMap>
#include <QObject>
#include "albumcoverfetcher.h"
class CoverProvider;
class CoverProviders;
class NetworkTimeouts;

View File

@ -21,11 +21,11 @@
#include "albumcoverloader.h"
#include <QPainter>
#include <QDir>
#include <QCoreApplication>
#include <QUrl>
#include <QDir>
#include <QNetworkReply>
#include <QPainter>
#include <QUrl>
#include "config.h"
#include "core/closure.h"
@ -205,7 +205,8 @@ AlbumCoverLoader::TryLoadResult AlbumCoverLoader::TryLoadImage(
}
#endif
else if (filename.isEmpty()) {
// Avoid "QFSFileEngine::open: No file name specified" messages if we know that the filename is empty
// Avoid "QFSFileEngine::open: No file name specified" messages if we know
// that the filename is empty
return TryLoadResult(false, false, task.options.default_output_image_);
}

View File

@ -21,16 +21,16 @@
#ifndef COVERS_ALBUMCOVERLOADER_H_
#define COVERS_ALBUMCOVERLOADER_H_
#include "albumcoverloaderoptions.h"
#include "config.h"
#include "core/song.h"
#include <QImage>
#include <QMutex>
#include <QObject>
#include <QQueue>
#include <QUrl>
#include "albumcoverloaderoptions.h"
#include "config.h"
#include "core/song.h"
class NetworkAccessManager;
class QNetworkReply;
@ -72,7 +72,10 @@ class AlbumCoverLoader : public QObject {
#endif
protected:
enum State { State_TryingManual, State_TryingAuto, };
enum State {
State_TryingManual,
State_TryingAuto,
};
struct Task {
Task() : redirects(0) {}

View File

@ -114,21 +114,24 @@ void CoverExportRunnable::ProcessAndExportCover() {
(cover_path == Song::kEmbeddedCover ? "jpg" : extension);
// If the file exists, do not override!
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode_None && QFile::exists(new_file)) {
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode_None &&
QFile::exists(new_file)) {
EmitCoverSkipped();
return;
}
// we're handling overwrite as remove + copy so we need to delete the old file
// first
if (QFile::exists(new_file) && dialog_result_.overwrite_ != AlbumCoverExport::OverwriteMode_None) {
if (QFile::exists(new_file) &&
dialog_result_.overwrite_ != AlbumCoverExport::OverwriteMode_None) {
// if the mode is "overwrite smaller" then skip the cover if a bigger one
// is already available in the folder
if (dialog_result_.overwrite_ == AlbumCoverExport::OverwriteMode_Smaller) {
QImage existing;
existing.load(new_file);
if (existing.isNull() || existing.size().height() >= cover.size().height() ||
if (existing.isNull() ||
existing.size().height() >= cover.size().height() ||
existing.size().width() >= cover.size().width()) {
EmitCoverSkipped();
return;

View File

@ -20,12 +20,12 @@
#ifndef COVERS_COVEREXPORTRUNNABLE_H_
#define COVERS_COVEREXPORTRUNNABLE_H_
#include "core/song.h"
#include "ui/albumcoverexport.h"
#include <QObject>
#include <QRunnable>
#include "core/song.h"
#include "ui/albumcoverexport.h"
class AlbumCoverExporter;
class CoverExportRunnable : public QObject, public QRunnable {

View File

@ -21,11 +21,11 @@
#ifndef COVERS_COVERPROVIDER_H_
#define COVERS_COVERPROVIDER_H_
#include <QObject>
#include "albumcoverfetcher.h"
#include "coverproviders.h"
#include <QObject>
class QNetworkReply;
// Each implementation of this interface downloads covers from one online

View File

@ -19,9 +19,10 @@
*/
#include "coverproviders.h"
#include "config.h"
#include "coverprovider.h"
#include "core/logging.h"
#include "coverprovider.h"
CoverProviders::CoverProviders(QObject* parent) : QObject(parent) {}

View File

@ -18,11 +18,12 @@
*/
#include "coversearchstatisticsdialog.h"
#include "ui_coversearchstatisticsdialog.h"
#include "core/utilities.h"
#include <algorithm>
#include "core/utilities.h"
#include "ui_coversearchstatisticsdialog.h"
CoverSearchStatisticsDialog::CoverSearchStatisticsDialog(QWidget* parent)
: QDialog(parent), ui_(new Ui_CoverSearchStatisticsDialog) {
ui_->setupUi(this);

Some files were not shown because too many files have changed in this diff Show More