diff --git a/plugins/mapq3/parse.cpp b/plugins/mapq3/parse.cpp index dec7fcae..6e779936 100644 --- a/plugins/mapq3/parse.cpp +++ b/plugins/mapq3/parse.cpp @@ -211,7 +211,7 @@ NodeSmartReference Entity_parseTokens( Tokeniser& tokeniser, EntityCreator& enti void Map_Read( scene::Node& root, Tokeniser& tokeniser, EntityCreator& entityTable, const PrimitiveParser& parser ){ LayersParser layersParser( root ); if( !layersParser.read_layers( tokeniser ) ){ - layersParser.construct_tree(); // contruct anytime to have at least one layer, e.g. when empty .map + layersParser.construct_tree(); // construct anytime to have at least one layer, e.g. when empty .map return; } layersParser.construct_tree(); diff --git a/radiant/colors.cpp b/radiant/colors.cpp index a45ff811..4a5ac5a6 100644 --- a/radiant/colors.cpp +++ b/radiant/colors.cpp @@ -208,7 +208,7 @@ static void load_colors_theme( const char *filepath ){ } void create_colours_menu( QMenu *menu ){ - menu = menu->addMenu( "Colors" ); + menu = menu->addMenu( "Theming" ); menu->setTearOffEnabled( g_Layout_enableDetachableMenus.m_value ); @@ -227,7 +227,7 @@ void create_colours_menu( QMenu *menu ){ } - theme_contruct_menu( menu ); + theme_construct_menu( menu ); create_menu_item_with_mnemonic( menu, "OpenGL Font...", "OpenGLFont" ); diff --git a/radiant/layerswindow.cpp b/radiant/layerswindow.cpp index 49594417..8519896d 100644 --- a/radiant/layerswindow.cpp +++ b/radiant/layerswindow.cpp @@ -61,6 +61,7 @@ ? undo button to add a layer buttons to hide/show all layers +? tree item highlight is torn with 'default' theme in windows */ class LayerAssignVisitor : public SelectionSystem::Visitor diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 67247b7e..9fdf0ec1 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -115,7 +115,6 @@ #include "referencecache.h" #include "colors.h" -#include "theme.h" #include "tools.h" #include "filterbar.h" @@ -1870,7 +1869,6 @@ void MainFrame::Create(){ PreferencesDialog_constructWindow( window ); FindTextureDialog_constructWindow( window ); SurfaceInspector_constructWindow( window ); - theme_contruct(); SetActiveXY( m_pXYWnd ); diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 283f825d..7d5166a7 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -44,6 +44,7 @@ #include "xywindow.h" #include "mainframe.h" #include "gtkdlgs.h" +#include "theme.h" #include #include @@ -181,6 +182,7 @@ bool Preferences_Save_Safe( PreferenceDictionary& preferences, const char* filen void RegisterGlobalPreferences( PreferenceSystem& preferences ){ preferences.registerPreference( "gamefile", makeCopiedStringStringImportCallback( LatchedAssignCaller( g_GamesDialog.m_sGameFile ) ), CopiedStringExportStringCaller( g_GamesDialog.m_sGameFile.m_latched ) ); preferences.registerPreference( "gamePrompt", BoolImportStringCaller( g_GamesDialog.m_bGamePrompt ), BoolExportStringCaller( g_GamesDialog.m_bGamePrompt ) ); + theme_registerGlobalPreference( preferences ); } @@ -241,15 +243,8 @@ void CGameDialog::GameFileImport( int value ){ void CGameDialog::GameFileExport( const IntImportCallback& importCallback ) const { // use m_sGameFile to set value - int i = 0; - for ( const auto *game : mGames ) - { - if ( game->mGameFile == m_sGameFile.m_latched ) { - m_nComboSelect = i; - break; - } - i++; - } + if( const auto found = std::ranges::find( mGames, m_sGameFile.m_latched, &CGameDescription::mGameFile ); found != mGames.cend() ) + m_nComboSelect = std::distance( mGames.cbegin(), found ); importCallback( m_nComboSelect ); } @@ -342,6 +337,7 @@ void CGameDialog::Reset(){ void CGameDialog::Init(){ InitGlobalPrefPath(); LoadPrefs(); + theme_construct(); // after global prefs, b4 any normal windows ScanForGames(); if ( mGames.empty() ) { Error( "Didn't find any valid game file descriptions, aborting\n" ); diff --git a/radiant/theme.cpp b/radiant/theme.cpp index 69eadf2d..0f414426 100644 --- a/radiant/theme.cpp +++ b/radiant/theme.cpp @@ -38,7 +38,6 @@ enum class ETheme{ Darker, }; -static QActionGroup *s_theme_group; static ETheme s_theme = ETheme::Dark; QString load_qss( const char *filename ){ @@ -139,10 +138,10 @@ void theme_set( ETheme theme ){ defaults.is1stThemeApplication = false; } -void theme_contruct_menu( class QMenu *menu ){ +void theme_construct_menu( class QMenu *menu ){ auto *m = menu->addMenu( "GUI Theme" ); m->setTearOffEnabled( g_Layout_enableDetachableMenus.m_value ); - auto *group = s_theme_group = new QActionGroup( m ); + auto *group = new QActionGroup( m ); for( const auto *name : { "Default", "Fusion", "Dark", "Darker" } ) { @@ -150,17 +149,17 @@ void theme_contruct_menu( class QMenu *menu ){ a->setCheckable( true ); group->addAction( a ); } + // init radio + if( const int value = static_cast( s_theme ); 0 <= value && value < group->actions().size() ) + group->actions().at( value )->setChecked( true ); - QObject::connect( s_theme_group, &QActionGroup::triggered, []( QAction *action ){ - theme_set( static_cast( s_theme_group->actions().indexOf( action ) ) ); + QObject::connect( group, &QActionGroup::triggered, []( QAction *action ){ + theme_set( static_cast( action->actionGroup()->actions().indexOf( action ) ) ); } ); } void ThemeImport( int value ){ s_theme = static_cast( value ); - if( s_theme_group != nullptr && 0 <= value && value < s_theme_group->actions().size() ){ - s_theme_group->actions().at( value )->setChecked( true ); - } } typedef FreeCaller ThemeImportCaller; @@ -170,7 +169,10 @@ void ThemeExport( const IntImportCallback& importer ){ typedef FreeCaller ThemeExportCaller; -void theme_contruct(){ - GlobalPreferenceSystem().registerPreference( "GUIThemeV2", makeIntStringImportCallback( ThemeImportCaller() ), makeIntStringExportCallback( ThemeExportCaller() ) ); +void theme_construct(){ theme_set( s_theme ); // set theme here, not in importer, so it's set on the very 1st start too (when there is no preference to load) } + +void theme_registerGlobalPreference( class PreferenceSystem& preferences ){ + preferences.registerPreference( "GUITheme", makeIntStringImportCallback( ThemeImportCaller() ), makeIntStringExportCallback( ThemeExportCaller() ) ); +} diff --git a/radiant/theme.h b/radiant/theme.h index c016b209..026fa650 100644 --- a/radiant/theme.h +++ b/radiant/theme.h @@ -21,5 +21,6 @@ #pragma once -void theme_contruct_menu( class QMenu *menu ); -void theme_contruct(); \ No newline at end of file +void theme_construct_menu( class QMenu *menu ); +void theme_construct(); +void theme_registerGlobalPreference( class PreferenceSystem& preferences ); diff --git a/radiant/url.cpp b/radiant/url.cpp index 2791798e..85f1c3ef 100644 --- a/radiant/url.cpp +++ b/radiant/url.cpp @@ -30,7 +30,7 @@ void OpenURL( const char *url ){ // let's put a little comment globalOutputStream() << "OpenURL: " << url << '\n'; // QUrl::fromUserInput appears to work well for urls and local paths with spaces - // alternatively can prepend file:/// to the latter and use default QUrl contructor + // alternatively can prepend file:/// to the latter and use default QUrl constructor if ( !QDesktopServices::openUrl( QUrl::fromUserInput( url ) ) ) { qt_MessageBox( MainFrame_getWindow(), "Failed to launch browser!" ); }