make the theme handling in musredit more flexible. At the same time adopted some part to more modern c++.

This commit is contained in:
2024-12-11 09:25:28 +01:00
parent 60e2d25ce8
commit 5d5ebde4c2
16 changed files with 716 additions and 714 deletions

View File

@@ -88,11 +88,11 @@
PTextEdit::PTextEdit( QWidget *parent )
: QMainWindow( parent )
{
bool gotTheme = getTheme();
// reads and manages the conents of the xml-startup (musredit_startup.xml) file
fAdmin = std::make_unique<PAdmin>();
bool gotTheme = getTheme();
// set default setting of the fDarkMenuIconIcons only if a theme has been recognized, otherwise take the
// one from the xml startup file.
if (gotTheme) {
@@ -117,8 +117,6 @@ PTextEdit::PTextEdit( QWidget *parent )
}
// initialize stuff
//as35 fMusrT0Action = nullptr;
fMsr2DataParam = nullptr;
fFindReplaceData = nullptr;
@@ -136,7 +134,6 @@ PTextEdit::PTextEdit( QWidget *parent )
textFamily(fAdmin->getFontName());
textSize(QString("%1").arg(fAdmin->getFontSize()));
fFontChanging = false;
QString iconName("");
if (fDarkMenuIcon)
@@ -165,12 +162,6 @@ PTextEdit::PTextEdit( QWidget *parent )
*/
void PTextEdit::aboutToQuit()
{
/* //as35
if (fMusrT0Action) {
delete fMusrT0Action;
fMusrT0Action = nullptr;
}
*/ //as35
if (fMsr2DataParam) {
delete fMsr2DataParam;
fMsr2DataParam = nullptr;
@@ -1193,7 +1184,6 @@ void PTextEdit::fileNew()
PSubTextEdit *edit = new PSubTextEdit( fAdmin.get() );
edit->setFont(QFont(fAdmin->getFontName(), fAdmin->getFontSize()));
edit->setCenterOnScroll(true);
doConnections( edit );
fTabWidget->addTab( edit, tr( "noname" ) );
fTabWidget->setCurrentIndex(fTabWidget->indexOf(edit));
@@ -2732,6 +2722,7 @@ void PTextEdit::musrPrefs()
}
if (dlg->exec() == QDialog::Accepted) {
fAdmin->setIgnoreThemeAutoDetection(dlg->getIgnoreThemeAutoDetection());
fAdmin->setDarkThemeIconsMenuFlag(dlg->getDarkThemeIconsMenuFlag());
fAdmin->setDarkThemeIconsToolbarFlag(dlg->getDarkThemeIconsToolbarFlag());
fAdmin->setMusrviewShowFourierFlag(dlg->getMusrviewShowFourierFlag());
@@ -3346,6 +3337,9 @@ void PTextEdit::jumpToBlock(int idx)
*/
bool PTextEdit::getTheme()
{
if (fAdmin->getIgnoreThemeAutoDetection())
return false;
fDarkMenuIcon = false; // true if theme is dark
fDarkToolBarIcon = false; // needed for ubuntu dark since there the menu icons are dark, however the toolbar icons are plain!
@@ -3377,10 +3371,9 @@ bool PTextEdit::getTheme()
if (str.contains("dark", Qt::CaseInsensitive)) {
fDarkMenuIcon = true;
if (str.contains("ubuntu", Qt::CaseInsensitive)) {
fDarkMenuIcon = false;
fDarkToolBarIcon = false;
} else if (str.contains("xfce", Qt::CaseInsensitive)) {
if (str.contains("ubuntu", Qt::CaseInsensitive) ||
str.contains("xfce", Qt::CaseInsensitive) ||
str.contains("mx", Qt::CaseInsensitive)) {
fDarkMenuIcon = false;
fDarkToolBarIcon = false;
} else {