void TabletSupport::start() { if(hasDevice()) { auto dispacher = QAbstractEventDispatcher::instance(window_->thread()); dispacher->installNativeEventFilter(this); } }
MainApplication::MainApplication(int& argc, char** argv) : QApplication(argc, argv), m_queuedFile() { #if defined(LMMS_BUILD_WIN32) && QT_VERSION >= 0x050000 installNativeEventFilter(this); #endif }
// Constructor. qsynthApplication(int& argc, char **argv) : QApplication(argc, argv), m_pQtTranslator(0), m_pMyTranslator(0), m_pWidget(0) { // Load translation support. QLocale loc; if (loc.language() != QLocale::C) { // Try own Qt translation... m_pQtTranslator = new QTranslator(this); QString sLocName = "qt_" + loc.name(); QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); if (m_pQtTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pQtTranslator); } else { delete m_pQtTranslator; m_pQtTranslator = 0; #ifdef CONFIG_DEBUG qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", loc.name().toLocal8Bit().data(), sLocPath.toLocal8Bit().data(), sLocName.toLocal8Bit().data()); #endif } // Try own application translation... m_pMyTranslator = new QTranslator(this); sLocName = "qsynth_" + loc.name(); if (m_pMyTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pMyTranslator); } else { sLocPath = CONFIG_DATADIR "/qsynth/translations"; if (m_pMyTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pMyTranslator); } else { delete m_pMyTranslator; m_pMyTranslator = 0; #ifdef CONFIG_DEBUG qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", loc.name().toLocal8Bit().data(), sLocPath.toLocal8Bit().data(), sLocName.toLocal8Bit().data()); #endif } } } #ifdef CONFIG_X11 #ifdef CONFIG_XUNIQUE // Instance uniqueness initialization... m_pDisplay = QX11Info::display(); m_aUnique = XInternAtom(m_pDisplay, QSYNTH_XUNIQUE, false); XGrabServer(m_pDisplay); m_wOwner = XGetSelectionOwner(m_pDisplay, m_aUnique); XUngrabServer(m_pDisplay); #if QT_VERSION >= 0x050100 m_pXcbEventFilter = new qsynthXcbEventFilter(this); installNativeEventFilter(m_pXcbEventFilter); #endif #endif // CONFIG_XUNIQUE #endif // CONFIG_X11 }
TouchApplication::TouchApplication(int& argc, char** argv) : QApplication(argc, argv), inputState(None) { // prevent Qt from handling touch to mouse translation QCoreApplication::setAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents, false); acceptCount = 0; #ifdef Q_OS_WIN // native event filter for handling WM_POINTER messages installNativeEventFilter(new WinInputFilter); #endif }
// Constructor. qjackctlApplication(int& argc, char **argv) : QApplication(argc, argv), m_pQtTranslator(0), m_pMyTranslator(0), m_pWidget(0) { // Load translation support. QLocale loc; if (loc.language() != QLocale::C) { // Try own Qt translation... m_pQtTranslator = new QTranslator(this); QString sLocName = "qt_" + loc.name(); QString sLocPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath); if (m_pQtTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pQtTranslator); } else { delete m_pQtTranslator; m_pQtTranslator = 0; #ifdef CONFIG_DEBUG qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", loc.name().toUtf8().constData(), sLocPath.toUtf8().constData(), sLocName.toUtf8().constData()); #endif } // Try own application translation... m_pMyTranslator = new QTranslator(this); sLocName = "qjackctl_" + loc.name(); if (m_pMyTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pMyTranslator); } else { sLocPath = CONFIG_DATADIR "/qjackctl/translations"; if (m_pMyTranslator->load(sLocName, sLocPath)) { QApplication::installTranslator(m_pMyTranslator); } else { delete m_pMyTranslator; m_pMyTranslator = 0; #ifdef CONFIG_DEBUG qWarning("Warning: no translation found for '%s' locale: %s/%s.qm", loc.name().toUtf8().constData(), sLocPath.toUtf8().constData(), sLocName.toUtf8().constData()); #endif } } } #ifdef CONFIG_X11 #ifdef CONFIG_XUNIQUE m_pDisplay = NULL; m_wOwner = None; #if QT_VERSION >= 0x050100 m_pXcbEventFilter = new qjackctlXcbEventFilter(this); installNativeEventFilter(m_pXcbEventFilter); #endif #endif // CONFIG_XUNIQUE #endif // CONFIG_X11 }
Application::Application(int &argc, char **argv) : SingleApplication(argc, argv) { #if QT_VERSION >= 0x050000 installNativeEventFilter(this); #endif QIcon::setThemeName(QLatin1String("oxygen")); #if QT_VERSION >= 0x050400 if (Settings::self()->retinaSupport()) { setAttribute(Qt::AA_UseHighDpiPixmaps); } #endif }
App::App(int argc, char** argv): QGuiApplication(argc, argv) ,m_eventFilter(new XcbEventFilter) ,m_init(false) ,m_bus(0) ,m_impanel(0) ,m_keyboardGrabbed(false) ,m_doGrab(false) ,m_syms(0) { m_syms = xcb_key_symbols_alloc(QX11Info::connection()); installNativeEventFilter(m_eventFilter.data()); ibus_init (); m_bus = ibus_bus_new (); g_signal_connect (m_bus, "connected", G_CALLBACK (ibus_connected_cb), this); g_signal_connect (m_bus, "disconnected", G_CALLBACK (ibus_disconnected_cb), this); if (ibus_bus_is_connected (m_bus)) { init(); } initIconMap(m_iconMap); }
void PsApplication::psInstallEventFilter() { delete _psEventFilter; _psEventFilter = new _PsEventFilter(); installNativeEventFilter(_psEventFilter); }
void Application::setupEventFilters() { installNativeEventFilter(m_eventFilter.data()); }
/*! Constructor. */ TWebApplication::TWebApplication(int &argc, char **argv) #ifdef TF_USE_GUI_MODULE : QApplication(argc, argv), #else : QCoreApplication(argc, argv), #endif dbEnvironment(DEFAULT_DATABASE_ENVIRONMENT), sqlSettings(0), mongoSetting(0), redisSetting(0), loggerSetting(0), validationSetting(0), mediaTypes(0), codecInternal(0), codecHttp(0), appServerId(-1), mpm(Invalid) { #if defined(Q_OS_WIN) && QT_VERSION >= 0x050000 installNativeEventFilter(new TNativeEventFilter); #endif // parse command-line args webRootAbsolutePath = "."; QStringList args = arguments(); args.removeFirst(); for (QStringListIterator i(args); i.hasNext(); ) { const QString &arg = i.next(); if (arg.startsWith('-')) { if (arg == "-e" && i.hasNext()) { dbEnvironment = i.next(); } if (arg == "-i" && i.hasNext()) { appServerId = i.next().toInt(); } } else { if (QDir(arg).exists()) { webRootAbsolutePath = arg; if (!webRootAbsolutePath.endsWith(QDir::separator())) webRootAbsolutePath += QDir::separator(); } } } QDir webRoot(webRootAbsolutePath); if (webRoot.exists()) { webRootAbsolutePath = webRoot.absolutePath() + QDir::separator(); } // Sets application name QString appName = QDir(webRootAbsolutePath).dirName(); if (!appName.isEmpty()) { setApplicationName(appName); } // Creates settings objects TAppSettings::instantiate(appSettingsFilePath()); loggerSetting = new QSettings(configPath() + "logger.ini", QSettings::IniFormat, this); validationSetting = new QSettings(configPath() + "validation.ini", QSettings::IniFormat, this); mediaTypes = new QSettings(configPath() + "initializers" + QDir::separator() + "internet_media_types.ini", QSettings::IniFormat, this); // Gets codecs codecInternal = searchCodec(Tf::appSettings()->value(Tf::InternalEncoding).toByteArray().trimmed().data()); codecHttp = searchCodec(Tf::appSettings()->value(Tf::HttpOutputEncoding).toByteArray().trimmed().data()); // Sets codecs for INI files loggerSetting->setIniCodec(codecInternal); validationSetting->setIniCodec(codecInternal); mediaTypes->setIniCodec(codecInternal); // SQL DB settings QString dbsets = Tf::appSettings()->value(Tf::SqlDatabaseSettingsFiles).toString().trimmed(); if (dbsets.isEmpty()) { dbsets = Tf::appSettings()->readValue("DatabaseSettingsFiles").toString().trimmed(); } const QStringList files = dbsets.split(QLatin1Char(' '), QString::SkipEmptyParts); for (auto &f : files) { QSettings *set = new QSettings(configPath() + f, QSettings::IniFormat, this); set->setIniCodec(codecInternal); sqlSettings.append(set); } // MongoDB settings QString mongoini = Tf::appSettings()->value(Tf::MongoDbSettingsFile).toString().trimmed(); if (!mongoini.isEmpty()) { QString mnginipath = configPath() + mongoini; if (QFile(mnginipath).exists()) mongoSetting = new QSettings(mnginipath, QSettings::IniFormat, this); } // Redis settings QString redisini = Tf::appSettings()->value(Tf::RedisSettingsFile).toString().trimmed(); if (!redisini.isEmpty()) { QString redisinipath = configPath() + redisini; if (QFile(redisinipath).exists()) redisSetting = new QSettings(redisinipath, QSettings::IniFormat, this); } }
Application::Application(int &argc, char **argv) : SingleApplication(argc, argv) { installNativeEventFilter(this); setAttribute(Qt::AA_DontShowIconsInMenus, true); }
AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : QCoreApplication(argc, argv) { # ifndef WIN32 setvbuf(stdout, NULL, _IOLBF, 0); # endif // setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us # ifdef _WIN32 installNativeEventFilter(&ShutdownEventListener::getInstance()); # else ShutdownEventListener::getInstance(); # endif // parse command-line QCommandLineParser parser; parser.setApplicationDescription("High Fidelity Assignment Client"); parser.addHelpOption(); const QCommandLineOption helpOption = parser.addHelpOption(); const QCommandLineOption clientTypeOption(ASSIGNMENT_TYPE_OVERRIDE_OPTION, "run single assignment client of given type", "type"); parser.addOption(clientTypeOption); const QCommandLineOption poolOption(ASSIGNMENT_POOL_OPTION, "set assignment pool", "pool-name"); parser.addOption(poolOption); const QCommandLineOption portOption(ASSIGNMENT_CLIENT_LISTEN_PORT_OPTION, "UDP port for this assignment client (or monitor)", "port"); parser.addOption(portOption); const QCommandLineOption walletDestinationOption(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION, "set wallet destination", "wallet-uuid"); parser.addOption(walletDestinationOption); const QCommandLineOption assignmentServerHostnameOption(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION, "set assignment-server hostname", "hostname"); parser.addOption(assignmentServerHostnameOption); const QCommandLineOption assignmentServerPortOption(CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION, "set assignment-server port", "port"); parser.addOption(assignmentServerPortOption); const QCommandLineOption numChildsOption(ASSIGNMENT_NUM_FORKS_OPTION, "number of children to fork", "child-count"); parser.addOption(numChildsOption); const QCommandLineOption minChildsOption(ASSIGNMENT_MIN_FORKS_OPTION, "minimum number of children", "child-count"); parser.addOption(minChildsOption); const QCommandLineOption maxChildsOption(ASSIGNMENT_MAX_FORKS_OPTION, "maximum number of children", "child-count"); parser.addOption(maxChildsOption); const QCommandLineOption monitorPortOption(ASSIGNMENT_CLIENT_MONITOR_PORT_OPTION, "assignment-client monitor port", "port"); parser.addOption(monitorPortOption); const QCommandLineOption httpStatusPortOption(ASSIGNMENT_HTTP_STATUS_PORT, "http status server port", "http-status-port"); parser.addOption(httpStatusPortOption); const QCommandLineOption logDirectoryOption(ASSIGNMENT_LOG_DIRECTORY, "directory to store logs", "log-directory"); parser.addOption(logDirectoryOption); if (!parser.parse(QCoreApplication::arguments())) { qCritical() << parser.errorText() << endl; parser.showHelp(); Q_UNREACHABLE(); } if (parser.isSet(helpOption)) { parser.showHelp(); Q_UNREACHABLE(); } const QVariantMap argumentVariantMap = HifiConfigVariantMap::mergeCLParametersWithJSONConfig(arguments()); unsigned int numForks = 0; if (parser.isSet(numChildsOption)) { numForks = parser.value(numChildsOption).toInt(); } unsigned int minForks = 0; if (parser.isSet(minChildsOption)) { minForks = parser.value(minChildsOption).toInt(); } unsigned int maxForks = 0; if (parser.isSet(maxChildsOption)) { maxForks = parser.value(maxChildsOption).toInt(); } unsigned short monitorPort = 0; if (parser.isSet(monitorPortOption)) { monitorPort = parser.value(monitorPortOption).toUShort(); } if (!numForks && minForks) { // if the user specified --min but not -n, set -n to --min numForks = minForks; } quint16 httpStatusPort { 0 }; if (parser.isSet(httpStatusPortOption)) { httpStatusPort = parser.value(httpStatusPortOption).toUShort(); } QString logDirectory; if (parser.isSet(logDirectoryOption)) { logDirectory = parser.value(logDirectoryOption); } Assignment::Type requestAssignmentType = Assignment::AllTypes; if (argumentVariantMap.contains(ASSIGNMENT_TYPE_OVERRIDE_OPTION)) { requestAssignmentType = (Assignment::Type) argumentVariantMap.value(ASSIGNMENT_TYPE_OVERRIDE_OPTION).toInt(); } if (parser.isSet(clientTypeOption)) { requestAssignmentType = (Assignment::Type) parser.value(clientTypeOption).toInt(); } QString assignmentPool; // check for an assignment pool passed on the command line or in the config if (argumentVariantMap.contains(ASSIGNMENT_POOL_OPTION)) { assignmentPool = argumentVariantMap.value(ASSIGNMENT_POOL_OPTION).toString(); } if (parser.isSet(poolOption)) { assignmentPool = parser.value(poolOption); } QUuid walletUUID; if (argumentVariantMap.contains(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION)) { walletUUID = argumentVariantMap.value(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION).toString(); } if (parser.isSet(walletDestinationOption)) { walletUUID = parser.value(walletDestinationOption); } QString assignmentServerHostname; if (argumentVariantMap.contains(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION)) { assignmentServerHostname = argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION).toString(); } if (parser.isSet(assignmentServerHostnameOption)) { assignmentServerHostname = parser.value(assignmentServerHostnameOption); } // check for an overriden assignment server port quint16 assignmentServerPort = DEFAULT_DOMAIN_SERVER_PORT; if (argumentVariantMap.contains(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION)) { assignmentServerPort = argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION).toUInt(); } if (parser.isSet(assignmentServerPortOption)) { assignmentServerPort = parser.value(assignmentServerPortOption).toInt(); } // check for an overidden listen port quint16 listenPort = 0; if (argumentVariantMap.contains(ASSIGNMENT_CLIENT_LISTEN_PORT_OPTION)) { listenPort = argumentVariantMap.value(ASSIGNMENT_CLIENT_LISTEN_PORT_OPTION).toUInt(); } if (parser.isSet(numChildsOption)) { if (minForks && minForks > numForks) { qCritical() << "--min can't be more than -n"; parser.showHelp(); Q_UNREACHABLE(); } if (maxForks && maxForks < numForks) { qCritical() << "--max can't be less than -n"; parser.showHelp(); Q_UNREACHABLE(); } } QThread::currentThread()->setObjectName("main thread"); DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); if (numForks || minForks || maxForks) { AssignmentClientMonitor* monitor = new AssignmentClientMonitor(numForks, minForks, maxForks, requestAssignmentType, assignmentPool, listenPort, walletUUID, assignmentServerHostname, assignmentServerPort, httpStatusPort, logDirectory); monitor->setParent(this); connect(this, &QCoreApplication::aboutToQuit, monitor, &AssignmentClientMonitor::aboutToQuit); } else { AssignmentClient* client = new AssignmentClient(requestAssignmentType, assignmentPool, listenPort, walletUUID, assignmentServerHostname, assignmentServerPort, monitorPort); client->setParent(this); connect(this, &QCoreApplication::aboutToQuit, client, &AssignmentClient::aboutToQuit); } }
void setMainWindow (MainWindow * mw) { installNativeEventFilter(this); m_main_window = mw; }
AssignmentClient::AssignmentClient(int &argc, char **argv) : QCoreApplication(argc, argv), _assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME), _localASPortSharedMem(NULL) { LogUtils::init(); setOrganizationName("High Fidelity"); setOrganizationDomain("highfidelity.io"); setApplicationName("assignment-client"); QSettings::setDefaultFormat(QSettings::IniFormat); // setup a shutdown event listener to handle SIGTERM or WM_CLOSE for us #ifdef _WIN32 installNativeEventFilter(&ShutdownEventListener::getInstance()); #else ShutdownEventListener::getInstance(); #endif // set the logging target to the the CHILD_TARGET_NAME LogHandler::getInstance().setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME); const QVariantMap argumentVariantMap = HifiConfigVariantMap::mergeCLParametersWithJSONConfig(arguments()); const QString ASSIGNMENT_TYPE_OVERRIDE_OPTION = "t"; const QString ASSIGNMENT_POOL_OPTION = "pool"; const QString ASSIGNMENT_WALLET_DESTINATION_ID_OPTION = "wallet"; const QString CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION = "a"; const QString CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION = "p"; Assignment::Type requestAssignmentType = Assignment::AllTypes; // check for an assignment type passed on the command line or in the config if (argumentVariantMap.contains(ASSIGNMENT_TYPE_OVERRIDE_OPTION)) { requestAssignmentType = (Assignment::Type) argumentVariantMap.value(ASSIGNMENT_TYPE_OVERRIDE_OPTION).toInt(); } QString assignmentPool; // check for an assignment pool passed on the command line or in the config if (argumentVariantMap.contains(ASSIGNMENT_POOL_OPTION)) { assignmentPool = argumentVariantMap.value(ASSIGNMENT_POOL_OPTION).toString(); } // setup our _requestAssignment member variable from the passed arguments _requestAssignment = Assignment(Assignment::RequestCommand, requestAssignmentType, assignmentPool); // check for a wallet UUID on the command line or in the config // this would represent where the user running AC wants funds sent to if (argumentVariantMap.contains(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION)) { QUuid walletUUID = argumentVariantMap.value(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION).toString(); qDebug() << "The destination wallet UUID for credits is" << uuidStringWithoutCurlyBraces(walletUUID); _requestAssignment.setWalletUUID(walletUUID); } // create a NodeList as an unassigned client NodeList* nodeList = NodeList::createInstance(NodeType::Unassigned); quint16 assignmentServerPort = DEFAULT_DOMAIN_SERVER_PORT; // check for an overriden assignment server hostname if (argumentVariantMap.contains(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION)) { // change the hostname for our assignment server _assignmentServerHostname = argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_HOSTNAME_OPTION).toString(); } // check for an overriden assignment server port if (argumentVariantMap.contains(CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION)) { assignmentServerPort = argumentVariantMap.value(CUSTOM_ASSIGNMENT_SERVER_PORT_OPTION).toString().toUInt(); } _assignmentServerSocket = HifiSockAddr(_assignmentServerHostname, assignmentServerPort, true); nodeList->setAssignmentServerSocket(_assignmentServerSocket); qDebug() << "Assignment server socket is" << _assignmentServerSocket; // call a timer function every ASSIGNMENT_REQUEST_INTERVAL_MSECS to ask for assignment, if required qDebug() << "Waiting for assignment -" << _requestAssignment; QTimer* timer = new QTimer(this); connect(timer, SIGNAL(timeout()), SLOT(sendAssignmentRequest())); timer->start(ASSIGNMENT_REQUEST_INTERVAL_MSECS); // connect our readPendingDatagrams method to the readyRead() signal of the socket connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, this, &AssignmentClient::readPendingDatagrams); // connections to AccountManager for authentication connect(&AccountManager::getInstance(), &AccountManager::authRequired, this, &AssignmentClient::handleAuthenticationRequest); // Create Singleton objects on main thread NetworkAccessManager::getInstance(); SoundCache::getInstance(); }