the RPC Console should be a QWidget...
authorfsb4000 <fsb4000@yandex.ru>
Tue, 6 Jan 2015 13:29:08 +0000 (19:29 +0600)
committerfsb4000 <fsb4000@yandex.ru>
Tue, 6 Jan 2015 13:29:08 +0000 (19:29 +0600)
to make window more independent

https://github.com/bitcoin/bitcoin/commit/4a8fc152a957e54e6dd910de4382678f5c405198

src/qt/bitcoingui.cpp
src/qt/forms/rpcconsole.ui
src/qt/rpcconsole.cpp
src/qt/rpcconsole.h

index 6cfe858..6b6b9e7 100644 (file)
@@ -197,7 +197,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
     // Double-clicking on a transaction on the transaction history page shows details
     connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
 
-    rpcConsole = new RPCConsole(this);
+    rpcConsole = new RPCConsole(0);
     connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));
 
     // Clicking on "Verify Message" in the address book sends you to the verify message tab
@@ -215,6 +215,8 @@ BitcoinGUI::~BitcoinGUI()
 #ifdef Q_OS_MAC
     delete appMenuBar;
 #endif
+
+    delete rpcConsole;
 }
 
 void BitcoinGUI::createActions()
@@ -809,6 +811,9 @@ void BitcoinGUI::closeEvent(QCloseEvent *event)
         }
 #endif
     }
+    // close rpcConsole in case it was open to make some space for the shutdown window
+    rpcConsole->close();
+
     QMainWindow::closeEvent(event);
 }
 
index 30d9ab2..30e1468 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
  <class>RPCConsole</class>
- <widget class="QDialog" name="RPCConsole">
+ <widget class="QWidget" name="RPCConsole">
   <property name="geometry">
    <rect>
     <x>0</x>
index 1f2fa9d..ce71379 100644 (file)
@@ -189,7 +189,7 @@ void RPCExecutor::request(const QString &command)
 }
 
 RPCConsole::RPCConsole(QWidget *parent) :
-    QDialog(parent, DIALOGWINDOWHINTS),
+    QWidget(parent),
     ui(new Ui::RPCConsole),
     historyPtr(0)
 {
@@ -255,7 +255,7 @@ bool RPCConsole::eventFilter(QObject* obj, QEvent *event)
             }
         }
     }
-    return QDialog::eventFilter(obj, event);
+    return QWidget::eventFilter(obj, event);
 }
 
 void RPCConsole::setClientModel(ClientModel *model)
@@ -494,3 +494,11 @@ void RPCConsole::hideEvent(QHideEvent *event)
     if (!clientModel)
         return;
 }
+
+void RPCConsole::keyPressEvent(QKeyEvent *event)
+{
+    if(windowType() != Qt::Widget && event->key() == Qt::Key_Escape)
+    {
+        close();
+    }
+}
\ No newline at end of file
index a4d1ebb..b523f0f 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef RPCCONSOLE_H
 #define RPCCONSOLE_H
 
-#include <QDialog>
+#include <QWidget>
 
 namespace Ui {
     class RPCConsole;
@@ -9,7 +9,7 @@ namespace Ui {
 class ClientModel;
 
 /** Local Bitcoin RPC console. */
-class RPCConsole: public QDialog
+class RPCConsole: public QWidget
 {
     Q_OBJECT
 
@@ -29,6 +29,7 @@ public:
 
 protected:
     virtual bool eventFilter(QObject* obj, QEvent *event);
+    void keyPressEvent(QKeyEvent *);
 
 private slots:
     void on_lineEdit_returnPressed();