Commit 6e48bb65 authored by David Jarvie's avatar David Jarvie
Browse files

Don't use QDir::separator() to build file paths

See documentation for QDir::separator()
parent 68615227
/* /*
* sounddlg.cpp - sound file selection and configuration dialog and widget * sounddlg.cpp - sound file selection and configuration dialog and widget
* Program: kalarm * Program: kalarm
* Copyright © 2005-2019 David Jarvie <djarvie@kde.org> * Copyright © 2005-2020 David Jarvie <djarvie@kde.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -190,7 +190,7 @@ SoundWidget::SoundWidget(bool showPlay, bool showRepeat, QWidget* parent) ...@@ -190,7 +190,7 @@ SoundWidget::SoundWidget(bool showPlay, bool showRepeat, QWidget* parent)
mFileBrowseButton = new PushButton(box); mFileBrowseButton = new PushButton(box);
boxHLayout->addWidget(mFileBrowseButton); boxHLayout->addWidget(mFileBrowseButton);
mFileBrowseButton->setIcon(QIcon(QIcon::fromTheme(QStringLiteral("document-open")))); mFileBrowseButton->setIcon(QIcon(QIcon::fromTheme(QStringLiteral("document-open"))));
int size = mFileBrowseButton->sizeHint().height(); const int size = mFileBrowseButton->sizeHint().height();
mFileBrowseButton->setFixedSize(size, size); mFileBrowseButton->setFixedSize(size, size);
connect(mFileBrowseButton, &PushButton::clicked, this, &SoundWidget::slotPickFile); connect(mFileBrowseButton, &PushButton::clicked, this, &SoundWidget::slotPickFile);
mFileBrowseButton->setToolTip(i18nc("@info:tooltip", "Choose a file")); mFileBrowseButton->setToolTip(i18nc("@info:tooltip", "Choose a file"));
...@@ -198,7 +198,7 @@ SoundWidget::SoundWidget(bool showPlay, bool showRepeat, QWidget* parent) ...@@ -198,7 +198,7 @@ SoundWidget::SoundWidget(bool showPlay, bool showRepeat, QWidget* parent)
if (mFilePlay) if (mFilePlay)
{ {
int size = qMax(mFilePlay->sizeHint().height(), mFileBrowseButton->sizeHint().height()); const int size = qMax(mFilePlay->sizeHint().height(), mFileBrowseButton->sizeHint().height());
mFilePlay->setFixedSize(size, size); mFilePlay->setFixedSize(size, size);
mFileBrowseButton->setFixedSize(size, size); mFileBrowseButton->setFixedSize(size, size);
} }
...@@ -237,11 +237,11 @@ SoundWidget::SoundWidget(bool showPlay, bool showRepeat, QWidget* parent) ...@@ -237,11 +237,11 @@ SoundWidget::SoundWidget(bool showPlay, bool showRepeat, QWidget* parent)
QGroupBox* group = new QGroupBox(i18nc("@title:group Sound volume", "Volume"), this); QGroupBox* group = new QGroupBox(i18nc("@title:group Sound volume", "Volume"), this);
layout->addWidget(group); layout->addWidget(group);
QGridLayout* grid = new QGridLayout(group); QGridLayout* grid = new QGridLayout(group);
int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin); const int dcm = style()->pixelMetric(QStyle::PM_DefaultChildMargin);
grid->setContentsMargins(dcm, dcm, dcm, dcm); grid->setContentsMargins(dcm, dcm, dcm, dcm);
grid->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing)); grid->setSpacing(style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
grid->setColumnStretch(2, 1); grid->setColumnStretch(2, 1);
int indentWidth = 3 * style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); const int indentWidth = 3 * style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
grid->setColumnMinimumWidth(0, indentWidth); grid->setColumnMinimumWidth(0, indentWidth);
grid->setColumnMinimumWidth(1, indentWidth); grid->setColumnMinimumWidth(1, indentWidth);
...@@ -371,7 +371,7 @@ QString SoundWidget::fileName() const ...@@ -371,7 +371,7 @@ QString SoundWidget::fileName() const
*/ */
bool SoundWidget::file(QUrl& url, bool showErrorMessage) const bool SoundWidget::file(QUrl& url, bool showErrorMessage) const
{ {
bool result = validate(showErrorMessage); const bool result = validate(showErrorMessage);
url = mUrl; url = mUrl;
return result; return result;
} }
...@@ -509,7 +509,7 @@ bool SoundWidget::validate(bool showErrorMessage) const ...@@ -509,7 +509,7 @@ bool SoundWidget::validate(bool showErrorMessage) const
dir.setPath(soundDirs[i]); dir.setPath(soundDirs[i]);
if (dir.isReadable() && dir.count() > 2) if (dir.isReadable() && dir.count() > 2)
{ {
QString f = soundDirs[i] + QDir::separator() + file; QString f = soundDirs[i] + QLatin1Char('/') + file;
err = File::checkFileExists(f, mUrl, MainWindow::mainMainWindow()); err = File::checkFileExists(f, mUrl, MainWindow::mainMainWindow());
if (err == File::FileErr::None) if (err == File::FileErr::None)
return true; return true;
...@@ -523,7 +523,7 @@ bool SoundWidget::validate(bool showErrorMessage) const ...@@ -523,7 +523,7 @@ bool SoundWidget::validate(bool showErrorMessage) const
} }
if (err == File::FileErr::Nonexistent) if (err == File::FileErr::Nonexistent)
{ {
QString f = QDir::homePath() + QDir::separator() + file; QString f = QDir::homePath() + QLatin1Char('/') + file;
err = File::checkFileExists(f, mUrl, MainWindow::mainMainWindow()); err = File::checkFileExists(f, mUrl, MainWindow::mainMainWindow());
if (err == File::FileErr::None) if (err == File::FileErr::None)
return true; return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment