#include "SplashScreen.hpp" #include #include #include #include #include #include #include "revision_utils.hpp" #include "pimpl_impl.hpp" #include "moc_SplashScreen.cpp" class SplashScreen::impl { public: impl () : checkbox_ {"Do not show this again"} { main_layout_.addStretch (); main_layout_.addWidget (&checkbox_, 0, Qt::AlignRight); } QVBoxLayout main_layout_; QCheckBox checkbox_; }; SplashScreen::SplashScreen () : QSplashScreen {QPixmap {":/splash.png"}, Qt::WindowStaysOnTopHint} { setLayout (&m_->main_layout_); setObjectName ("SplashScreen"); setWindowTitle (QCoreApplication::translate ("SplashScreen", "WSJT-X™ — Welcome")); setAccessibleName (windowTitle ()); setAccessibleDescription ( QCoreApplication::translate ("SplashScreen", "WSJT-X startup information. Press Escape to close.")); m_->checkbox_.setObjectName ("doNotShowSplashAgain"); m_->checkbox_.setAccessibleName (m_->checkbox_.text ()); // A QSplashScreen is a non-activating window and never becomes the key // window, so a key press event override would never fire. Filter the // application instead so Escape dismisses the splash regardless of which // window holds focus, giving keyboard and assistive-tech users a dismiss // path that the mouse-only click-to-dismiss does not. QCoreApplication::instance ()->installEventFilter (this); showMessage ("

" + QString {"WSJT-X™ v" + QCoreApplication::applicationVersion() + " " + revision ()}.simplified () + "

" "Send issue reports to https://wsjtx.groups.io, and be sure to save .wav
" "files where appropriate.

" "Open the Help menu and select Release Notes for more details.
" "" "", Qt::AlignCenter); connect (&m_->checkbox_, &QCheckBox::stateChanged, [this] (int s) { if (Qt::Checked == s) Q_EMIT disabled (); }); } SplashScreen::~SplashScreen () { } bool SplashScreen::eventFilter (QObject * object, QEvent * event) { if (isVisible () && QEvent::KeyPress == event->type () && Qt::Key_Escape == static_cast (event)->key ()) { close (); return true; } return QSplashScreen::eventFilter (object, event); }