Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI messagepage: add placeholder text to address field (like in sendcoins dialog)... #1204

Merged
merged 1 commit into from May 11, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/qt/bitcoingui.cpp
Expand Up @@ -724,8 +724,11 @@ void BitcoinGUI::gotoSendCoinsPage()
disconnect(exportAction, SIGNAL(triggered()), 0, 0);
}

void BitcoinGUI::gotoMessagePage()
void BitcoinGUI::gotoMessagePage(QString addr)
{
if(!addr.isEmpty())
messagePage->setAddress(addr);

#ifdef FIRST_CLASS_MESSAGING
messageAction->setChecked(true);
centralWidget->setCurrentWidget(messagePage);
Expand All @@ -734,16 +737,9 @@ void BitcoinGUI::gotoMessagePage()
disconnect(exportAction, SIGNAL(triggered()), 0, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we want the focus in signFrom, so this is obsolete. Try it out, it works!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"It works" != "It's guaranteed to work"; I would be fairly disappointed if setting focus on a widget also brought the window into focus.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I leave this setFocus(), signFrom is NOT focused, but I guess @laanwj should verify my code then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this. Would need to be tested on various OSes :/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I set the focus on an element in a widget instead of the widget itself ... perhaps I find the answer via a web-search. Sounds pretty logical though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the MessagePage has set the flag focusPolicy = NoFocus (which is the default), I'm rather sure the setFocus() had no function before! And signFrom has focusPolicy = StrongFocus, which allows setting the focus to.

See http://qt-project.org/doc/qt-4.8/qt.html#FocusPolicy-enum

#else
messagePage->show();
messagePage->setFocus();
#endif
}

void BitcoinGUI::gotoMessagePage(QString addr)
{
gotoMessagePage();
messagePage->setAddress(addr);
}

void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
{
// Accept only URIs
Expand Down
5 changes: 2 additions & 3 deletions src/qt/bitcoingui.h
Expand Up @@ -46,7 +46,7 @@ class BitcoinGUI : public QMainWindow
functionality.
*/
void setWalletModel(WalletModel *walletModel);

protected:
void changeEvent(QEvent *e);
void closeEvent(QCloseEvent *event);
Expand Down Expand Up @@ -130,8 +130,7 @@ public slots:
void askFee(qint64 nFeeRequired, bool *payFee);
void handleURI(QString strURI);

void gotoMessagePage();
void gotoMessagePage(QString);
void gotoMessagePage(QString addr = "");

private slots:
/** Switch to overview (home) page */
Expand Down
2 changes: 1 addition & 1 deletion src/qt/forms/messagepage.ui
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Message</string>
<string>Sign Message Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
Expand Down
7 changes: 6 additions & 1 deletion src/qt/messagepage.cpp
Expand Up @@ -24,14 +24,17 @@ MessagePage::MessagePage(QWidget *parent) :
ui(new Ui::MessagePage)
{
ui->setupUi(this);

#if (QT_VERSION >= 0x040700)
/* Do not move this to the XML file, Qt before 4.7 will choke on it */
ui->signFrom->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)"));
ui->signature->setPlaceholderText(tr("Click \"Sign Message\" to get signature"));
#endif

GUIUtil::setupAddressWidget(ui->signFrom, this);
ui->signature->installEventFilter(this);

ui->signFrom->setFocus();
}

MessagePage::~MessagePage()
Expand Down Expand Up @@ -117,6 +120,8 @@ void MessagePage::on_clearButton_clicked()
ui->signFrom->clear();
ui->message->clear();
ui->signature->clear();

ui->signFrom->setFocus();
}

bool MessagePage::eventFilter(QObject *object, QEvent *event)
Expand Down