InputSourceRef InputSource::getFileInDocuments(const fs::path &relativePath) { auto source = InputSource::getFile(getDocumentsDirectory() / relativePath); source->relativePath = relativePath; return source; }
const char* g_getProperty(const char* what, const char* arg) { QString returnedProperty = ""; QString argGet = QString::fromUtf8(arg); int arg1 = 0; int arg2 = 0; int arg3 = 0; QString argString = ""; if ( g_checkStringProperty(false,what)) { argString = argGet; argString.replace("\\","\\\\"); } else { QStringList arrayArg = argGet.split("|",QString::KeepEmptyParts); arg1 = arrayArg.at(0).toInt(); arg2 = arrayArg.at(1).toInt(); arg3 = arrayArg.at(2).toInt(); } /*------------------------------------------------------------------*/ if (strcmp(what, "windowPosition") == 0) { returnedProperty.append( QString::number(MainWindow::getInstance()->pos().x()) ); returnedProperty.append("|"); returnedProperty.append( QString::number(MainWindow::getInstance()->pos().y()) ); /*------------------------------------------------------------------*/ } else if (strcmp(what, "windowSize") == 0) { returnedProperty.append( QString::number(MainWindow::getInstance()->windowSize().width()) ); returnedProperty.append("|"); returnedProperty.append( QString::number(MainWindow::getInstance()->windowSize().height()) ); /*------------------------------------------------------------------*/ } else if (strcmp(what, "screenSize") == 0) { returnedProperty.append( QString::number(QApplication::desktop()->availableGeometry().width()) ); returnedProperty.append("|"); returnedProperty.append( QString::number(QApplication::desktop()->availableGeometry().height()) ); /*------------------------------------------------------------------*/ } else if (strcmp(what, "cursorPosition") == 0) { returnedProperty.append( QString::number(QCursor::pos().x()) ); returnedProperty.append("|"); returnedProperty.append( QString::number(QCursor::pos().y()) ); /*------------------------------------------------------------------*/ } else if (strcmp(what, "clipboard") == 0) { QClipboard *clipboard = QApplication::clipboard(); returnedProperty.append("s"); returnedProperty.append( clipboard->text() ); /*------------------------------------------------------------------*/ } else if (strcmp(what, "windowTitle") == 0) { returnedProperty.append("s"); returnedProperty.append( MainWindow::getInstance()->windowTitle() ); /*------------------------------------------------------------------*/ } else if (strcmp(what, "directory") == 0) { QStringList acceptedValue; acceptedValue << "executable" << "document" << "desktop" << "temporary" << "data" ; acceptedValue << "music" << "movies" << "pictures" << "cache" << "download" ; acceptedValue << "home"; if (acceptedValue.contains(argString)) { QString pathGet = ""; if (argString == "executable") { pathGet = QDir::currentPath(); } else if (argString == "document") { pathGet = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); } else if (argString == "desktop") { pathGet = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); } else if (argString == "temporary") { pathGet = QStandardPaths::writableLocation(QStandardPaths::TempLocation); } else if (argString == "data") { #ifdef RASPBERRY_PI pathGet = QStandardPaths::writableLocation(QStandardPaths::DataLocation); #else pathGet = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); #endif } else if (argString == "music") { pathGet = QStandardPaths::writableLocation(QStandardPaths::MusicLocation); } else if (argString == "movies") { pathGet = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation); } else if (argString == "pictures") { pathGet = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); } else if (argString == "cache") { pathGet = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); } else if (argString == "download") { pathGet = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); } else if (argString == "home") { pathGet = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); } else { } returnedProperty.append("s"); returnedProperty.append( pathGet ); } else { QString info = "Accepted value for "; info.append(what); info.append(" :"); MainWindow::getInstance()->printToOutput(info.toStdString().c_str()); for( int i=0; i<acceptedValue.size(); ++i ) { MainWindow::getInstance()->printToOutput( QString("- ").append(acceptedValue.at(i)).toStdString().c_str() ); } } /*------------------------------------------------------------------*/ } else if ((strcmp(what, "openDirectoryDialog") == 0) || (strcmp(what, "openFileDialog") == 0) || (strcmp(what, "saveFileDialog") == 0)) { QStringList dialogArg = argString.split("|",QString::KeepEmptyParts); if(dialogArg.size() == 1) { MainWindow::getInstance()->printToOutput("[[Usage Example]]"); if (strcmp(what, "openDirectoryDialog") == 0) { MainWindow::getInstance()->printToOutput("application:get(\"openDirectoryDialog\",\"Open Directory|C:/)\")"); } else if (strcmp(what, "openFileDialog") == 0) { MainWindow::getInstance()->printToOutput("application:get(\"openFileDialog\",\"Open File|C:/|Text File (*.txt);;Image File (*.jpg *.png)\")"); } else if (strcmp(what, "saveFileDialog") == 0) { MainWindow::getInstance()->printToOutput("application:get(\"saveFileDialog\",\"Save File|C:/|Text File (*.txt);;Image File (*.jpg *.png)\")"); } } else { QString title = dialogArg.at(0); QString place = ""; QString extension = ""; if (dialogArg.size() >= 2) { place = dialogArg.at(1); } if (dialogArg.size() >= 3) { extension = dialogArg.at(2); } QString fileName = ""; if (strcmp(what, "openDirectoryDialog") == 0) { fileName = QFileDialog::getExistingDirectory(MainWindow::getInstance(),title ,place, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); } else if (strcmp(what, "openFileDialog") == 0) { fileName = QFileDialog::getOpenFileName(MainWindow::getInstance(), title,place,extension); } else if (strcmp(what, "saveFileDialog") == 0) { fileName = QFileDialog::getSaveFileName(MainWindow::getInstance(), title,place,extension); } returnedProperty.append("s"); returnedProperty.append( fileName ); } /*------------------------------------------------------------------*/ } else if (strcmp(what, "temporaryDirectory") == 0) { returnedProperty.append("s"); returnedProperty.append( QString::fromUtf8( getTemporaryDirectory() ) ); /*------------------------------------------------------------------*/ } else if (strcmp(what, "documentDirectory") == 0) { returnedProperty.append("s"); returnedProperty.append( QString::fromUtf8( getDocumentsDirectory() ) ); /*------------------------------------------------------------------*/ } else { // feel free to change this list QStringList acceptedWhat; acceptedWhat << "[x,y] windowPosition"; acceptedWhat << "[w,h] windowSize"; acceptedWhat << "[w,h] screenSize"; acceptedWhat << "[x,y] cursorPosition"; acceptedWhat << "[text] clipboard"; acceptedWhat << "[text] windowTitle"; acceptedWhat << "[path] directory(where//help)"; acceptedWhat << "[path] openDirectoryDialog(title|path//help)"; acceptedWhat << "[path] openFileDialog(title|path|extensions//help)"; acceptedWhat << "[path] saveFileDialog(title|path|extensions//help)"; acceptedWhat << "[path] documentDirectory"; acceptedWhat << "[path] temporaryDirectory"; MainWindow::getInstance()->printToOutput("Accepted value for Desktop's application:get()"); for( int i=0; i<acceptedWhat.size(); ++i ) { MainWindow::getInstance()->printToOutput( QString("- ").append(acceptedWhat.at(i)).toStdString().c_str() ); } } return returnedProperty.toStdString().c_str(); }