| 1083 | } |
| 1084 | |
| 1085 | bool ThemeBase::SaveOneThemeComponents( teThemeType id ) |
| 1086 | { |
| 1087 | using namespace BasicUI; |
| 1088 | SwitchTheme( id ); |
| 1089 | auto &resources = *mpSet; |
| 1090 | // IF directory doesn't exist THEN create it |
| 1091 | const auto dir = ThemeComponentsDir(GetFilePath(), id); |
| 1092 | if( !wxDirExists( dir )) |
| 1093 | { |
| 1094 | /// \bug 1 in wxWidgets documentation; wxMkDir returns false if |
| 1095 | /// directory didn't exist, even if it successfully creates it. |
| 1096 | /// so we create and then test if it exists instead. |
| 1097 | /// \bug 2 in wxWidgets documentation; wxMkDir has only one argument |
| 1098 | /// under MSW |
| 1099 | #ifdef __WXMSW__ |
| 1100 | wxMkDir( dir.fn_str() ); |
| 1101 | #else |
| 1102 | wxMkDir( dir.fn_str(), 0700 ); |
| 1103 | #endif |
| 1104 | if( !wxDirExists( dir )) |
| 1105 | { |
| 1106 | ShowMessageBox( |
| 1107 | XO("Could not create directory:\n %s") |
| 1108 | .Format( dir ) ); |
| 1109 | return false; |
| 1110 | } |
| 1111 | } |
| 1112 | |
| 1113 | int n=0; |
| 1114 | FilePath FileName; |
| 1115 | for (size_t i = 0; i < resources.mImages.size(); ++i) |
| 1116 | { |
| 1117 | if( !(mBitmapFlags[i] & resFlagInternal) ) |
| 1118 | { |
| 1119 | FileName = ThemeComponent( dir, mBitmapNames[i] ); |
| 1120 | if( wxFileExists( FileName )) |
| 1121 | { |
| 1122 | ++n; |
| 1123 | break; |
| 1124 | } |
| 1125 | } |
| 1126 | } |
| 1127 | |
| 1128 | if( wxFileExists( ThemeComponent( dir, ColorFileName ) ) ) |
| 1129 | ++n; |
| 1130 | |
| 1131 | using namespace BasicUI; |
| 1132 | |
| 1133 | if (n > 0) |
| 1134 | { |
| 1135 | auto result = |
| 1136 | ShowMessageBox( |
| 1137 | XO( |
| 1138 | "Some required files in:\n %s\nwere already present. Overwrite?") |
| 1139 | .Format( dir ), |
| 1140 | MessageBoxOptions{} |
| 1141 | .ButtonStyle(Button::YesNo) |
| 1142 | .DefaultIsNo()); |
nothing calls this directly
no test coverage detected