Ejemplo n.º 1
0
void GeneralPage::openTranslationFileDialog()
{
	Settings& settings = Settings::getInstance();
	const QString translation_file_key(settings.getSettingPath(Settings::General_TranslationFile));
	const QString language_key(settings.getSettingPath(Settings::General_Language));
	
	QString current_filename(settings.getSetting(Settings::General_Language).toString());
	if (changes.contains(translation_file_key))
		current_filename = changes[translation_file_key].toString();
	
	QString filename = QFileDialog::getOpenFileName(this,
	  tr("Open translation"), current_filename, tr("Translation files (*.qm)"));
	if (!filename.isNull())
	{
		QString locale_name(TranslationUtil::localeNameForFile(filename));
		if (locale_name.isEmpty())
		{
			QMessageBox::critical(this, tr("Open translation"),
			  tr("The selected file is not a valid translation.") );
		}
		else
		{
			QLocale locale(locale_name);
			changes.insert(translation_file_key, filename);
			changes.insert(language_key, locale.language());
		}
	}
	updateLanguageBox();
}
Ejemplo n.º 2
0
void GeneralSettingsPage::updateWidgets()
{
	updateLanguageBox(getSetting(Settings::General_Language));
	
	ppi_edit->setValue(getSetting(Settings::General_PixelsPerInch).toFloat());
	open_mru_check->setChecked(getSetting(Settings::General_OpenMRUFile).toBool());
	tips_visible_check->setChecked(getSetting(Settings::HomeScreen_TipsVisible).toBool());
	compatibility_check->setChecked(getSetting(Settings::General_RetainCompatiblity).toBool());
	
	int autosave_interval = getSetting(Settings::General_AutosaveInterval).toInt();
	autosave_check->setChecked(autosave_interval > 0);
	autosave_interval_edit->setEnabled(autosave_interval > 0);
	autosave_interval_edit->setValue(qAbs(autosave_interval));
	
	encoding_box->setCurrentText(getSetting(Settings::General_Local8BitEncoding).toString());
	ocd_importer_check->setChecked(getSetting(Settings::General_NewOcd8Implementation).toBool());
}
Ejemplo n.º 3
0
// slot
void GeneralSettingsPage::openTranslationFileDialog()
{
	QString filename = translation_file;
	if (filename.isEmpty())
		filename = getSetting(Settings::General_TranslationFile).toString();
	
	filename = QFileDialog::getOpenFileName(this,
	  tr("Open translation"), filename, tr("Translation files (*.qm)"));
	if (!filename.isNull())
	{
		QString locale_name(TranslationUtil::localeNameForFile(filename));
		if (locale_name.isEmpty())
		{
			QMessageBox::critical(this, tr("Open translation"),
			  tr("The selected file is not a valid translation.") );
		}
		else
		{
			translation_file = filename;
			updateLanguageBox(QLocale(locale_name).language());
		}
	}
}
Ejemplo n.º 4
0
GeneralPage::GeneralPage(QWidget* parent)
 : SettingsPage(parent)
{
	QGridLayout* layout = new QGridLayout();
	setLayout(layout);
	
	int row = 0;
	layout->addWidget(Util::Headline::create(tr("Appearance")), row, 1, 1, 2);
	
	row++;
	QLabel* language_label = new QLabel(tr("Language:"));
	layout->addWidget(language_label, row, 1);
	
	language_box = new QComboBox(this);
	updateLanguageBox();
	layout->addWidget(language_box, row, 2);
	
	QAbstractButton* language_file_button = new QToolButton();
	language_file_button->setIcon(QIcon(QStringLiteral(":/images/open.png")));
	layout->addWidget(language_file_button, row, 3);
	
	row++;
	layout->addItem(Util::SpacerItem::create(this), row, 1);
	
	row++;
	layout->addWidget(Util::Headline::create(tr("Screen")), row, 1, 1, 2);
	
	row++;
	QLabel* ppi_label = new QLabel(tr("Pixels per inch:"));
	layout->addWidget(ppi_label, row, 1);
	
	ppi_edit = Util::SpinBox::create(2, 0.01, 9999);
	ppi_edit->setValue(Settings::getInstance().getSetting(Settings::General_PixelsPerInch).toFloat());
	layout->addWidget(ppi_edit, row, 2);
	
	QAbstractButton* ppi_calculate_button = new QToolButton();
	ppi_calculate_button->setIcon(QIcon(QStringLiteral(":/images/settings.png")));
	layout->addWidget(ppi_calculate_button, row, 3);
	
	row++;
	layout->addItem(Util::SpacerItem::create(this), row, 1);
	
	row++;
	layout->addWidget(Util::Headline::create(tr("Program start")), row, 1, 1, 2);
	
	row++;
	QCheckBox* open_mru_check = new QCheckBox(AbstractHomeScreenWidget::tr("Open most recently used file"));
	open_mru_check->setChecked(Settings::getInstance().getSetting(Settings::General_OpenMRUFile).toBool());
	layout->addWidget(open_mru_check, row, 1, 1, 2);
	
	row++;
	QCheckBox* tips_visible_check = new QCheckBox(AbstractHomeScreenWidget::tr("Show tip of the day"));
	tips_visible_check->setChecked(Settings::getInstance().getSetting(Settings::HomeScreen_TipsVisible).toBool());
	layout->addWidget(tips_visible_check, row, 1, 1, 2);
	
	row++;
	layout->addItem(Util::SpacerItem::create(this), row, 1);
	
	row++;
	layout->addWidget(Util::Headline::create(tr("Saving files")), row, 1, 1, 2);
	
	row++;
	QCheckBox* compatibility_check = new QCheckBox(tr("Retain compatibility with Mapper %1").arg(QStringLiteral("0.5")));
	compatibility_check->setChecked(Settings::getInstance().getSetting(Settings::General_RetainCompatiblity).toBool());
	layout->addWidget(compatibility_check, row, 1, 1, 2);
	
	// Possible point: limit size of undo/redo journal
	
	int autosave_interval = Settings::getInstance().getSetting(Settings::General_AutosaveInterval).toInt();
	
	row++;
	QCheckBox* autosave_check = new QCheckBox(tr("Save information for automatic recovery"));
	autosave_check->setChecked(autosave_interval > 0);
	layout->addWidget(autosave_check, row, 1, 1, 2);
	
	row++;
	autosave_interval_label = new QLabel(tr("Recovery information saving interval:"));
	layout->addWidget(autosave_interval_label, row, 1);
	
	autosave_interval_edit = Util::SpinBox::create(1, 120, tr("min", "unit minutes"), 1);
	autosave_interval_edit->setValue(qAbs(autosave_interval));
	autosave_interval_edit->setEnabled(autosave_interval > 0);
	layout->addWidget(autosave_interval_edit, row, 2);
	
	row++;
	layout->addItem(Util::SpacerItem::create(this), row, 1);
	
	row++;
	layout->addWidget(Util::Headline::create(tr("File import and export")), row, 1, 1, 2);
	
	row++;
	QLabel* encoding_label = new QLabel(tr("8-bit encoding:"));
	layout->addWidget(encoding_label, row, 1);
	
	encoding_box = new QComboBox();
	encoding_box->addItem(QStringLiteral("System"));
	encoding_box->addItem(QStringLiteral("Windows-1250"));
	encoding_box->addItem(QStringLiteral("Windows-1252"));
	encoding_box->addItem(QStringLiteral("ISO-8859-1"));
	encoding_box->addItem(QStringLiteral("ISO-8859-15"));
	encoding_box->setEditable(true);
	QStringList availableCodecs;
	for (const QByteArray& item : QTextCodec::availableCodecs())
	{
		availableCodecs.append(QString::fromUtf8(item));
	}
	if (!availableCodecs.empty())
	{
		availableCodecs.sort(Qt::CaseInsensitive);
		availableCodecs.removeDuplicates();
		encoding_box->addItem(tr("More..."));
	}
	QCompleter* completer = new QCompleter(availableCodecs, this);
	completer->setCaseSensitivity(Qt::CaseInsensitive);
	encoding_box->setCompleter(completer);
	encoding_box->setCurrentText(Settings::getInstance().getSetting(Settings::General_Local8BitEncoding).toString());
	layout->addWidget(encoding_box, row, 2);
	
	row++;
	QCheckBox* ocd_importer_check = new QCheckBox(tr("Use the new OCD importer also for version 8 files"));
	ocd_importer_check->setChecked(Settings::getInstance().getSetting(Settings::General_NewOcd8Implementation).toBool());
	layout->addWidget(ocd_importer_check, row, 1, 1, 2);
	
	row++;
	layout->setRowStretch(row, 1);
	
#if defined(Q_OS_MAC)
	// Center setting items
	layout->setColumnStretch(0, 2);
#endif
	layout->setColumnStretch(2, 1);
	layout->setColumnStretch(2, 2);
	layout->setColumnStretch(layout->columnCount(), 2);
	
	connect(language_box, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &GeneralPage::languageChanged);
	connect(language_file_button, &QAbstractButton::clicked, this, &GeneralPage::openTranslationFileDialog);
	connect(ppi_edit, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, &GeneralPage::ppiChanged);
	connect(ppi_calculate_button, &QAbstractButton::clicked, this, &GeneralPage::openPPICalculationDialog);
	connect(open_mru_check, &QAbstractButton::clicked, this, &GeneralPage::openMRUFileClicked);
	connect(tips_visible_check, &QAbstractButton::clicked, this, &GeneralPage::tipsVisibleClicked);
	connect(encoding_box, &QComboBox::currentTextChanged, this, &GeneralPage::encodingChanged);
	connect(ocd_importer_check, &QAbstractButton::clicked, this, &GeneralPage::ocdImporterClicked);
	connect(autosave_check, &QAbstractButton::clicked, this, &GeneralPage::autosaveChanged);
	connect(autosave_interval_edit, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &GeneralPage::autosaveIntervalChanged);
	connect(compatibility_check, &QAbstractButton::clicked, this, &GeneralPage::retainCompatibilityChanged);
}