aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/General
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/General')
-rw-r--r--src/plugins/General/fileops/hotkeydialog.cpp10
-rw-r--r--src/plugins/General/fileops/hotkeydialog.h6
-rw-r--r--src/plugins/General/fileops/settingsdialog.cpp8
-rw-r--r--src/plugins/General/fileops/settingsdialog.h10
-rw-r--r--src/plugins/General/hal/haldevice.cpp4
-rw-r--r--src/plugins/General/hal/haldevice.h6
-rw-r--r--src/plugins/General/hal/halplugin.cpp9
-rw-r--r--src/plugins/General/history/historywindow.cpp11
-rw-r--r--src/plugins/General/hotkey/hotkeymanager_win.cpp31
-rw-r--r--src/plugins/General/hotkey/settingsdialog.cpp17
-rw-r--r--src/plugins/General/listenbrainz/payloadcache.cpp17
-rw-r--r--src/plugins/General/listenbrainz/payloadcache.h4
-rw-r--r--src/plugins/General/lyrics/lyricsprovider.cpp6
-rw-r--r--src/plugins/General/lyrics/lyricswindow.h2
-rw-r--r--src/plugins/General/lyrics/ultimatelyricsparser.cpp13
-rw-r--r--src/plugins/General/lyrics/ultimatelyricsparser.h2
-rw-r--r--src/plugins/General/mpris/player2object.cpp9
-rw-r--r--src/plugins/General/mpris/player2object.h6
-rw-r--r--src/plugins/General/notifier/notifier.cpp4
-rw-r--r--src/plugins/General/notifier/notifier.h6
-rw-r--r--src/plugins/General/rgscan/rgscandialog.cpp23
-rw-r--r--src/plugins/General/rgscan/rgscandialog.h2
-rw-r--r--src/plugins/General/scrobbler/scrobbler.cpp31
-rw-r--r--src/plugins/General/scrobbler/scrobbler.h2
-rw-r--r--src/plugins/General/scrobbler/scrobblercache.cpp15
-rw-r--r--src/plugins/General/scrobbler/scrobblercache.h2
-rw-r--r--src/plugins/General/statusicon/qmmptrayicon.cpp12
-rw-r--r--src/plugins/General/streambrowser/streamwindow.cpp15
-rw-r--r--src/plugins/General/streambrowser/streamwindow.h4
-rw-r--r--src/plugins/General/trackchange/trackchange.cpp2
30 files changed, 123 insertions, 166 deletions
diff --git a/src/plugins/General/fileops/hotkeydialog.cpp b/src/plugins/General/fileops/hotkeydialog.cpp
index 3725bb826..f377432e6 100644
--- a/src/plugins/General/fileops/hotkeydialog.cpp
+++ b/src/plugins/General/fileops/hotkeydialog.cpp
@@ -24,8 +24,8 @@
HotkeyDialog::HotkeyDialog(const QString &key, QWidget *parent)
: QDialog(parent)
{
- ui.setupUi(this);
- ui.keyLineEdit->setText(key);
+ m_ui.setupUi(this);
+ m_ui.keyLineEdit->setText(key);
}
HotkeyDialog::~HotkeyDialog()
@@ -47,16 +47,16 @@ void HotkeyDialog::keyPressEvent (QKeyEvent *event)
case Qt::Key_Menu:
case 0:
case Qt::Key_unknown:
- ui.keyLineEdit->clear();
+ m_ui.keyLineEdit->clear();
QWidget::keyPressEvent(event);
return;
}
QKeySequence seq(event->modifiers() + event->key());
- ui.keyLineEdit->setText(seq.toString());
+ m_ui.keyLineEdit->setText(seq.toString());
QWidget::keyPressEvent(event);
}
const QString HotkeyDialog::key()
{
- return ui.keyLineEdit->text();
+ return m_ui.keyLineEdit->text();
}
diff --git a/src/plugins/General/fileops/hotkeydialog.h b/src/plugins/General/fileops/hotkeydialog.h
index bf37bfea1..505b4cf90 100644
--- a/src/plugins/General/fileops/hotkeydialog.h
+++ b/src/plugins/General/fileops/hotkeydialog.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009 by Ilya Kotov *
+ * Copyright (C) 2009-2020 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -33,7 +33,7 @@ class HotkeyDialog : public QDialog
{
Q_OBJECT
public:
- HotkeyDialog(const QString &key, QWidget *parent = nullptr);
+ explicit HotkeyDialog(const QString &key, QWidget *parent = nullptr);
~HotkeyDialog();
@@ -43,7 +43,7 @@ protected:
virtual void keyPressEvent (QKeyEvent *event) override;
private:
- Ui::HotkeyDialog ui;
+ Ui::HotkeyDialog m_ui;
};
diff --git a/src/plugins/General/fileops/settingsdialog.cpp b/src/plugins/General/fileops/settingsdialog.cpp
index 46b66403c..13d5e3c09 100644
--- a/src/plugins/General/fileops/settingsdialog.cpp
+++ b/src/plugins/General/fileops/settingsdialog.cpp
@@ -109,7 +109,7 @@ void SettingsDialog::accept()
QComboBox *comboBox = qobject_cast<QComboBox *>(m_ui.tableWidget->cellWidget (i, 1));
settings.setValue (QString("action_%1").arg(i), comboBox->itemData (comboBox->currentIndex()));
- ActionItem *item = (ActionItem *) m_ui.tableWidget->item(i,2);
+ ActionItem *item = dynamic_cast<ActionItem *>(m_ui.tableWidget->item(i,2));
settings.setValue (QString("name_%1").arg(i), item->text());
settings.setValue (QString("pattern_%1").arg(i), item->pattern());
settings.setValue (QString("destination_%1").arg(i), item->destination());
@@ -158,7 +158,7 @@ void SettingsDialog::updateLineEdits()
{
if (m_ui.tableWidget->currentRow () >= 0)
{
- ActionItem *item = (ActionItem *) m_ui.tableWidget->item(m_ui.tableWidget->currentRow (), 2);
+ ActionItem *item = dynamic_cast<ActionItem *>(m_ui.tableWidget->item(m_ui.tableWidget->currentRow (), 2));
m_ui.destinationEdit->setText(item->destination());
m_ui.patternEdit->setText(item->pattern());
@@ -200,7 +200,7 @@ void SettingsDialog::on_destinationEdit_textChanged(QString dest)
{
if (m_ui.tableWidget->currentRow () >= 0)
{
- ActionItem *item = (ActionItem *) m_ui.tableWidget->item(m_ui.tableWidget->currentRow (), 2);
+ ActionItem *item = dynamic_cast<ActionItem *>(m_ui.tableWidget->item(m_ui.tableWidget->currentRow (), 2));
item->setDestination(dest);
}
}
@@ -209,7 +209,7 @@ void SettingsDialog::on_patternEdit_textChanged(QString pattern)
{
if (m_ui.tableWidget->currentRow () >= 0)
{
- ActionItem *item = (ActionItem *) m_ui.tableWidget->item(m_ui.tableWidget->currentRow (), 2);
+ ActionItem *item = dynamic_cast<ActionItem *>(m_ui.tableWidget->item(m_ui.tableWidget->currentRow (), 2));
item->setPattern(pattern);
}
}
diff --git a/src/plugins/General/fileops/settingsdialog.h b/src/plugins/General/fileops/settingsdialog.h
index 6691e85c8..b8377bd8f 100644
--- a/src/plugins/General/fileops/settingsdialog.h
+++ b/src/plugins/General/fileops/settingsdialog.h
@@ -58,24 +58,24 @@ private:
class ActionItem: public QTableWidgetItem
{
public:
- ActionItem (const QString &text): QTableWidgetItem(text){}
+ explicit ActionItem (const QString &text): QTableWidgetItem(text){}
- QString pattern()
+ inline const QString &pattern() const
{
return m_pattern;
}
- QString destination()
+ inline const QString &destination() const
{
return m_destination;
}
- void setPattern(const QString &pattern)
+ inline void setPattern(const QString &pattern)
{
m_pattern = pattern;
}
- void setDestination(const QString &dest)
+ inline void setDestination(const QString &dest)
{
m_destination = dest;
}
diff --git a/src/plugins/General/hal/haldevice.cpp b/src/plugins/General/hal/haldevice.cpp
index 54ba54fb2..446a8dcd6 100644
--- a/src/plugins/General/hal/haldevice.cpp
+++ b/src/plugins/General/hal/haldevice.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009 by Ilya Kotov *
+ * Copyright (C) 2009-2020 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* Copyright (C) 2006 by Kevin Ottens <ervin@kde.org> *
@@ -88,7 +88,7 @@ HalDevice::~HalDevice()
{
}
-QString HalDevice::udi() const
+const QString &HalDevice::udi() const
{
return m_udi;
}
diff --git a/src/plugins/General/hal/haldevice.h b/src/plugins/General/hal/haldevice.h
index 08583fe0e..f220eb8ff 100644
--- a/src/plugins/General/hal/haldevice.h
+++ b/src/plugins/General/hal/haldevice.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009 by Ilya Kotov *
+ * Copyright (C) 2009-2020 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* Copyright (C) 2006 by Kevin Ottens <ervin@kde.org> *
@@ -46,12 +46,12 @@ class HalDevice : public QObject
{
Q_OBJECT
public:
- HalDevice(const QString &udi, QObject *parent = nullptr);
+ explicit HalDevice(const QString &udi, QObject *parent = nullptr);
~HalDevice();
QVariant property (const QString &key);
- QString udi() const;
+ const QString &udi() const;
signals:
void propertyModified(int count, const QList<ChangeDescription> &changes);
diff --git a/src/plugins/General/hal/halplugin.cpp b/src/plugins/General/hal/halplugin.cpp
index 5c4bb9c0d..868144fc4 100644
--- a/src/plugins/General/hal/halplugin.cpp
+++ b/src/plugins/General/hal/halplugin.cpp
@@ -22,6 +22,7 @@
#include <QActionGroup>
#include <QApplication>
#include <QStyle>
+#include <algorithm>
#include <qmmpui/uihelper.h>
#include <qmmpui/mediaplayer.h>
#include <qmmpui/playlistmanager.h>
@@ -83,11 +84,9 @@ void HalPlugin::removeDevice(const QString &udi)
void HalPlugin::addDevice(const QString &udi)
{
- for(const HalDevice *device : qAsConst(m_devices)) //is it already exists?
- {
- if (device->udi() == udi)
- return;
- }
+ if(std::any_of(m_devices.cbegin(), m_devices.cend(), [udi](const HalDevice *device) { return device->udi() == udi; }))
+ return;
+
HalDevice *device = new HalDevice(udi, this);
QStringList caps = device->property("info.capabilities").toStringList();
if (!caps.contains("block") || !caps.contains("volume") ||
diff --git a/src/plugins/General/history/historywindow.cpp b/src/plugins/General/history/historywindow.cpp
index cbd7439d2..8880b3c7c 100644
--- a/src/plugins/General/history/historywindow.cpp
+++ b/src/plugins/General/history/historywindow.cpp
@@ -192,7 +192,7 @@ void HistoryWindow::loadDistribution()
QString dayStr = date.toString(tr("dd MMMM"));
int topLevelCount = m_ui->distributionTreeWidget->topLevelItemCount();
- if(!topLevelCount)
+ if(!topLevelCount || m_ui->distributionTreeWidget->topLevelItem(topLevelCount - 1)->text(0) != monthStr)
{
m_ui->distributionTreeWidget->addTopLevelItem(new QTreeWidgetItem());
m_ui->distributionTreeWidget->topLevelItem(topLevelCount++)->setText(0, monthStr);
@@ -201,15 +201,6 @@ void HistoryWindow::loadDistribution()
m_ui->distributionTreeWidget->topLevelItem(topLevelCount - 1)->setBackground(0, bgColor);
m_ui->distributionTreeWidget->topLevelItem(topLevelCount - 1)->setForeground(0, textColor);
}
- else if(m_ui->distributionTreeWidget->topLevelItem(topLevelCount - 1)->text(0) != monthStr)
- {
- m_ui->distributionTreeWidget->addTopLevelItem(new QTreeWidgetItem());
- m_ui->distributionTreeWidget->topLevelItem(topLevelCount++)->setText(0, monthStr);
- m_ui->distributionTreeWidget->topLevelItem(topLevelCount - 1)->setFirstColumnSpanned(true);
- m_ui->distributionTreeWidget->topLevelItem(topLevelCount - 1)->setTextAlignment(0, Qt::AlignCenter);
- m_ui->distributionTreeWidget->topLevelItem(topLevelCount - 1)->setBackground(0, bgColor);
- m_ui->distributionTreeWidget->topLevelItem(topLevelCount - 1)->setForeground(0, textColor);
- }
QTreeWidgetItem *topLevelItem = m_ui->distributionTreeWidget->topLevelItem(topLevelCount - 1);
QTreeWidgetItem *item = new QTreeWidgetItem();
diff --git a/src/plugins/General/hotkey/hotkeymanager_win.cpp b/src/plugins/General/hotkey/hotkeymanager_win.cpp
index 8e28f116a..f806f7995 100644
--- a/src/plugins/General/hotkey/hotkeymanager_win.cpp
+++ b/src/plugins/General/hotkey/hotkeymanager_win.cpp
@@ -76,21 +76,22 @@ quint32 Hotkey::defaultKey()
quint32 Hotkey::defaultKey(int act)
{
//default key bindings
- QMap<int, quint32> keyMap;
- keyMap[PLAY] = 0;
- keyMap[STOP] = VK_MEDIA_STOP;
- keyMap[PAUSE] = 0;
- keyMap[PLAY_PAUSE] = VK_MEDIA_PLAY_PAUSE;
- keyMap[NEXT] = VK_MEDIA_NEXT_TRACK;
- keyMap[PREVIOUS] = VK_MEDIA_PREV_TRACK;
- keyMap[SHOW_HIDE] = 0;
- keyMap[VOLUME_UP] = VK_VOLUME_UP;
- keyMap[VOLUME_DOWN] = VK_VOLUME_DOWN;
- keyMap[FORWARD] = 0;
- keyMap[REWIND] = 0;
- keyMap[JUMP_TO_TRACK] = 0;
- keyMap[VOLUME_MUTE] = VK_VOLUME_MUTE;
- return keyMap[act];
+ static const QMap<int, quint32> defaultKeys = {
+ { PLAY, 0 },
+ { STOP, VK_MEDIA_STOP },
+ { PAUSE, 0 },
+ { PLAY_PAUSE, VK_MEDIA_PLAY_PAUSE },
+ { NEXT, VK_MEDIA_NEXT_TRACK },
+ { PREVIOUS, VK_MEDIA_PREV_TRACK },
+ { SHOW_HIDE, 0 },
+ { VOLUME_UP, VK_VOLUME_UP },
+ { VOLUME_DOWN, VK_VOLUME_DOWN },
+ { FORWARD, 0 },
+ { REWIND, 0 },
+ { JUMP_TO_TRACK, 0 },
+ { VOLUME_MUTE, VK_VOLUME_MUTE },
+ };
+ return defaultKeys[act];
}
HotkeyManager::HotkeyManager(QObject *parent) : QObject(parent)
diff --git a/src/plugins/General/hotkey/settingsdialog.cpp b/src/plugins/General/hotkey/settingsdialog.cpp
index 1255790e2..89ec737e8 100644
--- a/src/plugins/General/hotkey/settingsdialog.cpp
+++ b/src/plugins/General/hotkey/settingsdialog.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009-2015 by Ilya Kotov *
+ * Copyright (C) 2009-2020 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -22,6 +22,7 @@
#include <QHeaderView>
#include <QMessageBox>
#include <qmmp/qmmp.h>
+#include <algorithm>
#include "hotkeydialog.h"
#include "settingsdialog.h"
@@ -63,7 +64,6 @@ SettingsDialog::SettingsDialog(QWidget *parent)
settings.endGroup();
}
-
SettingsDialog::~SettingsDialog()
{
while (!m_hotkeys.isEmpty())
@@ -86,18 +86,11 @@ void SettingsDialog::accept()
void SettingsDialog::on_tableWidget_itemDoubleClicked (QTableWidgetItem *item)
{
- Hotkey *key = nullptr;
- for(Hotkey *k : m_hotkeys)
- {
- if (k->action == item->type())
- {
- key = k;
- break;
- }
- }
- if (!key)
+ auto it = std::find_if(m_hotkeys.cbegin(), m_hotkeys.cend(), [item](Hotkey *k) { return k->action == item->type(); });
+ if(it == m_hotkeys.cend())
return;
+ Hotkey *key = *it;
HotkeyDialog *dialog = new HotkeyDialog(key->key, key->mod, this);
if (item->type() >= QTableWidgetItem::UserType &&
dialog->exec() == QDialog::Accepted)
diff --git a/src/plugins/General/listenbrainz/payloadcache.cpp b/src/plugins/General/listenbrainz/payloadcache.cpp
index f142cbd7e..a715ed82b 100644
--- a/src/plugins/General/listenbrainz/payloadcache.cpp
+++ b/src/plugins/General/listenbrainz/payloadcache.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2019 by Ilya Kotov *
+ * Copyright (C) 2019-2020 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -61,16 +61,12 @@ uint TrackMetaData::timeStamp() const
return m_start_ts;
}
-PayloadCache::PayloadCache(const QString &filePath)
-{
- m_filePath = filePath;
-}
+PayloadCache::PayloadCache(const QString &filePath) : m_filePath(filePath)
+{}
QList<TrackMetaData> PayloadCache::load()
{
QList<TrackMetaData> songs;
- int s = 0;
- QString line, param, value;
QFile file(m_filePath);
if(!file.open(QIODevice::ReadOnly))
@@ -78,12 +74,13 @@ QList<TrackMetaData> PayloadCache::load()
while (!file.atEnd())
{
- line = QString::fromUtf8(file.readLine()).trimmed();
+ int s = 0;
+ QString line = QString::fromUtf8(file.readLine()).trimmed();
if ((s = line.indexOf("=")) < 0)
continue;
- param = line.left(s);
- value = line.right(line.size() - s - 1);
+ QString param = line.left(s);
+ QString value = line.right(line.size() - s - 1);
if (param == "title")
{
diff --git a/src/plugins/General/listenbrainz/payloadcache.h b/src/plugins/General/listenbrainz/payloadcache.h
index c117f634e..6500d57c8 100644
--- a/src/plugins/General/listenbrainz/payloadcache.h
+++ b/src/plugins/General/listenbrainz/payloadcache.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2019 by Ilya Kotov *
+ * Copyright (C) 2019-2020 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -31,7 +31,7 @@ class TrackMetaData : public TrackInfo
{
public:
TrackMetaData();
- TrackMetaData(const TrackInfo &info);
+ explicit TrackMetaData(const TrackInfo &info);
TrackMetaData(const TrackMetaData &other);
~TrackMetaData();
diff --git a/src/plugins/General/lyrics/lyricsprovider.cpp b/src/plugins/General/lyrics/lyricsprovider.cpp
index 775d3ee74..abd27a6f7 100644
--- a/src/plugins/General/lyrics/lyricsprovider.cpp
+++ b/src/plugins/General/lyrics/lyricsprovider.cpp
@@ -101,7 +101,7 @@ QString LyricsProvider::getUrl(const TrackInfo &track) const
url.replace(it.key(), it.value());
- it++;
+ ++it;
}
return url;
@@ -139,7 +139,7 @@ QString LyricsProvider::format(const QByteArray &data, const TrackInfo &track) c
{
item.begin.replace(it.key(), it.value());
item.url.replace(it.key(), it.value());
- it++;
+ ++it;
}
}
@@ -197,7 +197,7 @@ QString LyricsProvider::fixCase(const QString &title) const
else
out.append(*it);
- it++;
+ ++it;
}
return out;
diff --git a/src/plugins/General/lyrics/lyricswindow.h b/src/plugins/General/lyrics/lyricswindow.h
index 6aaf5fbef..5ea962461 100644
--- a/src/plugins/General/lyrics/lyricswindow.h
+++ b/src/plugins/General/lyrics/lyricswindow.h
@@ -37,7 +37,7 @@ class LyricsWindow : public QWidget
{
Q_OBJECT
public:
- LyricsWindow(const TrackInfo *info, QWidget *parent = nullptr);
+ explicit LyricsWindow(const TrackInfo *info, QWidget *parent = nullptr);
~LyricsWindow();
diff --git a/src/plugins/General/lyrics/ultimatelyricsparser.cpp b/src/plugins/General/lyrics/ultimatelyricsparser.cpp
index 7f3ffaa14..ef9f70dd7 100644
--- a/src/plugins/General/lyrics/ultimatelyricsparser.cpp
+++ b/src/plugins/General/lyrics/ultimatelyricsparser.cpp
@@ -24,6 +24,7 @@
#include <QXmlStreamReader>
#include <QFile>
#include <QtDebug>
+#include <algorithm>
#if (QT_VERSION < QT_VERSION_CHECK(5, 7, 0)) //qAsConst template
#include <qmmp/qmmp.h>
#endif
@@ -135,17 +136,13 @@ const QList<LyricsProvider *> &UltimateLyricsParser::providers()
LyricsProvider *UltimateLyricsParser::provider(const QString &name) const
{
- for(LyricsProvider *provider : qAsConst(m_providers))
- {
- if(provider->name() == name)
- return provider;
- }
- return nullptr;
+ auto it = std::find_if(m_providers.cbegin(), m_providers.cend(), [name](LyricsProvider *provider){ return provider->name() == name; });
+ return it == m_providers.cend() ? nullptr : *it;
}
-QStringList UltimateLyricsParser::defaultProviders()
+const QStringList &UltimateLyricsParser::defaultProviders()
{
- QStringList out = {
+ static const QStringList out = {
"lyrics.wikia.com",
"Encyclopaedia Metallum",
"letras.mus.br",
diff --git a/src/plugins/General/lyrics/ultimatelyricsparser.h b/src/plugins/General/lyrics/ultimatelyricsparser.h
index 994955f87..8d0f13004 100644
--- a/src/plugins/General/lyrics/ultimatelyricsparser.h
+++ b/src/plugins/General/lyrics/ultimatelyricsparser.h
@@ -40,7 +40,7 @@ public:
const QString &errorString() const;
const QList<LyricsProvider *> &providers();
LyricsProvider *provider(const QString &name) const;
- static QStringList defaultProviders();
+ static const QStringList &defaultProviders();
private:
QString m_errorString;
diff --git a/src/plugins/General/mpris/player2object.cpp b/src/plugins/General/mpris/player2object.cpp
index 666c9511e..211109d03 100644
--- a/src/plugins/General/mpris/player2object.cpp
+++ b/src/plugins/General/mpris/player2object.cpp
@@ -32,8 +32,6 @@
Player2Object::Player2Object(QObject *parent) : QDBusAbstractAdaptor(parent)
{
- m_prev_track = nullptr;
- m_previous_pos = 0;
m_core = SoundCore::instance();
m_player = MediaPlayer::instance();
m_pl_manager = m_player->playListManager();
@@ -334,9 +332,10 @@ void Player2Object::checkSeeking(qint64 elapsed)
void Player2Object::playTrack(PlayListTrack *item)
{
- m_pl_manager->selectPlayList((PlayListModel*)sender());
- m_pl_manager->activatePlayList((PlayListModel*)sender());
- disconnect(sender(), SIGNAL(trackAdded(PlayListTrack*)), this, SLOT(playTrack(PlayListTrack*)));
+ PlayListModel *model = qobject_cast<PlayListModel*>(sender());
+ m_pl_manager->selectPlayList(model);
+ m_pl_manager->activatePlayList(model);
+ disconnect(model, SIGNAL(trackAdded(PlayListTrack*)), this, SLOT(playTrack(PlayListTrack*)));
if(!m_pl_manager->currentPlayList()->setCurrent(item))
return;
m_core->stop();
diff --git a/src/plugins/General/mpris/player2object.h b/src/plugins/General/mpris/player2object.h
index af69844a4..dc271e630 100644
--- a/src/plugins/General/mpris/player2object.h
+++ b/src/plugins/General/mpris/player2object.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2010-2015 by Ilya Kotov *
+ * Copyright (C) 2010-2020 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -111,8 +111,8 @@ private:
QmmpUiSettings *m_ui_settings;
QMap<QString, QVariant> m_props;
QDBusObjectPath m_trackID;
- PlayListTrack *m_prev_track;
- qint64 m_previous_pos;
+ PlayListTrack *m_prev_track = nullptr;
+ qint64 m_previous_pos = 0;
};
diff --git a/src/plugins/General/notifier/notifier.cpp b/src/plugins/General/notifier/notifier.cpp
index b670e8e2c..ad3012e18 100644
--- a/src/plugins/General/notifier/notifier.cpp
+++ b/src/plugins/General/notifier/notifier.cpp
@@ -41,10 +41,6 @@
Notifier::Notifier(QObject *parent) : QObject(parent)
{
- m_popupWidget = nullptr;
- m_l = -1;
- m_r = -1;
- m_isPaused = false;
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
settings.beginGroup("Notifier");
m_desktop = settings.value("song_notification", true).toBool();
diff --git a/src/plugins/General/notifier/notifier.h b/src/plugins/General/notifier/notifier.h
index c612711e7..dcb8101e4 100644
--- a/src/plugins/General/notifier/notifier.h
+++ b/src/plugins/General/notifier/notifier.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2016 by Ilya Kotov *
+ * Copyright (C) 2008-2020 by Ilya Kotov *
* forkotov02@ya.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -51,8 +51,8 @@ private:
QPointer<PopupWidget> m_popupWidget;
bool m_desktop, m_showVolume;
bool m_psi;
- int m_l, m_r;
- bool m_isPaused;
+ int m_l = -1, m_r = -1;
+ bool m_isPaused = false;
bool m_resumeNotification;
bool m_disableForFullScreen;
SoundCore *m_core;
diff --git a/src/plugins/General/rgscan/rgscandialog.cpp b/src/plugins/General/rgscan/rgscandialog.cpp
index d37366784..c9376ba00 100644
--- a/src/plugins/General/rgscan/rgscandialog.cpp
+++ b/src/plugins/General/rgscan/rgscandialog.cpp
@@ -26,6 +26,7 @@
#include <qmmpui/metadataformatter.h>
#include <qmmpui/filedialog.h>
#include <qmmp/metadatamanager.h>
+#include <algorithm>
#include <taglib/mpegfile.h>
#include <taglib/apetag.h>
#include <taglib/flacfile.h>
@@ -147,7 +148,7 @@ void RGScanDialog::on_calculateButton_clicked()
}
}
-void RGScanDialog::onScanFinished(QString url)
+void RGScanDialog::onScanFinished(const QString &url)
{
for(int i = 0; i < m_ui.tableWidget->rowCount(); ++i)
{
@@ -161,13 +162,7 @@ void RGScanDialog::onScanFinished(QString url)
break;
}
- bool stopped = true;
-
- for(const RGScanner *scanner : qAsConst(m_scanners))
- {
- if(scanner->isRunning() || scanner->isPending())
- stopped = false;
- }
+ bool stopped = std::all_of(m_scanners.cbegin(), m_scanners.cend(), [](RGScanner *scanner) { return !scanner->isRunning() && !scanner->isPending(); });
if(stopped)
{
@@ -218,11 +213,11 @@ void RGScanDialog::onScanFinished(QString url)
m_replayGainItemList = itemGroupMap.values();
for(int i = 0; i < m_ui.tableWidget->rowCount(); ++i)
{
- QString url = m_ui.tableWidget->item(i, 0)->data(Qt::UserRole).toString();
+ QString itemUrl = m_ui.tableWidget->item(i, 0)->data(Qt::UserRole).toString();
bool found = false;
for(const ReplayGainInfoItem *item : qAsConst(m_replayGainItemList))
{
- if(item->url == url)
+ if(item->url == itemUrl)
{
found = true;
double album_gain = item->info[Qmmp::REPLAYGAIN_ALBUM_GAIN];
@@ -267,12 +262,8 @@ void RGScanDialog::stop()
RGScanner *RGScanDialog::findScannerByUrl(const QString &url)
{
- for(RGScanner *scanner : qAsConst(m_scanners))
- {
- if(scanner->url() == url)
- return scanner;
- }
- return nullptr;
+ auto it = std::find_if(m_scanners.cbegin(), m_scanners.cend(), [url](RGScanner *scanner){ return scanner->url() == url; });
+ return it == m_scanners.cend() ? nullptr : *it;
}
QString RGScanDialog::getAlbumName(const QString &url)
diff --git a/src/plugins/General/rgscan/rgscandialog.h b/src/plugins/General/rgscan/rgscandialog.h
index 3323cab4c..b93217fbc 100644
--- a/src/plugins/General/rgscan/rgscandialog.h
+++ b/src/plugins/General/rgscan/rgscandialog.h
@@ -66,7 +66,7 @@ public:
private slots:
void on_calculateButton_clicked();
- void onScanFinished(QString url);
+ void onScanFinished(const QString &url);
void reject() override;
void on_writeButton_clicked();
diff --git a/src/plugins/General/scrobbler/scrobbler.cpp b/src/plugins/General/scrobbler/scrobbler.cpp
index 61c60cdff..88faf050c 100644
--- a/src/plugins/General/scrobbler/scrobbler.cpp
+++ b/src/plugins/General/scrobbler/scrobbler.cpp
@@ -79,15 +79,16 @@ void ScrobblerResponse::parse(QIODevice *device)
}
Scrobbler::Scrobbler(const QString &scrobblerUrl, const QString &name, QObject *parent)
- : QObject(parent)
+ : QObject(parent),
+ m_ua(QString("qmmp-plugins/%1").arg(Qmmp::strVersion().toLower()).toLatin1()),
+ m_http(new QNetworkAccessManager(this)),
+ m_core(SoundCore::instance()),
+ m_time(new QElapsedTimer()),
+ m_cache(new ListenCache(Qmmp::configDir() + "/scrobbler_" + name + ".cache")),
+ m_scrobblerUrl(scrobblerUrl),
+ m_name(name)
{
- m_scrobblerUrl = scrobblerUrl;
- m_name = name;
- m_time = new QElapsedTimer();
- m_cache = new ListenCache(Qmmp::configDir() +"/scrobbler_"+name+".cache");
- m_ua = QString("qmmp-plugins/%1").arg(Qmmp::strVersion().toLower()).toLatin1();
- m_http = new QNetworkAccessManager(this);
- m_core = SoundCore::instance();
+
QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
m_session = settings.value("Scrobbler/"+name+"_session").toString();
@@ -380,15 +381,13 @@ void Scrobbler::sendNotification(const SongInfo &info)
}
ScrobblerAuth::ScrobblerAuth(const QString &scrobblerUrl, const QString &authUrl,
- const QString &name, QObject *parent) : QObject(parent)
+ const QString &name, QObject *parent) : QObject(parent),
+ m_ua(QString("qmmp-plugins/%1").arg(Qmmp::strVersion().toLower()).toLatin1()),
+ m_http(new QNetworkAccessManager(this)),
+ m_scrobblerUrl(scrobblerUrl),
+ m_authUrl(authUrl),
+ m_name(name)
{
- m_getTokenReply = nullptr;
- m_getSessionReply = nullptr;
- m_scrobblerUrl = scrobblerUrl;
- m_authUrl = authUrl;
- m_name = name;
- m_ua = QString("qmmp-plugins/%1").arg(Qmmp::strVersion().toLower()).toLatin1();
- m_http = new QNetworkAccessManager(this);
connect(m_http, SIGNAL(finished (QNetworkReply *)), SLOT(processResponse(QNetworkReply *)));
QmmpSettings *gs = QmmpSettings::instance();
diff --git a/src/plugins/General/scrobbler/scrobbler.h b/src/plugins/General/scrobbler/scrobbler.h
index b4f727424..29c40233c 100644
--- a/src/plugins/General/scrobbler/scrobbler.h
+++ b/src/plugins/General/scrobbler/scrobbler.h
@@ -118,7 +118,7 @@ private:
QString m_token, m_session;
QByteArray m_ua;
QNetworkAccessManager *m_http;
- QNetworkReply *m_getTokenReply, *m_getSessionReply, *m_checkSessionReply;
+ QNetworkReply *m_getTokenReply = nullptr, *m_getSessionReply = nullptr, *m_checkSessionReply = nullptr;
QString m_scrobblerUrl, m_authUrl, m_name;
};
diff --git a/src/plugins/General/scrobbler/scrobblercache.cpp b/src/plugins/General/scrobbler/scrobblercache.cpp
index f9ed95ed8..df405a51d 100644
--- a/src/plugins/General/scrobbler/scrobblercache.cpp
+++ b/src/plugins/General/scrobbler/scrobblercache.cpp
@@ -61,16 +61,12 @@ uint SongInfo::timeStamp() const
return m_start_ts;
}
-ListenCache::ListenCache(const QString &filePath)
-{
- m_filePath = filePath;
-}
+ListenCache::ListenCache(const QString &filePath) : m_filePath(filePath)
+{}
QList<SongInfo> ListenCache::load()
{
QList<SongInfo> songs;
- int s = 0;
- QString line, param, value;
QFile file(m_filePath);
if(!file.open(QIODevice::ReadOnly))
@@ -78,12 +74,13 @@ QList<SongInfo> ListenCache::load()
while (!file.atEnd())
{
- line = QString::fromUtf8(file.readLine()).trimmed();
+ int s;
+ QString line = QString::fromUtf8(file.readLine()).trimmed();
if ((s = line.indexOf("=")) < 0)
continue;
- param = line.left(s);
- value = line.right(line.size() - s - 1);
+ QString param = line.left(s);
+ QString value = line.right(line.size() - s - 1);
if (param == "title")
{
diff --git a/src/plugins/General/scrobbler/scrobblercache.h b/src/plugins/General/scrobbler/scrobblercache.h
index 1c16968b4..c267f2d4f 100644
--- a/src/plugins/General/scrobbler/scrobblercache.h
+++ b/src/plugins/General/scrobbler/scrobblercache.h
@@ -31,7 +31,7 @@ class SongInfo : public TrackInfo
{
public:
SongInfo();
- SongInfo(const TrackInfo &info);
+ explicit SongInfo(const TrackInfo &info);
SongInfo(const SongInfo &other);
~SongInfo();
diff --git a/src/plugins/General/statusicon/qmmptrayicon.cpp b/src/plugins/General/statusicon/qmmptrayicon.cpp
index 1f65a3a75..efaec4810 100644
--- a/src/plugins/General/statusicon/qmmptrayicon.cpp
+++ b/src/plugins/General/statusicon/qmmptrayicon.cpp
@@ -24,7 +24,7 @@
#include <QGuiApplication>
#include <QWindow>
#include <qmmp/soundcore.h>
-
+#include <algorithm>
#include "qmmptrayicon.h"
#ifdef QMMP_WS_X11
#include "statusiconpopupwidget.h"
@@ -61,7 +61,7 @@ bool QmmpTrayIcon::event(QEvent *e)
{
if (e->type() == QEvent::Wheel )
{
- wheelEvent((QWheelEvent *) e);
+ wheelEvent(dynamic_cast<QWheelEvent *>(e));
e->accept();
return true;
}
@@ -78,12 +78,8 @@ bool QmmpTrayIcon::hasToolTipEvent()
{
//checking for XEmbed system tray implementation
//only this implementation is able to send QHelpEvent
- for(const QWindow *w : qApp->allWindows())
- {
- if(w->objectName() == "QSystemTrayIconSysWindow")
- return true;
- }
- return false;
+ const QWindowList windowList = qApp->allWindows();
+ return std::any_of(windowList.cbegin(), windowList.cend(), [](QWindow *w){ return w->objectName() == "QSystemTrayIconSysWindow"; });
}
void QmmpTrayIcon::wheelEvent(QWheelEvent *e)
diff --git a/src/plugins/General/streambrowser/streamwindow.cpp b/src/plugins/General/streambrowser/streamwindow.cpp
index 814196132..8a5db864c 100644
--- a/src/plugins/General/streambrowser/streamwindow.cpp
+++ b/src/plugins/General/streambrowser/streamwindow.cpp
@@ -279,13 +279,14 @@ void StreamWindow::editStream()
EditStreamDialog dialog(this);
dialog.setWindowTitle(tr("Edit Stream"));
- QMap<EditStreamDialog::Key, QString> values;
- values[EditStreamDialog::URL] = m_favoritesModel->item(row, 0)->data().toString();
- values[EditStreamDialog::NAME] = m_favoritesModel->item(row, 0)->text();
- values[EditStreamDialog::GENRE] = m_favoritesModel->item(row, 1)->text();
- values[EditStreamDialog::BITRATE] = m_favoritesModel->item(row, 2)->text();
- values[EditStreamDialog::TYPE] = m_favoritesModel->item(row, 3)->text();
- dialog.setValues(values);
+ QMap<EditStreamDialog::Key, QString> initialValues = {
+ { EditStreamDialog::URL, m_favoritesModel->item(row, 0)->data().toString() },
+ { EditStreamDialog::NAME, m_favoritesModel->item(row, 0)->text() },
+ { EditStreamDialog::GENRE, m_favoritesModel->item(row, 1)->text() },
+ { EditStreamDialog::BITRATE, m_favoritesModel->item(row, 2)->text() },
+ { EditStreamDialog::TYPE, m_favoritesModel->item(row, 3)->text() }
+ };
+ dialog.setValues(initialValues);
if(dialog.exec() == QDialog::Accepted)
{
diff --git a/src/plugins/General/streambrowser/streamwindow.h b/src/plugins/General/streambrowser/streamwindow.h
index 7c878cc56..7c5bfcdc8 100644
--- a/src/plugins/General/streambrowser/streamwindow.h
+++ b/src/plugins/General/streambrowser/streamwindow.h
@@ -42,7 +42,7 @@ class StreamWindow : public QWidget
{
Q_OBJECT
public:
- StreamWindow(QWidget *parent = nullptr);
+ explicit StreamWindow(QWidget *parent = nullptr);
~StreamWindow();
@@ -81,7 +81,7 @@ class StreamsProxyModel: public QSortFilterProxyModel
{
Q_OBJECT
public:
- StreamsProxyModel(QObject *parent) : QSortFilterProxyModel(parent){}
+ explicit StreamsProxyModel(QObject *parent) : QSortFilterProxyModel(parent){}
protected:
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override
diff --git a/src/plugins/General/trackchange/trackchange.cpp b/src/plugins/General/trackchange/trackchange.cpp
index 55039cc0c..0889b7a3b 100644
--- a/src/plugins/General/trackchange/trackchange.cpp
+++ b/src/plugins/General/trackchange/trackchange.cpp
@@ -142,7 +142,7 @@ bool TrackChange::executeCommand(const TrackInfo &info, const QString &format)
#else
it.value() = it.value().replace("'", "'\\''");
#endif
- it++;
+ ++it;
}
tmp.setValues(metaData);
MetaDataFormatter formatter(format);