/cplusplus/scripts/getanddostuff/external.cpp
C++ | 27 lines | 19 code | 8 blank | 0 comment | 2 complexity | 42788cc0ea1ed1a767f46fc9c27497af MD5 | raw file
- #include "external.h"
- GetAndDoStuffExternal::GetAndDoStuffExternal(QObject *parent) : QObject(parent) { }
- GetAndDoStuffExternal::~GetAndDoStuffExternal() { }
- void GetAndDoStuffExternal::openLink(QString url) {
- QDesktopServices::openUrl(url);
- }
- void GetAndDoStuffExternal::executeApp(QString exec, QString fname) {
- fname = QByteArray::fromPercentEncoding(fname.toUtf8());
- QProcess *p = new QProcess;
- exec = exec.replace("%f", "\"" + fname + "\"");
- exec = exec.replace("%u", "\"" + QFileInfo(fname).fileName() + "\"");
- exec = exec.replace("%d", "\"" + QFileInfo(fname).absoluteDir().absolutePath() + "\"");
- p->start(exec);
- if(p->error() == 5)
- p->waitForStarted(2000);
- }
- void GetAndDoStuffExternal::openInDefaultFileManager(QString file) {
- QDesktopServices::openUrl(QUrl("file://" + QFileInfo(file).absolutePath()));
- }