Skip to content

Commit

Permalink
fix MSVC build finally
Browse files Browse the repository at this point in the history
  • Loading branch information
shenlebantongying committed Sep 30, 2024
1 parent 08e0f13 commit 4f886b3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ Class load()

c.showingDictBarNames = ( root.namedItem( "showingDictBarNames" ).toElement().text() == "1" );

c.usingToolbarsIconSize =( root.namedItem( "usingToolbarsIconSize" ).toElement().text().toInt() ) ;
c.usingToolbarsIconSize =( static_cast<ToolbarsIconSize>(root.namedItem( "usingToolbarsIconSize" ).toElement().text().toInt()) ) ;

if ( !root.namedItem( "historyExportPath" ).isNull() )
c.historyExportPath = root.namedItem( "historyExportPath" ).toElement().text();
Expand Down Expand Up @@ -2152,7 +2152,7 @@ void save( Class const & c )
root.appendChild( opt );

opt = dd.createElement( "usingToolbarsIconSize" );
opt.appendChild( dd.createTextNode( QString::number( c.usingToolbarsIconSize ) ) );
opt.appendChild( dd.createTextNode( QString::number( static_cast< int >( c.usingToolbarsIconSize ) ) ) );
root.appendChild( opt );

if ( !c.historyExportPath.isEmpty() ) {
Expand Down
14 changes: 7 additions & 7 deletions src/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -819,13 +819,13 @@ struct HeadwordsDialog
{
}
};

// TODO: arbitrary sizing
// Not using enum here to bypass MSVC 2022 BUG.
namespace ToolbarsIconSize {
static const int small = 0;
static const int normal = 1;
static const int large = 2;
} // namespace ToolbarsIconSize
enum class ToolbarsIconSize : std::uint8_t {
small_size = 0, // _size because `small` causes error in MSVC 2022
normal = 1,
large = 2,
};

struct Class
{
Expand Down Expand Up @@ -875,7 +875,7 @@ struct Class

bool showingDictBarNames;

int usingToolbarsIconSize = ToolbarsIconSize::normal;
ToolbarsIconSize usingToolbarsIconSize = ToolbarsIconSize::normal;

/// Maximum size for the headwords.
/// Bigger headwords won't be indexed. For now, only in DSL.
Expand Down
4 changes: 2 additions & 2 deletions src/ui/mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
// Use small icons in toolbars

useSmallIconsInToolbarsAction.setCheckable( true );
useSmallIconsInToolbarsAction.setChecked( cfg.usingToolbarsIconSize == Config::ToolbarsIconSize::small );
useSmallIconsInToolbarsAction.setChecked( cfg.usingToolbarsIconSize == Config::ToolbarsIconSize::small_size );

connect( &useSmallIconsInToolbarsAction, &QAction::triggered, this, &MainWindow::useSmallIconsInToolbarsTriggered );

Expand Down Expand Up @@ -3029,7 +3029,7 @@ void MainWindow::useSmallIconsInToolbarsTriggered()
{
bool useSmallIcons = useSmallIconsInToolbarsAction.isChecked();
if ( useSmallIcons ) {
cfg.usingToolbarsIconSize = Config::ToolbarsIconSize::small;
cfg.usingToolbarsIconSize = Config::ToolbarsIconSize::small_size;
useLargeIconsInToolbarsAction.setChecked( false );
}
else if ( !useLargeIconsInToolbarsAction.isChecked() ) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/scanpopup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ void ScanPopup::on_goForwardButton_clicked() const

void ScanPopup::setDictionaryIconSize()
{
if ( cfg.usingToolbarsIconSize == Config::ToolbarsIconSize::small ) {
if ( cfg.usingToolbarsIconSize == Config::ToolbarsIconSize::small_size ) {
dictionaryBar.setDictionaryIconSize( DictionaryBar::IconSize::Small );
}
else if ( cfg.usingToolbarsIconSize == Config::ToolbarsIconSize::normal ) {
Expand Down

0 comments on commit 4f886b3

Please sign in to comment.