当前位置: 首页>>代码示例>>C++>>正文


C++ QApplication::applicationFilePath方法代码示例

本文整理汇总了C++中QApplication::applicationFilePath方法的典型用法代码示例。如果您正苦于以下问题:C++ QApplication::applicationFilePath方法的具体用法?C++ QApplication::applicationFilePath怎么用?C++ QApplication::applicationFilePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QApplication的用法示例。


在下文中一共展示了QApplication::applicationFilePath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: registerXdgMime

void registerXdgMime(QApplication &app){
    // MacOS handled via Info.plist
    // Windows handled in the installer by rbrunner7

    QString xdg = QString(
            "[Desktop Entry]\n"
            "Name=Monero GUI\n"
            "GenericName=Monero-GUI\n"
            "X-GNOME-FullName=Monero-GUI\n"
            "Comment=Monero GUI\n"
            "Keywords=Monero;\n"
            "Exec=%1 %u\n"
            "Terminal=false\n"
            "Type=Application\n"
            "Icon=monero\n"
            "Categories=Network;GNOME;Qt;\n"
            "MimeType=x-scheme-handler/monero;x-scheme-handler/moneroseed\n"
            "StartupNotify=true\n"
            "X-GNOME-Bugzilla-Bugzilla=GNOME\n"
            "X-GNOME-UsesNotifications=true\n"
    ).arg(app.applicationFilePath());

    QString appPath = QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
    QString filePath = QString("%1/monero-gui.desktop").arg(appPath);

    qDebug() << QString("Writing %1").arg(filePath);
    QFile file(filePath);
    if(file.open(QIODevice::WriteOnly)){
        QTextStream out(&file); out << xdg << endl;
        file.close();
    }
    else
        file.close();
}
开发者ID:monero-project,项目名称:monero-core,代码行数:34,代码来源:mime.cpp

示例2: figureOutBinaryPath

void Backup::figureOutBinaryPath(const char *argv0, QApplication &app)
{
    /*
       The application can be launched by two ways:
       - Globaly (app.applicationFilePath() is good)
       - In KDevelop or with an absolute path (app.applicationFilePath() is wrong)
       This function is called at the very start of main() so that the current directory has not been changed yet.

       Command line (argv[0])   QDir(argv[0]).canonicalPath()                   app.applicationFilePath()
       ======================   =============================================   =========================
       "basket"                 ""                                              "/opt/kde3/bin/basket"
       "./src/.libs/basket"     "/home/seb/prog/basket/debug/src/.lib/basket"   "/opt/kde3/bin/basket"
    */

    binaryPath = QDir(argv0).canonicalPath();
    if (binaryPath.isEmpty())
        binaryPath = app.applicationFilePath();
}
开发者ID:KrissN,项目名称:basket,代码行数:18,代码来源:backup.cpp

示例3: main


//.........这里部分代码省略.........

					//        				H2Core::Logger::get_instance()->log("[LASH] Restore file: " + songFilename);

					lash_event_destroy(lash_event);
				}
				else if (lash_event)
				{
					//        				H2Core::Logger::get_instance()->log("[LASH] ERROR: Instead of restore file got event: " + lash_event_get_type(lash_event));
					lash_event_destroy(lash_event);
				}
			}
		}
#endif

#ifdef H2CORE_HAVE_JACKSESSION
		if(!sessionId.isEmpty()){
			pPref->setJackSessionUUID( sessionId );

			/*
					 * imo, jack sessions use jack as default audio driver.
					 * hydrogen remember last used audiodriver.
					 * here we make it save that hydrogen start in a jacksession case
					 * every time with jack as audio driver
					 */
			pPref->m_sAudioDriver = "Jack";

		}

		/*
		 * the use of applicationFilePath() make it
		 * possible to use different executables.
		* for example if you start hydrogen from a local
		* build directory.
		*/

		QString path = pQApp->applicationFilePath();
		pPref->setJackSessionApplicationPath( path );
#endif

		// Hydrogen here to honor all preferences.
		H2Core::Hydrogen::create_instance();

#ifdef H2CORE_HAVE_NSMSESSION
		H2Core::Hydrogen::get_instance()->startNsmClient();
		songFilename = pPref->getNsmSongName();
#endif

		MainForm *pMainForm = new MainForm( pQApp, songFilename );
		pMainForm->show();
		pSplash->finish( pMainForm );

		if( ! playlistFilename.isEmpty() ){
			bool loadlist = HydrogenApp::get_instance()->getPlayListDialog()->loadListByFileName( playlistFilename );
			if ( loadlist ){
				Playlist::get_instance()->setNextSongByNumber( 0 );
			} else {
				___ERRORLOG ( "Error loading the playlist" );
			}
		}

		if( ! drumkitToLoad.isEmpty() ) {
			H2Core::Drumkit* drumkitInfo = H2Core::Drumkit::load_by_name( drumkitToLoad, true );
			if ( drumkitInfo ) {
				H2Core::Hydrogen::get_instance()->loadDrumkit( drumkitInfo );
				HydrogenApp::get_instance()->onDrumkitLoad( drumkitInfo->get_name() );
			} else {
				___ERRORLOG ( "Error loading the drumkit" );
			}
		}

		pQApp->exec();

		delete pSplash;
		delete pMainForm;
		delete pQApp;
		delete pPref;
		delete H2Core::EventQueue::get_instance();
		delete H2Core::AudioEngine::get_instance();

		delete MidiMap::get_instance();
		delete MidiActionManager::get_instance();

		___INFOLOG( "Quitting..." );
		cout << "\nBye..." << endl;
		delete H2Core::Logger::get_instance();

		if (H2Core::Object::count_active()) {
			H2Core::Object::write_objects_map_to_cerr();
		}

	}
	catch ( const H2Core::H2Exception& ex ) {
		std::cerr << "[main] Exception: " << ex.what() << std::endl;
	}
	catch (...) {
		std::cerr << "[main] Unknown exception X-(" << std::endl;
	}

	return 0;
}
开发者ID:AdamFf,项目名称:hydrogen,代码行数:101,代码来源:main.cpp


注:本文中的QApplication::applicationFilePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。