Formatting
This commit is contained in:
@@ -311,10 +311,12 @@ bool CommandlineOptions::Parse() {
|
||||
for (int i = optind; i < argc_; ++i) {
|
||||
QString value = QFile::decodeName(argv_[i]);
|
||||
QFileInfo file_info(value);
|
||||
if (file_info.exists())
|
||||
if (file_info.exists()) {
|
||||
urls_ << QUrl::fromLocalFile(file_info.canonicalFilePath());
|
||||
else
|
||||
}
|
||||
else {
|
||||
urls_ << QUrl::fromUserInput(value);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -135,10 +135,12 @@ QSqlDatabase Database::Connect() {
|
||||
db.setConnectOptions("QSQLITE_BUSY_TIMEOUT=30000");
|
||||
//qLog(Debug) << "Opened database with connection id" << connection_id;
|
||||
|
||||
if (!injected_database_name_.isNull())
|
||||
db.setDatabaseName(injected_database_name_);
|
||||
else
|
||||
if (injected_database_name_.isNull()) {
|
||||
db.setDatabaseName(directory_ + "/" + kDatabaseFilename);
|
||||
}
|
||||
else {
|
||||
db.setDatabaseName(injected_database_name_);
|
||||
}
|
||||
|
||||
if (!db.open()) {
|
||||
app_->AddError("Database: " + db.lastError().text());
|
||||
@@ -206,8 +208,9 @@ QSqlDatabase Database::Connect() {
|
||||
// We might have to initialize the schema in some attached databases now, if they were deleted and don't match up with the main schema version.
|
||||
keys = attached_databases_.keys();
|
||||
for (const QString &key : keys) {
|
||||
if (attached_databases_[key].is_temporary_ && attached_databases_[key].schema_.isEmpty())
|
||||
if (attached_databases_[key].is_temporary_ && attached_databases_[key].schema_.isEmpty()) {
|
||||
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));
|
||||
@@ -346,7 +349,9 @@ void Database::DetachDatabase(const QString &database_name) {
|
||||
void Database::UpdateDatabaseSchema(int version, QSqlDatabase &db) {
|
||||
|
||||
QString filename;
|
||||
if (version == 0) filename = ":/schema/schema.sql";
|
||||
if (version == 0) {
|
||||
filename = ":/schema/schema.sql";
|
||||
}
|
||||
else {
|
||||
filename = QString(":/schema/schema-%1.sql").arg(version);
|
||||
qLog(Debug) << "Applying database schema update" << version << "from" << filename;
|
||||
|
||||
@@ -109,18 +109,22 @@ bool FilesystemMusicStorage::DeleteFromStorage(const DeleteJob &job) {
|
||||
|
||||
if (job.use_trash_) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
if (fileInfo.isDir())
|
||||
if (fileInfo.isDir()) {
|
||||
return Utilities::MoveToTrashRecursive(path);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return QFile::moveToTrash(path);
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (fileInfo.isDir())
|
||||
if (fileInfo.isDir()) {
|
||||
return Utilities::RemoveRecursive(path);
|
||||
else
|
||||
}
|
||||
else {
|
||||
return QFile::remove(path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -670,8 +670,9 @@ 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
|
||||
|
||||
#ifdef HAVE_QOBUZ
|
||||
@@ -1087,10 +1088,12 @@ void MainWindow::ReloadSettings() {
|
||||
s.beginGroup(SubsonicSettingsPage::kSettingsGroup);
|
||||
bool enable_subsonic = s.value("enabled", false).toBool();
|
||||
s.endGroup();
|
||||
if (enable_subsonic)
|
||||
if (enable_subsonic) {
|
||||
ui_->tabs->EnableTab(subsonic_view_);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui_->tabs->DisableTab(subsonic_view_);
|
||||
}
|
||||
app_->scrobbler()->Service<SubsonicScrobbler>()->ReloadSettings();
|
||||
#endif
|
||||
|
||||
@@ -1098,20 +1101,24 @@ void MainWindow::ReloadSettings() {
|
||||
s.beginGroup(TidalSettingsPage::kSettingsGroup);
|
||||
bool enable_tidal = s.value("enabled", false).toBool();
|
||||
s.endGroup();
|
||||
if (enable_tidal)
|
||||
if (enable_tidal) {
|
||||
ui_->tabs->EnableTab(tidal_view_);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui_->tabs->DisableTab(tidal_view_);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QOBUZ
|
||||
s.beginGroup(QobuzSettingsPage::kSettingsGroup);
|
||||
bool enable_qobuz = s.value("enabled", false).toBool();
|
||||
s.endGroup();
|
||||
if (enable_qobuz)
|
||||
if (enable_qobuz) {
|
||||
ui_->tabs->EnableTab(qobuz_view_);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ui_->tabs->DisableTab(qobuz_view_);
|
||||
}
|
||||
#endif
|
||||
|
||||
ui_->tabs->ReloadSettings();
|
||||
@@ -1884,10 +1891,12 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
|
||||
else if (in_queue == 0 && not_in_queue > 1) playlist_queue_->setText(tr("Queue selected tracks"));
|
||||
else playlist_queue_->setText(tr("Toggle queue status"));
|
||||
|
||||
if (selected > 1)
|
||||
if (selected > 1) {
|
||||
playlist_queue_play_next_->setText(tr("Queue selected tracks to play next"));
|
||||
else
|
||||
}
|
||||
else {
|
||||
playlist_queue_play_next_->setText(tr("Queue to play next"));
|
||||
}
|
||||
|
||||
if (in_skipped == 1 && not_in_skipped == 0) playlist_skip_->setText(tr("Unskip track"));
|
||||
else if (in_skipped > 1 && not_in_skipped == 0) playlist_skip_->setText(tr("Unskip selected tracks"));
|
||||
@@ -2816,7 +2825,7 @@ void MainWindow::CheckFullRescanRevisions() {
|
||||
|
||||
// Collect all reasons
|
||||
QSet<QString> reasons;
|
||||
for (int i = from ; i <= to ; ++i) {
|
||||
for (int i = from; i <= to; ++i) {
|
||||
QString reason = app_->collection()->full_rescan_reason(i);
|
||||
if (!reason.isEmpty()) {
|
||||
reasons.insert(reason);
|
||||
|
||||
@@ -237,8 +237,9 @@ void MergedProxyModel::SubModelResetSlot() {
|
||||
|
||||
QModelIndex MergedProxyModel::GetActualSourceParent(const QModelIndex &source_parent, QAbstractItemModel *model) const {
|
||||
|
||||
if (!source_parent.isValid() && model != sourceModel())
|
||||
if (!source_parent.isValid() && model != sourceModel()) {
|
||||
return merge_points_.value(model);
|
||||
}
|
||||
return source_parent;
|
||||
|
||||
}
|
||||
@@ -303,10 +304,12 @@ QModelIndex MergedProxyModel::index(int row, int column, const QModelIndex &pare
|
||||
QModelIndex source_parent = mapToSource(parent);
|
||||
const QAbstractItemModel *child_model = merge_points_.key(source_parent);
|
||||
|
||||
if (child_model)
|
||||
if (child_model) {
|
||||
source_index = child_model->index(row, column, QModelIndex());
|
||||
else
|
||||
}
|
||||
else {
|
||||
source_index = source_parent.model()->index(row, column, source_parent);
|
||||
}
|
||||
}
|
||||
|
||||
return mapFromSource(source_index);
|
||||
@@ -316,13 +319,16 @@ QModelIndex MergedProxyModel::index(int row, int column, const QModelIndex &pare
|
||||
QModelIndex MergedProxyModel::parent(const QModelIndex &child) const {
|
||||
|
||||
QModelIndex source_child = mapToSource(child);
|
||||
if (source_child.model() == sourceModel())
|
||||
if (source_child.model() == sourceModel()) {
|
||||
return mapFromSource(source_child.parent());
|
||||
}
|
||||
|
||||
if (!IsKnownModel(source_child.model())) return QModelIndex();
|
||||
|
||||
if (!source_child.parent().isValid())
|
||||
if (!source_child.parent().isValid()) {
|
||||
return mapFromSource(merge_points_.value(GetModel(source_child)));
|
||||
}
|
||||
|
||||
return mapFromSource(source_child.parent());
|
||||
|
||||
}
|
||||
@@ -404,8 +410,10 @@ bool MergedProxyModel::setData(const QModelIndex &idx, const QVariant &value, in
|
||||
|
||||
QModelIndex source_index = mapToSource(idx);
|
||||
|
||||
if (!source_index.isValid())
|
||||
if (!source_index.isValid()) {
|
||||
return sourceModel()->setData(idx, value, role);
|
||||
}
|
||||
|
||||
return GetModel(idx)->setData(idx, value, role);
|
||||
|
||||
}
|
||||
@@ -471,8 +479,10 @@ bool MergedProxyModel::canFetchMore(const QModelIndex &parent) const {
|
||||
|
||||
QModelIndex source_index = mapToSource(parent);
|
||||
|
||||
if (!source_index.isValid())
|
||||
if (!source_index.isValid()) {
|
||||
return sourceModel()->canFetchMore(QModelIndex());
|
||||
}
|
||||
|
||||
return source_index.model()->canFetchMore(source_index);
|
||||
|
||||
}
|
||||
@@ -481,10 +491,12 @@ void MergedProxyModel::fetchMore(const QModelIndex &parent) {
|
||||
|
||||
QModelIndex source_index = mapToSource(parent);
|
||||
|
||||
if (!source_index.isValid())
|
||||
if (!source_index.isValid()) {
|
||||
sourceModel()->fetchMore(QModelIndex());
|
||||
else
|
||||
}
|
||||
else {
|
||||
GetModel(source_index)->fetchMore(source_index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -497,6 +509,7 @@ QAbstractItemModel *MergedProxyModel::GetModel(const QModelIndex &source_index)
|
||||
for (QAbstractItemModel *submodel : submodels) {
|
||||
if (submodel == const_model) return submodel;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
@@ -133,8 +133,9 @@ Mpris2::Mpris2(Application *app, QObject *parent)
|
||||
|
||||
app_name_[0] = app_name_[0].toUpper();
|
||||
|
||||
if (!QGuiApplication::desktopFileName().isEmpty())
|
||||
if (!QGuiApplication::desktopFileName().isEmpty()) {
|
||||
desktop_files_ << QGuiApplication::desktopFileName();
|
||||
}
|
||||
|
||||
QStringList domain_split = QCoreApplication::organizationDomain().split(".");
|
||||
std::reverse(domain_split.begin(), domain_split.end());
|
||||
|
||||
@@ -97,10 +97,12 @@ int MultiSortFilterProxy::Compare(const QVariant &left, const QVariant &right) c
|
||||
case QVariant::String:
|
||||
#endif
|
||||
default:
|
||||
if (isSortLocaleAware())
|
||||
if (isSortLocaleAware()) {
|
||||
return left.toString().localeAwareCompare(right.toString());
|
||||
else
|
||||
}
|
||||
else {
|
||||
return left.toString().compare(right.toString(), sortCaseSensitivity());
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -114,10 +114,12 @@ QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &q
|
||||
ret.setPort(env_url_.port());
|
||||
ret.setUser(env_url_.userName());
|
||||
ret.setPassword(env_url_.password());
|
||||
if (env_url_.scheme().startsWith("http"))
|
||||
if (env_url_.scheme().startsWith("http")) {
|
||||
ret.setType(QNetworkProxy::HttpProxy);
|
||||
else
|
||||
}
|
||||
else {
|
||||
ret.setType(QNetworkProxy::Socks5Proxy);
|
||||
}
|
||||
qLog(Debug) << "Using proxy URL:" << env_url_;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -111,7 +111,7 @@ Engine::EngineType Player::CreateEngine(Engine::EngineType enginetype) {
|
||||
|
||||
Engine::EngineType use_enginetype(Engine::None);
|
||||
|
||||
for (int i = 0 ; use_enginetype == Engine::None ; i++) {
|
||||
for (int i = 0; use_enginetype == Engine::None; i++) {
|
||||
switch(enginetype) {
|
||||
case Engine::None:
|
||||
#ifdef HAVE_GSTREAMER
|
||||
|
||||
@@ -899,7 +899,7 @@ void Song::InitFromQuery(const SqlRow &q, bool reliable_metadata, int col) {
|
||||
int x = col;
|
||||
d->id_ = toint(col);
|
||||
|
||||
for (int i = 0 ; i < Song::kColumns.size(); i++) {
|
||||
for (int i = 0; i < Song::kColumns.size(); i++) {
|
||||
x++;
|
||||
|
||||
if (x >= q.columns_.size()) {
|
||||
@@ -1609,8 +1609,9 @@ bool Song::IsOnSameAlbum(const Song &other) const {
|
||||
|
||||
if (is_compilation() != other.is_compilation()) return false;
|
||||
|
||||
if (has_cue() && other.has_cue() && cue_path() == other.cue_path())
|
||||
if (has_cue() && other.has_cue() && cue_path() == other.cue_path()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_compilation() && album() == other.album()) return true;
|
||||
|
||||
|
||||
@@ -543,8 +543,9 @@ GstPadProbeReturn SongLoader::DataReady(GstPad*, GstPadProbeInfo *info, gpointer
|
||||
|
||||
SongLoader *instance = reinterpret_cast<SongLoader*>(self);
|
||||
|
||||
if (instance->state_ == Finished)
|
||||
if (instance->state_ == Finished) {
|
||||
return GST_PAD_PROBE_OK;
|
||||
}
|
||||
|
||||
GstBuffer *buffer = gst_pad_probe_info_get_buffer(info);
|
||||
GstMapInfo map;
|
||||
|
||||
@@ -71,7 +71,7 @@ void StandardItemIconLoader::LoadIcon(const Song &song, QStandardItem *for_item)
|
||||
|
||||
void StandardItemIconLoader::RowsAboutToBeRemoved(const QModelIndex &parent, int begin, int end) {
|
||||
|
||||
for (QMap<quint64, QStandardItem*>::iterator it = pending_covers_.begin() ; it != pending_covers_.end() ; ) {
|
||||
for (QMap<quint64, QStandardItem*>::iterator it = pending_covers_.begin(); it != pending_covers_.end();) {
|
||||
const QStandardItem *item = it.value();
|
||||
const QStandardItem *item_parent = item->parent();
|
||||
|
||||
|
||||
@@ -90,8 +90,9 @@ qreal StyleHelper::sidebarFontSize() {
|
||||
QColor StyleHelper::notTooBrightHighlightColor() {
|
||||
|
||||
QColor highlightColor = QApplication::palette().highlight().color();
|
||||
if (0.5 * highlightColor.saturationF() + 0.75 - highlightColor.valueF() < 0)
|
||||
if (0.5 * highlightColor.saturationF() + 0.75 - highlightColor.valueF() < 0) {
|
||||
highlightColor.setHsvF(highlightColor.hsvHueF(), 0.1 + highlightColor.saturationF() * 2.0, highlightColor.valueF());
|
||||
}
|
||||
return highlightColor;
|
||||
|
||||
}
|
||||
@@ -108,29 +109,36 @@ QPalette StyleHelper::sidebarFontPalette(const QPalette &original) {
|
||||
|
||||
QColor StyleHelper::panelTextColor(bool lightColored) {
|
||||
|
||||
if (!lightColored)
|
||||
return Qt::white;
|
||||
else
|
||||
if (lightColored) {
|
||||
return Qt::black;
|
||||
}
|
||||
else {
|
||||
return Qt::white;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QColor StyleHelper::baseColor(bool lightColored) {
|
||||
|
||||
if (!lightColored)
|
||||
return m_baseColor;
|
||||
else
|
||||
if (lightColored) {
|
||||
return m_baseColor.lighter(230);
|
||||
}
|
||||
else {
|
||||
return m_baseColor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QColor StyleHelper::highlightColor(bool lightColored) {
|
||||
|
||||
QColor result = baseColor(lightColored);
|
||||
if (!lightColored)
|
||||
result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.16));
|
||||
else
|
||||
if (lightColored) {
|
||||
result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.06));
|
||||
}
|
||||
else {
|
||||
result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.16));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
@@ -284,8 +292,9 @@ static void menuGradientHelper(QPainter *p, const QRect spanRect, const QRect re
|
||||
|
||||
void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option) {
|
||||
|
||||
if (option->rect.width() <= 1 || option->rect.height() <= 1)
|
||||
if (option->rect.width() <= 1 || option->rect.height() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
const qreal devicePixelRatio = painter->device()->devicePixelRatio();
|
||||
const bool enabled = option->state & QStyle::State_Enabled;
|
||||
@@ -383,24 +392,30 @@ void StyleHelper::drawCornerImage(const QImage &img, QPainter *painter, const QR
|
||||
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 (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)
|
||||
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));
|
||||
}
|
||||
//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
|
||||
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
|
||||
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
|
||||
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));
|
||||
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
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -445,8 +460,9 @@ QString StyleHelper::dpiSpecificImageFile(const QString &fileName) {
|
||||
// See QIcon::addFile()
|
||||
if (qApp->devicePixelRatio() > 1.0) {
|
||||
const QString atDprfileName = imageFileWithResolution(fileName, qRound(qApp->devicePixelRatio()));
|
||||
if (QFile::exists(atDprfileName))
|
||||
if (QFile::exists(atDprfileName)) {
|
||||
return atDprfileName;
|
||||
}
|
||||
}
|
||||
return fileName;
|
||||
|
||||
@@ -463,9 +479,11 @@ QList<int> StyleHelper::availableImageResolutions(const QString &fileName) {
|
||||
|
||||
QList<int> result;
|
||||
const int maxResolutions = qApp->devicePixelRatio();
|
||||
for (int i = 1; i <= maxResolutions; ++i)
|
||||
if (QFile::exists(imageFileWithResolution(fileName, i)))
|
||||
for (int i = 1; i <= maxResolutions; ++i) {
|
||||
if (QFile::exists(imageFileWithResolution(fileName, i))) {
|
||||
result.append(i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@@ -187,14 +187,18 @@ QString PrettySize(const quint64 bytes) {
|
||||
QString ret;
|
||||
|
||||
if (bytes > 0) {
|
||||
if (bytes <= 1000)
|
||||
if (bytes <= 1000) {
|
||||
ret = QString::number(bytes) + " bytes";
|
||||
else if (bytes <= 1000 * 1000)
|
||||
}
|
||||
else if (bytes <= 1000 * 1000) {
|
||||
ret = QString::asprintf("%.1f KB", float(bytes) / 1000);
|
||||
else if (bytes <= 1000 * 1000 * 1000)
|
||||
}
|
||||
else if (bytes <= 1000 * 1000 * 1000) {
|
||||
ret = QString::asprintf("%.1f MB", float(bytes) / (1000 * 1000));
|
||||
else
|
||||
}
|
||||
else {
|
||||
ret = QString::asprintf("%.1f GB", float(bytes) / (1000 * 1000 * 1000));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
@@ -239,13 +243,15 @@ bool MoveToTrashRecursive(const QString &path) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
||||
QDir dir(path);
|
||||
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) {
|
||||
if (!MoveToTrashRecursive(path + "/" + child))
|
||||
if (!MoveToTrashRecursive(path + "/" + child)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) {
|
||||
if (!QFile::moveToTrash(path + "/" + child))
|
||||
if (!QFile::moveToTrash(path + "/" + child)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return dir.rmdir(path);
|
||||
@@ -262,13 +268,15 @@ bool RemoveRecursive(const QString &path) {
|
||||
|
||||
QDir dir(path);
|
||||
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) {
|
||||
if (!RemoveRecursive(path + "/" + child))
|
||||
if (!RemoveRecursive(path + "/" + child)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) {
|
||||
if (!QFile::remove(path + "/" + child))
|
||||
if (!QFile::remove(path + "/" + child)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return dir.rmdir(path);
|
||||
@@ -736,7 +744,7 @@ QString CryptographicRandomString(const int len) {
|
||||
QString GetRandomString(const int len, const QString &UseCharacters) {
|
||||
|
||||
QString randstr;
|
||||
for (int i = 0 ; i < len ; ++i) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
||||
const int index = QRandomGenerator::global()->bounded(0, UseCharacters.length());
|
||||
#else
|
||||
@@ -844,7 +852,7 @@ QString ReplaceMessage(const QString &message, const Song &song, const QString &
|
||||
// Replace the first line
|
||||
int pos = 0;
|
||||
QRegularExpressionMatch match;
|
||||
for (match = variable_replacer.match(message, pos) ; match.hasMatch() ; match = variable_replacer.match(message, pos)) {
|
||||
for (match = variable_replacer.match(message, pos); match.hasMatch(); match = variable_replacer.match(message, pos)) {
|
||||
pos = match.capturedStart();
|
||||
QStringList captured = match.capturedTexts();
|
||||
copy.replace(captured[0], ReplaceVariable(captured[0], song, newline, html_escaped));
|
||||
@@ -976,7 +984,7 @@ HRGN toHRGN(const QRegion ®ion) {
|
||||
HRGN resultRgn = nullptr;
|
||||
QRegion::const_iterator rects = region.begin();
|
||||
resultRgn = qt_RectToHRGN(rects[0]);
|
||||
for (int i = 1 ; i < rect_count ; ++i) {
|
||||
for (int i = 1; i < rect_count; ++i) {
|
||||
HRGN tmpRgn = qt_RectToHRGN(rects[i]);
|
||||
const int res = CombineRgn(resultRgn, resultRgn, tmpRgn, RGN_OR);
|
||||
if (res == ERROR) qWarning("Error combining HRGNs.");
|
||||
|
||||
@@ -135,7 +135,7 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) {
|
||||
|
||||
// Add the buttons
|
||||
THUMBBUTTON buttons[kMaxButtonCount];
|
||||
for (int i = 0 ; i < actions_.count() ; ++i) {
|
||||
for (int i = 0; i < actions_.count(); ++i) {
|
||||
const QAction *action = actions_[i];
|
||||
THUMBBUTTON *button = &buttons[i];
|
||||
button->iId = i;
|
||||
@@ -148,7 +148,7 @@ void Windows7ThumbBar::HandleWinEvent(MSG *msg) {
|
||||
qLog(Debug) << "Failed to add buttons" << Qt::hex << DWORD (hr);
|
||||
}
|
||||
|
||||
for (int i = 0 ; i < actions_.count() ; ++i) {
|
||||
for (int i = 0; i < actions_.count(); ++i) {
|
||||
if (buttons[i].hIcon) {
|
||||
DestroyIcon(buttons[i].hIcon);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ void Windows7ThumbBar::ActionChanged() {
|
||||
qLog(Debug) << "Updating" << actions_.count() << "buttons";
|
||||
|
||||
THUMBBUTTON buttons[kMaxButtonCount];
|
||||
for (int i = 0 ; i < actions_.count() ; ++i) {
|
||||
for (int i = 0; i < actions_.count(); ++i) {
|
||||
QAction *action = actions_[i];
|
||||
THUMBBUTTON *button = &buttons[i];
|
||||
|
||||
@@ -196,7 +196,7 @@ void Windows7ThumbBar::ActionChanged() {
|
||||
qLog(Debug) << "Failed to update buttons" << Qt::hex << DWORD (hr);
|
||||
}
|
||||
|
||||
for (int i = 0 ; i < actions_.count() ; ++i) {
|
||||
for (int i = 0; i < actions_.count(); ++i) {
|
||||
if (buttons[i].hIcon) {
|
||||
DestroyIcon(buttons[i].hIcon);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user