From 0695b70cd534d78abebc0556f01a02978c19c574 Mon Sep 17 00:00:00 2001 From: codereader Date: Mon, 18 Dec 2017 16:54:56 +0100 Subject: [PATCH] Remove a few #ifdefs from the Splash header, just skip the call to Splash::OnAppStartup in Linux. --- radiant/RadiantApp.cpp | 10 ++++++---- radiant/ui/splash/Splash.cpp | 21 ++++++++++----------- radiant/ui/splash/Splash.h | 13 +++++-------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/radiant/RadiantApp.cpp b/radiant/RadiantApp.cpp index b6af674920..0310818ee0 100644 --- a/radiant/RadiantApp.cpp +++ b/radiant/RadiantApp.cpp @@ -8,10 +8,13 @@ #include "modulesystem/ModuleRegistry.h" #include +#include #include +#include +#ifndef __linux__ #include "ui/splash/Splash.h" -#include +#endif #ifndef POSIX #include "settings/LanguageManager.h" @@ -74,7 +77,7 @@ bool RadiantApp::OnInit() wxInitAllImageHandlers(); // Register to the start up signal - Connect(EV_RadiantStartup, wxCommandEventHandler(RadiantApp::onStartupEvent), NULL, this); + Bind(EV_RadiantStartup, sigc::mem_fun(*this, &RadiantApp::onStartupEvent)); // Activate the Popup Error Handler _context.initErrorHandler(); @@ -135,8 +138,7 @@ void RadiantApp::onStartupEvent(wxCommandEvent& ev) #ifndef __linux__ // We skip the splash screen in Linux, but the other platforms will show a progress bar // Connect the progress callback to the Splash instance. - module::ModuleRegistry::Instance().signal_moduleInitialisationProgress().connect( - sigc::mem_fun(ui::Splash::Instance(), &ui::Splash::setProgressAndText)); + ui::Splash::OnAppStartup(); #endif module::ModuleRegistry::Instance().loadAndInitialiseModules(); diff --git a/radiant/ui/splash/Splash.cpp b/radiant/ui/splash/Splash.cpp index cf83045274..4ec39ac40d 100644 --- a/radiant/ui/splash/Splash.cpp +++ b/radiant/ui/splash/Splash.cpp @@ -6,13 +6,13 @@ #include #include #include +#include #include "modulesystem/ModuleRegistry.h" namespace ui { -#if !defined(__linux__) namespace { const char* const SPLASH_FILENAME = "darksplash.png"; @@ -67,8 +67,8 @@ void wxImagePanel::render(wxDC& dc) } Splash::Splash() : - wxFrame(NULL, wxID_ANY, wxT("DarkRadiant"), wxDefaultPosition, wxDefaultSize, wxCENTRE), - _progressBar(NULL) + wxFrame(nullptr, wxID_ANY, wxT("DarkRadiant"), wxDefaultPosition, wxDefaultSize, wxCENTRE), + _progressBar(nullptr) { const ApplicationContext& ctx = module::ModuleRegistry::Instance().getApplicationContext(); std::string fullFileName(ctx.getBitmapsPath() + SPLASH_FILENAME); @@ -101,30 +101,22 @@ void Splash::queueDraw() wxTheApp->Yield(true); } -#endif - void Splash::setText(const std::string& text) { -#if !defined(__linux__) _imagePanel->setText(text); queueDraw(); -#endif } void Splash::setProgress(float fraction) { -#if !defined(__linux__) _progressBar->SetValue(static_cast(fraction*100)); queueDraw(); -#endif } void Splash::setProgressAndText(const std::string& text, float fraction) { -#if !defined(__linux__) setText(text); setProgress(fraction); -#endif } Splash& Splash::Instance() @@ -133,4 +125,11 @@ Splash& Splash::Instance() return *instance; } +void Splash::OnAppStartup() +{ + // Connect the module progress callback + module::ModuleRegistry::Instance().signal_moduleInitialisationProgress().connect( + sigc::mem_fun(Instance(), &Splash::setProgressAndText)); +} + } // namespace ui diff --git a/radiant/ui/splash/Splash.h b/radiant/ui/splash/Splash.h index 9bae1c12f1..78a5056f07 100644 --- a/radiant/ui/splash/Splash.h +++ b/radiant/ui/splash/Splash.h @@ -16,14 +16,12 @@ class Splash : public wxFrame, public sigc::trackable { -#if !defined(__linux__) private: wxGauge* _progressBar; wxImagePanel* _imagePanel; // Private constructor, creates all the widgets Splash(); -#endif public: /** greebo: Sets the text and/or progress of the progress bar. @@ -34,14 +32,13 @@ class Splash : static Splash& Instance(); -#if !defined(__linux__) -private: - void createProgressBar(); + // Shows and connects the Splash screen window for progress display + // Note: does nothing for the Linux platform + static void OnAppStartup(); - /** greebo: Triggers a redraw of the splash screen - */ +private: + // greebo: Triggers a redraw of the splash screen void queueDraw(); -#endif }; } // namespace ui