Skip to content

Commit

Permalink
[Qt] make most Windows appear centered on main GUI
Browse files Browse the repository at this point in the history
- remove default value for parent variable in dialogs, which should appear
  centered over main GUI and pass appropriate value
- add some addition NULL pointer checks
  • Loading branch information
Philip Kaufmann committed Nov 14, 2013
1 parent 6ad44f5 commit 309f796
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/qt/aboutdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AboutDialog : public QDialog
Q_OBJECT

public:
explicit AboutDialog(QWidget *parent = 0);
explicit AboutDialog(QWidget *parent);
~AboutDialog();

void setModel(ClientModel *model);
Expand Down
15 changes: 9 additions & 6 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,19 @@ void AddressBookPage::onCopyLabelAction()

void AddressBookPage::onEditAction()
{
if(!model)
return;

if(!ui->tableView->selectionModel())
return;
QModelIndexList indexes = ui->tableView->selectionModel()->selectedRows();
if(indexes.isEmpty())
return;

EditAddressDialog dlg(
tab == SendingTab ?
EditAddressDialog::EditSendingAddress :
EditAddressDialog::EditReceivingAddress);
tab == SendingTab ?
EditAddressDialog::EditSendingAddress :
EditAddressDialog::EditReceivingAddress, this);
dlg.setModel(model);
QModelIndex origIndex = proxyModel->mapToSource(indexes.at(0));
dlg.loadRow(origIndex.row());
Expand All @@ -180,9 +183,9 @@ void AddressBookPage::on_newAddress_clicked()
return;

EditAddressDialog dlg(
tab == SendingTab ?
EditAddressDialog::NewSendingAddress :
EditAddressDialog::NewReceivingAddress, this);
tab == SendingTab ?
EditAddressDialog::NewSendingAddress :
EditAddressDialog::NewReceivingAddress, this);
dlg.setModel(model);
if(dlg.exec())
{
Expand Down
2 changes: 1 addition & 1 deletion src/qt/addressbookpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AddressBookPage : public QDialog
ForEditing /**< Open address book for editing */
};

explicit AddressBookPage(Mode mode, Tabs tab, QWidget *parent = 0);
explicit AddressBookPage(Mode mode, Tabs tab, QWidget *parent);
~AddressBookPage();

void setModel(AddressTableModel *model);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/askpassphrasedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AskPassphraseDialog : public QDialog
Decrypt /**< Ask passphrase and decrypt wallet */
};

explicit AskPassphraseDialog(Mode mode, QWidget *parent = 0);
explicit AskPassphraseDialog(Mode mode, QWidget *parent);
~AskPassphraseDialog();

void accept();
Expand Down
14 changes: 9 additions & 5 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#include "guiconstants.h"
#include "guiutil.h"
#include "notificator.h"
#include "openuridialog.h"
#include "optionsdialog.h"
#include "optionsmodel.h"
#include "rpcconsole.h"
#include "walletframe.h"
#include "walletmodel.h"
#include "openuridialog.h"

#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
Expand Down Expand Up @@ -345,7 +345,7 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
setNumBlocks(clientModel->getNumBlocks(), clientModel->getNumBlocksOfPeers());
connect(clientModel, SIGNAL(numBlocksChanged(int,int)), this, SLOT(setNumBlocks(int,int)));

// Receive and report messages from network/worker thread
// Receive and report messages from client model
connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));

rpcConsole->setClientModel(clientModel);
Expand Down Expand Up @@ -460,21 +460,25 @@ void BitcoinGUI::optionsClicked()
{
if(!clientModel || !clientModel->getOptionsModel())
return;
OptionsDialog dlg;

OptionsDialog dlg(this);
dlg.setModel(clientModel->getOptionsModel());
dlg.exec();
}

void BitcoinGUI::aboutClicked()
{
AboutDialog dlg;
if(!clientModel)
return;

AboutDialog dlg(this);
dlg.setModel(clientModel);
dlg.exec();
}

void BitcoinGUI::openClicked()
{
OpenURIDialog dlg;
OpenURIDialog dlg(this);
if(dlg.exec())
{
emit receivedURI(dlg.getURI());
Expand Down
2 changes: 1 addition & 1 deletion src/qt/editaddressdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EditAddressDialog : public QDialog
EditSendingAddress
};

explicit EditAddressDialog(Mode mode, QWidget *parent = 0);
explicit EditAddressDialog(Mode mode, QWidget *parent);
~EditAddressDialog();

void setModel(AddressTableModel *model);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/openuridialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class OpenURIDialog : public QDialog
Q_OBJECT

public:
explicit OpenURIDialog(QWidget *parent = 0);
explicit OpenURIDialog(QWidget *parent);
~OpenURIDialog();

QString getURI();
Expand Down
2 changes: 1 addition & 1 deletion src/qt/optionsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class OptionsDialog : public QDialog
Q_OBJECT

public:
explicit OptionsDialog(QWidget *parent = 0);
explicit OptionsDialog(QWidget *parent);
~OptionsDialog();

void setModel(OptionsModel *model);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RPCConsole: public QDialog
Q_OBJECT

public:
explicit RPCConsole(QWidget *parent = 0);
explicit RPCConsole(QWidget *parent);
~RPCConsole();

void setClientModel(ClientModel *model);
Expand Down
2 changes: 1 addition & 1 deletion src/qt/signverifymessagedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SignVerifyMessageDialog : public QDialog
Q_OBJECT

public:
explicit SignVerifyMessageDialog(QWidget *parent = 0);
explicit SignVerifyMessageDialog(QWidget *parent);
~SignVerifyMessageDialog();

void setModel(WalletModel *model);
Expand Down
12 changes: 5 additions & 7 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,12 @@ TransactionView::TransactionView(QWidget *parent) :

addressWidget = new QLineEdit(this);
#if QT_VERSION >= 0x040700
/* Do not move this to the XML file, Qt before 4.7 will choke on it */
addressWidget->setPlaceholderText(tr("Enter address or label to search"));
#endif
hlayout->addWidget(addressWidget);

amountWidget = new QLineEdit(this);
#if QT_VERSION >= 0x040700
/* Do not move this to the XML file, Qt before 4.7 will choke on it */
amountWidget->setPlaceholderText(tr("Min amount"));
#endif
#ifdef Q_OS_MAC
Expand Down Expand Up @@ -355,10 +353,10 @@ void TransactionView::editLabel()
// Determine type of address, launch appropriate editor dialog type
QString type = modelIdx.data(AddressTableModel::TypeRole).toString();

EditAddressDialog dlg(type==AddressTableModel::Receive
? EditAddressDialog::EditReceivingAddress
: EditAddressDialog::EditSendingAddress,
this);
EditAddressDialog dlg(
type == AddressTableModel::Receive
? EditAddressDialog::EditReceivingAddress
: EditAddressDialog::EditSendingAddress, this);
dlg.setModel(addressBook);
dlg.loadRow(idx);
dlg.exec();
Expand All @@ -367,7 +365,7 @@ void TransactionView::editLabel()
{
// Add sending address
EditAddressDialog dlg(EditAddressDialog::NewSendingAddress,
this);
this);
dlg.setModel(addressBook);
dlg.setAddress(address);
dlg.exec();
Expand Down

0 comments on commit 309f796

Please sign in to comment.