int UInputEventHandler::openUInputHandle() { int filehandle = -1; QTextStream err(stderr); QStringList locations; locations.append("/dev/input/uinput"); locations.append("/dev/uinput"); locations.append("/dev/misc/uinput"); QString possibleLocation; QStringListIterator iter(locations); while (iter.hasNext()) { QString temp = iter.next(); QFileInfo tempFileInfo(temp); if (tempFileInfo.exists()) { possibleLocation = temp; iter.toBack(); } } if (possibleLocation.isEmpty()) { lastErrorString = tr("Could not find a valid uinput device file.\n" "Please check that you have the uinput module loaded.\n" "lsmod | grep uinput"); err << lastErrorString << endl << endl; } else { //qDebug() << "LOCATION: " << possibleLocation; QByteArray tempArray = possibleLocation.toUtf8(); filehandle = open(tempArray.constData(), O_WRONLY | O_NONBLOCK); if (filehandle < 0) { lastErrorString = tr("Could not open uinput device file\n" "Please check that you have permission to write to the device"); lastErrorString.append("\n").append(possibleLocation); err << lastErrorString << endl << endl; //err << possibleLocation << endl << endl; } } return filehandle; }
/*! Processes the qdoc config file \a fileName. This is the controller for all of qdoc. */ static void processQdocconfFile(const QString &fileName) { #ifndef QT_NO_TRANSLATION QList<QTranslator *> translators; #endif /* The Config instance represents the configuration data for qdoc. All the other classes are initialized with the config. Here we initialize the configuration with some default values. */ Config config(tr("qdoc")); int i = 0; while (defaults[i].key) { config.setStringList(defaults[i].key, QStringList() << defaults[i].value); ++i; } config.setStringList(CONFIG_SYNTAXHIGHLIGHTING, QStringList(highlighting ? "true" : "false")); config.setStringList(CONFIG_SHOWINTERNAL, QStringList(showInternal ? "true" : "false")); config.setStringList(CONFIG_NOLINKERRORS, QStringList(noLinkErrors ? "true" : "false")); config.setStringList(CONFIG_OBSOLETELINKS, QStringList(obsoleteLinks ? "true" : "false")); QString documentationPath = QLibraryInfo::rawLocation(QLibraryInfo::DocumentationPath, QLibraryInfo::EffectivePaths); // Set a few environment variables that can be used from the qdocconf file qputenv("QT_INSTALL_DOCS", documentationPath.toLatin1()); /* With the default configuration values in place, load the qdoc configuration file. Note that the configuration file may include other configuration files. The Location class keeps track of the current location in the file being processed, mainly for error reporting purposes. */ Location::initialize(config); config.load(fileName); /* Add the defines to the configuration variables. */ QStringList defs = defines + config.getStringList(CONFIG_DEFINES); config.setStringList(CONFIG_DEFINES,defs); Location::terminate(); QString prevCurrentDir = QDir::currentPath(); QString dir = QFileInfo(fileName).path(); if (!dir.isEmpty()) QDir::setCurrent(dir); /* Initialize all the classes and data structures with the qdoc configuration. */ Location::initialize(config); Tokenizer::initialize(config); Doc::initialize(config); CodeMarker::initialize(config); CodeParser::initialize(config); Generator::initialize(config); #ifndef QT_NO_TRANSLATION /* Load the language translators, if the configuration specifies any. */ QStringList fileNames = config.getStringList(CONFIG_TRANSLATORS); QStringList::Iterator fn = fileNames.constBegin(); while (fn != fileNames.constEnd()) { QTranslator *translator = new QTranslator(0); if (!translator->load(*fn)) config.lastLocation().error(tr("Cannot load translator '%1'") .arg(*fn)); QCoreApplication::instance()->installTranslator(translator); translators.append(translator); ++fn; } #endif //QSet<QString> outputLanguages = config.getStringSet(CONFIG_OUTPUTLANGUAGES); /* Get the source language (Cpp) from the configuration and the location in the configuration file where the source language was set. */ QString lang = config.getString(CONFIG_LANGUAGE); Location langLocation = config.lastLocation(); /* Initialize the qdoc database, where all the parsed source files will be stored. The database includes a tree of nodes, which gets built as the source files are parsed. The documentation output is generated by traversing that tree. */ QDocDatabase* qdb = QDocDatabase::qdocDB(); qdb->setVersion(config.getString(CONFIG_VERSION)); /* By default, the only output format is HTML. */ QSet<QString> outputFormats = config.getOutputFormats(); Location outputFormatsLocation = config.lastLocation(); /* Read some XML indexes containing definitions from other documentation sets. */ QStringList indexFiles = config.getStringList(CONFIG_INDEXES); dependModules += config.getStringList(CONFIG_DEPENDS); // Allow modules and third-party application/libraries to link // to the Qt docs without having to explicitly pass --indexdir. if (!indexDirs.contains(documentationPath)) indexDirs.append(documentationPath); if (dependModules.size() > 0) { if (indexDirs.size() > 0) { for (int i = 0; i < indexDirs.size(); i++) { if (indexDirs[i].startsWith("..")) { const QString prefix(QDir(dir).relativeFilePath(prevCurrentDir)); if (!prefix.isEmpty()) indexDirs[i].prepend(prefix + QLatin1Char('/')); } } /* Add all subdirectories of the indexdirs as dependModules when an asterisk is used in the 'depends' list. */ if (dependModules.contains("*")) { dependModules.removeOne("*"); for (int i = 0; i < indexDirs.size(); i++) { QDir scanDir = QDir(indexDirs[i]); scanDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); QFileInfoList dirList = scanDir.entryInfoList(); for (int j = 0; j < dirList.size(); j++) { if (dirList[j].fileName().toLower() != config.getString(CONFIG_PROJECT).toLower()) dependModules.append(dirList[j].fileName()); } } } for (int i = 0; i < dependModules.size(); i++) { QString indexToAdd; QList<QFileInfo> foundIndices; for (int j = 0; j < indexDirs.size(); j++) { QString fileToLookFor = indexDirs[j] + QLatin1Char('/') + dependModules[i] + QLatin1Char('/') + dependModules[i] + QLatin1String(".index"); if (QFile::exists(fileToLookFor)) { QFileInfo tempFileInfo(fileToLookFor); if (!foundIndices.contains(tempFileInfo)) foundIndices.append(tempFileInfo); } } qSort(foundIndices.begin(), foundIndices.end(), creationTimeBefore); if (foundIndices.size() > 1) { /* QDoc should always use the last entry in the multimap when there are multiple index files for a module, since the last modified file has the highest UNIX timestamp. */ qDebug() << "Multiple indices found for dependency:" << dependModules[i] << "\nFound:"; for (int k = 0; k < foundIndices.size(); k++) qDebug() << foundIndices[k].absoluteFilePath(); qDebug() << "Using" << foundIndices[foundIndices.size() - 1].absoluteFilePath() << "as index for" << dependModules[i]; indexToAdd = foundIndices[foundIndices.size() - 1].absoluteFilePath(); } else if (foundIndices.size() == 1) { indexToAdd = foundIndices[0].absoluteFilePath(); } else { qDebug() << "No indices for" << dependModules[i] << "could be found in the specified index directories."; } if (!indexToAdd.isEmpty() && !indexFiles.contains(indexToAdd)) indexFiles << indexToAdd; } } else { qDebug() << "Dependant modules specified, but no index directories or install directory were set." << "There will probably be errors for missing links."; } } qdb->readIndexes(indexFiles); QSet<QString> excludedDirs; QSet<QString> excludedFiles; QStringList headerList; QStringList sourceList; QStringList excludedDirsList; QStringList excludedFilesList; Generator::debugSegfault("Reading excludedirs"); excludedDirsList = config.getCanonicalRelativePathList(CONFIG_EXCLUDEDIRS); foreach (const QString &excludeDir, excludedDirsList) { QString p = QDir::fromNativeSeparators(excludeDir); excludedDirs.insert(p); }
void CDoodFileViewManager::openFile() { QFileInfo tempFileInfo(mPath); QDesktopServices::openUrl(QUrl(tempFileInfo.absolutePath(), QUrl::TolerantMode)); }
static void loadIndexFiles(Config& config) { QDocDatabase* qdb = QDocDatabase::qdocDB(); /* Read some XML indexes containing definitions from other documentation sets. */ QStringList indexFiles = config.getStringList(CONFIG_INDEXES); dependModules += config.getStringList(CONFIG_DEPENDS); // Allow modules and third-party application/libraries to link // to the Qt docs without having to explicitly pass --indexdir. if (!indexDirs.contains(documentationPath)) indexDirs.append(documentationPath); if (dependModules.size() > 0) { if (indexDirs.size() > 0) { for (int i = 0; i < indexDirs.size(); i++) { if (indexDirs[i].startsWith("..")) { const QString prefix(QDir(currentDir).relativeFilePath(prevCurrentDir)); if (!prefix.isEmpty()) indexDirs[i].prepend(prefix + QLatin1Char('/')); } } /* Add all subdirectories of the indexdirs as dependModules, when an asterisk is used in the 'depends' list. */ if (dependModules.contains("*")) { dependModules.removeOne("*"); for (int i = 0; i < indexDirs.size(); i++) { QDir scanDir = QDir(indexDirs[i]); scanDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); QFileInfoList dirList = scanDir.entryInfoList(); for (int j = 0; j < dirList.size(); j++) { if (dirList[j].fileName().toLower() != config.getString(CONFIG_PROJECT).toLower()) dependModules.append(dirList[j].fileName()); } } } for (int i = 0; i < dependModules.size(); i++) { QString indexToAdd; QList<QFileInfo> foundIndices; for (int j = 0; j < indexDirs.size(); j++) { QString fileToLookFor = indexDirs[j] + QLatin1Char('/') + dependModules[i] + QLatin1Char('/') + dependModules[i] + QLatin1String(".index"); if (QFile::exists(fileToLookFor)) { QFileInfo tempFileInfo(fileToLookFor); if (!foundIndices.contains(tempFileInfo)) foundIndices.append(tempFileInfo); } } qSort(foundIndices.begin(), foundIndices.end(), creationTimeBefore); if (foundIndices.size() > 1) { /* QDoc should always use the last entry in the multimap when there are multiple index files for a module, since the last modified file has the highest UNIX timestamp. */ qDebug() << "Multiple indices found for dependency:" << dependModules[i] << "\nFound:"; for (int k = 0; k < foundIndices.size(); k++) qDebug() << foundIndices[k].absoluteFilePath(); qDebug() << "Using" << foundIndices[foundIndices.size() - 1].absoluteFilePath() << "as index for" << dependModules[i]; indexToAdd = foundIndices[foundIndices.size() - 1].absoluteFilePath(); } else if (foundIndices.size() == 1) { indexToAdd = foundIndices[0].absoluteFilePath(); } if (!indexToAdd.isEmpty() && !indexFiles.contains(indexToAdd)) indexFiles << indexToAdd; } } else { qDebug() << "Dependant modules specified, but no index directories or " << "install directory were set." << "There will probably be errors for missing links."; } } qdb->readIndexes(indexFiles); }
QString JoyButtonSlot::getSlotString() { QString newlabel; if (deviceCode >= 0) { if (mode == JoyButtonSlot::JoyKeyboard) { unsigned int tempDeviceCode = deviceCode; #ifdef Q_OS_WIN QtKeyMapperBase *nativeWinKeyMapper = AntKeyMapper::getInstance()->getNativeKeyMapper(); if (nativeWinKeyMapper) { tempDeviceCode = nativeWinKeyMapper->returnVirtualKey(qkeyaliasCode); } #endif newlabel = newlabel.append(keysymToKeyString(tempDeviceCode, qkeyaliasCode).toUpper()); } else if (mode == JoyButtonSlot::JoyMouseButton) { newlabel.append(tr("Mouse")).append(" "); switch (deviceCode) { case 1: newlabel.append(tr("LB")); break; case 2: newlabel.append(tr("MB")); break; case 3: newlabel.append(tr("RB")); break; #ifdef Q_OS_WIN case 8: newlabel.append(tr("B4")); break; case 9: newlabel.append(tr("B5")); break; #endif default: newlabel.append(QString::number(deviceCode)); break; } } else if (mode == JoyMouseMovement) { newlabel.append(movementString()); } else if (mode == JoyPause) { int minutes = deviceCode / 1000 / 60; int seconds = (deviceCode / 1000 % 60); int hundredths = deviceCode % 1000 / 10; newlabel.append(tr("Pause")).append(" "); if (minutes > 0) { newlabel.append(QString("%1:").arg(minutes, 2, 10, QChar('0'))); } newlabel.append(QString("%1.%2") .arg(seconds, 2, 10, QChar('0')) .arg(hundredths, 2, 10, QChar('0'))); } else if (mode == JoyHold) { int minutes = deviceCode / 1000 / 60; int seconds = (deviceCode / 1000 % 60); int hundredths = deviceCode % 1000 / 10; newlabel.append(tr("Hold")).append(" "); if (minutes > 0) { newlabel.append(QString("%1:").arg(minutes, 2, 10, QChar('0'))); } newlabel.append(QString("%1.%2") .arg(seconds, 2, 10, QChar('0')) .arg(hundredths, 2, 10, QChar('0'))); } else if (mode == JoyButtonSlot::JoyCycle) { newlabel.append(tr("Cycle")); } else if (mode == JoyDistance) { QString temp(tr("Distance")); temp.append(" ").append(QString::number(deviceCode).append("%")); newlabel.append(temp); } else if (mode == JoyRelease) { int minutes = deviceCode / 1000 / 60; int seconds = (deviceCode / 1000 % 60); int hundredths = deviceCode % 1000 / 10; newlabel.append(tr("Release")).append(" "); if (minutes > 0) { newlabel.append(QString("%1:").arg(minutes, 2, 10, QChar('0'))); } newlabel.append(QString("%1.%2") .arg(seconds, 2, 10, QChar('0')) .arg(hundredths, 2, 10, QChar('0'))); } else if (mode == JoyMouseSpeedMod) { QString temp; temp.append(tr("Mouse Mod")).append(" "); temp.append(QString::number(deviceCode).append("%")); newlabel.append(temp); } else if (mode == JoyKeyPress) { int minutes = deviceCode / 1000 / 60; int seconds = (deviceCode / 1000 % 60); int hundredths = deviceCode % 1000 / 10; QString temp; temp.append(tr("Press Time")).append(" "); if (minutes > 0) { temp.append(QString("%1:").arg(minutes, 2, 10, QChar('0'))); } temp.append(QString("%1.%2") .arg(seconds, 2, 10, QChar('0')) .arg(hundredths, 2, 10, QChar('0'))); newlabel.append(temp); } else if (mode == JoyDelay) { int minutes = deviceCode / 1000 / 60; int seconds = (deviceCode / 1000 % 60); int hundredths = deviceCode % 1000 / 10; QString temp; temp.append(tr("Delay")).append(" "); if (minutes > 0) { temp.append(QString("%1:").arg(minutes, 2, 10, QChar('0'))); } temp.append(QString("%1.%2") .arg(seconds, 2, 10, QChar('0')) .arg(hundredths, 2, 10, QChar('0'))); newlabel.append(temp); } else if (mode == JoyLoadProfile) { if (!textData.isEmpty()) { QFileInfo profileInfo(textData); QString temp; temp.append(tr("Load %1").arg(profileInfo.baseName())); newlabel.append(temp); } } else if (mode == JoySetChange) { newlabel.append(tr("Set Change %1").arg(deviceCode+1)); } else if (mode == JoyTextEntry) { QString temp = textData; if (temp.length() > MAXTEXTENTRYDISPLAYLENGTH) { temp.truncate(MAXTEXTENTRYDISPLAYLENGTH - 3); temp.append("..."); } newlabel.append(tr("[Text] %1").arg(temp)); } else if (mode == JoyExecute) { QString temp; if (!textData.isEmpty()) { QFileInfo tempFileInfo(textData); temp.append(tempFileInfo.fileName()); } newlabel.append(tr("[Exec] %1").arg(temp)); } } else { newlabel = newlabel.append(tr("[NO KEY]")); } return newlabel; }