8 #include <QApplication>
36 #include <QVBoxLayout>
40 #include <QMessageBox>
41 #include <QProgressBar>
42 #include <QStackedWidget>
46 #include <QDragEnterEvent>
47 #if QT_VERSION < 0x050000
53 #include <QDesktopWidget>
54 #include <QListWidget>
63 encryptWalletAction(0),
64 changePassphraseAction(0),
72 setWindowTitle(tr(
"Feathercoin") +
" - " + tr(
"Wallet"));
74 QApplication::setWindowIcon(QIcon(
":icons/bitcoin"));
75 setWindowIcon(QIcon(
":icons/bitcoin"));
77 setUnifiedTitleAndToolBarOnMac(
true);
78 QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
104 QFrame *frameBlocks =
new QFrame();
105 frameBlocks->setContentsMargins(0,0,0,0);
106 frameBlocks->setMinimumWidth(56);
107 frameBlocks->setMaximumWidth(56);
108 QHBoxLayout *frameBlocksLayout =
new QHBoxLayout(frameBlocks);
109 frameBlocksLayout->setContentsMargins(3,0,3,0);
110 frameBlocksLayout->setSpacing(3);
114 frameBlocksLayout->addStretch();
116 frameBlocksLayout->addStretch();
118 frameBlocksLayout->addStretch();
120 frameBlocksLayout->addStretch();
132 QString curStyle = QApplication::style()->metaObject()->className();
133 if(curStyle ==
"QWindowsStyle" || curStyle ==
"QWindowsXPStyle")
135 progressBar->setStyleSheet(
"QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
140 statusBar()->addPermanentWidget(frameBlocks);
142 syncIconMovie =
new QMovie(
":/movies/update_spinner",
"mng",
this);
148 this->installEventFilter(
this);
167 QActionGroup *tabGroup =
new QActionGroup(
this);
169 overviewAction =
new QAction(QIcon(
":/icons/overview"), tr(
"&Overview"),
this);
170 overviewAction->setStatusTip(tr(
"Show general overview of wallet"));
176 sendCoinsAction =
new QAction(QIcon(
":/icons/send"), tr(
"&Send"),
this);
177 sendCoinsAction->setStatusTip(tr(
"Send coins to a Feathercoin address"));
183 receiveCoinsAction =
new QAction(QIcon(
":/icons/receiving_addresses"), tr(
"&Receive"),
this);
184 receiveCoinsAction->setStatusTip(tr(
"Show the list of addresses for receiving payments"));
190 historyAction =
new QAction(QIcon(
":/icons/history"), tr(
"&Transactions"),
this);
191 historyAction->setStatusTip(tr(
"Browse transaction history"));
194 historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
197 addressBookAction =
new QAction(QIcon(
":/icons/address-book"), tr(
"&Addresses"),
this);
198 addressBookAction->setStatusTip(tr(
"Edit the list of stored addresses and labels"));
215 quitAction =
new QAction(QIcon(
":/icons/quit"), tr(
"E&xit"),
this);
216 quitAction->setStatusTip(tr(
"Quit application"));
217 quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
219 aboutAction =
new QAction(QIcon(
":/icons/bitcoin"), tr(
"&About Feathercoin"),
this);
220 aboutAction->setStatusTip(tr(
"Show information about Feathercoin"));
222 aboutQtAction =
new QAction(QIcon(
":/trolltech/qmessagebox/images/qtlogo-64.png"), tr(
"About &Qt"),
this);
223 aboutQtAction->setStatusTip(tr(
"Show information about Qt"));
225 optionsAction =
new QAction(QIcon(
":/icons/options"), tr(
"&Options..."),
this);
226 optionsAction->setStatusTip(tr(
"Modify configuration options for Feathercoin"));
228 toggleHideAction =
new QAction(QIcon(
":/icons/bitcoin"), tr(
"&Show / Hide"),
this);
231 encryptWalletAction =
new QAction(QIcon(
":/icons/lock_closed"), tr(
"&Encrypt Wallet..."),
this);
232 encryptWalletAction->setStatusTip(tr(
"Encrypt the private keys that belong to your wallet"));
234 backupWalletAction =
new QAction(QIcon(
":/icons/filesave"), tr(
"&Backup Wallet..."),
this);
238 signMessageAction =
new QAction(QIcon(
":/icons/edit"), tr(
"Sign &message..."),
this);
239 signMessageAction->setStatusTip(tr(
"Sign messages with your Feathercoin addresses to prove you own them"));
240 verifyMessageAction =
new QAction(QIcon(
":/icons/transaction_0"), tr(
"&Verify message..."),
this);
241 verifyMessageAction->setStatusTip(tr(
"Verify messages to ensure they were signed with specified Feathercoin addresses"));
246 connect(
quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
248 connect(
aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
269 QMenu *file =
appMenuBar->addMenu(tr(
"&File"));
273 file->addSeparator();
276 QMenu *settings =
appMenuBar->addMenu(tr(
"&Settings"));
279 settings->addSeparator();
284 help->addSeparator();
291 QToolBar *toolbar = addToolBar(tr(
"Tabs toolbar"));
292 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
308 setWindowTitle(windowTitle() + QString(
" ") + tr(
"[testnet]"));
310 QApplication::setWindowIcon(QIcon(
":icons/bitcoin_testnet"));
311 setWindowIcon(QIcon(
":icons/bitcoin_testnet"));
319 trayIcon->setIcon(QIcon(
":/icons/toolbar_testnet"));
323 aboutAction->setIcon(QIcon(
":/icons/toolbar_testnet"));
332 connect(clientModel, SIGNAL(numConnectionsChanged(
int)),
this, SLOT(
setNumConnections(
int)));
335 connect(clientModel, SIGNAL(numBlocksChanged(
int,
int)),
this, SLOT(
setNumBlocks(
int,
int)));
338 connect(clientModel, SIGNAL(
message(QString,QString,
unsigned int)),
this, SLOT(
message(QString,QString,
unsigned int)));
379 trayIcon =
new QSystemTrayIcon(
this);
381 trayIcon->setToolTip(tr(
"Feathercoin client"));
382 trayIcon->setIcon(QIcon(
":/icons/toolbar"));
397 trayIconMenu =
new QMenu(
this);
398 trayIcon->setContextMenu(trayIconMenu);
400 connect(
trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
406 trayIconMenu = dockIconHandler->
dockMenu();
411 trayIconMenu->addSeparator();
414 trayIconMenu->addSeparator();
417 trayIconMenu->addSeparator();
420 #ifndef Q_OS_MAC // This is built-in on Mac
421 trayIconMenu->addSeparator();
429 if(reason == QSystemTrayIcon::Trigger)
440 settings.setValue(
"nWindowPos", pos());
441 settings.setValue(
"nWindowSize", size());
447 QPoint pos = settings.value(
"nWindowPos").toPoint();
448 QSize size = settings.value(
"nWindowSize", QSize(850, 550)).toSize();
449 if (!pos.x() && !pos.y())
451 QRect screen = QApplication::desktop()->screenGeometry();
452 pos.setX((screen.width()-size.width())/2);
453 pos.setY((screen.height()-size.height())/2);
515 case 0: icon =
":/icons/connect_0";
break;
516 case 1:
case 2:
case 3: icon =
":/icons/connect_1";
break;
517 case 4:
case 5:
case 6: icon =
":/icons/connect_2";
break;
518 case 7:
case 8:
case 9: icon =
":/icons/connect_3";
break;
519 default: icon =
":/icons/connect_4";
break;
522 labelConnectionsIcon->setToolTip(tr(
"%n active connection(s) to Feathercoin network",
"", count));
528 statusBar()->clearMessage();
532 switch (blockSource) {
551 QDateTime currentDate = QDateTime::currentDateTime();
552 int secs = lastBlockDate.secsTo(currentDate);
554 if(count < nTotalBlocks)
556 tooltip = tr(
"Processed %1 of %2 (estimated) blocks of transaction history.").arg(count).arg(nTotalBlocks);
560 tooltip = tr(
"Processed %1 blocks of transaction history.").arg(count);
564 if(secs < 90*60 && count >= nTotalBlocks)
566 tooltip = tr(
"Up to date") + QString(
".<br>") + tooltip;
567 labelBlocksIcon->setPixmap(QIcon(
":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
577 QString timeBehindText;
580 timeBehindText = tr(
"%n hour(s)",
"",secs/(60*60));
582 else if(secs < 14*24*60*60)
584 timeBehindText = tr(
"%n day(s)",
"",secs/(24*60*60));
588 timeBehindText = tr(
"%n week(s)",
"",secs/(7*24*60*60));
597 tooltip = tr(
"Catching up...") + QString(
"<br>") + tooltip;
605 tooltip += QString(
"<br>");
606 tooltip += tr(
"Last received block was generated %1 ago.").arg(timeBehindText);
607 tooltip += QString(
"<br>");
608 tooltip += tr(
"Transactions after this will not yet be visible.");
612 tooltip = QString(
"<nobr>") + tooltip + QString(
"</nobr>");
621 QString strTitle = tr(
"Feathercoin");
623 int nMBoxIcon = QMessageBox::Information;
630 msgType = tr(
"Error");
633 msgType = tr(
"Warning");
636 msgType = tr(
"Information");
641 if (!msgType.isEmpty())
642 strTitle +=
" - " + msgType;
646 nMBoxIcon = QMessageBox::Critical;
650 nMBoxIcon = QMessageBox::Warning;
657 QMessageBox::StandardButton buttons;
659 buttons = QMessageBox::Ok;
661 QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons);
664 *ret = r == QMessageBox::Ok;
672 QMainWindow::changeEvent(e);
673 #ifndef Q_OS_MAC // Ignored on Mac
674 if(e->type() == QEvent::WindowStateChange)
678 QWindowStateChangeEvent *wsevt =
static_cast<QWindowStateChangeEvent*
>(e);
679 if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
681 QTimer::singleShot(0,
this, SLOT(hide()));
693 #ifndef Q_OS_MAC // Ignored on Mac
697 QApplication::quit();
701 QMainWindow::closeEvent(event);
706 QString strMessage = tr(
"This transaction is over the size limit. You can still send it for a fee of %1, "
707 "which goes to the nodes that process your transaction and helps to support the network. "
709 QMessageBox::StandardButton retval = QMessageBox::question(
710 this, tr(
"Confirm transaction fee"), strMessage,
711 QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
712 *payFee = (retval == QMessageBox::Yes);
718 message((amount)<0 ? tr(
"Sent transaction") : tr(
"Incoming transaction"),
732 if(event->mimeData()->hasUrls())
733 event->acceptProposedAction();
738 if(event->mimeData()->hasUrls())
740 int nValidUrisFound = 0;
741 QList<QUrl> uris =
event->mimeData()->urls();
742 foreach(
const QUrl &uri, uris)
752 message(tr(
"URI handling"), tr(
"URI can not be parsed! This can be caused by an invalid Feathercoin address or malformed URI parameters."),
756 event->acceptProposedAction();
762 if (event->type() == QEvent::StatusTip)
768 return QMainWindow::eventFilter(
object, event);
775 message(tr(
"URI handling"), tr(
"URI can not be parsed! This can be caused by an invalid Feathercoin address or malformed URI parameters."),
791 labelEncryptionIcon->setPixmap(QIcon(
":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
792 labelEncryptionIcon->setToolTip(tr(
"Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
799 labelEncryptionIcon->setPixmap(QIcon(
":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
800 labelEncryptionIcon->setToolTip(tr(
"Wallet is <b>encrypted</b> and currently <b>locked</b>"));
816 else if (isMinimized())
826 else if(fToggleHidden)
838 QMetaObject::invokeMethod(QCoreApplication::instance(),
"quit", Qt::QueuedConnection);
bool setCurrentWallet(const QString &name)
bool getMinimizeOnClose()
QAction * receiveCoinsAction
Local Bitcoin RPC console.
static const QString DEFAULT_WALLET
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
QAction * signMessageAction
bool handleURI(const QString &uri)
void showNormalIfMinimized(bool fToggleHidden=false)
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
static QString formatWithUnit(int unit, qint64 amount, bool plussign=false)
Format as string (with unit)
void handleURI(QString strURI)
void createTrayIcon()
Create system tray icon and notification.
Value help(const Array ¶ms, bool fHelp)
bool setCurrentWallet(const QString &name)
ClientModel * clientModel
void createToolBars()
Create the toolbars.
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
QAction * verifyMessageAction
void dropEvent(QDropEvent *event)
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
void gotoAddressBookPage()
Switch to address book page.
OptionsModel * getOptionsModel()
Macintosh-specific dock icon handler.
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated...
QLabel * progressBarLabel
QSystemTrayIcon * trayIcon
int getNumBlocksOfPeers() const
Return conservative estimate of total number of blocks, or 0 if unknown.
Notify user of potential problem.
QAction * backupWalletAction
QLabel * labelConnectionsIcon
void saveWindowGeometry()
Save window size and position.
Force blocking, modal message box dialog (not just OS notification)
void showOutOfSyncWarning(bool fShow)
void setIcon(const QIcon &icon)
void setClientModel(ClientModel *model)
void gotoHistoryPage()
Switch to history (transactions) page.
void gotoOverviewPage()
Switch to overview (home) page.
void setClientModel(ClientModel *clientModel)
Set the client model.
int getNumConnections() const
void gotoOverviewPage()
Switch to overview (home) page.
QAction * toggleHideAction
double getVerificationProgress() const
static MacDockIconHandler * instance()
QAction * addressBookAction
void setClientModel(ClientModel *clientModel)
void setMainWindow(QMainWindow *window)
bool isObscured(QWidget *w)
void optionsClicked()
Show configuration dialog.
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
void notify(Class cls, const QString &title, const QString &text, const QIcon &icon=QIcon(), int millisTimeout=10000)
Show notification message.
bool eventFilter(QObject *object, QEvent *event)
bool addWallet(const QString &name, WalletModel *walletModel)
QDateTime getLastBlockDate() const
WalletFrame * walletFrame
void incomingTransaction(const QString &date, int unit, qint64 amount, const QString &type, const QString &address)
Show incoming transaction notification for new transactions.
void setModel(OptionsModel *model)
QAction * openRPCConsoleAction
void detectShutdown()
called by a timer to check if fRequestShutdown has been set
Cross-platform desktop notification client.
bool addWallet(const QString &name, WalletModel *walletModel)
Set the wallet model.
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
void gotoReceiveCoinsPage()
Switch to receive coins page.
BitcoinGUI(QWidget *parent=0)
void dragEnterEvent(QDragEnterEvent *event)
Notificator * notificator
Model for Bitcoin network client.
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
QAction * sendCoinsAction
void gotoAddressBookPage()
Switch to address book page.
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
QAction * changePassphraseAction
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
void gotoReceiveCoinsPage()
Switch to receive coins page.
void closeEvent(QCloseEvent *event)
void setEncryptionStatus(int status)
Set the encryption status as shown in the UI.
Interface to Bitcoin wallet from Qt view code.
void changeEvent(QEvent *e)
bool isTestNet() const
Return true if client connected to testnet.
int prevBlocks
Keep track of previous number of blocks, to detect progress.
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
QProgressBar * progressBar
void setNumConnections(int count)
Set number of connections shown in the UI.
void createActions()
Create the main UI actions.
QAction * encryptWalletAction
void aboutClicked()
Show about dialog.
void message(const QString &title, const QString &message, unsigned int style, bool *ret=NULL)
Notify the user of an event from the core network or transaction handling code.
void restoreWindowGeometry()
Restore window size and position.
QLabel * labelEncryptionIcon
void askFee(qint64 nFeeRequired, bool *payFee)
Asks the user whether to pay the transaction fee or to cancel the transaction.
enum BlockSource getBlockSource() const
Return true if core is importing blocks.
void gotoHistoryPage()
Switch to history (transactions) page.
void createMenuBar()
Create the menu bar and sub-menus.
Predefined combinations for certain default usage cases.
void setModel(ClientModel *model)
void setNumBlocks(int count, int nTotalBlocks)
Set number of blocks shown in the UI.