Update Utils.cpp

This commit is contained in:
souchikjoardar201 2025-02-28 19:29:25 +00:00 committed by GitHub
parent 465576aa5a
commit 1e8045649c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -15,6 +15,8 @@
#include <QLayoutItem>
#include <QJsonDocument>
#include <QThread>
#include <QDir>
#include <QFile>
#include <QStandardPaths>
#include <QProcess>
@ -132,6 +134,26 @@ QString getSaveFileName(QWidget* parent, const QString &caption, const QString &
return fn;
}
bool Utils::copyIconToUserFolder(const QString &sourcePath, const QString &destinationPath) {
QDir dir(destinationPath);
if (!dir.exists()) {
dir.mkpath(".");
}
QFile file(sourcePath);
if (!file.exists()) {
return false;
}
QString destFilePath = destinationPath + "/feather.svg";
QFile::remove(destFilePath); // Remove if it already exists to avoid copy failure
return file.copy(destFilePath);
}
QString Utils::getDefaultIconPath() {
return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/icons/hicolor/scalable/apps";
}
QString getOpenFileName(QWidget* parent, const QString& caption, const QString& filter) {
QString lastPath = conf()->get(Config::lastPath).toString();
QString fn = QFileDialog::getOpenFileName(parent, caption, lastPath, filter);