Commit ca4dd4d3 authored by Carson Black's avatar Carson Black

Merge branch 'const_ref' into 'master'

Pass QString by const & instead of copy

See merge request !2
parents 292d5445 d4cc114a
......@@ -14,7 +14,7 @@ IconSetter::IconSetter(QObject *parent) : QObject(parent)
{
}
bool IconSetter::fileExists(QString path)
bool IconSetter::fileExists(const QString &path)
{
QFileInfo check_file(path);
if (check_file.exists() && check_file.isFile()) {
......@@ -23,7 +23,7 @@ bool IconSetter::fileExists(QString path)
return false;
}
}
void IconSetter::setIconTheme(QString themeName)
void IconSetter::setIconTheme(const QString &themeName)
{
QFile file(QDir::homePath() + "/.iconPreviewTheme");
if (IconSetter::fileExists(QDir::homePath() + "/.iconPreviewTheme")) {
......@@ -34,7 +34,7 @@ void IconSetter::setIconTheme(QString themeName)
in << themeName << endl;
}
}
void IconSetter::copy(QString from, QString to)
void IconSetter::copy(const QString &from, const QString &to)
{
QFile fromfile(from);
if (QFile::exists(to))
......@@ -43,7 +43,7 @@ void IconSetter::copy(QString from, QString to)
}
fromfile.copy(to);
}
void IconSetter::linkIcon(QString from)
void IconSetter::linkIcon(const QString &from)
{
QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << QDir::homePath() + "/.ikona");
QString to = QDir::homePath() + "/.ikona/" + "ikonapreviewicon.svg";
......@@ -53,14 +53,14 @@ void IconSetter::linkIcon(QString from)
}
QFile::link(from, to);
}
void IconSetter::xdgOpen(QString file)
void IconSetter::xdgOpen(const QString &file)
{
QProcess::startDetached("xdg-open \"" + file + "\"");
// QDesktopServices::openUrl(QUrl(file));
// KIO doesn't like QUrl's encoding for whatever reason.
}
void IconSetter::clipboardCopy(QString string)
void IconSetter::clipboardCopy(const QString &string)
{
QClipboard *clipboard = QGuiApplication::clipboard();
clipboard->setText(string);
......
......@@ -5,15 +5,15 @@ class IconSetter : public QObject
Q_OBJECT
public:
explicit IconSetter(QObject *parent = nullptr);
Q_INVOKABLE void setIconTheme(QString themeName);
Q_INVOKABLE void copy(QString from, QString to);
Q_INVOKABLE void linkIcon(QString from);
Q_INVOKABLE void xdgOpen(QString file);
Q_INVOKABLE void clipboardCopy(QString string);
Q_INVOKABLE void setIconTheme(const QString &themeName);
Q_INVOKABLE void copy(const QString &from, const QString &to);
Q_INVOKABLE void linkIcon(const QString &from);
Q_INVOKABLE void xdgOpen(const QString &file);
Q_INVOKABLE void clipboardCopy(const QString &string);
private:
bool fileExists(QString path);
bool fileExists(const QString &path);
signals:
public slots:
};
\ No newline at end of file
};
......@@ -39,7 +39,7 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS
}
}
bool fileExists(QString path)
bool fileExists(const QString &path)
{
QFileInfo check_file(path);
if (check_file.exists() && check_file.isFile()) {
......
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