Example #1
6
void Pane::doubleClickedOnEntry(QModelIndex index)
{
    Qt::KeyboardModifiers keybMod = QApplication::keyboardModifiers();
    if(keybMod == Qt::ControlModifier || keybMod == Qt::ShiftModifier)
        return;

    QFileInfo fileInfo(mainWindow->fileSystemModel->filePath(index));

    if(fileInfo.isDir())
        moveTo(fileInfo.absoluteFilePath());
    else if (fileInfo.isExecutable()) {
        QProcess *process = new QProcess(this);
        process->startDetached(fileInfo.absoluteFilePath());
    }
    else {
        QProcess *process = new QProcess(this);
#ifdef __HAIKU__
        process->startDetached("open \"" + fileInfo.absoluteFilePath() + "\"");
#endif
#ifdef Q_OS_WIN
        process->startDetached("\"" + fileInfo.absoluteFilePath() + "\"");
//        qDebug()<< "*\"" + fileInfo.absoluteFilePath() + "\"" ;
#endif
#ifdef __linux__
        process->startDetached("open \"" + fileInfo.absoluteFilePath() + "\"");
//        qDebug()<<"open \"" + fileInfo.absoluteFilePath() + "\"";
#endif
    }
}
Example #2
0
void BidPage::SummonBTCWallet()
{
    QProcess *proc = new QProcess(this);
    #ifdef linux
        proc->startDetached("bitcoin-qt");
    #elif _WIN32
        proc->startDetached("bitcoin-qt.exe");
    #endif
}
Example #3
0
/*
 * Opens a terminal based on your DE.
 */
void WMHelper::openTerminal(const QString& dirName){
  QProcess *p = new QProcess(qApp->activeWindow());
  QStringList s;
  QFileInfo f(dirName);

  if (f.exists()){
    if(isXFCERunning() && UnixCommand::hasTheExecutable(ctn_XFCE_TERMINAL)){
      s << "--working-directory=" + dirName;
      p->startDetached( ctn_XFCE_TERMINAL, s );
    }
    else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE_TERMINAL)){
      s << "--workdir";            
      s << dirName;

      if (UnixCommand::isRootRunning())
      {
        p->startDetached( "dbus-launch " + ctn_KDE_TERMINAL + " --workdir " + dirName);
      }
      else
      {
        p->startDetached( ctn_KDE_TERMINAL, s );
      }
    }
    else if (isTDERunning() && UnixCommand::hasTheExecutable(ctn_TDE_TERMINAL)){
      s << "--workdir";
      s << dirName;
      p->startDetached( ctn_TDE_TERMINAL, s );
    }
    else if (isLXDERunning() && UnixCommand::hasTheExecutable(ctn_LXDE_TERMINAL)){
      s << "--working-directory=" + dirName;
      p->startDetached( ctn_LXDE_TERMINAL, s );
    }
    else if (isMATERunning() && UnixCommand::hasTheExecutable(ctn_MATE_TERMINAL)){
      s << "--working-directory=" + dirName;
      p->startDetached( ctn_MATE_TERMINAL, s );
    }
    else if (isCinnamonRunning() && UnixCommand::hasTheExecutable(ctn_CINNAMON_TERMINAL)){
      s << "--working-directory=" + dirName;
      p->startDetached( ctn_CINNAMON_TERMINAL, s );
    }
    else if (UnixCommand::hasTheExecutable(ctn_XFCE_TERMINAL)){
      s << "--working-directory=" + dirName;
      p->startDetached( ctn_XFCE_TERMINAL, s );
    }
    else if (UnixCommand::hasTheExecutable(ctn_LXDE_TERMINAL)){
      s << "--working-directory=" + dirName;
      p->startDetached( ctn_LXDE_TERMINAL, s );
    }
    else if (UnixCommand::hasTheExecutable(ctn_XTERM)){
      QString cmd = ctn_XTERM +
          " -fn \"*-fixed-*-*-*-18-*\" -fg White -bg Black -title xterm -e \"" +
          "cd " + dirName + " && /bin/bash\"";
      p->startDetached( cmd );
    }
  }
}
Example #4
0
/*
 * Edits a file based on your DE.
 */
