OSDN Git Service

Bitcoin-Qt: BitcoinGUI::message() updates/fixes
authormonacoinproject <monacoinproject@gmail.com>
Sun, 6 Apr 2014 13:30:22 +0000 (22:30 +0900)
committermonacoinproject <monacoinproject@gmail.com>
Sun, 6 Apr 2014 13:30:22 +0000 (22:30 +0900)
- ensure message boxes are shown in center of our main window, not
centered on the users desktop
- always prefer user supplied titles for message boxes over the
functions
defaults (fixes a bug, where transaction info messages did not contain
information, if it was incoming or outgoing)

src/qt/bitcoingui.cpp

index 722cbd2..0f90691 100644 (file)
@@ -623,21 +623,28 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
     int nMBoxIcon = QMessageBox::Information;
     int nNotifyIcon = Notificator::Information;
 
-    // Override title based on style
     QString msgType;
-    switch (style) {
-    case CClientUIInterface::MSG_ERROR:
-        msgType = tr("Error");
-        break;
-    case CClientUIInterface::MSG_WARNING:
-        msgType = tr("Warning");
-        break;
-    case CClientUIInterface::MSG_INFORMATION:
-        msgType = tr("Information");
-        break;
-    default:
-        msgType = title; // Use supplied title
+
+    // Prefer supplied title over style based title
+    if (!title.isEmpty()) {
+         msgType = title;
+    }
+    else {
+        switch (style) {
+        case CClientUIInterface::MSG_ERROR:
+            msgType = tr("Error");
+            break;
+        case CClientUIInterface::MSG_WARNING:
+            msgType = tr("Warning");
+            break;
+        case CClientUIInterface::MSG_INFORMATION:
+            msgType = tr("Information");
+            break;
+        default:
+            break;
+        }
     }
+    // Append title to "Bitcoin - "
     if (!msgType.isEmpty())
         strTitle += " - " + msgType;
 
@@ -658,7 +665,7 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
         if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
             buttons = QMessageBox::Ok;
 
-        QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons);
+        QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
         int r = mBox.exec();
         if (ret != NULL)
             *ret = r == QMessageBox::Ok;