PageRenderTime 54ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/cplusplus/scripts/getanddostuff/external.cpp

https://gitlab.com/vladius/photoqt
C++ | 27 lines | 19 code | 8 blank | 0 comment | 2 complexity | 42788cc0ea1ed1a767f46fc9c27497af MD5 | raw file
  1. #include "external.h"
  2. GetAndDoStuffExternal::GetAndDoStuffExternal(QObject *parent) : QObject(parent) { }
  3. GetAndDoStuffExternal::~GetAndDoStuffExternal() { }
  4. void GetAndDoStuffExternal::openLink(QString url) {
  5. QDesktopServices::openUrl(url);
  6. }
  7. void GetAndDoStuffExternal::executeApp(QString exec, QString fname) {
  8. fname = QByteArray::fromPercentEncoding(fname.toUtf8());
  9. QProcess *p = new QProcess;
  10. exec = exec.replace("%f", "\"" + fname + "\"");
  11. exec = exec.replace("%u", "\"" + QFileInfo(fname).fileName() + "\"");
  12. exec = exec.replace("%d", "\"" + QFileInfo(fname).absoluteDir().absolutePath() + "\"");
  13. p->start(exec);
  14. if(p->error() == 5)
  15. p->waitForStarted(2000);
  16. }
  17. void GetAndDoStuffExternal::openInDefaultFileManager(QString file) {
  18. QDesktopServices::openUrl(QUrl("file://" + QFileInfo(file).absolutePath()));
  19. }