mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 16:55:59 +08:00
Add random option for splashscreen
can set the default splashscreen in the colors.ini set default splash for v56 to 'cars' utf8 fix
This commit is contained in:
parent
b7837c43dc
commit
3f1ec6decd
BIN
resources/splashscreen/cars.jpg
Normal file
BIN
resources/splashscreen/cars.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 135 KiB |
@ -21,4 +21,6 @@ Gui_color_very_dark = ada230
|
||||
Gui_color_dark = cabe39
|
||||
Gui_color = eddc21
|
||||
Gui_color_light = ffee38
|
||||
Gui_color_very_light = fef48b
|
||||
Gui_color_very_light = fef48b
|
||||
splash_screen_editor = cars.jpg
|
||||
splash_screen_gcodeviewer = prusa-gcodepreview.jpg
|
||||
|
@ -58,6 +58,9 @@ int CLI::run(int argc, char **argv)
|
||||
// Mark the main thread for the debugger and for runtime checks.
|
||||
set_current_thread_name("slic3r_main");
|
||||
|
||||
//init random generator
|
||||
std::srand(std::time(nullptr));
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// On Linux, wxGTK has no support for Wayland, and the app crashes on
|
||||
// startup if gtk3 is used. This env var has to be set explicitly to
|
||||
|
@ -214,11 +214,38 @@ void AppConfig::set_defaults()
|
||||
if (get("show_splash_screen").empty())
|
||||
set("show_splash_screen", "1");
|
||||
|
||||
if (get("splash_screen_editor").empty())
|
||||
set("splash_screen_editor", "benchy-splashscreen.jpg");
|
||||
if (get("show_splash_screen_random").empty())
|
||||
set("show_splash_screen_random", "0");
|
||||
|
||||
if (get("splash_screen_gcodeviewer").empty())
|
||||
set("splash_screen_gcodeviewer", "prusa-gcodepreview.jpg");
|
||||
{
|
||||
|
||||
//try to load splashscreen from ui file
|
||||
std::map<std::string, std::string> key2splashscreen = {{"splash_screen_editor", "benchy-splashscreen.jpg"}, {"splash_screen_gcodeviewer", "prusa-gcodepreview.jpg"} };
|
||||
boost::property_tree::ptree tree_splashscreen;
|
||||
boost::filesystem::path path_colors = boost::filesystem::path(resources_dir()) / "ui_layout" / "colors.ini";
|
||||
try {
|
||||
boost::nowide::ifstream ifs;
|
||||
ifs.imbue(boost::locale::generator()("en_US.UTF-8"));
|
||||
ifs.open(path_colors.string());
|
||||
boost::property_tree::read_ini(ifs, tree_splashscreen);
|
||||
|
||||
for (std::map<std::string, std::string>::iterator it = key2splashscreen.begin(); it != key2splashscreen.end(); ++it) {
|
||||
std::string splashscreen_filename = tree_splashscreen.get<std::string>(it->first);
|
||||
it->second = splashscreen_filename;
|
||||
}
|
||||
}
|
||||
catch (const std::ifstream::failure& err) {
|
||||
trace(1, (std::string("The splashscreen file cannot be loaded. Reason: ") + err.what(), path_colors.string()).c_str());
|
||||
}
|
||||
catch (const std::runtime_error& err) {
|
||||
trace(1, (std::string("Failed loading the splashscreen file. Reason: ") + err.what(), path_colors.string()).c_str());
|
||||
}
|
||||
if (get("splash_screen_editor").empty())
|
||||
set("splash_screen_editor", key2splashscreen["splash_screen_editor"]);
|
||||
|
||||
if (get("splash_screen_gcodeviewer").empty())
|
||||
set("splash_screen_gcodeviewer", key2splashscreen["splash_screen_gcodeviewer"]);
|
||||
}
|
||||
|
||||
#if ENABLE_CTRL_M_ON_WINDOWS
|
||||
#ifdef _WIN32
|
||||
|
@ -827,9 +827,17 @@ bool GUI_App::on_init_inner()
|
||||
std::string file_name = is_editor()
|
||||
? app_config->get("splash_screen_editor")
|
||||
: app_config->get("splash_screen_gcodeviewer");
|
||||
if (app_config->get("show_splash_screen_random") == "1") {
|
||||
std::vector<std::string> names;
|
||||
//get all images in the spashscreen dir
|
||||
for (const boost::filesystem::directory_entry& dir_entry : boost::filesystem::directory_iterator(boost::filesystem::path(Slic3r::resources_dir()) / "splashscreen"))
|
||||
if (dir_entry.path().has_extension() && std::set<std::string>{ ".jpg", ".JPG", ".jpeg" }.count(dir_entry.path().extension().string()) > 0)
|
||||
names.push_back(dir_entry.path().filename().string());
|
||||
file_name = names[rand() % names.size()];
|
||||
}
|
||||
wxString artist;
|
||||
if (!file_name.empty() && file_name != (std::string(SLIC3R_APP_NAME) + L(" icon"))) {
|
||||
wxString splash_screen_path = (boost::filesystem::path(Slic3r::resources_dir()) / "splashscreen" / file_name).string();
|
||||
wxString splash_screen_path = wxString::FromUTF8((boost::filesystem::path(Slic3r::resources_dir()) / "splashscreen" / file_name).string());
|
||||
// make a bitmap with dark grey banner on the left side
|
||||
bmp = SplashScreen::MakeBitmap(wxBitmap(splash_screen_path, wxBITMAP_TYPE_JPEG));
|
||||
|
||||
@ -842,7 +850,7 @@ bool GUI_App::on_init_inner()
|
||||
tag = exif_getTagInfo(ifdArray, IFD_0TH, TAG_Artist);
|
||||
if (tag) {
|
||||
if (!tag->error) {
|
||||
artist = (_L("Artwork model by") + " " + ((char*)tag->byteData));
|
||||
artist = (_L("Artwork model by") + " " + wxString::FromUTF8((char*)tag->byteData));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,6 +238,13 @@ void PreferencesDialog::build()
|
||||
def.set_default_value(new ConfigOptionBool{ app_config->get("show_splash_screen") == "1" });
|
||||
option = Option(def, "show_splash_screen");
|
||||
m_optgroup_general->append_single_option_line(option);
|
||||
|
||||
def.label = L("Random splash screen");
|
||||
def.type = coBool;
|
||||
def.tooltip = L("Show a random splash screen image from the list at each startup");
|
||||
def.set_default_value(new ConfigOptionBool{ app_config->get("show_splash_screen_random") == "1" });
|
||||
option = Option(def, "show_splash_screen_random");
|
||||
m_optgroup_general->append_single_option_line(option);
|
||||
|
||||
// splashscreen image
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user