Example #1
0
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);
}
Example #2
0
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
}