Formatting

This commit is contained in:
Jonas Kvinge
2022-03-22 21:09:05 +01:00
parent 8cb4e75f70
commit f6b70fda71
106 changed files with 446 additions and 479 deletions

View File

@@ -20,14 +20,14 @@
// This template function declaration is used in defining arraysize.
// Note that the function doesn't need an implementation, as we only
// use its type.
template <typename T, size_t N>
template<typename T, size_t N>
char (&ArraySizeHelper(T (&array)[N]))[N];
// That gcc wants both of these prototypes seems mysterious. VC, for
// its part, can't decide which to use (another mystery). Matching of
// template overloads: the final frontier.
#ifndef _MSC_VER
template <typename T, size_t N>
template<typename T, size_t N>
char (&ArraySizeHelper(const T (&array)[N]))[N];
#endif

View File

@@ -109,12 +109,12 @@ bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob &job) {
if (job.use_trash_) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
if (fileInfo.isDir()) {
return Utilities::MoveToTrashRecursive(path);
}
else {
return QFile::moveToTrash(path);
}
if (fileInfo.isDir()) {
return Utilities::MoveToTrashRecursive(path);
}
else {
return QFile::moveToTrash(path);
}
#else
return false;
#endif

View File

@@ -25,7 +25,7 @@
// Usage:
// Lazy<Foo> my_lazy_object([]() { return new Foo; });
template <typename T>
template<typename T>
class Lazy {
public:
explicit Lazy(std::function<T*()> init) : init_(init) {}

View File

@@ -476,9 +476,9 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
QObject::connect(file_view_, &FileView::CopyToCollection, this, &MainWindow::CopyFilesToCollection);
QObject::connect(file_view_, &FileView::MoveToCollection, this, &MainWindow::MoveFilesToCollection);
QObject::connect(file_view_, &FileView::EditTags, this, &MainWindow::EditFileTags);
#ifndef Q_OS_WIN
# ifndef Q_OS_WIN
QObject::connect(file_view_, &FileView::CopyToDevice, this, &MainWindow::CopyFilesToDevice);
#endif
# endif
#endif
file_view_->SetTaskManager(app_->task_manager());
@@ -536,8 +536,8 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
QObject::connect(app_->scrobbler(), &AudioScrobbler::ErrorMessage, this, &MainWindow::ShowErrorDialog);
// Playlist view actions
ui_->action_next_playlist->setShortcuts(QList<QKeySequence>() << QKeySequence::fromString("Ctrl+Tab")<< QKeySequence::fromString("Ctrl+PgDown"));
ui_->action_previous_playlist->setShortcuts(QList<QKeySequence>() << QKeySequence::fromString("Ctrl+Shift+Tab")<< QKeySequence::fromString("Ctrl+PgUp"));
ui_->action_next_playlist->setShortcuts(QList<QKeySequence>() << QKeySequence::fromString("Ctrl+Tab") << QKeySequence::fromString("Ctrl+PgDown"));
ui_->action_previous_playlist->setShortcuts(QList<QKeySequence>() << QKeySequence::fromString("Ctrl+Shift+Tab") << QKeySequence::fromString("Ctrl+PgUp"));
// Actions for switching tabs will be global to the entire window, so adding them here
addAction(ui_->action_next_playlist);
@@ -680,7 +680,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
QObject::connect(tidal_view_->albums_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
QObject::connect(tidal_view_->songs_collection_view(), &InternetCollectionView::AddToPlaylistSignal, this, &MainWindow::AddToPlaylist);
QObject::connect(tidal_view_->search_view(), &InternetSearchView::AddToPlaylist, this, &MainWindow::AddToPlaylist);
if (TidalService *tidalservice = qobject_cast<TidalService*> (app_->internet_services()->ServiceBySource(Song::Source_Tidal))) {
if (TidalService *tidalservice = qobject_cast<TidalService*>(app_->internet_services()->ServiceBySource(Song::Source_Tidal))) {
QObject::connect(this, &MainWindow::AuthorizationUrlReceived, tidalservice, &TidalService::AuthorizationUrlReceived);
}
#endif
@@ -1001,11 +1001,11 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
#ifdef HAVE_QTSPARKLE
QUrl sparkle_url;
#if defined(Q_OS_MACOS)
# if defined(Q_OS_MACOS)
sparkle_url.setUrl("https://www.strawberrymusicplayer.org/sparkle-macos");
#elif defined(Q_OS_WIN)
# elif defined(Q_OS_WIN)
sparkle_url.setUrl("https://www.strawberrymusicplayer.org/sparkle-windows");
#endif
# endif
if (!sparkle_url.isEmpty()) {
qLog(Debug) << "Creating Qt Sparkle updater";
qtsparkle::Updater *updater = new qtsparkle::Updater(sparkle_url, this);
@@ -2274,7 +2274,7 @@ void MainWindow::PlaylistRemoveCurrent() {
void MainWindow::PlaylistClearCurrent() {
if (app_->playlist_manager()->current()->rowCount() > Playlist::kUndoItemLimit) {
QMessageBox messagebox(QMessageBox::Warning, tr("Clear playlist"), tr("Playlist has %1 songs, too large to undo, are you sure you want to clear the playlist?").arg(app_->playlist_manager()->current()->rowCount()), QMessageBox::Ok|QMessageBox::Cancel);
QMessageBox messagebox(QMessageBox::Warning, tr("Clear playlist"), tr("Playlist has %1 songs, too large to undo, are you sure you want to clear the playlist?").arg(app_->playlist_manager()->current()->rowCount()), QMessageBox::Ok | QMessageBox::Cancel);
messagebox.setTextFormat(Qt::RichText);
int result = messagebox.exec();
switch (result) {
@@ -2874,22 +2874,20 @@ void MainWindow::Raise() {
show();
activateWindow();
hidden_ = false;
}
#ifdef Q_OS_WIN
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, qintptr *result) {
#else
# else
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) {
#endif
# endif
if (exit_count_ == 0 && message) {
MSG *msg = static_cast<MSG*>(message);
thumbbar_->HandleWinEvent(msg);
}
return QMainWindow::nativeEvent(eventType, message, result);
}
#endif // Q_OS_WIN

View File

@@ -120,11 +120,11 @@ class MainWindow : public QMainWindow, public PlatformInterface {
void closeEvent(QCloseEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
#ifdef Q_OS_WIN
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
#else
# else
bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
#endif
# endif
#endif
// PlatformInterface

View File

@@ -75,7 +75,7 @@
#include "radios/radiochannel.h"
#ifdef HAVE_LIBMTP
#include "device/mtpconnection.h"
# include "device/mtpconnection.h"
#endif
void RegisterMetaTypes() {

View File

@@ -113,7 +113,7 @@ Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
Engine::EngineType use_enginetype(Engine::None);
for (int i = 0; use_enginetype == Engine::None; i++) {
switch(enginetype) {
switch (enginetype) {
case Engine::None:
#ifdef HAVE_GSTREAMER
case Engine::GStreamer:{
@@ -126,18 +126,20 @@ Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
#endif
#ifdef HAVE_VLC
case Engine::VLC:
use_enginetype=Engine::VLC;
use_enginetype = Engine::VLC;
engine_ = std::make_shared<VLCEngine>(app_->task_manager());
break;
#endif
default:
if (i > 0) { qFatal("No engine available!"); }
if (i > 0) {
qFatal("No engine available!");
}
enginetype = Engine::None;
break;
}
}
if (use_enginetype != enginetype) { // Engine was set to something else. Reset output and device.
if (use_enginetype != enginetype) { // Engine was set to something else. Reset output and device.
QSettings s;
s.beginGroup(BackendSettingsPage::kSettingsGroup);
s.setValue("engine", EngineName(use_enginetype));
@@ -167,7 +169,9 @@ void Player::Init() {
CreateEngine(enginetype);
}
if (!engine_->Init()) { qFatal("Error initializing audio engine"); }
if (!engine_->Init()) {
qFatal("Error initializing audio engine");
}
analyzer_->SetEngine(engine_.get());
@@ -426,7 +430,7 @@ void Player::PlayPlaylistInternal(const Engine::TrackChangeFlags change, const P
if (playlist == nullptr) {
qLog(Warning) << "Playlist '" << playlist_name << "' not found.";
return;
}
}
app_->playlist_manager()->SetActivePlaylist(playlist->id());
app_->playlist_manager()->SetCurrentPlaylist(playlist->id());
@@ -515,7 +519,7 @@ void Player::UnPause() {
const Song &song = current_item_->Metadata();
if (url_handlers_.contains(song.url().scheme()) && song.stream_url_can_expire()) {
const quint64 time = QDateTime::currentDateTime().toSecsSinceEpoch() - pause_time_.toSecsSinceEpoch();
if (time >= 30) { // Stream URL might be expired.
if (time >= 30) { // Stream URL might be expired.
qLog(Debug) << "Re-requesting stream URL for" << song.url();
play_offset_nanosec_ = engine_->position_nanosec();
HandleLoadResult(url_handlers_[song.url().scheme()]->StartLoading(song.url()));

View File

@@ -17,7 +17,7 @@
// caller must own the object it gives to ScopedCFTypeRef<>, and relinquishes
// an ownership claim to that object. ScopedCFTypeRef<> does not call
// CFRetain().
template <typename CFT>
template<typename CFT>
class ScopedCFTypeRef {
public:
typedef CFT element_type;

View File

@@ -27,7 +27,7 @@
#include <QtDebug>
template <typename T>
template<typename T>
class ScopedGObject {
public:
ScopedGObject() : object_(nullptr) {}

View File

@@ -30,7 +30,7 @@
#include "simpletreemodel.h"
template <typename T>
template<typename T>
class SimpleTreeItem {
public:
explicit SimpleTreeItem(int _type, SimpleTreeModel<T> *_model); // For the root item
@@ -58,13 +58,13 @@ class SimpleTreeItem {
bool lazy_loaded;
T *parent;
QList<T*> children;
QList<T *> children;
QAbstractItemModel *child_model;
SimpleTreeModel<T> *model;
};
template <typename T>
template<typename T>
SimpleTreeItem<T>::SimpleTreeItem(int _type, SimpleTreeModel<T> *_model)
: type(_type),
row(0),
@@ -73,7 +73,7 @@ SimpleTreeItem<T>::SimpleTreeItem(int _type, SimpleTreeModel<T> *_model)
child_model(nullptr),
model(_model) {}
template <typename T>
template<typename T>
SimpleTreeItem<T>::SimpleTreeItem(int _type, const QString &_key, T *_parent)
: type(_type),
key(_key),
@@ -87,7 +87,7 @@ SimpleTreeItem<T>::SimpleTreeItem(int _type, const QString &_key, T *_parent)
}
}
template <typename T>
template<typename T>
SimpleTreeItem<T>::SimpleTreeItem(int _type, T *_parent)
: type(_type),
lazy_loaded(false),
@@ -100,7 +100,7 @@ SimpleTreeItem<T>::SimpleTreeItem(int _type, T *_parent)
}
}
template <typename T>
template<typename T>
void SimpleTreeItem<T>::InsertNotify(T *_parent) {
parent = _parent;
model = parent->model;
@@ -111,7 +111,7 @@ void SimpleTreeItem<T>::InsertNotify(T *_parent) {
model->EndInsert();
}
template <typename T>
template<typename T>
void SimpleTreeItem<T>::DeleteNotify(int child_row) {
model->BeginDelete(static_cast<T*>(this), child_row);
delete children.takeAt(child_row);
@@ -121,7 +121,7 @@ void SimpleTreeItem<T>::DeleteNotify(int child_row) {
model->EndDelete();
}
template <typename T>
template<typename T>
void SimpleTreeItem<T>::ClearNotify() {
if (children.count()) {
model->BeginDelete(static_cast<T*>(this), 0, children.count() - 1);
@@ -133,17 +133,17 @@ void SimpleTreeItem<T>::ClearNotify() {
}
}
template <typename T>
template<typename T>
void SimpleTreeItem<T>::ChangedNotify() {
model->EmitDataChanged(static_cast<T*>(this));
}
template <typename T>
template<typename T>
SimpleTreeItem<T>::~SimpleTreeItem() {
qDeleteAll(children);
}
template <typename T>
template<typename T>
void SimpleTreeItem<T>::Delete(int child_row) {
delete children.takeAt(child_row);
@@ -151,7 +151,7 @@ void SimpleTreeItem<T>::Delete(int child_row) {
for (int i = child_row; i < children.count(); ++i) children[i]->row--;
}
template <typename T>
template<typename T>
T *SimpleTreeItem<T>::ChildByKey(const QString &_key) const {
for (T *child : children) {
if (child->key == _key) return child;

View File

@@ -27,7 +27,7 @@
#include <QObject>
#include <QAbstractItemModel>
template <typename T>
template<typename T>
class SimpleTreeModel : public QAbstractItemModel {
public:
explicit SimpleTreeModel(T *root = nullptr, QObject *parent = nullptr);
@@ -59,17 +59,17 @@ class SimpleTreeModel : public QAbstractItemModel {
T *root_;
};
template <typename T>
template<typename T>
SimpleTreeModel<T>::SimpleTreeModel(T *root, QObject *parent)
: QAbstractItemModel(parent), root_(root) {}
template <typename T>
template<typename T>
T *SimpleTreeModel<T>::IndexToItem(const QModelIndex &idx) const {
if (!idx.isValid()) return root_;
return reinterpret_cast<T*>(idx.internalPointer());
}
template <typename T>
template<typename T>
QModelIndex SimpleTreeModel<T>::ItemToIndex(T *item) const {
if (!item || !item->parent) return QModelIndex();
return createIndex(item->row, 0, item);
@@ -80,7 +80,7 @@ int SimpleTreeModel<T>::columnCount(const QModelIndex&) const {
return 1;
}
template <typename T>
template<typename T>
QModelIndex SimpleTreeModel<T>::index(int row, int, const QModelIndex &parent) const {
T *parent_item = IndexToItem(parent);
@@ -88,21 +88,20 @@ QModelIndex SimpleTreeModel<T>::index(int row, int, const QModelIndex &parent) c
return QModelIndex();
return ItemToIndex(parent_item->children[row]);
}
template <typename T>
template<typename T>
QModelIndex SimpleTreeModel<T>::parent(const QModelIndex &idx) const {
return ItemToIndex(IndexToItem(idx)->parent);
}
template <typename T>
template<typename T>
int SimpleTreeModel<T>::rowCount(const QModelIndex &parent) const {
T *item = IndexToItem(parent);
return item->children.count();
}
template <typename T>
template<typename T>
bool SimpleTreeModel<T>::hasChildren(const QModelIndex &parent) const {
T *item = IndexToItem(parent);
if (item->lazy_loaded)
@@ -111,13 +110,13 @@ bool SimpleTreeModel<T>::hasChildren(const QModelIndex &parent) const {
return true;
}
template <typename T>
template<typename T>
bool SimpleTreeModel<T>::canFetchMore(const QModelIndex &parent) const {
T *item = IndexToItem(parent);
return !item->lazy_loaded;
}
template <typename T>
template<typename T>
void SimpleTreeModel<T>::fetchMore(const QModelIndex &parent) {
T *item = IndexToItem(parent);
if (!item->lazy_loaded) {
@@ -125,29 +124,29 @@ void SimpleTreeModel<T>::fetchMore(const QModelIndex &parent) {
}
}
template <typename T>
template<typename T>
void SimpleTreeModel<T>::BeginInsert(T *parent, int start, int end) {
if (end == -1) end = start;
beginInsertRows(ItemToIndex(parent), start, end);
}
template <typename T>
template<typename T>
void SimpleTreeModel<T>::EndInsert() {
endInsertRows();
}
template <typename T>
template<typename T>
void SimpleTreeModel<T>::BeginDelete(T *parent, int start, int end) {
if (end == -1) end = start;
beginRemoveRows(ItemToIndex(parent), start, end);
}
template <typename T>
template<typename T>
void SimpleTreeModel<T>::EndDelete() {
endRemoveRows();
}
template <typename T>
template<typename T>
void SimpleTreeModel<T>::EmitDataChanged(T *item) {
QModelIndex index(ItemToIndex(item));
emit dataChanged(index, index);

View File

@@ -178,7 +178,7 @@ struct Song::Private : public QSharedData {
int year_;
int originalyear_;
QString genre_;
bool compilation_; // From the file tag
bool compilation_; // From the file tag
QString composer_;
QString performer_;
QString grouping_;
@@ -1117,7 +1117,7 @@ void Song::ToItdb(Itdb_Track *track) const {
track->type1 = (d->filetype_ == FileType_MPEG ? 1 : 0);
track->type2 = (d->filetype_ == FileType_MPEG ? 1 : 0);
track->mediatype = 1; // Audio
track->mediatype = 1; // Audio
track->size = static_cast<uint>(d->filesize_);
track->time_modified = d->mtime_;
track->time_added = d->ctime_;

View File

@@ -367,7 +367,7 @@ QPixmap StyleHelper::disabledSideBarIcon(const QPixmap &enabledicon) {
for (int y = 0; y < im.height(); ++y) {
auto scanLine = reinterpret_cast<QRgb*>(im.scanLine(y));
for (int x=0; x<im.width(); ++x) {
for (int x = 0; x < im.width(); ++x) {
QRgb pixel = *scanLine;
char intensity = static_cast<char>(qGray(pixel));
*scanLine = qRgba(intensity, intensity, intensity, qAlpha(pixel));
@@ -390,34 +390,33 @@ void StyleHelper::drawCornerImage(const QImage &img, QPainter *painter, const QR
const qreal bottomDIP = bottom * imagePixelRatio;
const QSize size = img.size();
if (top > 0) { //top
painter->drawImage(QRectF(rect.left() + left, rect.top(), rect.width() -right - left, top), img, QRectF(leftDIP, 0, size.width() - rightDIP - leftDIP, topDIP));
if (left > 0) { //top-left
if (top > 0) { //top
painter->drawImage(QRectF(rect.left() + left, rect.top(), rect.width() - right - left, top), img, QRectF(leftDIP, 0, size.width() - rightDIP - leftDIP, topDIP));
if (left > 0) { //top-left
painter->drawImage(QRectF(rect.left(), rect.top(), left, top), img, QRectF(0, 0, leftDIP, topDIP));
}
if (right > 0) { //top-right
if (right > 0) { //top-right
painter->drawImage(QRectF(rect.left() + rect.width() - right, rect.top(), right, top), img, QRectF(size.width() - rightDIP, 0, rightDIP, topDIP));
}
}
//left
if (left > 0) {
painter->drawImage(QRectF(rect.left(), rect.top()+top, left, rect.height() - top - bottom), img, QRectF(0, topDIP, leftDIP, size.height() - bottomDIP - topDIP));
painter->drawImage(QRectF(rect.left(), rect.top() + top, left, rect.height() - top - bottom), img, QRectF(0, topDIP, leftDIP, size.height() - bottomDIP - topDIP));
}
//center
painter->drawImage(QRectF(rect.left() + left, rect.top()+top, rect.width() -right - left, rect.height() - bottom - top), img, QRectF(leftDIP, topDIP, size.width() - rightDIP - leftDIP, size.height() - bottomDIP - topDIP));
if (right > 0) { //right
painter->drawImage(QRectF(rect.left() +rect.width() - right, rect.top()+top, right, rect.height() - top - bottom), img, QRectF(size.width() - rightDIP, topDIP, rightDIP, size.height() - bottomDIP - topDIP));
painter->drawImage(QRectF(rect.left() + left, rect.top() + top, rect.width() - right - left, rect.height() - bottom - top), img, QRectF(leftDIP, topDIP, size.width() - rightDIP - leftDIP, size.height() - bottomDIP - topDIP));
if (right > 0) { //right
painter->drawImage(QRectF(rect.left() + rect.width() - right, rect.top() + top, right, rect.height() - top - bottom), img, QRectF(size.width() - rightDIP, topDIP, rightDIP, size.height() - bottomDIP - topDIP));
}
if (bottom > 0) { //bottom
painter->drawImage(QRectF(rect.left() +left, rect.top() + rect.height() - bottom, rect.width() - right - left, bottom), img, QRectF(leftDIP, size.height() - bottomDIP, size.width() - rightDIP - leftDIP, bottomDIP));
if (left > 0) { //bottom-left
if (bottom > 0) { //bottom
painter->drawImage(QRectF(rect.left() + left, rect.top() + rect.height() - bottom, rect.width() - right - left, bottom), img, QRectF(leftDIP, size.height() - bottomDIP, size.width() - rightDIP - leftDIP, bottomDIP));
if (left > 0) { //bottom-left
painter->drawImage(QRectF(rect.left(), rect.top() + rect.height() - bottom, left, bottom), img, QRectF(0, size.height() - bottomDIP, leftDIP, bottomDIP));
}
if (right > 0) { //bottom-right
if (right > 0) { //bottom-right
painter->drawImage(QRectF(rect.left() + rect.width() - right, rect.top() + rect.height() - bottom, right, bottom), img, QRectF(size.width() - rightDIP, size.height() - bottomDIP, rightDIP, bottomDIP));
}
}
}
// Tints an image with tintColor, while preserving alpha and lightness
@@ -485,7 +484,6 @@ QList<int> StyleHelper::availableImageResolutions(const QString &fileName) {
}
}
return result;
}
} // namespace Utils
} // namespace Utils

View File

@@ -41,67 +41,66 @@ QT_END_NAMESPACE
// Helper class holding all custom color values
namespace Utils {
class StyleHelper
{
public:
static const unsigned int DEFAULT_BASE_COLOR = 0x666666;
static const int progressFadeAnimationDuration = 600;
class StyleHelper {
public:
static const unsigned int DEFAULT_BASE_COLOR = 0x666666;
static const int progressFadeAnimationDuration = 600;
// Height of the project explorer navigation bar
static int navigationWidgetHeight() { return 24; }
static qreal sidebarFontSize();
static QPalette sidebarFontPalette(const QPalette &original);
// Height of the project explorer navigation bar
static int navigationWidgetHeight() { return 24; }
static qreal sidebarFontSize();
static QPalette sidebarFontPalette(const QPalette &original);
// This is our color table, all colors derive from baseColor
static QColor requestedBaseColor() { return m_requestedBaseColor; }
static QColor baseColor(bool lightColored = false);
static QColor panelTextColor(bool lightColored = false);
static QColor highlightColor(bool lightColored = false);
static QColor shadowColor(bool lightColored = false);
static QColor borderColor(bool lightColored = false);
static QColor toolBarBorderColor();
static QColor buttonTextColor() { return QColor(0x4c4c4c); }
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50);
static QColor alphaBlendedColors(const QColor &colorA, const QColor &colorB);
// This is our color table, all colors derive from baseColor
static QColor requestedBaseColor() { return m_requestedBaseColor; }
static QColor baseColor(bool lightColored = false);
static QColor panelTextColor(bool lightColored = false);
static QColor highlightColor(bool lightColored = false);
static QColor shadowColor(bool lightColored = false);
static QColor borderColor(bool lightColored = false);
static QColor toolBarBorderColor();
static QColor buttonTextColor() { return QColor(0x4c4c4c); }
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50);
static QColor alphaBlendedColors(const QColor &colorA, const QColor &colorB);
static QColor sidebarHighlight() { return QColor(255, 255, 255, 40); }
static QColor sidebarShadow() { return QColor(0, 0, 0, 40); }
static QColor sidebarHighlight() { return QColor(255, 255, 255, 40); }
static QColor sidebarShadow() { return QColor(0, 0, 0, 40); }
static QColor toolBarDropShadowColor() { return QColor(0, 0, 0, 70); }
static QColor toolBarDropShadowColor() { return QColor(0, 0, 0, 70); }
static QColor notTooBrightHighlightColor();
static QColor notTooBrightHighlightColor();
// Sets the base color and makes sure all top level widgets are updated
static void setBaseColor(const QColor &color);
// Sets the base color and makes sure all top level widgets are updated
static void setBaseColor(const QColor &color);
// Draws a shaded anti-aliased arrow
static void drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option);
// Draws a shaded anti-aliased arrow
static void drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option);
// Gradients used for panels
static void horizontalGradient(QPainter *painter, const QRect spanRect, const QRect clipRect, bool lightColored = false);
static void verticalGradient(QPainter *painter, const QRect spanRect, const QRect clipRect, bool lightColored = false);
static void menuGradient(QPainter *painter, const QRect spanRect, const QRect clipRect);
static bool usePixmapCache() { return true; }
// Gradients used for panels
static void horizontalGradient(QPainter *painter, const QRect spanRect, const QRect clipRect, bool lightColored = false);
static void verticalGradient(QPainter *painter, const QRect spanRect, const QRect clipRect, bool lightColored = false);
static void menuGradient(QPainter *painter, const QRect spanRect, const QRect clipRect);
static bool usePixmapCache() { return true; }
static QPixmap disabledSideBarIcon(const QPixmap &enabledicon);
static void drawCornerImage(const QImage &img, QPainter *painter, const QRect rect, int left = 0, int top = 0, int right = 0, int bottom = 0);
static QPixmap disabledSideBarIcon(const QPixmap &enabledicon);
static void drawCornerImage(const QImage &img, QPainter *painter, const QRect rect, int left = 0, int top = 0, int right = 0, int bottom = 0);
static void tintImage(QImage &img, const QColor &tintColor);
static QLinearGradient statusBarGradient(const QRect statusBarRect);
static void tintImage(QImage &img, const QColor &tintColor);
static QLinearGradient statusBarGradient(const QRect statusBarRect);
static QString dpiSpecificImageFile(const QString &fileName);
static QString imageFileWithResolution(const QString &fileName, int dpr);
static QList<int> availableImageResolutions(const QString &fileName);
static QString dpiSpecificImageFile(const QString &fileName);
static QString imageFileWithResolution(const QString &fileName, int dpr);
static QList<int> availableImageResolutions(const QString &fileName);
private:
static QColor m_baseColor;
static QColor m_requestedBaseColor;
static QColor m_IconsBaseColor;
static QColor m_IconsDisabledColor;
static QColor m_ProgressBarTitleColor;
private:
static QColor m_baseColor;
static QColor m_requestedBaseColor;
static QColor m_IconsBaseColor;
static QColor m_IconsDisabledColor;
static QColor m_ProgressBarTitleColor;
};
} // namespace Utils
} // namespace Utils
using Utils::StyleHelper;
#endif // STYLEHELPER_H
#endif // STYLEHELPER_H

View File

@@ -37,7 +37,7 @@
class QThread;
class Song;
template <typename HandlerType> class WorkerPool;
template<typename HandlerType> class WorkerPool;
class TagReaderClient : public QObject {
Q_OBJECT
@@ -58,8 +58,8 @@ class TagReaderClient : public QObject {
ReplyType *IsMediaFile(const QString &filename);
ReplyType *LoadEmbeddedArt(const QString &filename);
ReplyType *SaveEmbeddedArt(const QString &filename, const QByteArray &data);
ReplyType* UpdateSongPlaycount(const Song &metadata);
ReplyType* UpdateSongRating(const Song &metadata);
ReplyType *UpdateSongPlaycount(const Song &metadata);
ReplyType *UpdateSongRating(const Song &metadata);
// Convenience functions that call the above functions and wait for a response.
// These block the calling thread with a semaphore, and must NOT be called from the TagReaderClient's thread.

View File

@@ -376,11 +376,11 @@ void OpenInFileManager(const QString &path, const QUrl &url) {
QString cmd = setting.value("Exec").toString();
if (cmd.isEmpty()) break;
cmd = cmd.remove(QRegularExpression("[%][a-zA-Z]*( |$)", QRegularExpression::CaseInsensitiveOption));
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
# if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
command_params = cmd.split(' ', Qt::SkipEmptyParts);
#else
# else
command_params = cmd.split(' ', QString::SkipEmptyParts);
#endif
# endif
command = command_params.first();
command_params.removeFirst();
}
@@ -800,9 +800,9 @@ QString UnicodeToAscii(QString unicode) {
#else
#ifdef LC_ALL
# ifdef LC_ALL
setlocale(LC_ALL, "");
#endif
# endif
iconv_t conv = iconv_open("ASCII//TRANSLIT", "UTF-8");
if (conv == reinterpret_cast<iconv_t>(-1)) return unicode;
@@ -830,8 +830,7 @@ QString UnicodeToAscii(QString unicode) {
return ret;
#endif // _MSC_VER
#endif // _MSC_VER
}
QString MacAddress() {
@@ -988,9 +987,9 @@ HRGN qt_RectToHRGN(const QRect &rc) {
HRGN toHRGN(const QRegion &region);
HRGN toHRGN(const QRegion &region) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
return region.toHRGN();
#else
# else
const int rect_count = region.rectCount();
if (rect_count == 0) {
@@ -1009,13 +1008,12 @@ HRGN toHRGN(const QRegion &region) {
return resultRgn;
#endif // Qt 6
# endif // Qt 6
}
void enableBlurBehindWindow(QWindow *window, const QRegion &region) {
DWM_BLURBEHIND dwmbb = {0, 0, nullptr, 0};
DWM_BLURBEHIND dwmbb = { 0, 0, nullptr, 0 };
dwmbb.dwFlags = DWM_BB_ENABLE;
dwmbb.fEnable = TRUE;
HRGN rgn = nullptr;

View File

@@ -115,11 +115,11 @@ enum IoPriority {
IOPRIO_CLASS_BE,
IOPRIO_CLASS_IDLE,
};
enum {
IOPRIO_WHO_PROCESS = 1,
IOPRIO_WHO_PGRP,
IOPRIO_WHO_USER,
};
enum {
IOPRIO_WHO_PROCESS = 1,
IOPRIO_WHO_PGRP,
IOPRIO_WHO_USER,
};
static const int IOPRIO_CLASS_SHIFT = 13;
long SetThreadIOPriority(const IoPriority priority);
@@ -157,10 +157,10 @@ class ScopedWCharArray {
QString ToString() const { return QString::fromWCharArray(data_.get()); }
wchar_t *get() const { return data_.get(); }
explicit operator wchar_t*() const { return get(); }
explicit operator wchar_t *() const { return get(); }
qint64 characters() const { return chars_; }
qint64 bytes() const { return (chars_ + 1) *sizeof(wchar_t); }
qint64 bytes() const { return (chars_ + 1) * sizeof(wchar_t); }
private:
Q_DISABLE_COPY(ScopedWCharArray)

View File

@@ -30,7 +30,7 @@
#include <QtDebug>
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0600
# define _WIN32_WINNT 0x0600
#endif
#include <windows.h>
@@ -77,24 +77,23 @@ ITaskbarList3 *Windows7ThumbBar::CreateTaskbarList() {
ITaskbarList3 *taskbar_list = nullptr;
// Copied from win7 SDK shobjidl.h
static const GUID CLSID_ITaskbarList = { 0x56FDF344,0xFD6D,0x11d0,{0x95,0x8A,0x00,0x60,0x97,0xC9,0xA0,0x90}};
static const GUID CLSID_ITaskbarList = { 0x56FDF344, 0xFD6D, 0x11d0, { 0x95, 0x8A, 0x00, 0x60, 0x97, 0xC9, 0xA0, 0x90 } };
// Create the taskbar list
HRESULT hr = CoCreateInstance(CLSID_ITaskbarList, nullptr, CLSCTX_ALL, IID_ITaskbarList3, reinterpret_cast<void**>(&taskbar_list));
if (hr != S_OK) {
qLog(Warning) << "Error creating the ITaskbarList3 interface" << Qt::hex << DWORD (hr);
qLog(Warning) << "Error creating the ITaskbarList3 interface" << Qt::hex << DWORD(hr);
return nullptr;
}
hr = taskbar_list->HrInit();
if (hr != S_OK) {
qLog(Warning) << "Error initializing taskbar list" << Qt::hex << DWORD (hr);
qLog(Warning) << "Error initializing taskbar list" << Qt::hex << DWORD(hr);
taskbar_list->Release();
return nullptr;
}
return taskbar_list;
}
void Windows7ThumbBar::SetupButton(const QAction *action, THUMBBUTTON *button) {
@@ -145,7 +144,7 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) {
qLog(Debug) << "Adding" << actions_.count() << "buttons";
HRESULT hr = taskbar_list->ThumbBarAddButtons(reinterpret_cast<HWND>(widget_->winId()), actions_.count(), buttons);
if (hr != S_OK) {
qLog(Debug) << "Failed to add buttons" << Qt::hex << DWORD (hr);
qLog(Debug) << "Failed to add buttons" << Qt::hex << DWORD(hr);
}
for (int i = 0; i < actions_.count(); ++i) {
@@ -188,12 +187,11 @@ void Windows7ThumbBar::ActionChanged() {
button->iId = i;
SetupButton(action, button);
}
HRESULT hr = taskbar_list->ThumbBarUpdateButtons(reinterpret_cast<HWND>(widget_->winId()), actions_.count(), buttons);
if (hr != S_OK) {
qLog(Debug) << "Failed to update buttons" << Qt::hex << DWORD (hr);
qLog(Debug) << "Failed to update buttons" << Qt::hex << DWORD(hr);
}
for (int i = 0; i < actions_.count(); ++i) {