示例#1
1
AboutWindow::AboutWindow(QWidget *parent) :
	QDialog(parent)
{
	setWindowTitle(tr("About Symmetries"));
	setFixedSize(QSize(WINDOW_WIDTH, WINDOW_HEIGHT));

	m_appNameLabel = new QLabel(PROGRAM_NAME, this);
	QFont font = m_appNameLabel->font();
	font.setPointSize(APPNAME_FONT_POINT_SIZE);
	font.setBold(true);
	m_appNameLabel->setFont(font);

	QString appVersion("Version: ");
	appVersion.append(PROGRAM_VERSION);
	m_appVersionLabel = new QLabel(appVersion, this);

	QTextDocument* developersInfo = new QTextDocument(this);
	developersInfo->setHtml("<b>Copyright (C) 2014</b><br><br>"
		"<i>Alexey Kuzin ([email protected])</i><br>"
		"Author, Maintainer, Designer<br><br>"
		"<i>Mikhail Barenboim ([email protected])</i><br>"
		"Designer");
	m_developInfo = new QTextEdit(this);
	m_developInfo->setDocument(developersInfo);
	m_developInfo->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
	m_developInfo->setReadOnly(true);

	m_pushBtnOk = new QPushButton(tr("OK"), this);
	m_pushBtnOk->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);

	QVBoxLayout* mainLayout = new QVBoxLayout;
	mainLayout->addWidget(m_appNameLabel, 0, Qt::AlignLeft);
	mainLayout->addWidget(m_appVersionLabel, 0, Qt::AlignLeft);
	mainLayout->addWidget(m_developInfo, 1);
	mainLayout->addWidget(m_pushBtnOk, 0, Qt::AlignRight);
	setLayout(mainLayout);

	connect(m_pushBtnOk, SIGNAL(clicked()), this, SLOT(close()));
}
示例#2
0
文件: main.cpp 项目: Artiom-M/xpiks
void initQSettings() {
    QCoreApplication::setOrganizationName(Constants::ORGANIZATION_NAME);
    QCoreApplication::setOrganizationDomain(Constants::ORGANIZATION_DOMAIN);
    QCoreApplication::setApplicationName(Constants::APPLICATION_NAME);
    QString appVersion(STRINGIZE(BUILDNUMBER));
    QCoreApplication::setApplicationVersion(XPIKS_VERSION_STRING " " STRINGIZE(XPIKS_VERSION_SUFFIX) " - " +
                                            appVersion.left(10));
}
std::string GlobalSettings::appTitle()
{
  std::string title = appName() + appVersion(std::string(" v")) + " " + m_platform;
  if(m_isBetaVersion)
    title += " - BETA VERSION";
  if(m_isAlphaVersion)
    title += " - ALPHA VERSION";
  return title;
}
示例#4
0
  AboutDialog::AboutDialog(QWidget *parent)
    : QDialog(parent
#ifdef Q_WS_MAC
        , Qt::Tool
#endif
        )
    {
      QGridLayout *layout = new QGridLayout(this);
      QLabel *label = new QLabel(this);
      QLabel *lbl = new QLabel(this);
      QPushButton *cmd = new QPushButton(tr("OK"), this);
      QPixmap logo = QPixmap(":/icons/avogadro.png");

      label->setPixmap(logo.scaled(256, 256,
            Qt::KeepAspectRatio,
            Qt::SmoothTransformation));

      lbl->setWordWrap(true);
      lbl->setOpenExternalLinks(true);

      // Build up the SCM revision numbers if present
      QString scmVersion(SCM_REVISION);
      QString appVersion(VERSION);
      QLatin1String obVersion(BABEL_VERSION);
      QLatin1String qtVersion(QT_VERSION_STR);
      if (scmVersion.length())
        appVersion += ' ' + QString(tr("(Git revision: %1)", "%1 is the Git revision number.")).arg(scmVersion);
      QString libVersion(Library::version());
      if (Library::scmRevision().length())
        libVersion += ' ' + QString(tr("(Git revision: %1)", "%1 is the Git revision number.")).arg(Library::scmRevision());

      lbl->setText(
          tr("<h3>%1</h3>"
            "<br/><br/>Application Version: %2"
            "<br/><br/>Library Version: %3"
            "<br/><br/>Open Babel Version: %4").arg(tr("Avogadro")).arg(appVersion).arg(libVersion).arg(obVersion) +
          tr("<br/><br/>Qt Version: %1"
            "<br/><br/>For more information check the <a href=\"http://avogadro.openmolecules.net/\">Avogadro homepage</a>."
            "<br/><br/>The program is provided AS IS with NO WARRANTY OF ANY KIND,"
            " INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A"
            " PARTICULAR PURPOSE.<br/>"
             ).arg(qtVersion));

      cmd->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
      cmd->setDefault(true);
      connect(cmd, SIGNAL(clicked()),
          this, SLOT(reject()));

      layout->addWidget(label, 0, 0, 1, 1);
      layout->addWidget(lbl, 0, 1, 4, 4);
      layout->addWidget(cmd, 4, 2, 1, 1);
    }
