Skip to content

Commit

Permalink
Simplify code for adding messages to the splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmcclinch committed Apr 26, 2020
1 parent 340cd9b commit 41cfef0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
20 changes: 4 additions & 16 deletions mscore/mssplashscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,11 @@ namespace Ms {

void MsSplashScreen::drawContents(QPainter* painter)
{
qreal width = static_cast<qreal>(QWidget::width());
qreal height = static_cast<qreal>(QWidget::height());
QRectF rect = QRectF(0.0, 0.65 * height, width, 0.35 * height);
static const QRectF rect = QRectF(0.0, 0.65 * height(), width(), 0.35 * height());
static const QColor color = QColor(255, 255, 255, 255 * 0.8);

painter->setPen(QColor(255, 255, 255, 255 * 0.8));
painter->drawText(rect, Qt::AlignTop | Qt::AlignHCenter, _message);
}

//---------------------------------------------------------
// showMessage
//---------------------------------------------------------

void MsSplashScreen::showMessage(const QString& message)
{
_message = message;
// The align flags and color don't matter here as drawContents() is overwritten
QSplashScreen::showMessage(message, Qt::AlignTop | Qt::AlignHCenter, QColor(255, 255, 255, 255 * 0.8));
painter->setPen(color);
painter->drawText(rect, Qt::AlignTop | Qt::AlignHCenter, message());
}

}
8 changes: 0 additions & 8 deletions mscore/mssplashscreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,9 @@ namespace Ms {
//---------------------------------------------------------

class MsSplashScreen : public QSplashScreen {
QString _message;

public:
MsSplashScreen(const QPixmap& pixmap) : QSplashScreen(pixmap) {}

void setMessage(QString& message) { _message = message; }

void drawContents(QPainter* painter) override;

public slots:
void showMessage(const QString& message);
};

}
2 changes: 1 addition & 1 deletion mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7783,7 +7783,7 @@ inline static void showSplashMessage(MsSplashScreen* sc, QString&& message)
if (sc)
sc->showMessage(message);
else
qInfo(message.toStdString().c_str());
qInfo("%s", qPrintable(message));
}

//---------------------------------------------------------
Expand Down

0 comments on commit 41cfef0

Please sign in to comment.