summaryrefslogtreecommitdiffstats
path: root/depends/util/src
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-08-18 20:52:17 +0200
committerPetr Mrázek <peterix@gmail.com>2013-08-18 20:52:17 +0200
commitc92ad7dcf86f2e5e71d71a68e24e79fbdeceb56d (patch)
tree7be301a5123e216a41646f9639ec887609497a87 /depends/util/src
parent253067c782955380bbf66ac0475dc954375b1ff4 (diff)
downloadMultiMC-c92ad7dcf86f2e5e71d71a68e24e79fbdeceb56d.tar
MultiMC-c92ad7dcf86f2e5e71d71a68e24e79fbdeceb56d.tar.gz
MultiMC-c92ad7dcf86f2e5e71d71a68e24e79fbdeceb56d.tar.lz
MultiMC-c92ad7dcf86f2e5e71d71a68e24e79fbdeceb56d.tar.xz
MultiMC-c92ad7dcf86f2e5e71d71a68e24e79fbdeceb56d.zip
Drag and Drop, mod management.
Diffstat (limited to 'depends/util/src')
-rw-r--r--depends/util/src/pathutils.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/depends/util/src/pathutils.cpp b/depends/util/src/pathutils.cpp
index 97287840..5bafdf0f 100644
--- a/depends/util/src/pathutils.cpp
+++ b/depends/util/src/pathutils.cpp
@@ -17,6 +17,8 @@
#include <QFileInfo>
#include <QDir>
+#include <QDesktopServices>
+#include <QUrl>
QString PathCombine(QString path1, QString path2)
{
@@ -70,7 +72,7 @@ bool ensurePathExists(QString filenamepath)
{
QFileInfo a ( filenamepath );
QDir dir;
- return (dir.mkpath ( a.path() ));
+ return (dir.mkpath ( a.filePath() ));
}
bool copyPath(QString src, QString dst)
@@ -78,12 +80,14 @@ bool copyPath(QString src, QString dst)
QDir dir(src);
if (!dir.exists())
return false;
+ if(!ensurePathExists(dst))
+ return false;
foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
{
- QString dst_path = dst + QDir::separator() + d;
- dir.mkpath(dst_path);
- copyPath(src+ QDir::separator() + d, dst_path);
+ QString inner_src = src+ QDir::separator() + d;
+ QString inner_dst = dst + QDir::separator() + d;
+ copyPath(inner_src, inner_dst);
}
foreach (QString f, dir.entryList(QDir::Files))
@@ -92,3 +96,19 @@ bool copyPath(QString src, QString dst)
}
return true;
}
+
+void openDirInDefaultProgram ( QString path, bool ensureExists )
+{
+ QDir parentPath;
+ QDir dir( path );
+ if(!dir.exists())
+ {
+ parentPath.mkpath(dir.absolutePath());
+ }
+ QDesktopServices::openUrl ( "file:///" + dir.absolutePath() );
+}
+
+void openFileInDefaultProgram ( QString filename )
+{
+ QDesktopServices::openUrl ( "file:///" + QFileInfo ( filename ).absolutePath() );
+}