@@ -60,7 +60,7 @@ QString QgsApplication::mConfigPath = QD QgsApplication::QgsApplication( int & argc, char ** argv, bool GUIenabled, QString customConfigPath ) : QApplication( argc, argv, GUIenabled ) { -#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32) +#if defined(Q_WS_WIN32) || defined(WIN32) setPrefixPath( applicationDirPath(), true ); #else QDir myDir( applicationDirPath() );
void unicorn::Application::init() { #ifdef Q_OS_MAC addLibraryPath( applicationDirPath() + "/../plugins" ); #elif defined Q_OS_WIN addLibraryPath( applicationDirPath() + "/plugins" ); #endif #ifdef Q_WS_MAC qt_mac_set_menubar_icons( false ); #endif CoreApplication::init(); setupHotKeys(); #ifdef __APPLE__ setGetURLEventHandler(); AEEventHandlerUPP urlHandler = NewAEEventHandlerUPP( appleEventHandler ); AEInstallEventHandler( kInternetEventClass, kAEGetURL, urlHandler, 0, false ); setOpenApplicationEventHandler(); AEEventHandlerUPP openHandler = NewAEEventHandlerUPP( appleEventHandler ); AEInstallEventHandler( kCoreEventClass, kAEReopenApplication, openHandler, 0, false ); #endif #ifdef Q_WS_MAC #define CSS_PATH "/../Resources/" #else #define CSS_PATH "/" #endif refreshStyleSheet(); translate(); m_icm = new lastfm::InternetConnectionMonitor( this ); connect( m_icm, SIGNAL( up( QString ) ), this, SIGNAL( internetConnectionUp() ) ); connect( m_icm, SIGNAL( down( QString ) ), this, SIGNAL( internetConnectionDown() ) ); connect( &m_bus, SIGNAL( wizardRunningQuery( QString )), SLOT( onWizardRunningQuery( QString ))); connect( &m_bus, SIGNAL( sessionQuery( QString )), SLOT( onBusSessionQuery( QString ))); connect( &m_bus, SIGNAL( sessionChanged( const QMap<QString, QString>& )), SLOT( onBusSessionChanged( const QMap<QString, QString>& ))); connect( &m_bus, SIGNAL( lovedStateChanged(bool)), SIGNAL( busLovedStateChanged(bool))); m_bus.board(); #ifdef __APPLE__ setQuitOnLastWindowClosed( false ); #endif }
QString App::bundledNodePath() const { auto path = applicationDirPath().split("/"); #if defined Q_OS_MAC // On Mac, the 'nodes' folder should be either in // Antimony.app/Contents/Resources/nodes (when deployed) // or Antimony.app/../sb/nodes (when running from the build directory) path.removeLast(); // Trim the MacOS folder from the path // When deployed, the nodes folder is in Resources/sb if (QDir(path.join("/") + "/Resources/nodes").exists()) { path << "Resources" << "nodes"; } // Otherwise, assume it's at the same level as antimony.app else { for (int i=0; i < 2; ++i) path.removeLast(); path << "sb" << "nodes"; } #else path << "sb" << "nodes"; #endif return path.join("/"); }
void TSBrowserApplication::setLogLevel(const QString& level) { //Trace|Debug|Info|Warn|Error|Fatal|None default value is Info if( !level.compare("Trace", Qt::CaseInsensitive) ) this->logLevel = QsLogging::TraceLevel; else if( !level.compare("Debug", Qt::CaseInsensitive) ) this->logLevel = QsLogging::DebugLevel; else if( !level.compare("Info", Qt::CaseInsensitive) ) this->logLevel = QsLogging::InfoLevel; else if( !level.compare("Warn", Qt::CaseInsensitive) ) this->logLevel = QsLogging::WarnLevel; else if( !level.compare("Error", Qt::CaseInsensitive) ) this->logLevel = QsLogging::ErrorLevel; else if( !level.compare("Fatal", Qt::CaseInsensitive) ) this->logLevel = QsLogging::FatalLevel; else if( !level.compare("None", Qt::CaseInsensitive) ) this->logLevel = QsLogging::NoneLevel; else // default is Info this->logLevel = QsLogging::InfoLevel; // Configure Logger QsLogging::Logger& logger = QsLogging::Logger::instance(); logger.setLoggingLevel(this->getLogLevel()); QLOG_INFO() << QString("Program starting: Config log level to %1 and log into file %2.") .arg(level) .arg(QString(QDir(applicationDirPath()).filePath("tsweb.log"))); }
QString BrowserApplication::dataDirectory() const { #if defined(Q_WS_X11) return PKGDATADIR; #else return applicationDirPath(); #endif }
ClockWidget::ClockWidget(const QRectF &rect, QWidget *widget) : DesktopWidget(rect, widget) { shade = 0; setPath(applicationDirPath() + "/share/plexy/skins/default/clock/"); drawClockWidget(); }
Application::Application(int &argc, char **argv) : QApplication(argc, argv) { setApplicationName("Installer Jukebox"); // All paths are relative to the location of the executable QString appPath = applicationDirPath(); qDebug() << "Application path:" << appPath; QDir::addSearchPath("app", appPath); // Parse configuration file (required) if (!QFileInfo("app:InstallerJukebox.ini").isReadable()) { QString configPath = appPath + QDir::separator() + "InstallerJukebox.ini"; qDebug() << "Cannot read" << configPath; critical(tr("Cannot read %1").arg(configPath)); throw 1; } config = new QSettings("app:InstallerJukebox.ini", QSettings::IniFormat); // Get working directory from config. Must be configured, exist and be writable. tmpDir = config->value("Working directory").toString(); if (tmpDir.isEmpty()) { qDebug() << "Working directory not configured!"; critical(tr("Working directory is not configured!")); throw 1; } QFileInfo fileInfo(tmpDir); if (!fileInfo.isDir()) { qDebug() << tmpDir << "is not a directory!"; Application::critical(tr("'%1' is not a directory!").arg(tmpDir)); throw 1; } if (!fileInfo.isWritable()) { qDebug() << tmpDir << "is not writable!"; Application::critical(tr("Directory '%1' is not writable!").arg(tmpDir)); throw 1; } tmpDir = QDir::cleanPath(fileInfo.absoluteFilePath()); qDebug() << "tmpDir is" << tmpDir; // Parse "Keep temp files" option. Must be valid if configured, default to "Never". QString keepTempFiles = config->value("Keep temp files", "never").toString().toLower(); qDebug() << "Keep temp files:" << keepTempFiles; if (keepTempFiles == "never") { tmpFileHandling = Never; } else if (keepTempFiles == "onerror") { tmpFileHandling = OnError; } else if (keepTempFiles == "always") { tmpFileHandling = Always; } else { qDebug() << "Invalid!"; critical(tr("'Keep temp files' setting is invalid!")); throw 1; } // Use system's default proxy configuration QNetworkProxyFactory::setUseSystemConfiguration(true); }
ListView::ListView(const QRectF &rect, QWidget *win): DesktopWidget(rect, win), d(new Private) { d->clip = QRectF(10, 10, rect.width() - 40, rect.height() - 20); d->view = QRectF(0, 0, rect.width() - 80, 0); d->prefix = applicationDirPath() + "/theme/skins/default/widget/default/youtube/"; d->m_bg = QImage(d->prefix + "bacground.png"); d->mItem_bg = QImage(d->prefix + "videotag.png"); }
const QString FolderUtils::libraryPath() { #ifdef Q_OS_MAC // mac plugins are always in the bundle return QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../lib"); #endif return QDir::cleanPath(applicationDirPath() + "/lib"); }
Local::Local(int &argc, char **argv) : QApplication(argc, argv) { QDir::setCurrent(applicationDirPath()); setPalette(setStyle("Fusion")->standardPalette()); setAttribute(Qt::AA_UseOpenGLES); thread()->setPriority(QThread::TimeCriticalPriority); Config::load(); qsrand(QTime::currentTime().msec()); }
/*! Returns the path to the help application. */ const QString QgsApplication::helpAppPath() { QString helpAppPath; #ifdef Q_OS_MACX helpAppPath = applicationDirPath() + "/bin/qgis_help.app/Contents/MacOS"; #else helpAppPath = libexecPath(); #endif helpAppPath += "/qgis_help"; return helpAppPath; }
FrameworkQtApplication::FrameworkQtApplication (Framework *framework, int &argc, char** argv) : QApplication (argc, argv), framework_ (framework), app_activated_(true) { #ifdef Q_WS_WIN // If under windows, add run_dir/plugins as library path // unix users will get plugins from their OS Qt installation folder automatically QString run_directory = applicationDirPath(); run_directory += "/qtplugins"; addLibraryPath(run_directory); #endif }
Welcome::Welcome(QObject *object) { frm = new Frame(QRect(0, 0, 140 * 4, 128*3)); icon1 = new WellcomeItem(QRect(0, 0, 128, 256), frm); icon1->setName(""); icon1->setIcon(QPixmap(applicationDirPath() + "/share/plexy/skins/default/welcome/kfm_home.png")); icon1->setPos(60, 70); icon2 = new WellcomeItem(QRect(0, 0, 128, 256), frm); icon2->setName(""); icon2->setIcon(QPixmap(applicationDirPath() + "/share/plexy/skins/default/welcome/colors.png")); icon2->setPos(220, 70); icon3 = new WellcomeItem(QRect(0, 0, 128, 256), frm); icon3->setName(""); icon3->setIcon(QPixmap(applicationDirPath() + "/share/plexy/skins/default/welcome/gnome_apps.png")); icon3->setPos(380, 70); }
googleweatherWidget::googleweatherWidget (const QRectF &rect, QWidget *widget): DesktopWidget(rect,widget) { shade = 0; moveY = 0; setPath(applicationDirPath() +"/theme/skins/default/widget/default/googleweather/"); setDockImage(QPixmap(prefix + "icon.png")); drawWidget(); clip = QRectF(10, 10, rect.width()-40, rect.height()-20); view = QRectF(0, 0, rect.width()-80, 0); initD = 0; DS_EXTF = 0; initTimer = 1; weather = new SocialQDBusPluginData(); }
XCA_application::XCA_application(int &argc, char *argv[]) :QApplication(argc, argv) { qtTr = NULL; xcaTr = NULL; mainw = NULL; QFile file(getUserSettingsDir() + QDir::separator() + "defaultlang"); if (file.open(QIODevice::ReadOnly)) { lang = QLocale(QString(file.read(128))); } langAvail << QLocale::system(); langAvail << QString("en"); QDirIterator qmIt(getPrefix(), QStringList() << "*.qm", QDir::Files); while (qmIt.hasNext()) { XcaTranslator t; qmIt.next(); QString language = qmIt.fileInfo().baseName().mid(4, -1); if (t.load(language, "xca", getPrefix())) langAvail << QLocale(language); } setupLanguage(lang); #ifdef Q_OS_MAC QStringList libp = libraryPaths(); libp.prepend(applicationDirPath() + "/../Plugins"); setLibraryPaths(libp); #endif tableFont = QFont("Courier", QApplication::font().pointSize() #if defined (Q_OS_WIN32) +1 #else +2 #endif ); installEventFilter(this); }
Application(int &argc, char **argv) : QApplication(argc, argv) { QDir dir(applicationDirPath()); dir.cd("lib"); dir.cd("qt5"); addLibraryPath(dir.absolutePath()); setOrganizationName("Meltytech"); setOrganizationDomain("meltytech.com"); setApplicationName("Shotcut"); setApplicationVersion(SHOTCUT_VERSION); setAttribute(Qt::AA_UseHighDpiPixmaps); #if defined(Q_OS_MAC) setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); setAttribute(Qt::AA_DontShowIconsInMenus); #endif // Startup logging. dir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); if (!dir.exists()) dir.mkpath(dir.path()); const QString logFileName = dir.filePath("shotcut-log.txt"); QFile::remove(logFileName); FileAppender* fileAppender = new FileAppender(logFileName); fileAppender->setFormat("[%-7l] <%C> %m\n"); Logger::registerAppender(fileAppender); #ifndef NDEBUG // Only log to console in dev debug builds. ConsoleAppender* consoleAppender = new ConsoleAppender(); consoleAppender->setFormat(fileAppender->format()); Logger::registerAppender(consoleAppender); mlt_log_set_level(MLT_LOG_VERBOSE); #else mlt_log_set_level(MLT_LOG_INFO); #endif mlt_log_set_callback(mlt_log_handler); // Log some basic info. LOG_INFO() << "Starting Shotcut version" << SHOTCUT_VERSION; #if defined (Q_OS_WIN) LOG_INFO() << "Windows version" << QSysInfo::windowsVersion(); #elif defined(Q_OS_MAC) LOG_INFO() << "OS X version" << QSysInfo::macVersion(); #else LOG_INFO() << "Linux version"; #endif LOG_INFO() << "number of logical cores =" << QThread::idealThreadCount(); LOG_INFO() << "locale =" << QLocale(); LOG_INFO() << "install dir =" << applicationDirPath(); // Load translations const QString locale = Settings.language(); QLocale::setDefault(QLocale(locale)); dir = applicationDirPath(); #if defined(Q_OS_MAC) dir.cdUp(); dir.cd("Resources"); dir.cd("translations"); #elif defined(Q_OS_WIN) dir.cd("share"); dir.cd("translations"); #else dir.cdUp(); dir.cd("share"); dir.cd("shotcut"); dir.cd("translations"); #endif if (qtTranslator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) installTranslator(&qtTranslator); else if (qtTranslator.load("qt_" + locale, dir.absolutePath())) installTranslator(&qtTranslator); if (qtBaseTranslator.load("qtbase_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) installTranslator(&qtBaseTranslator); else if (qtBaseTranslator.load("qtbase_" + locale, dir.absolutePath())) installTranslator(&qtBaseTranslator); if (shotcutTranslator.load("shotcut_" + locale, dir.absolutePath())) installTranslator(&shotcutTranslator); if (argc > 1) resourceArg = QString::fromUtf8(argv[1]); }
Application::Application( int &argc, char **argv ) : Common( argc, argv ) , d( new ApplicationPrivate ) { QStringList args = arguments(); args.removeFirst(); #ifndef Q_OS_MAC if( isRunning() ) { sendMessage( args.join( "\", \"" ) ); return; } connect( this, SIGNAL(messageReceived(QString)), SLOT(parseArgs(QString)) ); #endif setApplicationName( APP ); setApplicationVersion( QString( "%1.%2.%3.%4" ) .arg( MAJOR_VER ).arg( MINOR_VER ).arg( RELEASE_VER ).arg( BUILD_VER ) ); setOrganizationDomain( DOMAINURL ); setOrganizationName( ORG ); setWindowIcon( QIcon( ":/images/crypto_128x128.png" ) ); // Actions d->closeAction = new QAction( this ); d->closeAction->setShortcut( Qt::CTRL + Qt::Key_W ); connect( d->closeAction, SIGNAL(triggered()), SLOT(closeWindow()) ); d->newAction = new QAction( this ); d->newAction->setShortcut( Qt::CTRL + Qt::Key_N ); connect( d->newAction, SIGNAL(triggered()), SLOT(parseArgs()) ); #if defined(Q_OS_MAC) setQuitOnLastWindowClosed( false ); d->bar = new MacMenuBar; d->bar->addAction( MacMenuBar::AboutAction, this, SLOT(showAbout()) ); d->bar->addAction( MacMenuBar::PreferencesAction, this, SLOT(showSettings()) ); d->bar->fileMenu()->addAction( d->newAction ); d->bar->fileMenu()->addAction( d->closeAction ); d->bar->dockMenu()->addAction( d->newAction ); #endif installTranslator( d->appTranslator = new QTranslator( this ) ); installTranslator( d->commonTranslator = new QTranslator( this ) ); installTranslator( d->qtTranslator = new QTranslator( this ) ); loadTranslation( Settings::language() ); initDigiDocLib(); QString ini = QString( "%1/digidoc.ini" ).arg( applicationDirPath() ); if( QFileInfo( ini ).isFile() ) initConfigStore( ini.toUtf8() ); else initConfigStore( NULL ); Poller::ApiType api = Poller::PKCS11; #ifdef Q_OS_WIN QString provider; QSettings reg( "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography\\Calais\\SmartCards", QSettings::NativeFormat ); Q_FOREACH( const QString &group, reg.childGroups() ) { if( group.contains( "esteid", Qt::CaseInsensitive ) ) { provider = reg.value( group + "/" + "Crypto Provider" ).toString(); break; } } if( QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA && provider != "EstEID Card CSP" ) api = Poller::CNG; if( args.contains("-capi") && QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA ) showWarning( tr("CAPI parameter is not supported on Windows Vista and newer") ); else if( args.contains("-capi") ) api = Poller::CAPI; if( args.contains("-cng") ) api = Poller::CNG; #endif if( args.contains("-pkcs11") ) api = Poller::PKCS11; d->poller = new Poller( api, this ); parseArgs( args ); }
StandaloneApplication( int argc, char **argv ) : QApplication(argc, argv) { // initialize core ======================= core::init(); core::setVariable( "$HERE", applicationDirPath() ); }
int main(int argc, char *argv[]) { QByteArray key("k04LbM3wLGa97rVm30Kyhas"); QByteArray salt("013oPQLbplrz39g2oJElNyPQ20ms7H5v"); QApplication app(argc, argv); QApplication::setStyle("plastique"); Q_INIT_RESOURCE(marbles); _engine = new MaEngine(); _engine->setEncryptKey(key); _engine->setEncryptSalt(salt); QString applicationDirPath(QCoreApplication::applicationDirPath()); QFileInfo appFileInfo(QCoreApplication::applicationFilePath()); const QString appFileName(appFileInfo.fileName()); QString configPath; #if defined(Q_WS_MAC) int pos = applicationDirPath.indexOf(QObject::tr("/%1.app/Contents/MacOS").arg(appFileName)); if (pos > 0) { applicationDirPath.append("/../Resources"); } #endif // defined(Q_WS_MAC) configPath = QObject::tr("%1/%2.xml").arg(applicationDirPath).arg(appFileName); QFileInfo fi(configPath); if (fi.exists()) _engine->loadConfig(fi.absoluteFilePath()); _mainWindow = new MaMainWindow(); QObject::connect(_engine, SIGNAL(openedStore()), _mainWindow, SLOT(onOpenedStore())); _mainWindow->show(); if (!_engine->lastOpenedStoreLocation().isEmpty()) _engine->openStore(_engine->lastOpenedStoreLocation()); else _mainWindow->onOpenStore(); // _engine->store()->setPassword("skyout"); /* QString text("this is a test string."); QByteArray btext(text.toAscii()); QByteArray key("THIS IS THE KEY"); QByteArray salt; MaStore::encrypt(btext, key, salt); qDebug() << "text (encrypted)" << btext << ", salt=" << salt; MaStore::encrypt(btext, key, salt); qDebug() << "text (clear)" << btext << ", salt=" << salt; return 0; */ int res = app.exec(); _engine->onShuttingDown(); delete _engine; return res; }
VideoWidget::VideoWidget(const QRectF &rect, QWidget *widget): DesktopWidget(rect, widget) { setDockImage(QPixmap(applicationDirPath() + "/share/plexy/skins/widgets/widget01/pila.png")); cover = QImage(200, 200, QImage::Format_ARGB32_Premultiplied); video = QImage(200, 200, QImage::Format_ARGB32_Premultiplied); }
void QgsApplication::init( QString customConfigPath ) { // check if QGIS is run from build directory (not the install directory) QDir appDir( applicationDirPath() ); if ( appDir.exists( "source_path.txt" ) ) { QFile f( applicationDirPath() + "/source_path.txt" ); if ( f.open( QIODevice::ReadOnly ) ) { mRunningFromBuildDir = true; mBuildSourcePath = f.readAll(); #if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32) mBuildOutputPath = applicationDirPath(); #else mBuildOutputPath = applicationDirPath() + "/.."; // on linux #endif qDebug( "Running from build directory!" ); qDebug( "- source directory: %s", mBuildSourcePath.toAscii().data() ); qDebug( "- output directory of the build: %s", mBuildOutputPath.toAscii().data() ); } } if ( mRunningFromBuildDir ) { // we run from source directory - not installed to destination (specified prefix) mPrefixPath = QString(); // set invalid path setPluginPath( mBuildOutputPath + "/" + QString( QGIS_PLUGIN_SUBDIR ) ); setPkgDataPath( mBuildSourcePath ); // directly source path - used for: doc, resources, svg mLibraryPath = mBuildOutputPath + "/" + QGIS_LIB_SUBDIR + "/"; mLibexecPath = mBuildOutputPath + "/" + QGIS_LIBEXEC_SUBDIR + "/"; } else { #if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32) setPrefixPath( applicationDirPath(), true ); #else QDir myDir( applicationDirPath() ); myDir.cdUp(); QString myPrefix = myDir.absolutePath(); setPrefixPath( myPrefix, true ); #endif } if ( !customConfigPath.isEmpty() ) { mConfigPath = customConfigPath + "/"; // make sure trailing slash is included } mDefaultSvgPaths << qgisSettingsDirPath() + QString( "svg/" ); // set a working directory up for gdal to write .aux.xml files into // for cases where the raster dir is read only to the user // if the env var is already set it will be used preferentially QString myPamPath = qgisSettingsDirPath() + QString( "gdal_pam/" ); QDir myDir( myPamPath ); if ( !myDir.exists() ) { myDir.mkpath( myPamPath ); //fail silently } #if defined(Q_WS_WIN32) || defined(WIN32) CPLSetConfigOption( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() ); #else //under other OS's we use an environment var so the user can //override the path if he likes int myChangeFlag = 0; //whether we want to force the env var to change setenv( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag ); #endif }
static inline QString sharedDirPath() { QString appPath = applicationDirPath(); return QFileInfo(appPath + SHARE_PATH).absoluteFilePath(); }
void QgsApplication::init( QString customConfigPath ) { if ( customConfigPath.isEmpty() ) { customConfigPath = QDir::homePath() + QString( "/.qgis/" ); } qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" ); // check if QGIS is run from build directory (not the install directory) QDir appDir( applicationDirPath() ); #ifndef _MSC_VER #define SOURCE_PATH "source_path.txt" #else #define SOURCE_PATH "../source_path.txt" #endif if ( appDir.exists( SOURCE_PATH ) ) { QFile f( applicationDirPath() + "/" + SOURCE_PATH ); if ( f.open( QIODevice::ReadOnly ) ) { ABISYM( mRunningFromBuildDir ) = true; ABISYM( mBuildSourcePath ) = f.readAll(); #if _MSC_VER QStringList elems = applicationDirPath().split( "/", QString::SkipEmptyParts ); ABISYM( mCfgIntDir ) = elems.last(); ABISYM( mBuildOutputPath ) = applicationDirPath() + "/../.."; #elif defined(Q_WS_MACX) ABISYM( mBuildOutputPath ) = applicationDirPath(); #else ABISYM( mBuildOutputPath ) = applicationDirPath() + "/.."; // on linux #endif qDebug( "Running from build directory!" ); qDebug( "- source directory: %s", ABISYM( mBuildSourcePath ).toAscii().data() ); qDebug( "- output directory of the build: %s", ABISYM( mBuildOutputPath ).toAscii().data() ); } } if ( ABISYM( mRunningFromBuildDir ) ) { // we run from source directory - not installed to destination (specified prefix) ABISYM( mPrefixPath ) = QString(); // set invalid path #ifdef _MSC_VER setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) + "/" + ABISYM( mCfgIntDir ) ); #else setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) ); #endif setPkgDataPath( ABISYM( mBuildSourcePath ) ); // directly source path - used for: doc, resources, svg ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) + "/" + QGIS_LIB_SUBDIR + "/"; ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) + "/" + QGIS_LIBEXEC_SUBDIR + "/"; } else { char *prefixPath = getenv( "QGIS_PREFIX_PATH" ); if ( !prefixPath ) { #if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32) setPrefixPath( applicationDirPath(), true ); #else QDir myDir( applicationDirPath() ); myDir.cdUp(); QString myPrefix = myDir.absolutePath(); setPrefixPath( myPrefix, true ); #endif } else { setPrefixPath( prefixPath, true ); } } if ( !customConfigPath.isEmpty() ) { ABISYM( mConfigPath ) = customConfigPath + "/"; // make sure trailing slash is included } ABISYM( mDefaultSvgPaths ) << qgisSettingsDirPath() + QString( "svg/" ); // set a working directory up for gdal to write .aux.xml files into // for cases where the raster dir is read only to the user // if the env var is already set it will be used preferentially QString myPamPath = qgisSettingsDirPath() + QString( "gdal_pam/" ); QDir myDir( myPamPath ); if ( !myDir.exists() ) { myDir.mkpath( myPamPath ); //fail silently } #if defined(Q_WS_WIN32) || defined(WIN32) CPLSetConfigOption( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8() ); #else //under other OS's we use an environment var so the user can //override the path if he likes int myChangeFlag = 0; //whether we want to force the env var to change setenv( "GDAL_PAM_PROXY_DIR", myPamPath.toUtf8(), myChangeFlag ); #endif }
App::App(int &argc, char **argv) : QApplication(argc, argv), d(new Data(this)) { if (QFile::exists(applicationDirPath() % "/bomi.ini"_a)) { QSettings set(applicationDirPath() % "/bomi.ini"_a, QSettings::IniFormat); d->useLocalConfig = set.value(u"app/use-local-config"_q, false).toBool(); Global::useLocalConfig = set.value(u"global/use-local-config"_q, false).toBool(); if (d->useLocalConfig != Global::useLocalConfig) { const auto from = _WritablePath(Location::Config, false); Global::useLocalConfig = d->useLocalConfig; const auto to = _WritablePath(Location::Config, false); d->copyConfig(from, to); set.setValue(u"global/use-local-config"_q, Global::useLocalConfig); } } #ifdef Q_OS_LINUX setlocale(LC_NUMERIC,"C"); #endif OS::initialize(); _New(d->parser); d->parser->addOption(LineCmd::Open, u"open"_q, u"Open given %1 for file path or URL."_q, u"mrl"_q); d->parser->addOption(LineCmd::SetSubtitle, u"set-subtitle"_q, u"Set subtitle file to display."_q, u"file"_q); // d->parser->addOption(LineCmd::AddSubtitle, u"add-subtitle"_q, // u"Add subtitle file to display."_q, u"file"_q); d->parser->addOption(LineCmd::Wake, u"wake"_q, u"Bring the application window in front."_q); d->parser->addOption(LineCmd::Action, u"action"_q, u"Exectute %1 action or open %1 menu."_q, u"id"_q); d->parser->addOption(LineCmd::LogLevel, u"log-level"_q, u"Maximum verbosity for log. %1 should be one of nexts:\n "_q % Log::levelNames().join(u", "_q), u"lv"_q); d->parser->addOption(LineCmd::Debug, u"debug"_q, u"Turn on options for debugging."_q); d->parser->addOption(LineCmd::DumpApiTree, u"dump-api-tree"_q, u"Dump API structure tree to stdout."_q); d->parser->addOption(LineCmd::DumpActionList, u"dump-action-list"_q, u"Dump executable action list to stdout."_q); #ifdef Q_OS_WIN d->parser->addOption(LineCmd::WinAssoc, u"win-assoc"_q, u"Associate given comma-separated extension list."_q, u"ext"_q); d->parser->addOption(LineCmd::WinUnassoc, u"win-unassoc"_q, u"Unassociate all extensions."_q); d->parser->addOption(LineCmd::WinAssocDefault, u"win-assoc-default"_q, u"Associate default extensions."_q); #endif d->parser->parse(arguments()); d->gldebug = d->parser->isSet(LineCmd::Debug); const auto lvStdOut = d->parser->stdoutLogLevel(); d->import(); d->storage.setObject(this, u"application"_q); d->storage.add("locale", &d->locale); d->storage.json("log-option", &d->logOption); d->storage.add("style-name", &d->styleName); d->storage.add("unique", &d->unique); d->storage.add("open-folders", open_folders, set_open_folders); d->storage.add("font"); d->storage.add("fixedFont"); d->storage.restore(); setLocale(d->locale); auto logOption = d->logOption; if (logOption.level(LogOutput::StdOut) < lvStdOut) logOption.setLevel(LogOutput::StdOut, lvStdOut); Log::setOption(logOption); setQuitOnLastWindowClosed(false); #ifndef Q_OS_MAC setWindowIcon(defaultIcon()); #endif d->styleNames = [this] () { auto names = QStyleFactory::keys(); const auto defaultName = style()->objectName(); for (auto it = ++names.begin(); it != names.end(); ++it) { if (defaultName.compare(*it, Qt::CaseInsensitive) == 0) { const auto name = *it; names.erase(it); names.prepend(name); break; } } return names; }(); auto makeStyle = [&]() { auto name = d->styleName; if (style()->objectName().compare(name, Qt::CaseInsensitive) == 0) return; if (!d->styleNames.contains(name, Qt::CaseInsensitive)) return; setStyle(QStyleFactory::create(name)); }; makeStyle(); connect(&d->connection, &LocalConnection::messageReceived, this, &App::handleMessage); }
TSBrowserApplication::TSBrowserApplication(int &argc, char **argv) : QApplication(argc, argv) , m_localServer(0) , bOpenLinkInTab(false) { QCoreApplication::setOrganizationName(QLatin1String("IJAB")); QCoreApplication::setApplicationName(QLatin1String("SpeechNav")); QCoreApplication::setApplicationVersion(QLatin1String("1.0.0")); #ifdef Q_WS_QWS // Use a different server name for QWS so we can run an X11 // browser and a QWS browser in parallel on the same machine for // debugging QString serverName = QCoreApplication::applicationName() + QLatin1String("_qws"); #else QString serverName = QCoreApplication::applicationName(); #endif QLocalSocket socket; socket.connectToServer(serverName); if (socket.waitForConnected(500)) { QTextStream stream(&socket); QStringList args = QCoreApplication::arguments(); if (args.count() > 1) stream << args.last(); else stream << QString(); stream.flush(); socket.waitForBytesWritten(); return; } #if defined(Q_WS_MAC) QApplication::setQuitOnLastWindowClosed(false); #else QApplication::setQuitOnLastWindowClosed(true); #endif m_localServer = new QLocalServer(this); connect(m_localServer, SIGNAL(newConnection()), this, SLOT(newLocalSocketConnection())); if (!m_localServer->listen(serverName)) { if (m_localServer->serverError() == QAbstractSocket::AddressInUseError && QFile::exists(m_localServer->serverName())) { QFile::remove(m_localServer->serverName()); m_localServer->listen(serverName); } } #ifndef QT_NO_OPENSSL if (!QSslSocket::supportsSsl()) { QMessageBox::information(0, "SpeechNav", "This system does not support OpenSSL. SSL websites will not be available."); } #endif QDesktopServices::setUrlHandler(QLatin1String("http"), this, "openUrl"); QString localSysName = QLocale::system().name(); installTranslator(QLatin1String("qt_") + localSysName); #if defined(Q_WS_MAC) connect(this, SIGNAL(lastWindowClosed()), this, SLOT(lastWindowClosed())); #endif QTimer::singleShot(0, this, SLOT(postLaunch())); // Set logger QsLogging::Logger& logger = QsLogging::Logger::instance(); const QString sLogPath(QDir(applicationDirPath()).filePath("tsweb.log")); logFileDestination = QsLogging::DestinationFactory::MakeFileDestination(sLogPath); logger.addDestination(logFileDestination.get()); }
Application::Application(int &argc, char **argv) : SharedTools::QtSingleApplication(argc, argv), _tray(0), _sslErrorDialog(0), #if QT_VERSION >= 0x040700 _networkMgr(new QNetworkConfigurationManager(this)), #endif _contextMenu(0), _theme(Theme::instance()), _updateDetector(0), _showLogWindow(false), _logFlush(false), _helpOnly(false), _logBrowser(0) { setApplicationName( _theme->appName() ); setWindowIcon( _theme->applicationIcon() ); parseOptions(arguments()); setupLogBrowser(); //no need to waste time; if ( _helpOnly ) return; processEvents(); QTranslator *qtTranslator = new QTranslator(this); qtTranslator->load(QLatin1String("qt_") + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); installTranslator(qtTranslator); QTranslator *mirallTranslator = new QTranslator(this); #ifdef Q_OS_LINUX // FIXME - proper path! mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), QLatin1String("/usr/share/mirall/i18n/")); #endif #ifdef Q_OS_MAC mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), applicationDirPath()+QLatin1String("/../translations") ); // path defaults to app dir. #endif #ifdef Q_OS_WIN32 mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), applicationDirPath()); #endif installTranslator(mirallTranslator); connect( this, SIGNAL(messageReceived(QString)), SLOT(slotParseOptions(QString))); // create folder manager for sync folder management _folderMan = new FolderMan(this); connect( _folderMan, SIGNAL(folderSyncStateChange(QString)), this,SLOT(slotSyncStateChange(QString))); /* use a signal mapper to map the open requests to the alias names */ _folderOpenActionMapper = new QSignalMapper(this); connect(_folderOpenActionMapper, SIGNAL(mapped(const QString &)), this, SLOT(slotFolderOpenAction(const QString &))); setQuitOnLastWindowClosed(false); _folderWizard = new FolderWizard; _owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme, this ); connect( _owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)), SLOT(slotStartFolderSetup(int))); _statusDialog = new StatusDialog( _theme ); connect( _statusDialog, SIGNAL(addASync()), this, SLOT(slotAddFolder()) ); connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)), SLOT(slotRemoveFolder(const QString&))); connect( _statusDialog, SIGNAL(openLogBrowser()), this, SLOT(slotOpenLogBrowser())); connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)), SLOT(slotEnableFolder(QString,bool))); connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)), SLOT(slotInfoFolder( const QString&))); connect( _statusDialog, SIGNAL(openFolderAlias(const QString&)), SLOT(slotFolderOpenAction(QString))); #if QT_VERSION >= 0x040700 qDebug() << "* Network is" << (_networkMgr->isOnline() ? "online" : "offline"); foreach (const QNetworkConfiguration& netCfg, _networkMgr->allConfigurations(QNetworkConfiguration::Active)) { //qDebug() << "Network:" << netCfg.identifier(); } #endif setupActions(); setupSystemTray(); setupProxy(); processEvents(); QObject::connect( this, SIGNAL(messageReceived(QString)), this, SLOT(slotOpenStatus()) ); QTimer::singleShot( 0, this, SLOT( slotStartFolderSetup() )); MirallConfigFile cfg; if( !cfg.ownCloudSkipUpdateCheck() ) { QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() )); } connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)), this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>))); qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded(); }
Common::Common( int &argc, char **argv, const QString &app, const QString &icon ) : BaseApplication( argc, argv ) { setApplicationName( app ); setApplicationVersion( QString( "%1.%2.%3.%4" ) .arg( MAJOR_VER ).arg( MINOR_VER ).arg( RELEASE_VER ).arg( BUILD_VER ) ); setOrganizationDomain( "ria.ee" ); setOrganizationName( ORG ); setWindowIcon( QIcon( icon ) ); if( QFile::exists( QString("%1/%2.log").arg( QDir::tempPath(), app ) ) ) qInstallMessageHandler(msgHandler); #ifdef BREAKPAD new QBreakPad(this); #ifdef TESTING if( arguments().contains( "-crash" ) ) { QBreakPad *crash; delete crash; } #endif #endif Q_INIT_RESOURCE(common_images); Q_INIT_RESOURCE(common_tr); #if defined(Q_OS_WIN) setLibraryPaths( QStringList() << applicationDirPath() ); #elif defined(Q_OS_MAC) setLibraryPaths( QStringList() << applicationDirPath() + "/../PlugIns" ); #endif setStyleSheet( "QDialogButtonBox { dialogbuttonbox-buttons-have-icons: 0; }\n" ); QPalette p = palette(); p.setBrush( QPalette::Link, QBrush( "#509B00" ) ); p.setBrush( QPalette::LinkVisited, QBrush( "#509B00" ) ); setPalette( p ); qRegisterMetaType<TokenData>("TokenData"); QNetworkProxyFactory::setUseSystemConfiguration(true); #if defined(Q_OS_WIN) AllowSetForegroundWindow( ASFW_ANY ); #elif defined(Q_OS_MAC) #ifdef BREAKPAD if(arguments().contains("-crashreport", Qt::CaseInsensitive)) return; #endif if(!QSettings().value("plugins").isNull()) return; QTimer *timer = new QTimer(this); timer->setSingleShot(true); connect(timer, &QTimer::timeout, this, [=]{ timer->deleteLater(); QMessageBox *b = new QMessageBox(QMessageBox::Information, tr("Browser plugins"), tr("If you are using e-services for authentication and signing documents in addition to " "Mobile-ID an ID-card or only ID-card, you should install the browser integration packages.<br />" "<a href='http://installer.id.ee'>http://installer.id.ee</a>"), 0, activeWindow()); QAbstractButton *install = b->addButton(tr("Install"), QMessageBox::AcceptRole); b->addButton(tr("Remind later"), QMessageBox::AcceptRole); QAbstractButton *ignore = b->addButton(tr("Ignore forever"), QMessageBox::AcceptRole); b->exec(); if(b->clickedButton() == install) QDesktopServices::openUrl(QUrl("http://installer.id.ee")); else if(b->clickedButton() == ignore) QSettings().setValue("plugins", "ignore"); }); timer->start(1000); #endif }
Application(int &argc, char **argv) : QApplication(argc, argv) { QDir dir(applicationDirPath()); #ifdef Q_OS_MAC dir.cdUp(); dir.cd("PlugIns"); dir.cd("qt"); #else dir.cd("lib"); dir.cd("qt5"); #endif addLibraryPath(dir.absolutePath()); setOrganizationName("Meltytech"); #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) setOrganizationDomain("shotcut.org"); setDesktopFileName("org.shotcut.Shotcut"); #else setOrganizationDomain("meltytech.com"); #endif setApplicationName("Shotcut"); setApplicationVersion(SHOTCUT_VERSION); setAttribute(Qt::AA_UseHighDpiPixmaps); setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); #if defined(Q_OS_MAC) setAttribute(Qt::AA_DontShowIconsInMenus); #endif // Process command line options. QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); #ifndef Q_OS_WIN QCommandLineOption fullscreenOption("fullscreen", QCoreApplication::translate("main", "Fill the screen with the Shotcut window.")); parser.addOption(fullscreenOption); #endif QCommandLineOption noupgradeOption("noupgrade", QCoreApplication::translate("main", "Hide upgrade prompt and menu item.")); parser.addOption(noupgradeOption); QCommandLineOption gpuOption("gpu", QCoreApplication::translate("main", "Use GPU processing.")); parser.addOption(gpuOption); QCommandLineOption clearRecentOption("clear-recent", QCoreApplication::translate("main", "Clear Recent on Exit")); parser.addOption(clearRecentOption); QCommandLineOption appDataOption("appdata", QCoreApplication::translate("main", "The directory for app configuration and data."), QCoreApplication::translate("main", "directory")); parser.addOption(appDataOption); QCommandLineOption scaleOption("QT_SCALE_FACTOR", QCoreApplication::translate("main", "The scale factor for a high-DPI screen"), QCoreApplication::translate("main", "number")); parser.addOption(scaleOption); scaleOption = QCommandLineOption("QT_SCREEN_SCALE_FACTORS", QCoreApplication::translate("main", "A semicolon-separated list of scale factors for each screen"), QCoreApplication::translate("main", "list")); parser.addOption(scaleOption); parser.addPositionalArgument("[FILE]...", QCoreApplication::translate("main", "Zero or more files or folders to open")); parser.process(arguments()); #ifdef Q_OS_WIN isFullScreen = false; #else isFullScreen = parser.isSet(fullscreenOption); #endif setProperty("noupgrade", parser.isSet(noupgradeOption)); setProperty("clearRecent", parser.isSet(clearRecentOption)); if (!parser.value(appDataOption).isEmpty()) { appDirArg = parser.value(appDataOption); ShotcutSettings::setAppDataForSession(appDirArg); } if (parser.isSet(gpuOption)) Settings.setPlayerGPU(true); if (!parser.positionalArguments().isEmpty()) resourceArg = parser.positionalArguments(); // Startup logging. dir = Settings.appDataLocation(); if (!dir.exists()) dir.mkpath(dir.path()); const QString logFileName = dir.filePath("shotcut-log.txt"); QFile::remove(logFileName); FileAppender* fileAppender = new FileAppender(logFileName); fileAppender->setFormat("[%{type:-7}] <%{function}> %{message}\n"); cuteLogger->registerAppender(fileAppender); #ifndef NDEBUG // Only log to console in dev debug builds. ConsoleAppender* consoleAppender = new ConsoleAppender(); consoleAppender->setFormat(fileAppender->format()); cuteLogger->registerAppender(consoleAppender); mlt_log_set_level(MLT_LOG_VERBOSE); #else mlt_log_set_level(MLT_LOG_INFO); #endif mlt_log_set_callback(mlt_log_handler); cuteLogger->logToGlobalInstance("qml", true); // Log some basic info. LOG_INFO() << "Starting Shotcut version" << SHOTCUT_VERSION; #if defined (Q_OS_WIN) LOG_INFO() << "Windows version" << QSysInfo::windowsVersion(); #elif defined(Q_OS_MAC) LOG_INFO() << "macOS version" << QSysInfo::macVersion(); #else LOG_INFO() << "Linux version"; #endif LOG_INFO() << "number of logical cores =" << QThread::idealThreadCount(); LOG_INFO() << "locale =" << QLocale(); LOG_INFO() << "install dir =" << applicationDirPath(); LOG_INFO() << "device pixel ratio =" << devicePixelRatio(); Settings.log(); #if defined(Q_OS_WIN) if (Settings.playerGPU()) { QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL); } else if (Settings.drawMethod() >= Qt::AA_UseDesktopOpenGL && Settings.drawMethod() <= Qt::AA_UseSoftwareOpenGL) { QCoreApplication::setAttribute(Qt::ApplicationAttribute(Settings.drawMethod())); } #endif // Load translations QString locale = Settings.language(); dir = applicationDirPath(); #if defined(Q_OS_MAC) dir.cdUp(); dir.cd("Resources"); dir.cd("translations"); #elif defined(Q_OS_WIN) dir.cd("share"); dir.cd("translations"); #else dir.cdUp(); dir.cd("share"); dir.cd("shotcut"); dir.cd("translations"); #endif if (locale.startsWith("pt_")) locale = "pt"; else if (locale.startsWith("en_")) locale = "en"; if (qtTranslator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) installTranslator(&qtTranslator); else if (qtTranslator.load("qt_" + locale, dir.absolutePath())) installTranslator(&qtTranslator); if (qtBaseTranslator.load("qtbase_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) installTranslator(&qtBaseTranslator); else if (qtBaseTranslator.load("qtbase_" + locale, dir.absolutePath())) installTranslator(&qtBaseTranslator); if (shotcutTranslator.load("shotcut_" + Settings.language(), dir.absolutePath())) installTranslator(&shotcutTranslator); }
void QgsApplication::init( QString customConfigPath ) { if ( customConfigPath.isEmpty() ) { if ( getenv( "QGIS_CUSTOM_CONFIG_PATH" ) ) { customConfigPath = getenv( "QGIS_CUSTOM_CONFIG_PATH" ); } else { customConfigPath = QStringLiteral( "%1/.qgis3/" ).arg( QDir::homePath() ); } } qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" ); qRegisterMetaType<QgsProcessingFeatureSourceDefinition>( "QgsProcessingFeatureSourceDefinition" ); qRegisterMetaType<QgsProcessingOutputLayerDefinition>( "QgsProcessingOutputLayerDefinition" ); QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() ); // QgsDebugMsg( QString( "prefixPath(): %1" ).arg( prefixPath ) ); // check if QGIS is run from build directory (not the install directory) QFile f; // "/../../.." is for Mac bundled app in build directory Q_FOREACH ( const QString &path, QStringList() << "" << "/.." << "/bin" << "/../../.." ) { f.setFileName( prefixPath + path + "/qgisbuildpath.txt" ); if ( f.exists() ) break; } if ( f.exists() && f.open( QIODevice::ReadOnly ) ) { ABISYM( mRunningFromBuildDir ) = true; ABISYM( mBuildSourcePath ) = f.readLine().trimmed(); ABISYM( mBuildOutputPath ) = f.readLine().trimmed(); qDebug( "Running from build directory!" ); qDebug( "- source directory: %s", ABISYM( mBuildSourcePath ).toUtf8().data() ); qDebug( "- output directory of the build: %s", ABISYM( mBuildOutputPath ).toUtf8().data() ); #ifdef _MSC_VER ABISYM( mCfgIntDir ) = prefixPath.split( '/', QString::SkipEmptyParts ).last(); qDebug( "- cfg: %s", ABISYM( mCfgIntDir ).toUtf8().data() ); #endif } if ( ABISYM( mRunningFromBuildDir ) ) { // we run from source directory - not installed to destination (specified prefix) ABISYM( mPrefixPath ) = QString(); // set invalid path #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) setPluginPath( ABISYM( mBuildOutputPath ) + '/' + QString( QGIS_PLUGIN_SUBDIR ) + '/' + ABISYM( mCfgIntDir ) ); #else setPluginPath( ABISYM( mBuildOutputPath ) + '/' + QStringLiteral( QGIS_PLUGIN_SUBDIR ) ); #endif setPkgDataPath( ABISYM( mBuildSourcePath ) ); // directly source path - used for: doc, resources, svg ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) + '/' + QGIS_LIB_SUBDIR + '/'; #if defined(_MSC_VER) && !defined(USING_NMAKE) && !defined(USING_NINJA) ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) + '/' + QGIS_LIBEXEC_SUBDIR + '/' + ABISYM( mCfgIntDir ) + '/'; #else ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) + '/' + QGIS_LIBEXEC_SUBDIR + '/'; #endif } else { char *prefixPath = getenv( "QGIS_PREFIX_PATH" ); if ( !prefixPath ) { #if defined(Q_OS_MACX) || defined(Q_OS_WIN) setPrefixPath( applicationDirPath(), true ); #elif defined(ANDROID) // this is "/data/data/org.qgis.qgis" in android QDir myDir( QDir::homePath() ); myDir.cdUp(); QString myPrefix = myDir.absolutePath(); setPrefixPath( myPrefix, true ); #else QDir myDir( applicationDirPath() ); myDir.cdUp(); QString myPrefix = myDir.absolutePath(); setPrefixPath( myPrefix, true ); #endif } else { setPrefixPath( prefixPath, true ); } } if ( !customConfigPath.isEmpty() ) { ABISYM( mConfigPath ) = customConfigPath + '/'; // make sure trailing slash is included } ABISYM( mDefaultSvgPaths ) << qgisSettingsDirPath() + QStringLiteral( "svg/" ); ABISYM( mAuthDbDirPath ) = qgisSettingsDirPath(); if ( getenv( "QGIS_AUTH_DB_DIR_PATH" ) ) { setAuthDatabaseDirPath( getenv( "QGIS_AUTH_DB_DIR_PATH" ) ); } // store system environment variables passed to application, before they are adjusted QMap<QString, QString> systemEnvVarMap; QString passfile( QStringLiteral( "QGIS_AUTH_PASSWORD_FILE" ) ); // QString, for comparison Q_FOREACH ( const QString &varStr, QProcess::systemEnvironment() ) { int pos = varStr.indexOf( QLatin1Char( '=' ) ); if ( pos == -1 ) continue; QString varStrName = varStr.left( pos ); QString varStrValue = varStr.mid( pos + 1 ); if ( varStrName != passfile ) { systemEnvVarMap.insert( varStrName, varStrValue ); } }
Application(int &argc, char **argv) : QApplication(argc, argv) { QDir dir(applicationDirPath()); dir.cd("lib"); dir.cd("qt5"); addLibraryPath(dir.absolutePath()); setOrganizationName("Meltytech"); setOrganizationDomain("meltytech.com"); setApplicationName("Shotcut"); setApplicationVersion(SHOTCUT_VERSION); setAttribute(Qt::AA_UseHighDpiPixmaps); setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); #if defined(Q_OS_MAC) setAttribute(Qt::AA_DontShowIconsInMenus); #endif #if defined(Q_OS_WIN) if (Settings.playerGPU()) { QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL); } else if (Settings.drawMethod() >= Qt::AA_UseDesktopOpenGL && Settings.drawMethod() <= Qt::AA_UseSoftwareOpenGL) { QCoreApplication::setAttribute(Qt::ApplicationAttribute(Settings.drawMethod())); } #endif // Startup logging. dir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); if (!dir.exists()) dir.mkpath(dir.path()); const QString logFileName = dir.filePath("shotcut-log.txt"); QFile::remove(logFileName); FileAppender* fileAppender = new FileAppender(logFileName); fileAppender->setFormat("[%-7l] <%C> %m\n"); Logger::registerAppender(fileAppender); #ifndef NDEBUG // Only log to console in dev debug builds. ConsoleAppender* consoleAppender = new ConsoleAppender(); consoleAppender->setFormat(fileAppender->format()); Logger::registerAppender(consoleAppender); mlt_log_set_level(MLT_LOG_VERBOSE); #else mlt_log_set_level(MLT_LOG_INFO); #endif mlt_log_set_callback(mlt_log_handler); // Log some basic info. LOG_INFO() << "Starting Shotcut version" << SHOTCUT_VERSION; #if defined (Q_OS_WIN) LOG_INFO() << "Windows version" << QSysInfo::windowsVersion(); #elif defined(Q_OS_MAC) LOG_INFO() << "OS X version" << QSysInfo::macVersion(); #else LOG_INFO() << "Linux version"; #endif LOG_INFO() << "number of logical cores =" << QThread::idealThreadCount(); LOG_INFO() << "locale =" << QLocale(); LOG_INFO() << "install dir =" << applicationDirPath(); // Load translations QString locale = Settings.language(); dir = applicationDirPath(); #if defined(Q_OS_MAC) dir.cdUp(); dir.cd("Resources"); dir.cd("translations"); #elif defined(Q_OS_WIN) dir.cd("share"); dir.cd("translations"); #else dir.cdUp(); dir.cd("share"); dir.cd("shotcut"); dir.cd("translations"); #endif if (locale.startsWith("pt_")) locale = "pt"; if (qtTranslator.load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) installTranslator(&qtTranslator); else if (qtTranslator.load("qt_" + locale, dir.absolutePath())) installTranslator(&qtTranslator); if (qtBaseTranslator.load("qtbase_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) installTranslator(&qtBaseTranslator); else if (qtBaseTranslator.load("qtbase_" + locale, dir.absolutePath())) installTranslator(&qtBaseTranslator); if (shotcutTranslator.load("shotcut_" + Settings.language(), dir.absolutePath())) installTranslator(&shotcutTranslator); QCommandLineParser parser; parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption fullscreenOption("fullscreen", QCoreApplication::translate("main", "Fill the screen with the Shotcut window.")); parser.addOption(fullscreenOption); QCommandLineOption gpuOption("gpu", QCoreApplication::translate("main", "Use GPU processing.")); parser.addOption(gpuOption); parser.addPositionalArgument("resource", QCoreApplication::translate("main", "A file to open.")); parser.process(arguments()); isFullScreen = parser.isSet(fullscreenOption); if (parser.isSet(gpuOption)) Settings.setPlayerGPU(true); if (!parser.positionalArguments().isEmpty()) resourceArg = parser.positionalArguments().first(); }