void WMHelper::editFile( const QString& fileName, EditOptions opt ){
  QProcess *process = new QProcess(qApp->activeWindow());
  QString p;

  LinuxDistro distro = UnixCommand::getLinuxDistro();
  if (distro == ectn_ARCHBANGLINUX && UnixCommand::hasTheExecutable(ctn_ARCHBANG_EDITOR))
  {
    p = ctn_ARCHBANG_EDITOR + " " + fileName;
  }
  else if (distro == ectn_MOOOSLINUX && UnixCommand::hasTheExecutable(ctn_MOOOS_EDITOR))
  {
    p = ctn_MOOOS_EDITOR + " " + fileName;
  }
  else if (isXFCERunning() && (UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR) ||
                               UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR_ALT))){

    p = getXFCEEditor() + " " + fileName;
  }
  else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE_EDITOR)){
    p += ctn_KDE_EDITOR + " " + fileName;
  }
  else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE4_EDITOR)){
    p += ctn_KDE4_EDITOR + " " + fileName;
  }
  else if (isTDERunning() && UnixCommand::hasTheExecutable(ctn_TDE_EDITOR)){
    p += ctn_TDE_EDITOR + " " + fileName;
  }
  else if (isMATERunning() && UnixCommand::hasTheExecutable(ctn_MATE_EDITOR)){
    p = ctn_MATE_EDITOR + " " + fileName;
  }
  else if (isLXQTRunning() && UnixCommand::hasTheExecutable(ctn_LXQT_EDITOR)){
    p = ctn_LXQT_EDITOR + " " + fileName;
  }
  if (UnixCommand::hasTheExecutable(ctn_ARCHBANG_EDITOR))
  {
    p = ctn_ARCHBANG_EDITOR + " " + fileName;
  }
  else if (UnixCommand::hasTheExecutable(ctn_CINNAMON_EDITOR)){
    p = ctn_CINNAMON_EDITOR + " " + fileName;
  }
  else if (UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR) || UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR_ALT)){
    p = getXFCEEditor() + " " + fileName;
  }

  if (UnixCommand::isRootRunning() || opt == ectn_EDIT_AS_NORMAL_USER)
  {
    process->startDetached("/bin/sh -c \"" + p + "\"");
  }
  else
  {
    process->startDetached(getSUCommand() + p);
  }
}
Example #5
0
void Interpreter::run()
{
    QProcess* runner = new QProcess();

#if defined(Q_OS_WIN) //if current platform is Windows
    runner->startDetached(path, arguments);
#elif defined(Q_OS_LINUX) //if current platform is Linux
    runner->startDetached("xterm", QStringList()<< "-e" << path << arguments);
#endif

    delete runner;
}
Example #6
0
/*
 * Edits a file based on your DE.
 */
