1 |
// qsamplerOptionsForm.cpp |
// qsamplerOptionsForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2020, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
33 |
|
|
34 |
#include <QStyleFactory> |
#include <QStyleFactory> |
35 |
|
|
|
namespace QSampler { |
|
36 |
|
|
37 |
// Default (empty/blank) name. |
// Default (empty/blank) name. |
38 |
static const char *g_pszDefName = QT_TR_NOOP("(default)"); |
static const char *g_pszDefName = QT_TRANSLATE_NOOP("qsamplerOptionsForm", "(default)"); |
39 |
|
|
40 |
|
|
41 |
|
namespace QSampler { |
42 |
|
|
43 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
44 |
// QSampler::OptionsForm -- Options form implementation. |
// QSampler::OptionsForm -- Options form implementation. |
345 |
m_pOptions->iMaxRecentFiles = m_ui.MaxRecentFilesSpinBox->value(); |
m_pOptions->iMaxRecentFiles = m_ui.MaxRecentFilesSpinBox->value(); |
346 |
m_pOptions->iBaseFontSize = m_ui.BaseFontSizeComboBox->currentText().toInt(); |
m_pOptions->iBaseFontSize = m_ui.BaseFontSizeComboBox->currentText().toInt(); |
347 |
// Custom color/style theme options... |
// Custom color/style theme options... |
|
const QString sOldCustomStyleTheme = m_pOptions->sCustomStyleTheme; |
|
348 |
if (m_ui.CustomStyleThemeComboBox->currentIndex() > 0) |
if (m_ui.CustomStyleThemeComboBox->currentIndex() > 0) |
349 |
m_pOptions->sCustomStyleTheme = m_ui.CustomStyleThemeComboBox->currentText(); |
m_pOptions->sCustomStyleTheme = m_ui.CustomStyleThemeComboBox->currentText(); |
350 |
else |
else |
351 |
m_pOptions->sCustomStyleTheme.clear(); |
m_pOptions->sCustomStyleTheme.clear(); |
|
const QString sOldCustomColorTheme = m_pOptions->sCustomColorTheme; |
|
352 |
if (m_ui.CustomColorThemeComboBox->currentIndex() > 0) |
if (m_ui.CustomColorThemeComboBox->currentIndex() > 0) |
353 |
m_pOptions->sCustomColorTheme = m_ui.CustomColorThemeComboBox->currentText(); |
m_pOptions->sCustomColorTheme = m_ui.CustomColorThemeComboBox->currentText(); |
354 |
else |
else |
355 |
m_pOptions->sCustomColorTheme.clear(); |
m_pOptions->sCustomColorTheme.clear(); |
|
// Check whether restart is needed or whether |
|
|
// custom options maybe set up immediately... |
|
|
int iNeedRestart = 0; |
|
|
if (m_pOptions->sCustomStyleTheme != sOldCustomStyleTheme) { |
|
|
if (m_pOptions->sCustomStyleTheme.isEmpty()) { |
|
|
++iNeedRestart; |
|
|
} else { |
|
|
QApplication::setStyle( |
|
|
QStyleFactory::create(m_pOptions->sCustomStyleTheme)); |
|
|
} |
|
|
} |
|
|
if (m_pOptions->sCustomColorTheme != sOldCustomColorTheme) { |
|
|
if (m_pOptions->sCustomColorTheme.isEmpty()) { |
|
|
++iNeedRestart; |
|
|
} else { |
|
|
QPalette pal; |
|
|
if (PaletteForm::namedPalette( |
|
|
&m_pOptions->settings(), m_pOptions->sCustomColorTheme, pal)) |
|
|
QApplication::setPalette(pal); |
|
|
} |
|
|
} |
|
|
// Show restart message if needed... |
|
|
if (iNeedRestart > 0) { |
|
|
QMessageBox::information(this, |
|
|
tr("Information"), |
|
|
tr("Some settings may be only effective\n" |
|
|
"next time you start this application.")); |
|
|
} |
|
356 |
// Reset dirty flag. |
// Reset dirty flag. |
357 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
358 |
} |
} |
563 |
PaletteForm::namedPaletteList(&m_pOptions->settings())); |
PaletteForm::namedPaletteList(&m_pOptions->settings())); |
564 |
|
|
565 |
int iCustomColorTheme = 0; |
int iCustomColorTheme = 0; |
566 |
if (!sCustomColorTheme.isEmpty()) |
if (!sCustomColorTheme.isEmpty()) { |
567 |
iCustomColorTheme = m_ui.CustomColorThemeComboBox->findText( |
iCustomColorTheme = m_ui.CustomColorThemeComboBox->findText( |
568 |
sCustomColorTheme); |
sCustomColorTheme); |
569 |
|
if (iCustomColorTheme < 0) |
570 |
|
iCustomColorTheme = 0; |
571 |
|
} |
572 |
m_ui.CustomColorThemeComboBox->setCurrentIndex(iCustomColorTheme); |
m_ui.CustomColorThemeComboBox->setCurrentIndex(iCustomColorTheme); |
573 |
} |
} |
574 |
|
|
583 |
m_ui.CustomStyleThemeComboBox->addItems(QStyleFactory::keys()); |
m_ui.CustomStyleThemeComboBox->addItems(QStyleFactory::keys()); |
584 |
|
|
585 |
int iCustomStyleTheme = 0; |
int iCustomStyleTheme = 0; |
586 |
if (!sCustomStyleTheme.isEmpty()) |
if (!sCustomStyleTheme.isEmpty()) { |
587 |
iCustomStyleTheme = m_ui.CustomStyleThemeComboBox->findText( |
iCustomStyleTheme = m_ui.CustomStyleThemeComboBox->findText( |
588 |
sCustomStyleTheme); |
sCustomStyleTheme); |
589 |
|
if (iCustomStyleTheme < 0) |
590 |
|
iCustomStyleTheme = 0; |
591 |
|
} |
592 |
m_ui.CustomStyleThemeComboBox->setCurrentIndex(iCustomStyleTheme); |
m_ui.CustomStyleThemeComboBox->setCurrentIndex(iCustomStyleTheme); |
593 |
} |
} |
594 |
|
|