mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
qt: Unify AboutDialog and HelpMessageDialog
They share so much code and functionality that they may as well be one class.
This commit is contained in:
parent
45615af26f
commit
5c97aae6da
@ -76,7 +76,6 @@ QT_TS = \
|
|||||||
qt/locale/bitcoin_zh_TW.ts
|
qt/locale/bitcoin_zh_TW.ts
|
||||||
|
|
||||||
QT_FORMS_UI = \
|
QT_FORMS_UI = \
|
||||||
qt/forms/aboutdialog.ui \
|
|
||||||
qt/forms/addressbookpage.ui \
|
qt/forms/addressbookpage.ui \
|
||||||
qt/forms/askpassphrasedialog.ui \
|
qt/forms/askpassphrasedialog.ui \
|
||||||
qt/forms/coincontroldialog.ui \
|
qt/forms/coincontroldialog.ui \
|
||||||
|
@ -549,8 +549,7 @@ void BitcoinGUI::aboutClicked()
|
|||||||
if(!clientModel)
|
if(!clientModel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AboutDialog dlg(this);
|
HelpMessageDialog dlg(this, true);
|
||||||
dlg.setModel(clientModel);
|
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,130 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>AboutDialog</class>
|
|
||||||
<widget class="QDialog" name="AboutDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>593</width>
|
|
||||||
<height>319</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>About Bitcoin Core</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Ignored">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="pixmap">
|
|
||||||
<pixmap resource="../bitcoin.qrc">:/images/about</pixmap>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="versionLabel">
|
|
||||||
<property name="cursor">
|
|
||||||
<cursorShape>IBeamCursor</cursorShape>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">
|
|
||||||
(placeholder for version message)
|
|
||||||
</string>
|
|
||||||
</property>
|
|
||||||
<property name="textFormat">
|
|
||||||
<enum>Qt::RichText</enum>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="textInteractionFlags">
|
|
||||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources>
|
|
||||||
<include location="../bitcoin.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>AboutDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>20</x>
|
|
||||||
<y>20</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>20</x>
|
|
||||||
<y>20</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>AboutDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>20</x>
|
|
||||||
<y>20</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>20</x>
|
|
||||||
<y>20</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
@ -16,7 +16,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Bitcoin Core - Command-line options</string>
|
<string notr="true">Bitcoin Core - Command-line options</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
@ -54,11 +54,6 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="helpMessageLabel">
|
<widget class="QLabel" name="helpMessageLabel">
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Terminal</family>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="cursor">
|
<property name="cursor">
|
||||||
<cursorShape>IBeamCursor</cursorShape>
|
<cursorShape>IBeamCursor</cursorShape>
|
||||||
</property>
|
</property>
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "utilitydialog.h"
|
#include "utilitydialog.h"
|
||||||
|
|
||||||
#include "ui_aboutdialog.h"
|
|
||||||
#include "ui_helpmessagedialog.h"
|
#include "ui_helpmessagedialog.h"
|
||||||
|
|
||||||
#include "bitcoingui.h"
|
#include "bitcoingui.h"
|
||||||
@ -19,19 +18,15 @@
|
|||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
/** "About" dialog box */
|
/** "Help message" or "About" dialog box */
|
||||||
AboutDialog::AboutDialog(QWidget *parent) :
|
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::AboutDialog)
|
ui(new Ui::HelpMessageDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
}
|
GUIUtil::restoreWindowGeometry("nHelpMessageDialogWindow", this->size(), this);
|
||||||
|
|
||||||
void AboutDialog::setModel(ClientModel *model)
|
QString version = tr("Bitcoin Core") + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion());
|
||||||
{
|
|
||||||
if(model)
|
|
||||||
{
|
|
||||||
QString version = tr("Bitcoin Core") + " " + tr("version") + " " + model->formatFullVersion();
|
|
||||||
/* On x86 add a bit specifier to the version so that users can distinguish between
|
/* On x86 add a bit specifier to the version so that users can distinguish between
|
||||||
* 32 and 64 bit builds. On other architectures, 32/64 bit may be more ambigious.
|
* 32 and 64 bit builds. On other architectures, 32/64 bit may be more ambigious.
|
||||||
*/
|
*/
|
||||||
@ -41,38 +36,27 @@ void AboutDialog::setModel(ClientModel *model)
|
|||||||
version += " " + tr("(%1-bit)").arg(32);
|
version += " " + tr("(%1-bit)").arg(32);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (about)
|
||||||
|
{
|
||||||
|
setWindowTitle(tr("About Bitcoin Core"));
|
||||||
|
|
||||||
/// HTML-format the license message from the core
|
/// HTML-format the license message from the core
|
||||||
QString licenseInfo = QString::fromStdString(LicenseInfo());
|
QString licenseInfo = QString::fromStdString(LicenseInfo());
|
||||||
|
QString licenseInfoHTML = licenseInfo;
|
||||||
// Make URLs clickable
|
// Make URLs clickable
|
||||||
QRegExp uri("<(.*)>", Qt::CaseSensitive, QRegExp::RegExp2);
|
QRegExp uri("<(.*)>", Qt::CaseSensitive, QRegExp::RegExp2);
|
||||||
uri.setMinimal(true); // use non-greedy matching
|
uri.setMinimal(true); // use non-greedy matching
|
||||||
licenseInfo = licenseInfo.replace(uri, "<a href=\"\\1\">\\1</a>");
|
licenseInfoHTML.replace(uri, "<a href=\"\\1\">\\1</a>");
|
||||||
// Replace newlines with HTML breaks
|
// Replace newlines with HTML breaks
|
||||||
licenseInfo = licenseInfo.replace("\n\n", "<br><br>");
|
licenseInfoHTML.replace("\n\n", "<br><br>");
|
||||||
|
|
||||||
ui->versionLabel->setText(version + "<br><br>" + licenseInfo);
|
ui->helpMessageLabel->setTextFormat(Qt::RichText);
|
||||||
}
|
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
}
|
text = version + "\n" + licenseInfo;
|
||||||
|
ui->helpMessageLabel->setText(version + "<br><br>" + licenseInfoHTML);
|
||||||
AboutDialog::~AboutDialog()
|
ui->helpMessageLabel->setWordWrap(true);
|
||||||
{
|
} else {
|
||||||
delete ui;
|
setWindowTitle(tr("Command-line options"));
|
||||||
}
|
|
||||||
|
|
||||||
void AboutDialog::on_buttonBox_accepted()
|
|
||||||
{
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** "Help message" dialog box */
|
|
||||||
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool versionOnly) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::HelpMessageDialog)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
GUIUtil::restoreWindowGeometry("nHelpMessageDialogWindow", this->size(), this);
|
|
||||||
|
|
||||||
QString version = tr("Bitcoin Core") + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion());
|
|
||||||
QString header = tr("Usage:") + "\n" +
|
QString header = tr("Usage:") + "\n" +
|
||||||
" bitcoin-qt [" + tr("command-line options") + "] " + "\n";
|
" bitcoin-qt [" + tr("command-line options") + "] " + "\n";
|
||||||
|
|
||||||
@ -86,12 +70,9 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool versionOnly) :
|
|||||||
" -splash " + tr("Show splash screen on startup (default: 1)");
|
" -splash " + tr("Show splash screen on startup (default: 1)");
|
||||||
|
|
||||||
ui->helpMessageLabel->setFont(GUIUtil::bitcoinAddressFont());
|
ui->helpMessageLabel->setFont(GUIUtil::bitcoinAddressFont());
|
||||||
|
text = version + "\n" + header + "\n" + coreOptions + "\n" + uiOptions;
|
||||||
// Set help message text
|
ui->helpMessageLabel->setText(text);
|
||||||
if(versionOnly)
|
}
|
||||||
ui->helpMessageLabel->setText(version + "\n" + QString::fromStdString(LicenseInfo()));
|
|
||||||
else
|
|
||||||
ui->helpMessageLabel->setText(version + "\n" + header + "\n" + coreOptions + "\n" + uiOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpMessageDialog::~HelpMessageDialog()
|
HelpMessageDialog::~HelpMessageDialog()
|
||||||
@ -103,7 +84,7 @@ HelpMessageDialog::~HelpMessageDialog()
|
|||||||
void HelpMessageDialog::printToConsole()
|
void HelpMessageDialog::printToConsole()
|
||||||
{
|
{
|
||||||
// On other operating systems, the expected action is to print the message to the console.
|
// On other operating systems, the expected action is to print the message to the console.
|
||||||
fprintf(stdout, "%s\n", qPrintable(ui->helpMessageLabel->text()));
|
fprintf(stdout, "%s\n", qPrintable(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpMessageDialog::showOrPrint()
|
void HelpMessageDialog::showOrPrint()
|
||||||
|
@ -12,35 +12,16 @@ class BitcoinGUI;
|
|||||||
class ClientModel;
|
class ClientModel;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class AboutDialog;
|
|
||||||
class HelpMessageDialog;
|
class HelpMessageDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "About" dialog box */
|
|
||||||
class AboutDialog : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit AboutDialog(QWidget *parent);
|
|
||||||
~AboutDialog();
|
|
||||||
|
|
||||||
void setModel(ClientModel *model);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::AboutDialog *ui;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_buttonBox_accepted();
|
|
||||||
};
|
|
||||||
|
|
||||||
/** "Help message" dialog box */
|
/** "Help message" dialog box */
|
||||||
class HelpMessageDialog : public QDialog
|
class HelpMessageDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit HelpMessageDialog(QWidget *parent, bool versionOnly);
|
explicit HelpMessageDialog(QWidget *parent, bool about);
|
||||||
~HelpMessageDialog();
|
~HelpMessageDialog();
|
||||||
|
|
||||||
void printToConsole();
|
void printToConsole();
|
||||||
@ -48,6 +29,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::HelpMessageDialog *ui;
|
Ui::HelpMessageDialog *ui;
|
||||||
|
QString text;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_okButton_accepted();
|
void on_okButton_accepted();
|
||||||
|
Loading…
Reference in New Issue
Block a user