void setupEventHandler_mac(SRefCon handlerRef) { appleEventProcessorUPP = AEEventHandlerUPP(appleEventProcessor); AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, appleEventProcessorUPP, handlerRef, true); macCallbackUrlHandlerUPP = AEEventHandlerUPP(macCallbackUrlHandler); AEInstallEventHandler(kInternetEventClass, kAEGetURL, macCallbackUrlHandlerUPP, handlerRef, false); }
int main( int argc, char *argv[] ) { #ifdef Q_WS_MAC // Do Mac specific startup to get media keys working. // This must go before QApplication initialisation. Tomahawk::macMain(); // used for url handler AEEventHandlerUPP h = AEEventHandlerUPP( appleEventHandler ); AEInstallEventHandler( 'GURL', 'GURL', h, 0, false ); #endif TomahawkApp a( argc, argv ); KDSingleApplicationGuard guard( &a, KDSingleApplicationGuard::AutoKillOtherInstances ); QObject::connect( &guard, SIGNAL( instanceStarted( KDSingleApplicationGuard::Instance ) ), &a, SLOT( instanceStarted( KDSingleApplicationGuard::Instance ) ) ); if ( guard.isPrimaryInstance() ) a.init(); QString locale = QLocale::system().name(); QTranslator translator; translator.load( QString( ":/lang/tomahawk_" ) + locale ); a.installTranslator( &translator ); if ( argc > 1 ) { QString arg = a.arguments()[ 1 ]; a.loadUrl( arg ); } return a.exec(); }
int QxApplication::exec() { mainWindow_ = new QxMainWindow(); #ifdef Q_WS_MAC mainWindow_->setAttribute(Qt::WA_DeleteOnClose, false); #else mainWindow_->setAttribute(Qt::WA_DeleteOnClose, true); #endif mainWindow_->show(); #ifdef Q_WS_MAC #ifndef QT_MAC_USE_COCOA AEEventHandlerUPP appleEventProcessorUPP = AEEventHandlerUPP(appleEventProcessor); AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, appleEventProcessorUPP, 0, true); #endif #endif return QApplication::exec(); }
int UBApplication::exec(const QString& pFileToImport) { QPixmapCache::setCacheLimit(1024 * 100); QString webDbPath = UBSettings::userDataDirectory() + "/web-databases"; QDir webDbDir(webDbPath); if (!webDbDir.exists(webDbPath)) webDbDir.mkpath(webDbPath); QWebSettings::setIconDatabasePath(webDbPath); QWebSettings::setOfflineStoragePath (webDbPath); QWebSettings *gs = QWebSettings::globalSettings(); gs->setAttribute(QWebSettings::JavaEnabled, true); gs->setAttribute(QWebSettings::PluginsEnabled, true); gs->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); gs->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); gs->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); gs->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); gs->setAttribute(QWebSettings::DnsPrefetchEnabled, true); mainWindow = new UBMainWindow(0, Qt::FramelessWindowHint); // deleted by application destructor mainWindow->setAttribute(Qt::WA_NativeWindow, true); mainWindow->actionCopy->setShortcuts(QKeySequence::Copy); mainWindow->actionPaste->setShortcuts(QKeySequence::Paste); mainWindow->actionCut->setShortcuts(QKeySequence::Cut); connect(mainWindow->actionBoard, SIGNAL(triggered()), this, SLOT(showBoard())); connect(mainWindow->actionWeb, SIGNAL(triggered()), this, SLOT(showInternet())); connect(mainWindow->actionWeb, SIGNAL(triggered()), this, SLOT(stopScript())); connect(mainWindow->actionDocument, SIGNAL(triggered()), this, SLOT(showDocument())); connect(mainWindow->actionDocument, SIGNAL(triggered()), this, SLOT(stopScript())); connect(mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(closing())); connect(mainWindow, SIGNAL(closeEvent_Signal(QCloseEvent*)), this, SLOT(closeEvent(QCloseEvent*))); boardController = new UBBoardController(mainWindow); boardController->init(); webController = new UBWebController(mainWindow); documentController = new UBDocumentController(mainWindow); boardController->paletteManager()->connectToDocumentController(); UBDrawingController::drawingController()->setStylusTool((int)UBStylusTool::Pen); applicationController = new UBApplicationController(boardController->controlView(), boardController->displayView(), mainWindow, staticMemoryCleaner); connect(applicationController, SIGNAL(mainModeChanged(UBApplicationController::MainMode)), boardController->paletteManager(), SLOT(slot_changeMainMode(UBApplicationController::MainMode))); connect(applicationController, SIGNAL(desktopMode(bool)), boardController->paletteManager(), SLOT(slot_changeDesktopMode(bool))); connect(mainWindow->actionDesktop, SIGNAL(triggered(bool)), applicationController, SLOT(showDesktop(bool))); connect(mainWindow->actionDesktop, SIGNAL(triggered(bool)), this, SLOT(stopScript())); #ifndef Q_WS_MAC connect(mainWindow->actionHideApplication, SIGNAL(triggered()), mainWindow, SLOT(showMinimized())); #else connect(mainWindow->actionHideApplication, SIGNAL(triggered()), this, SLOT(showMinimized())); #endif mPreferencesController = new UBPreferencesController(mainWindow); connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show())); connect(mainWindow->actionTutorial, SIGNAL(triggered()), applicationController, SLOT(showTutorial())); connect(mainWindow->actionTutorial, SIGNAL(triggered()), this, SLOT(stopScript())); connect(mainWindow->actionSankoreEditor, SIGNAL(triggered()), applicationController, SLOT(showSankoreEditor())); connect(mainWindow->actionCheckUpdate, SIGNAL(triggered()), applicationController, SLOT(checkUpdateRequest())); toolBarPositionChanged(UBSettings::settings()->appToolBarPositionedAtTop->get()); bool bUseMultiScreen = UBSettings::settings()->appUseMultiscreen->get().toBool(); mainWindow->actionMultiScreen->setChecked(bUseMultiScreen); connect(mainWindow->actionMultiScreen, SIGNAL(triggered(bool)), applicationController, SLOT(useMultiScreen(bool))); connect(mainWindow->actionWidePageSize, SIGNAL(triggered(bool)), boardController, SLOT(setWidePageSize(bool))); connect(mainWindow->actionRegularPageSize, SIGNAL(triggered(bool)), boardController, SLOT(setRegularPageSize(bool))); connect(mainWindow->actionImportUniboardDocuments, SIGNAL(triggered()), this, SLOT(importUniboardFiles())); connect(mainWindow->actionCut, SIGNAL(triggered()), applicationController, SLOT(actionCut())); connect(mainWindow->actionCopy, SIGNAL(triggered()), applicationController, SLOT(actionCopy())); connect(mainWindow->actionPaste, SIGNAL(triggered()), applicationController, SLOT(actionPaste())); applicationController->initScreenLayout(bUseMultiScreen); boardController->setupLayout(); if (pFileToImport.length() > 0) { UBApplication::applicationController->importFile(pFileToImport); } #if defined(Q_WS_MAC) static AEEventHandlerUPP ub_proc_ae_handlerUPP = AEEventHandlerUPP(ub_appleEventProcessor); AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, ub_proc_ae_handlerUPP, SRefCon(UBApplication::applicationController), true); #endif if (UBSettings::settings()->appStartMode->get() == "Desktop") applicationController->showDesktop(); else applicationController->showBoard(); return QApplication::exec(); }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow ) { hKeyboardHook = NULL; hGuiLibInstance = hInstance; // setup keyboard hook to receive multimedia key events when application is at background hKeyboardHook = SetWindowsHookEx( WH_KEYBOARD_LL,(HOOKPROC) qt_LowLevelKeyboardHookProc, hGuiLibInstance, 0 ); if ( fileno( stdout ) != -1 && _get_osfhandle( fileno( stdout ) ) != -1 ) { /* stdout is fine, presumably redirected to a file or pipe */ } else { typedef BOOL (WINAPI * AttachConsole_t) (DWORD); AttachConsole_t p_AttachConsole = (AttachConsole_t) GetProcAddress( GetModuleHandleW( L"kernel32.dll" ), "AttachConsole" ); if ( p_AttachConsole != NULL && p_AttachConsole( ATTACH_PARENT_PROCESS ) ) { _wfreopen ( L"CONOUT$", L"w", stdout ); dup2( fileno( stdout ), 1 ); _wfreopen ( L"CONOUT$", L"w", stderr ); dup2( fileno( stderr ), 2 ); } } #else // Q_OS_WIN int main( int argc, char *argv[] ) { #ifdef Q_WS_MAC // Do Mac specific startup to get media keys working. // This must go before QApplication initialisation. Tomahawk::macMain(); // Fixes focus issue with NSSearchField, see QTBUG-11401 // code taken from clementine:main.cpp:336 QCoreApplication::setAttribute( Qt::AA_NativeWindows, true ); // used for url handler AEEventHandlerUPP h = AEEventHandlerUPP( appleEventHandler ); AEInstallEventHandler( 'GURL', 'GURL', h, 0, false ); #endif // Q_WS_MAC #endif //Q_OS_WIN TomahawkApp a( argc, argv ); // MUST register StateHash ****before*** initing TomahawkSettingsGui as constructor of settings does upgrade before Gui subclass registers type TomahawkSettings::registerCustomSettingsHandlers(); TomahawkSettingsGui::registerCustomSettingsHandlers(); #ifdef ENABLE_HEADLESS new TomahawkSettings( &a ); #else new TomahawkSettingsGui( &a ); #endif #ifndef ENABLE_HEADLESSs #ifdef WITH_BREAKPAD new BreakPad( QDir::tempPath(), TomahawkSettings::instance()->crashReporterEnabled() && !TomahawkUtils::headless() ); #endif #endif KDSingleApplicationGuard guard( KDSingleApplicationGuard::AutoKillOtherInstances ); QObject::connect( &guard, SIGNAL( instanceStarted( KDSingleApplicationGuard::Instance ) ), &a, SLOT( instanceStarted( KDSingleApplicationGuard::Instance ) ) ); if ( guard.isPrimaryInstance() ) a.init(); int returnCode = 0; if ( guard.isPrimaryInstance() ) returnCode = a.exec(); #ifdef Q_OS_WIN // clean up keyboard hook if ( hKeyboardHook ) { UnhookWindowsHookEx( hKeyboardHook ); hKeyboardHook = NULL; } #endif return returnCode; }