void WMHelper::editFile( const QString& fileName ){
  QProcess *process = new QProcess(qApp->activeWindow());
  QStringList s;

  if (!UnixCommand::isRootRunning()){
    LinuxDistro distro = UnixCommand::getLinuxDistro();
    if (distro == ectn_ARCHBANGLINUX && UnixCommand::hasTheExecutable(ctn_ARCHBANG_EDITOR))
    {
      QString p = ctn_ARCHBANG_EDITOR + " " + fileName;
      process->startDetached(getSUCommand() + p);
    }
    else if (isXFCERunning() && (UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR) ||
                             UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR_ALT))){

      QString p = getXFCEEditor() + " " + fileName;
      process->startDetached(getSUCommand() + p);
    }
    else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE_EDITOR)){
      QString p = " -d -t --noignorebutton -c ";
      p += ctn_KDE_EDITOR + " " + fileName;
      process->startDetached(getSUCommand() + p);
    }
    else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE4_EDITOR)){
      QString p = " -d -t --noignorebutton -c ";
      p += ctn_KDE4_EDITOR + " " + fileName;
      process->startDetached(getSUCommand() + p);
    }
    else if (isTDERunning() && UnixCommand::hasTheExecutable(ctn_TDE_EDITOR)){
      QString p = " -d -t --noignorebutton ";
      p += ctn_TDE_EDITOR + " " + fileName;
      process->startDetached(getSUCommand() + p);
    }
    else if (isMATERunning() && UnixCommand::hasTheExecutable(ctn_MATE_EDITOR)){
      QString p = ctn_MATE_EDITOR + " " + fileName;
      process->startDetached(getSUCommand() + p);
    }
    else if (isCinnamonRunning() && UnixCommand::hasTheExecutable(ctn_CINNAMON_EDITOR)){
      QString p = ctn_CINNAMON_EDITOR + " " + fileName;
      process->startDetached(getSUCommand() + p);
    }
    else if (UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR) || UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR_ALT)){
      QString p = getXFCEEditor() + " " + fileName;
      process->startDetached(getSUCommand() + p);
    }
  }
  //Octopi was started by root account.
  else{
    if (UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR) || UnixCommand::hasTheExecutable(ctn_XFCE_EDITOR_ALT))
      s << getXFCEEditor() + " " + fileName;
    else if (UnixCommand::hasTheExecutable(ctn_KDE_EDITOR))
      s << ctn_KDE_EDITOR + " " + fileName;
    else if (UnixCommand::hasTheExecutable(ctn_TDE_EDITOR))
      s << ctn_TDE_EDITOR + " " + fileName;

    process->startDetached("/bin/sh", s);
  }
}
Example #7
0
/*
 * Opens a file based on your DE
 */