示例#5
0
int EmulateSp::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 10)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 10;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = appVersion(); break;
        case 1: *reinterpret_cast< QString*>(_v) = getUri(); break;
        case 2: *reinterpret_cast< QString*>(_v) = getText(); break;
        }
        _id -= 3;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setAppVersion(*reinterpret_cast< QString*>(_v)); break;
        case 1: setUri(*reinterpret_cast< QString*>(_v)); break;
        case 2: setText(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 3;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 3;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 3;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
示例#6
0
int _SMERP_posixMain( int argc, char* argv[] )
{
// i18n global stuff
	if ( setlocale( LC_ALL, "" ) == NULL )	{
		std::cerr << "Unable to set locale. Falling back to default." << std::endl;
	}
	else	{
		if ( bindtextdomain( "SMERP", "../po" ) == NULL )	{
			std::cerr << "Not enough memory to bind textdomain" << std::endl;
			return _SMERP::ErrorCodes::FAILURE;
		}
		if ( textdomain( "SMERP" ) == NULL )	{
			std::cerr << "Not enough memory to set textdomain" << std::endl;
			return _SMERP::ErrorCodes::FAILURE;
		}
	}
// end of i18n global stuff

	try	{
		_SMERP::Version		appVersion( MAJOR_VERSION, MINOR_VERSION, REVISION_NUMBER );
		_SMERP::CmdLineConfig	cmdLineCfg;
		const char		*configFile;

// it's just a DUMMY for now
		_SMERP::HandlerConfiguration	handlerConfig;

		if ( !cmdLineCfg.parse( argc, argv ))	{	// there was an error parsing the command line
			std::cerr << cmdLineCfg.errMsg() << std::endl << std::endl;
			cmdLineCfg.usage( std::cerr );
			std::cerr << std::endl;
			return _SMERP::ErrorCodes::FAILURE;
		}
// command line has been parsed successfully
// if cmdLineCfg.errMsg() is not empty than we have a warning
		if ( !cmdLineCfg.errMsg().empty() )	// there was a warning parsing the command line
			std::cerr << "BOO:" << cmdLineCfg.errMsg() << std::endl << std::endl;

// if we have to print the version or the help do it and exit
		if ( cmdLineCfg.command == _SMERP::CmdLineConfig::PRINT_VERSION )	{
			std::cout << std::endl << gettext( "BOBOBO version " )
				<< appVersion.toString() << std::endl << std::endl;
			return _SMERP::ErrorCodes::OK;
		}
		if ( cmdLineCfg.command == _SMERP::CmdLineConfig::PRINT_HELP )	{
			std::cout << std::endl << gettext( "BOBOBO version " )
				<< appVersion.toString() << std::endl;
			cmdLineCfg.usage( std::cout );
			std::cout << std::endl;
			return _SMERP::ErrorCodes::OK;
		}

// decide what configuration file to use
		if ( !cmdLineCfg.cfgFile.empty() )	// if it has been specified than that's The One ! (and only)
			configFile = cmdLineCfg.cfgFile.c_str();
		else
			configFile = _SMERP::CfgFileConfig::chooseFile( DEFAULT_MAIN_CONFIG,
								       DEFAULT_USER_CONFIG,
								       DEFAULT_LOCAL_CONFIG );
		if ( configFile == NULL )	{	// there is no configuration file
			std::cerr << gettext ( "MOMOMO: no configuration file found !" ) << std::endl << std::endl;
			return _SMERP::ErrorCodes::FAILURE;
		}

		_SMERP::CfgFileConfig	cfgFileCfg;
		if ( !cfgFileCfg.parse( configFile ))	{	// there was an error parsing the configuration file
			std::cerr << cfgFileCfg.errMsg() << std::endl << std::endl;
			return _SMERP::ErrorCodes::FAILURE;
		}
		else if ( !cfgFileCfg.errMsg().empty())
			std::cerr << cfgFileCfg.errMsg() << std::endl;
// configuration file has been parsed successfully
// build the application configuration
		_SMERP::ApplicationConfiguration config( cmdLineCfg, cfgFileCfg);

// now here we know where to log to on stderr
		_SMERP::LogBackend::instance().setConsoleLevel( config.stderrLogLevel );

// Check the configuration
		if ( cmdLineCfg.command == _SMERP::CmdLineConfig::CHECK_CONFIG )	{
			std::cout << std::endl << gettext( "BOBOBO version " )
				<< appVersion.toString() << std::endl;
			if ( config.check() )	{
				if ( config.errMsg().empty() )	{
					std::cout << "Configuration OK" << std::endl << std::endl;
					return _SMERP::ErrorCodes::OK;
				}
				else	{
					std::cout << "WARNING: " << config.errMsg() << std::endl << std::endl;
					return _SMERP::ErrorCodes::OK;
				}
			}
			else	{
				std::cout << "ERROR: " << config.errMsg() << std::endl << std::endl;
				return _SMERP::ErrorCodes::OK;
			}
		}

		if ( cmdLineCfg.command == _SMERP::CmdLineConfig::PRINT_CONFIG )	{
			std::cout << std::endl << gettext( "BOBOBO version " )
				<< appVersion.toString() << std::endl;
			config.print( std::cout );
			std::cout << std::endl;
			return _SMERP::ErrorCodes::OK;
		}

		if ( cmdLineCfg.command == _SMERP::CmdLineConfig::TEST_CONFIG )	{
			std::cout << "Not implemented yet" << std::endl << std::endl;
			return _SMERP::ErrorCodes::OK;
		}

		// Daemon stuff
		if( !config.foreground ) {
			// Aba: maybe also in the foreground?
			// try to lock the pidfile, bail out if not possible
			if( boost::filesystem::exists( config.pidFile ) ) {
				boost::interprocess::file_lock lock( config.pidFile.c_str( ) );
				if( lock.try_lock( ) ) {
					std::cerr << "Pidfile is locked, another daemon running?" << std::endl;
					return _SMERP::ErrorCodes::FAILURE;
				}
			}

			// daemonize, lose process group, terminal output, etc.
			if( daemon( 0, 0 ) ) {
				std::cerr << "Daemonizing server failed" << std::endl;
				return _SMERP::ErrorCodes::FAILURE;
			}

			// now here we lost constrol over the console, we should
			// create a temporary logger which at least tells what's
			// going on in the syslog
			_SMERP::LogBackend::instance().setSyslogLevel( config.syslogLogLevel );
			_SMERP::LogBackend::instance().setSyslogFacility( config.syslogFacility );
			_SMERP::LogBackend::instance().setSyslogIdent( config.syslogIdent );

			// if we are root we can drop privileges now
			struct group *groupent;
			struct passwd *passwdent;

			groupent = getgrnam( config.group.c_str( ) );
			passwdent = getpwnam( config.user.c_str( ) );
			if( groupent == NULL || passwdent == NULL ) {
				LOG_CRITICAL << "Illegal group '" << config.group << "' or user '" << config.user << "'";
				return _SMERP::ErrorCodes::FAILURE;
			}

			if( setgid( groupent->gr_gid ) < 0 ) {
				LOG_CRITICAL << "setgid for group '" << config.group << "' failed!";
				return _SMERP::ErrorCodes::FAILURE;
			}

			if( setuid( passwdent->pw_uid ) < 0 ) {
				LOG_CRITICAL << "setgid for user '" << config.user << "' failed!";
				return _SMERP::ErrorCodes::FAILURE;
			}

			// create a pid file and lock id
			std::ofstream pidFile( config.pidFile.c_str( ), std::ios_base::trunc );
			if( !pidFile.good( ) ) {
				LOG_CRITICAL << "Unable to create PID file '" << config.pidFile << "'!";
				return _SMERP::ErrorCodes::FAILURE;
			}
			pidFile << getpid( ) << std::endl;
			pidFile.close( );

			// Create the final logger based on the configuration
			// file logger only here to get the right permissions
			_SMERP::LogBackend::instance().setLogfileLevel( config.logFileLogLevel );
			_SMERP::LogBackend::instance().setLogfileName( config.logFile );
		}

		// Block all signals for background thread.
		sigset_t new_mask;
		sigfillset( &new_mask );
		sigset_t old_mask;
		pthread_sigmask( SIG_BLOCK, &new_mask, &old_mask );

		LOG_NOTICE << "Starting server";

		// Run server in background thread(s).
		_SMERP::ServerHandler	handler( handlerConfig );
		_SMERP::Network::server s( config.address, config.SSLaddress, handler,
					   config.threads, config.maxConnections );
		boost::thread t( boost::bind( &_SMERP::Network::server::run, &s ));

		// Restore previous signals.
		pthread_sigmask( SIG_SETMASK, &old_mask, 0 );

		// Wait for signal indicating time to shut down.
		sigset_t wait_mask;
		sigemptyset( &wait_mask );
		sigaddset( &wait_mask, SIGINT );
		sigaddset( &wait_mask, SIGQUIT );
		sigaddset( &wait_mask, SIGTERM );
		pthread_sigmask( SIG_BLOCK, &wait_mask, 0 );
		int sig = 0;
		sigwait( &wait_mask, &sig );

		// Stop the server.
		LOG_INFO << "Stopping server";
		s.stop();
		t.join();
		LOG_NOTICE << "Server stopped";

		// Daemon stuff
		if( !config.foreground ) {
			(void)remove( config.pidFile.c_str( ) );
		}
	}
	catch (std::exception& e)	{
		// Aba: how to delete the pid file here?
		LOG_ERROR << "posixMain: exception: " << e.what() << "\n";
		return _SMERP::ErrorCodes::FAILURE;
	}

	return _SMERP::ErrorCodes::OK;
}