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


C++ KviThemeInfo::setSubdirectory方法代码示例

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


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

示例1: theme_kvs_cmd_apply

/*
	@doc: theme.apply
	@type:
		command
	@title:
		theme.apply
	@short:
		Apply a theme.
	@syntax:
		theme.apply <package_name:string>
	@description:
		Attempts to apply the theme specified by <package_name>.
*/
static bool theme_kvs_cmd_apply(KviKvsModuleCommandCall * c)
{
	QString szThemePackFile;

	KVSM_PARAMETERS_BEGIN(c)
		KVSM_PARAMETER("package_name",KVS_PT_STRING,0,szThemePackFile)
	KVSM_PARAMETERS_END(c)
	KviThemeInfo * themeInfo = new KviThemeInfo();
	if(themeInfo->load(szThemePackFile))
	{
		themeInfo->setSubdirectory(szThemePackFile);
		if(KviMessageBox::yesNo(__tr2qs_ctx("Apply theme - KVIrc","theme"),
		__tr2qs_ctx("Do you wish to apply theme \"%Q\" (version %Q)?","theme"),
		&(themeInfo->name()),&(themeInfo->version())))
		{
			KviThemeInfo out;
			if(!KviTheme::load(szThemePackFile,out))
			{
				QString szErr = out.lastError();
				QString szMsg = QString(__tr2qs_ctx("Failed to apply the specified theme: %1","theme")).arg(szErr);
				QMessageBox::critical(0,__tr2qs_ctx("Apply theme - KVIrc","theme"),szMsg,
				QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
			}
			return true;
		}
	}
	c->warning(__tr2qs_ctx("The theme package '%Q' does not exist","theme"),&szThemePackFile);
	return true;
}
开发者ID:netrunner-debian-kde-extras,项目名称:kvirc,代码行数:42,代码来源:libkvitheme.cpp

示例2: saveTheme

bool SaveThemeDialog::saveTheme()
{
	m_pImageSelector->commit();

	KviThemeInfo sto;
	sto.setName(m_pThemeNameEdit->text());
	if(sto.name().isEmpty())
	{
		QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("You must choose a theme name!","theme"),QMessageBox::Ok,
			QMessageBox::NoButton,QMessageBox::NoButton);
		return false;
	}

	sto.setAuthor(m_pAuthorNameEdit->text());
	sto.setDescription(m_pThemeDescriptionEdit->toPlainText());

	QString szTmp;
	QDateTime date = QDateTime::currentDateTime();
	switch(KVI_OPTION_UINT(KviOption_uintOutputDatetimeFormat))
	{
		case 0:
			// this is the equivalent to an empty date.toString() call, but it's needed
			// to ensure qt4 will use the default() locale and not the system() one
			szTmp = QLocale().toString(date, "ddd MMM d hh:mm:ss yyyy");
			break;
		case 1:
			szTmp = date.toString(Qt::ISODate);
			break;
		case 2:
			szTmp = date.toString(Qt::SystemLocaleShortDate);
			break;
	}

	sto.setDate(szTmp);
	sto.setVersion(m_pThemeVersionEdit->text());
	sto.setApplication("KVIrc " KVI_VERSION "." KVI_SOURCES_DATE);

	if(sto.version().isEmpty())sto.setVersion("1.0.0");

	QString szSubdir = sto.name() + QString("-") + sto.version();
	szSubdir.replace(QRegExp("[ \\\\/:][ \\\\/:]*"),"_");
	sto.setSubdirectory(szSubdir);

	QString szAbsDir;
	g_pApp->getLocalKvircDirectory(szAbsDir,KviApplication::Themes,sto.subdirectory(),true);
	if(!KviFileUtils::makeDir(szAbsDir))
	{
		QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("Unable to create theme directory.","theme"),
			QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
		return false;
	}


	if(!KviTheme::save(sto))
	{
		QString szErr = sto.lastError();
		QString szMsg2 = QString(__tr2qs_ctx("Unable to save theme: %1","theme")).arg(szErr);
		QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),szMsg2,
			QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
		return false;
	}
	// write down the screenshot, if needed

	if(!m_szScreenshotPath.isEmpty())
	{
		if(!KviTheme::saveScreenshots(sto,m_szScreenshotPath))
		{
			QMessageBox::critical(this,__tr2qs_ctx("Save Current Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected screenshot image: please fix it","theme"),
				QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
			setCurrentPage(m_pImageSelectionPage);
			return false;
		}
	}

	QString szMsg = __tr2qs_ctx("Theme saved successfully to %1","theme").arg(szAbsDir);

	QMessageBox::information(this,__tr2qs_ctx("Save Theme - KVIrc","theme"),szMsg,QMessageBox::Ok,
		QMessageBox::NoButton,QMessageBox::NoButton);

	return true;
}
开发者ID:namikaze90,项目名称:KVIrc-old,代码行数:81,代码来源:SaveThemeDialog.cpp


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