void WMHelper::openFile(const QString& fileName){
  QString fileToOpen(fileName);

  if (!UnixCommand::isTextFile(fileToOpen)){
    int res = QMessageBox::question(qApp->activeWindow(), StrConstants::getConfirmation(),
                                    StrConstants::getThisIsNotATextFile(),
                                    QMessageBox::Yes | QMessageBox::No,
                                    QMessageBox::No);

    if ( res == QMessageBox::No ) return;
  }

  QProcess *p = new QProcess(qApp->activeWindow());
  QStringList s;

  LinuxDistro distro = UnixCommand::getLinuxDistro();
  if (distro == ectn_ARCHBANGLINUX && UnixCommand::hasTheExecutable(ctn_ARCHBANG_FILE_MANAGER))
  {
    s << fileToOpen;
    p->startDetached( ctn_ARCHBANG_FILE_MANAGER, s );
  }

  else if (isXFCERunning() && UnixCommand::hasTheExecutable(ctn_XFCE_FILE_MANAGER)){
    s << fileToOpen;
    p->startDetached( ctn_XFCE_FILE_MANAGER, s );
  }
  else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE_FILE_MANAGER)){
    s << "exec";
    s << "file:" + fileToOpen;
    p->startDetached( ctn_KDE_FILE_MANAGER, s );
  }
  else if (isKDERunning() && UnixCommand::hasTheExecutable(ctn_KDE4_FILE_MANAGER)){
    s << fileToOpen;
    p->startDetached( ctn_KDE4_OPEN, s );
  }
  else if (isTDERunning() && UnixCommand::hasTheExecutable(ctn_TDE_FILE_MANAGER)){
    s << "exec";
    s << "file:" + fileToOpen;
    p->startDetached( ctn_TDE_FILE_MANAGER, s );
  }
  else if (isMATERunning() && UnixCommand::hasTheExecutable(ctn_MATE_EDITOR)){
    s << fileToOpen;
    p->startDetached( ctn_MATE_EDITOR, s );
  }
  else if (isCinnamonRunning() && UnixCommand::hasTheExecutable(ctn_CINNAMON_EDITOR)){
    s << fileToOpen;
    p->startDetached( ctn_CINNAMON_EDITOR, s );
  }
  else if (UnixCommand::hasTheExecutable(ctn_XFCE_FILE_MANAGER)){
    s << fileToOpen;
    p->startDetached( ctn_XFCE_FILE_MANAGER, s );
  }
  else if (UnixCommand::hasTheExecutable(ctn_LXDE_FILE_MANAGER)){
    s << fileToOpen;
    p->startDetached( ctn_LXDE_FILE_MANAGER, s );
  }
}
void ITmagesApplet::dropEvent(QGraphicsSceneDragDropEvent *e)
{
  // preventing next files drop
  setAcceptDrops(false);

  QString tempText = e->mimeData()->text();
  QStringList paths = tempText.split("\n");
  if (paths.count()>1) paths.removeLast();
  // remove "file://", because we get 'file:///path_to_file'
  paths.replaceInStrings(QRegExp("file://"),"");

  // add supported files recursive
  QStringList imagesPaths;
  QFileInfo info;
  for (int i = 0; i<paths.count(); ++i) {
    info.setFile(paths.at(0));
    if (info.isDir()) {
      imagesPaths = loadImgFromFolder(info.absoluteFilePath());
    } else if (info.isFile()) {
      if (paths.at(i).contains(QRegExp("png$|jpg$|jpeg$|gif$", Qt::CaseInsensitive)))
        imagesPaths.append(paths.at(i));
    }
  }

  // start ITmages context menu extension
  if (!imagesPaths.isEmpty()) {
    QProcess load;
    load.startDetached(path,imagesPaths);
  }

  setAcceptDrops(true);
}
Example #9
0
void MainWindow::createText() {
    // Creates a new process to be called
    QProcess *process = new QProcess;

#ifdef Q_WS_WIN
    // Runs the CreateText.exe from debug folder
    process->startDetached("CreateText");

    // If the program runs, display a message saying it ran fine
    if (process->waitForStarted() == true) {
        qDebug() << "\nRunning CreateText";
    }
#endif

#ifdef Q_WS_MACX
    // Holds the path to the CreateText.exe
    QString path = "open \"/Users/Teramino/Desktop/Qt/build-CreateText-Desktop_Qt_4_8_5-Debug/CreateText.app/Contents/MacOS/CreateText\"";

    // Runs the CreateText.exe
    process->start(path);

    // If the program fails to start, display an error message and exit the program
    if (process->waitForStarted() == false) {
        qDebug() << "\nError starting CreateText";
        qDebug() << process->errorString();
        exit (-1);
    }

    // If the program runs, display a message saying it ran fine
    if (process->waitForStarted() == true) {
        qDebug() << "\nRunning CreateText";
    }
#endif
}
Example #10
0
    void SelfUpdater::askForRestart()
    {
        QString text = "The Server Control Panel was updated from ";
        text.append(QString("v%1 to v%2.").arg(APP_VERSION_SHORT, versionInfo["latest_version"].toString()));

        QString infoText = "The update was installed. "
                           "You can restart the Server Control Panel now, "
                           "or continue working and restart later.";

        QPixmap iconPixmap = QIcon(":/update").pixmap(80,80);

        QMessageBox msgBox;
        msgBox.setIconPixmap(iconPixmap);
        msgBox.setWindowTitle("WPN-XM Server Control Panel - Self Updater");
        msgBox.setText(text);
        msgBox.setInformativeText(infoText);
        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        msgBox.setButtonText(QMessageBox::Yes, tr("Restart SCP"));
        msgBox.setButtonText(QMessageBox::No, tr("Continue"));
        msgBox.setDefaultButton(QMessageBox::Yes);

        if(msgBox.exec() == QMessageBox::Yes)
        {
          // Should we send a final farewell signal before we leave?
          // QApplication::aboutToQuit(finalFarewellSignal);

          // cross fingers and hope and pray, that starting the new process is slow
          // and we are not running into the single application check.. ;)

          QProcess p;
          p.startDetached(QApplication::applicationFilePath());

          QApplication::exit();
        }
    }
