1
0
Fork 0
forked from blue/squawk

Downloads folder now is movable

This commit is contained in:
Blue 2022-02-19 21:31:49 +03:00
parent d8b5ccb2da
commit 73b1b58a96
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
16 changed files with 141 additions and 12 deletions

View file

@ -53,3 +53,26 @@ QString Shared::resolvePath(QString path)
QVariant dpv = settings.value("downloadsPath");
return path.replace(squawk, dpv.toString() + "/");
}
QString Shared::squawkifyPath(QString path)
{
QSettings settings;
QString current = settings.value("downloadsPath").toString();
if (path.startsWith(current)) {
path.replace(0, current.size() + 1, "squawk://");
}
return path;
}
bool Shared::isSubdirectoryOfSettings(const QString& path)
{
QSettings settings;
QDir oldPath(settings.value("downloadsPath").toString());
QDir newPath(path);
return newPath.canonicalPath().startsWith(oldPath.canonicalPath());
}

View file

@ -13,10 +13,13 @@
namespace Shared {
QString downloadsPathCheck();
QString downloadsPathCheck(QString path);
QString defaultDownloadsPath();
QString getAbsoluteWritablePath(const QString& path);
QString resolvePath(QString path);
QString squawkifyPath(QString path);
bool isSubdirectoryOfSettings(const QString& path);
}