Esempio n. 1
0
/*!
  Loads translate proper file basing on \a index of the language in languages list.
*/
void Translate::loadTranslate(int index)
{
    mTranslator = new QTranslator();

    QString languageCode;
    QString language;

    if (index < availableLanguages().count())
        language = availableLanguages()[index];
    else
        return;

    if (language == QObject::tr("Polish"))
        languageCode = "pl";
    else if (language == QObject::tr("German"))
        languageCode = "ge";
    else if (language == QObject::tr("Finnish"))
        languageCode = "fi";
    else
        languageCode = "en";

    mTranslator->load(":/base_" + languageCode);

    QApplication::instance()->installTranslator(mTranslator);

    loadLanguagesStrings();
}
Esempio n. 2
0
void Speller::loadLanguage(QString lang) {

    if (lang.isEmpty() || !availableLanguages().contains(lang))
        return;

    if (initialized() && (s_language == lang))
        return;

    QString dicPath = m_dictionaryPath + lang + ".dic";
    QString affPath = m_dictionaryPath + lang + ".aff";

    if (!QFile(dicPath).exists() || !QFile(affPath).exists()) {
        LOG_WARNING("SpellCheck: Initialization failed!");
        return;
    }

    if (initialized()) {
        delete s_hunspell;
        s_language = "";
        s_codec = 0;
    }

    s_hunspell = new Hunspell(affPath.toLocal8Bit().constData(),
                              dicPath .toLocal8Bit().constData());

    s_codec = QTextCodec::codecForName(s_hunspell->get_dic_encoding());
    s_language = lang;
}
Esempio n. 3
0
bool Speller::initialize()
{
    if (initialized())
        return true;

    m_dictionaryPath = getDictionaryPath();

    QString defLanguage;

    if (m_settings)
        defLanguage = m_settings->language();
    else
        defLanguage = QLocale::system().name();

    if (!availableLanguages().contains(defLanguage))
        defLanguage = availableLanguages().keys().first();

    loadLanguage(defLanguage);

    if (!m_settings)
        m_enabled = true;

    return initialized();
}
Esempio n. 4
0
void Speller::populateLanguagesMenu()
{
    QMenu* menu = qobject_cast<QMenu*>(sender());

    if (!menu || !menu->isEmpty()) {
        return;
    }

    const QList<Language> langs = availableLanguages();
    foreach(const Language & lang, langs) {
        QAction* act = menu->addAction(lang.name, this, SLOT(changeLanguage()));
        act->setCheckable(true);
        act->setChecked(m_language == lang);
        act->setData(QVariant::fromValue(lang));
    }
Esempio n. 5
0
void ccTranslationManager::populateMenu( QMenu *menu, const QString &pathToTranslationFiles )
{
	const LanguageList	cList = availableLanguages( QStringLiteral( "CloudCompare" ), pathToTranslationFiles );
	
	QActionGroup	*group = new QActionGroup( menu );
	
	group->setExclusive( true );
	
	QAction	*action = group->addAction( tr( "No Translation (English)" ) );
	
	action->setCheckable( true );
	action->setChecked( true );
	
	connect( action, &QAction::triggered, this, [this] ()
	{
		setLanguagePref( QStringLiteral( "en" ) );
	} );
	
	QAction	*separator = new QAction( group );
	separator->setSeparator( true );
	
	const QString	currentLanguage = languagePref();
	
	for ( auto &langInfo : cList )
	{
		action = group->addAction( langInfo.second );
	
		action->setCheckable( true );
		
		if ( currentLanguage == langInfo.first )
		{
			action->setChecked( true );
		}
		
		connect( action, &QAction::triggered, this, [=] ()
		{
			setLanguagePref( langInfo.first );
		} );
	}
	
	menu->addActions( group->actions() );
}
Esempio n. 6
0
QWidget *ConfigComputerDialog::createMainWidget()
{
    QWidget *mainWidget = new QWidget(this);

    // general
    cmbGUIStyle = new QComboBox(mainWidget);
    cmbGUIStyle->addItems(QStyleFactory::keys());

    cmbLanguage = new QComboBox(mainWidget);
    cmbLanguage->addItems(availableLanguages());

    QGridLayout *layoutGeneral = new QGridLayout();
    layoutGeneral->addWidget(new QLabel(tr("UI:")), 0, 0);
    layoutGeneral->addWidget(cmbGUIStyle, 0, 1);
    layoutGeneral->addWidget(new QLabel(tr("Language:")), 1, 0);
    layoutGeneral->addWidget(cmbLanguage, 1, 1);

    QGroupBox *grpGeneral = new QGroupBox(tr("General"));
    grpGeneral->setLayout(layoutGeneral);

    // other
    chkLineEditValueShowResult = new QCheckBox(tr("Show value result in line edit input"));

    chkLogStdOut = new QCheckBox(tr("Print application log to standard output."));

    QVBoxLayout *layoutOther = new QVBoxLayout();
    layoutOther->addWidget(chkLineEditValueShowResult);
    layoutOther->addWidget(chkLogStdOut);

    QGroupBox *grpOther = new QGroupBox(tr("Other"));
    grpOther->setLayout(layoutOther);

    // workspace
    chkShowGrid = new QCheckBox(tr("Show grid"));
    chkShowRulers = new QCheckBox(tr("Show rulers"));
    chkShowAxes = new QCheckBox(tr("Show axes"));

    QGridLayout *layoutGrid = new QGridLayout();
    layoutGrid->addWidget(chkShowGrid, 0, 0);
    layoutGrid->addWidget(chkShowAxes, 1, 0);
    layoutGrid->addWidget(chkShowRulers, 2, 0);

    QGroupBox *grpGrid = new QGroupBox(tr("Grid"));
    grpGrid->setLayout(layoutGrid);

    cmbRulersFont = new QComboBox();
    fillComboBoxFonts(cmbRulersFont);
    txtRulersFontSizes = new QSpinBox();
    txtRulersFontSizes->setMinimum(6);
    txtRulersFontSizes->setMaximum(40);

    cmbPostFont = new QComboBox();
    fillComboBoxFonts(cmbPostFont);
    txtPostFontSizes = new QSpinBox();
    txtPostFontSizes->setMinimum(6);
    txtPostFontSizes->setMaximum(40);

    QGridLayout *layoutFont = new QGridLayout();
    layoutFont->setColumnStretch(1, 1);
    layoutFont->addWidget(new QLabel(tr("Rulers:")), 0, 0);
    layoutFont->addWidget(cmbRulersFont, 0, 1);
    layoutFont->addWidget(txtRulersFontSizes, 0, 2);
    layoutFont->addWidget(new QLabel(tr("Postprocessor:")), 2, 0);
    layoutFont->addWidget(cmbPostFont, 2, 1);
    layoutFont->addWidget(txtPostFontSizes, 2, 2);

    QGroupBox *grpFont = new QGroupBox(tr("Fonts"));
    grpFont->setLayout(layoutFont);

    // layout
    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(grpGeneral);
    layout->addWidget(grpOther);
    layout->addWidget(grpGrid);
    layout->addWidget(grpFont);
    layout->addStretch();

    mainWidget->setLayout(layout);

    return mainWidget;
}
Esempio n. 7
0
QWidget *ConfigDialog::createMainWidget()
{
    logMessage("ConfigDialog::createMainWidget()");

    QWidget *mainWidget = new QWidget(this);

    // general
    cmbGUIStyle = new QComboBox(mainWidget);
    cmbGUIStyle->addItems(QStyleFactory::keys());
    cmbGUIStyle->addItem("Manhattan");

    cmbLanguage = new QComboBox(mainWidget);
    cmbLanguage->addItems(availableLanguages());

    cmbDefaultPhysicField = new QComboBox();
    fillComboBoxPhysicField(cmbDefaultPhysicField);

    QGridLayout *layoutGeneral = new QGridLayout();
    layoutGeneral->addWidget(new QLabel(tr("UI:")), 0, 0);
    layoutGeneral->addWidget(cmbGUIStyle, 0, 1);
    layoutGeneral->addWidget(new QLabel(tr("Language:")), 1, 0);
    layoutGeneral->addWidget(cmbLanguage, 1, 1);
    layoutGeneral->addWidget(new QLabel(tr("Default physic field:")), 2, 0);
    layoutGeneral->addWidget(cmbDefaultPhysicField, 2, 1);

    QGroupBox *grpGeneral = new QGroupBox(tr("General"));
    grpGeneral->setLayout(layoutGeneral);

    // collaboration
    txtCollaborationServerURL = new SLineEditDouble();

    QVBoxLayout *layoutCollaboration = new QVBoxLayout();
    layoutCollaboration->addWidget(new QLabel(tr("Collaboration server URL:")));
    layoutCollaboration->addWidget(txtCollaborationServerURL);

    QGroupBox *grpCollaboration = new QGroupBox(tr("Collaboration"));
    grpCollaboration->setLayout(layoutCollaboration);

    // logs
    chkEnabledApplicationLog = new QCheckBox(tr("Enabled application log"));
    chkEnabledProgressLog = new QCheckBox(tr("Enabled progress log"));

    cmdClearApplicationLog = new QPushButton(mainWidget);
    cmdClearApplicationLog->setText(tr("Clear application log"));
    connect(cmdClearApplicationLog, SIGNAL(clicked()), this, SLOT(doClearApplicationLog()));

    QGridLayout *layoutClearButtons = new QGridLayout();
    layoutClearButtons->addWidget(cmdClearApplicationLog, 0, 0);

    QVBoxLayout *layoutLogs = new QVBoxLayout();
    layoutLogs->addWidget(chkEnabledProgressLog);
    layoutLogs->addWidget(chkEnabledApplicationLog);
    layoutLogs->addLayout(layoutClearButtons);

    QGroupBox *grpLogs = new QGroupBox(tr("Logs"));
    grpLogs->setLayout(layoutLogs);

    // other
    chkLineEditValueShowResult = new QCheckBox(tr("Show value result in line edit input"));
    chkCheckVersion = new QCheckBox(tr("Check new version during startup."));
    chkExperimentalFeatures = new QCheckBox(tr("Enable experimental features"));
    chkExperimentalFeatures->setToolTip(tr("Warning: Agros2D should be unstable!"));

    QVBoxLayout *layoutOther = new QVBoxLayout();
    layoutOther->addWidget(chkLineEditValueShowResult);
    layoutOther->addWidget(chkCheckVersion);
    layoutOther->addWidget(chkExperimentalFeatures);

    QGroupBox *grpOther = new QGroupBox(tr("Other"));
    grpOther->setLayout(layoutOther);

    // layout
    QVBoxLayout *layout = new QVBoxLayout();
    layout->addWidget(grpGeneral);
    layout->addWidget(grpCollaboration);
    layout->addWidget(grpLogs);
    layout->addWidget(grpOther);
    layout->addStretch();

    mainWidget->setLayout(layout);

    return mainWidget;
}