Example #11
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QTextCodec* codec = QTextCodec::codecForName("CP1251");
    QTextCodec::setCodecForLocale(codec);

    if(argc == 6) {
        QString prog_name = argv[5];

        QString update_command = QString("%1 %2 %3%4 ").arg(argv[1]).arg(argv[2]).arg(argv[3]).arg(QDir::toNativeSeparators(argv[4]));

        QProcess *vec = new QProcess;

        qDebug() << "Update application...";

        int res = vec->execute(update_command);
        //TODO:
        //Message Box with warning of fault update process if res != 0
        // -2 = нет файла обновления

        qDebug() << "Restart programm...";
        vec->startDetached(prog_name);
        delete vec;

        return 0;
    }

    return a.exec();
}
Example #12
0
void MainWindow::on_startSim_clicked()
{
    QProcess *sim = new QProcess(this);
    sim->startDetached("C:\\UDK\\UDK-2013-07\\USARRunMaps\\ExampleMap.bat");
    //QThread::sleep(3);
    qDebug()<<sim->errorString();
}
Example #13
0
void Updater::launchInstaller()
{

    if(!installer) {
        QMessageBox mbox;
        mbox.setText("Could not load the installer. Please download it manually and run the update.");
        mbox.setIcon(QMessageBox::Warning);
        mbox.exec();
        return;
    }
        
#if defined(Q_OS_WIN32)
    QDesktopServices::openUrl(installer->fileName());

#elif defined(Q_OS_LINUX)
    QDesktopServices::openUrl(installer->fileName());
#elif defined(Q_OS_DARWIN)
    QProcess* installProc = new QProcess(this);
    QString program = "open " + installer->fileName();

    installProc->startDetached(program);
    installProc->waitForStarted();
#endif
    
    qApp->quit();
}
Example #14
0
bool FileEnvProcess::startDetached(const QString& program)
{
    QByteArray programBa = program.toLatin1();
    const char* programCharPtr = programBa.data();
    
    QString* tmpFileNameStrPtr = new QString("/tmp/tmpRideFile.bash");
    QFile* tmpRideFilePtr = new QFile(*tmpFileNameStrPtr);
    tmpRideFilePtr->open(QIODevice::WriteOnly);

    addHeader(tmpRideFilePtr);
    tmpRideFilePtr->write(programCharPtr);
    tmpRideFilePtr->write("\nrm /tmp/tmpRideFile.bash");
    tmpRideFilePtr->write("\necho \"Finished execution.\"");
    tmpRideFilePtr->close();

    QStringList stringlst; stringlst.push_back("+x"); stringlst.push_back("/tmp/tmpRideFile.bash");
    QProcess qprocess;
    qprocess.setProcessChannelMode(QProcess::MergedChannels);
    //QByteArray output = qprocess.readAll();
    qprocess.execute("chmod", stringlst);
    
    int rtn = qprocess.startDetached(*tmpFileNameStrPtr); //don't run this->execute; this would result in infinate recursion!!!
    //cout << cct::bold("\nOutput: ") << output.data() << cct::bold("\nEnd of output") << endl;
    
    return rtn;
}
Example #15
0
bool FileEnvProcess::startDetached(const QString& program, const QStringList& arguments, const QString& workingDirectory, qint64* pid)
{
    QByteArray programBa = program.toLatin1();
    const char* programCharPtr = programBa.data();
    
    QString* tmpFileNameStrPtr = new QString("/tmp/tmpRideFile.bash");
    QFile* tmpRideFilePtr = new QFile(*tmpFileNameStrPtr);
    tmpRideFilePtr->open(QIODevice::WriteOnly);
    
    addHeader(tmpRideFilePtr);
    tmpRideFilePtr->write(programCharPtr);
    
    QByteArray tmpByteArray;
    for(size_t i = 0; i < arguments.size(); i++)
    {
        tmpByteArray.append(arguments.at(i) + "\n");
        tmpRideFilePtr->write(tmpByteArray);
        tmpByteArray.clear();
    }
    
    tmpRideFilePtr->write("\nrm /tmp/tmpRideFile.bash");
    tmpRideFilePtr->write("\necho \"Finished execution.\"");
    tmpRideFilePtr->close();
    
    QStringList stringlst; stringlst.push_back("+x"); stringlst.push_back("/tmp/tmpRideFile.bash");
    QProcess qprocess;
    qprocess.execute("chmod", stringlst);
    
    // Don't run this->startDetached; this would result in infinite recursion!!!
    return qprocess.startDetached(*tmpFileNameStrPtr, QStringList(), workingDirectory, pid);
}
Example #16
0
bool FileEnvProcess::startDetached(const QString& program, const QStringList& arguments)
{   
    //cout << "Program: " << program.toStdString() << endl;
    //cout << "args: " << arguments.at(0).toStdString() << " " << arguments.at(1).toStdString() << endl;

    QByteArray programBa = program.toLatin1();
    const char* programCharPtr = programBa.data();
    
    QString* tmpFileNameStrPtr = new QString("/tmp/tmpRideFile.bash");
    QFile* tmpRideFilePtr = new QFile(*tmpFileNameStrPtr);
    tmpRideFilePtr->open(QIODevice::WriteOnly);

    addHeader(tmpRideFilePtr);
    tmpRideFilePtr->write(programCharPtr);
    tmpRideFilePtr->write(" ");

    QByteArray tmpByteArray;
    for(size_t i = 0; i < arguments.size(); i++)
    {
        tmpByteArray.append(arguments.at(i) + " ");
        tmpRideFilePtr->write(tmpByteArray);
        tmpByteArray.clear();
    }

    tmpRideFilePtr->write("\nrm /tmp/tmpRideFile.bash");
    tmpRideFilePtr->write("\necho \"Finished execution.\"");
    tmpRideFilePtr->close();

    QStringList stringlst; stringlst.push_back("+x"); stringlst.push_back("/tmp/tmpRideFile.bash");
    QProcess qprocess;
    qprocess.execute("chmod", stringlst);
    
    return qprocess.startDetached(*tmpFileNameStrPtr); //don't run this->execute; this would result in infinate recursion!!!
}
Example #17
0
void SettingsUi::startApplication(QString appname)
{
    QProcess proc;
    proc.startDetached("/usr/bin/xdg-open" , QStringList() << appname);

    QThread::msleep(100);
}
void UBOpenSankoreImporter::onProceedClicked()
{
    QProcess newProcess;
#ifdef Q_OS_LINUX
    newProcess.startDetached(qApp->applicationDirPath()+"/importer/OpenBoardImporter");
#elif defined Q_OS_OSX
    newProcess.startDetached(qApp->applicationDirPath()+"/../Resources/OpenBoardImporter.app/Contents/MacOS/OpenBoardImporter");
#else
    // Windows does not allows to run easily an exe located in a subdirectory when the main
    // directory is placed into programs files.
    //newProcess.startDetached(qApp->applicationDirPath()+"\\Importer\\OpenBoardImporter.exe");
    newProcess.startDetached("C:/OpenBoard/Importer/OpenBoardImporter.exe");
#endif
    qApp->exit(0);

}
Example #19
0
bool QCrashReporter::restart(const QString &path)
{
    QProcess process;
    process.startDetached(path);

    return true;
}
Example #20
0
//*******************************************************************
// diff                                                      PRIVATE
//*******************************************************************
void QBtWorkspace::diff( const QString& in_fname_1, const QString& in_fname_2 ) const
{
    const QString fname1  = QBtShared::quoted_fpath( in_fname_1 );
    const QString fname2  = QBtShared::quoted_fpath( in_fname_2 );
    const QString beediff = QBtShared::slashed_dir( QDir::homePath() ) + "/beediff/beediff %1 %2";
    bool          ok      = true;

    QBtSettings stt;
    QVariant data;
    if( stt.read( QBtConfig::DIFF_GROUP + QBtConfig::USE_DEFAULT_KEY, data ) ) {
        ok = data.toBool();
    }

    QString muster = beediff;
    if( !ok ) {
        if( stt.read( QBtConfig::DIFF_GROUP + QBtConfig::COMMAND_KEY, data ) ) {
            muster = data.toString().trimmed();
            if( muster.isEmpty() ) {
                return;
            }
        }
    }

    QProcess process;
    const QString cmd = muster.arg( fname1 ).arg( fname2 );
    process.startDetached( cmd );
}
Example #21
0
void ApplicationWindow::openLogfile()
{
        QDateTime dt = QDateTime::currentDateTime();
        QString Logfile=logfilePath;
            QProcess *p = new QProcess(this);
        p->startDetached("notepad.exe",QStringList() << Logfile);
}
void GwtCallback::browseUrl(QString url)
{
   QUrl qurl = QUrl::fromEncoded(url.toAscii());

#ifdef Q_WS_MAC
   if (qurl.scheme() == QString::fromAscii("file"))
   {
      QProcess open;
      QStringList args;
      // force use of Preview for PDFs (Adobe Reader 10.01 crashes)
      if (url.toLower().endsWith(QString::fromAscii(".pdf")))
      {
         args.append(QString::fromAscii("-a"));
         args.append(QString::fromAscii("Preview"));
         args.append(url);
      }
      else
      {
         args.append(url);
      }
      open.start(QString::fromAscii("open"), args);
      open.waitForFinished(5000);
      if (open.exitCode() != 0)
      {
         // Probably means that the file doesn't have a registered
         // application or something.
         QProcess reveal;
         reveal.startDetached(QString::fromAscii("open"), QStringList() << QString::fromAscii("-R") << url);
      }
      return;
   }
#endif

   desktop::openUrl(qurl);
}
Example #23
0
void Player::startRecordScreen() {

        if (!isStopRecord)
                return;

#if 0
        if(access(FIFO_NAME, F_OK) ==  -1)
        {
                fifo_fd = mkfifo(FIFO_NAME, 0777);
                if(fifo_fd < 0)
                {
                }
        }

#endif

        QProcess *myProcess = new QProcess();
        //   myProcess->startDetached("ffmpeg -f x11grab  -s 1366x768 -y -i :0.0+0+0
        //   /tmp/output.mp4");  only x11
        //    myProcess->startDetached("ffmpeg -r 25 -y -i /tmp/screen_pipe
        //    /tmp/output.mp4");  //slowly
        // myProcess->startDetached("avconv -f x11grab -s cif -y -r 25 -i :0.0
        // /tmp/output.mp4"); //only x11
        // myProcess->startDetached("ffmpeg  -f fbdev -y -r 25 -i /dev/fb0
        // /tmp/output.mp4"); //only linux fb
        myProcess->startDetached(
                                "ffmpeg -y -i udp://127.0.0.1:8888  /tmp/output.mp4");

#if 0
        fifo_fd = open(FIFO_NAME, O_WRONLY);
#endif
        isStopRecord = false;
        ui->recordstatus->show();
}
Example #24
0
void ProcessForker::_launch(const QString& command, const QString& workingDir,
                            const QStringList& env)
{
    for (const QString& var : env)
    {
        // Know Qt bug: QProcess::setProcessEnvironment() does not work with
        // startDetached(). Calling qputenv() directly as a workaround.
        const QStringList kv = var.split("=");
        if (kv.length() == 2 &&
            !qputenv(kv[0].toLocal8Bit().constData(), kv[1].toLocal8Bit()))
        {
            print_log(LOG_ERROR, LOG_GENERAL, "Setting %s ENV variable failed.",
                      var.toLocal8Bit().constData());
        }
    }

    // forcefully disable touch point compression to ensure every touch point
    // update is received on the QML side (e.g. necessary for the whiteboard).
    // See undocumented QML_NO_TOUCH_COMPRESSION env variable in
    // <qt5-source>/qtdeclarative/src/quick/items/qquickwindow.cpp
    qputenv("QML_NO_TOUCH_COMPRESSION", "1");

    QProcess* process = new QProcess();
    process->setWorkingDirectory(workingDir);
    process->startDetached(command);
}
Example #25
0
void QDesktopViewWidget::execDesktopSettings()
{
    QProcess commandLine;
    dSettings = new QSettings("chipara", "desktop");
    dSettings->beginGroup("window");
    commandLine.startDetached(dSettings->value("desktopSettings").toString());
    dSettings->endGroup();
}
Example #26
0
void StaticHelpers::OpenFolderNautilus(QString& file)
{
	QProcess* nautilus = new QProcess();
	QStringList arguments;
	arguments << "--browser" << file;
	nautilus->startDetached("nautilus", arguments);
	nautilus->deleteLater();
}
Example #27
0
//*******************************************************************
// touch                                                PRIVATE slot
//*******************************************************************
void QBtShared::touch( const QString& in_muster_fpath, const QString& in_dst_fpath )
{
   static const QString Touch ="touch -c -t %1 %2";
   static const QString Format ="yyyyMMddhhmm.ss";

   const QString dt  = QFileInfo( in_muster_fpath ).lastModified().toString( Format );
   const QString cmd = Touch.arg( dt ).arg( QBtShared::quoted_fpath( in_dst_fpath ) );
   QProcess process;
   process.startDetached( cmd );
}
Example #28
0
void Gaveta::open()
{
  QProcess process;
  process.startDetached("sudo", QStringList() << "python" << "/home/pi/py-thermal-printer-master/printer2.py");
  process.startDetached("sudo", QStringList() << "python" << "/home/pi/lemonpos/script/pulse.py");
  QFile file(printerDevice);
  if (file.open(QIODevice::ReadWrite)) {
    qDebug()<<"Pinter | Openning drawer...";
    QTextStream out(&file);
    out << "\x10\x14\x01\x00\x01";              // Pulse on pin 2 100 ms
    out << "\x10\x14\x01\x01\x01";              // Pulse on pin 5 100 ms
    QString msg = "\x10\x14\x01\x00\x01";
    qint64 r = file.write( msg.toUtf8() );
    qDebug()<<"bytes sent:"<<r;
    if (r == -1) { qDebug()<<"ERRROR Writing file.";}
    file.close();
  } else qDebug()<<"ERROR: Could not open printer...";

}
Example #29
0
void Updater::closeEvent(QCloseEvent *event)
{
    if (downFinished)
    {
        QProcess *process;
        process->startDetached(QDir::tempPath() + "/" + fileName);
        u_parent->close();
    }
    event->setAccepted(true);
}
Example #30
0
int main(int argc, char *argv[])
{
    QApplication    application(argc, argv);
    QMessageBox     msgBox;

    // Creating application's main window and a dispatcher object for communicating
    // between GUI and SkypeKit callbacks.

    mainForm            = new MainWindow();
    dispatcher          = new QSKSignalDispatcher();
    dispatcher->ConnectToUI();


    // Prefilling login credential input fields from command-line
    if (argc == 3) { mainForm->prefillLogin(argv[1], argv[2]); };

    // Attempting to programmatically start runtime.
    // Note that QProcess::startDetached leaves the shell terminal open on desktop.
    // For demp application this is ok - for production apps you might want go for other
    // methods of starting the runtime process. On Windows, ShellExecute will give you
    // an option to run a program with SW_HIDE switch, for example.

    QProcess runtime;
    if (!runtime.startDetached(runtimePath))
    {
        QMessageBox msgBox;
        msgBox.setText("ERROR: Unable to execute " + runtimePath);
        msgBox.exec();
    }
    else
    {
        skype = new QSKSkype();
        TransportInterface::Status skypeStatus;

        char* keyBuf = 0;
        getKeyPair (keyBuf);
        skypeStatus = skype->init(keyBuf, "127.0.0.1", 8963);

        if (skypeStatus != TransportInterface::OK)
        {
            msgBox.setText("ERROR: Could not connect to SkypeKit runtime. Are you using correct .pem file?");
            msgBox.exec();
        }
        else
        {
            skype->start();
            mainForm->on_EnableCallBtn(false);
            mainForm->show();
            application.exec();
        };

        skype->stop();
        delete skype;
    };
};