Browse Source

qt: Make splash and shutdown window ignore close events

It's strange to be able to close these windows while there is work
in progress.

Also set Qt::WA_DeleteOnClose on both windows to make sure that they
are deleted eventually, no matter what happens.
0.10
Wladimir J. van der Laan 10 years ago
parent
commit
cfc5cfb0f0
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 3
      src/qt/bitcoin.cpp
  2. 9
      src/qt/splashscreen.cpp
  3. 9
      src/qt/splashscreen.h
  4. 26
      src/qt/utilitydialog.cpp
  5. 6
      src/qt/utilitydialog.h

3
src/qt/bitcoin.cpp

@ -339,6 +339,9 @@ void BitcoinApplication::createWindow(bool isaTestNet) @@ -339,6 +339,9 @@ void BitcoinApplication::createWindow(bool isaTestNet)
void BitcoinApplication::createSplashScreen(bool isaTestNet)
{
SplashScreen *splash = new SplashScreen(0, isaTestNet);
// We don't hold a direct pointer to the splash screen after creation, so use
// Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
splash->setAttribute(Qt::WA_DeleteOnClose);
splash->show();
connect(this, SIGNAL(splashFinished(QWidget*)), splash, SLOT(slotFinish(QWidget*)));
}

9
src/qt/splashscreen.cpp

@ -14,8 +14,9 @@ @@ -14,8 +14,9 @@
#endif
#include <QApplication>
#include <QPainter>
#include <QCloseEvent>
#include <QDesktopWidget>
#include <QPainter>
SplashScreen::SplashScreen(Qt::WindowFlags f, bool isTestNet) :
QWidget(0, f), curAlignment(0)
@ -113,7 +114,6 @@ SplashScreen::~SplashScreen() @@ -113,7 +114,6 @@ SplashScreen::~SplashScreen()
void SplashScreen::slotFinish(QWidget *mainWin)
{
hide();
deleteLater();
}
static void InitMessage(SplashScreen *splash, const std::string &message)
@ -175,3 +175,8 @@ void SplashScreen::paintEvent(QPaintEvent *event) @@ -175,3 +175,8 @@ void SplashScreen::paintEvent(QPaintEvent *event)
painter.drawText(r, curAlignment, curMessage);
}
void SplashScreen::closeEvent(QCloseEvent *event)
{
event->ignore();
}

9
src/qt/splashscreen.h

@ -7,7 +7,11 @@ @@ -7,7 +7,11 @@
#include <QSplashScreen>
/** class for the splashscreen with information of the running client
/** Class for the splashscreen with information of the running client.
*
* @note this is intentionally not a QSplashScreen. Bitcoin Core initialization
* can take a long time, and in that case a progress window that cannot be
* moved around and minimized has turned out to be frustrating to the user.
*/
class SplashScreen : public QWidget
{
@ -18,7 +22,8 @@ public: @@ -18,7 +22,8 @@ public:
~SplashScreen();
protected:
void paintEvent(QPaintEvent *event);
void paintEvent(QPaintEvent *event);
void closeEvent(QCloseEvent *event);
public slots:
/** Slot to call finish() method as it's not defined as slot */

26
src/qt/utilitydialog.cpp

@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
#include <stdio.h>
#include <QCloseEvent>
#include <QLabel>
#include <QRegExp>
#include <QVBoxLayout>
@ -106,18 +107,26 @@ void HelpMessageDialog::on_okButton_accepted() @@ -106,18 +107,26 @@ void HelpMessageDialog::on_okButton_accepted()
/** "Shutdown" window */
ShutdownWindow::ShutdownWindow(QWidget *parent, Qt::WindowFlags f):
QWidget(parent, f)
{
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(new QLabel(
tr("Bitcoin Core is shutting down...") + "<br /><br />" +
tr("Do not shut down the computer until this window disappears.")));
setLayout(layout);
}
void ShutdownWindow::showShutdownWindow(BitcoinGUI *window)
{
if (!window)
return;
// Show a simple window indicating shutdown status
QWidget *shutdownWindow = new QWidget();
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(new QLabel(
tr("Bitcoin Core is shutting down...") + "<br /><br />" +
tr("Do not shut down the computer until this window disappears.")));
shutdownWindow->setLayout(layout);
QWidget *shutdownWindow = new ShutdownWindow();
// We don't hold a direct pointer to the shutdown window after creation, so use
// Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
shutdownWindow->setAttribute(Qt::WA_DeleteOnClose);
shutdownWindow->setWindowTitle(window->windowTitle());
// Center shutdown window at where main window was
@ -125,3 +134,8 @@ void ShutdownWindow::showShutdownWindow(BitcoinGUI *window) @@ -125,3 +134,8 @@ void ShutdownWindow::showShutdownWindow(BitcoinGUI *window)
shutdownWindow->move(global.x() - shutdownWindow->width() / 2, global.y() - shutdownWindow->height() / 2);
shutdownWindow->show();
}
void ShutdownWindow::closeEvent(QCloseEvent *event)
{
event->ignore();
}

6
src/qt/utilitydialog.h

@ -37,12 +37,16 @@ private slots: @@ -37,12 +37,16 @@ private slots:
/** "Shutdown" window */
class ShutdownWindow : public QObject
class ShutdownWindow : public QWidget
{
Q_OBJECT
public:
ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0);
static void showShutdownWindow(BitcoinGUI *window);
protected:
void closeEvent(QCloseEvent *event);
};
#endif // UTILITYDIALOG_H

Loading…
Cancel
Save