From 2a25b98ea47dfeb0356068804b08dd2e5ec1680e Mon Sep 17 00:00:00 2001 From: Alan Westbrook Date: Sun, 9 Feb 2014 03:43:39 -0800 Subject: [PATCH] Fix for Menu problem in #226 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Qt’s menu imll appears to be buggy, it will disappear, and then show up forever after switching back to the app. This deletes the menu when it’s not in use in order to solve the problem. --- src/qt/transactionview.cpp | 49 ++++++++++++++------------------------ 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 1fc5e3403..0eb3d7e41 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -29,8 +29,11 @@ #include TransactionView::TransactionView(QWidget *parent) : - QWidget(parent), model(0), transactionProxyModel(0), - transactionView(0) + QWidget(parent) + , model(0) + , transactionProxyModel(0) + , transactionView(0) + , contextMenu(0) { // Build filter row setContentsMargins(0,0,0,0); @@ -121,26 +124,6 @@ TransactionView::TransactionView(QWidget *parent) : transactionView = view; - // Actions - QAction *copyAddressAction = new QAction(tr("Copy address"), this); - QAction *copyLabelAction = new QAction(tr("Copy label"), this); - QAction *copyAmountAction = new QAction(tr("Copy amount"), this); - QAction *copyTxIDAction = new QAction(tr("Copy transaction ID"), this); - QAction *editLabelAction = new QAction(tr("Edit label"), this); - QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); - QAction *viewOnDogechain = new QAction(tr("Show transaction on Dogechain"), this); - - contextMenu = new QMenu(); - contextMenu->addAction(copyAddressAction); - contextMenu->addAction(copyLabelAction); - contextMenu->addAction(copyAmountAction); - contextMenu->addAction(copyTxIDAction); - contextMenu->addSeparator(); - contextMenu->addAction(editLabelAction); - contextMenu->addAction(showDetailsAction); - contextMenu->addSeparator(); - contextMenu->addAction(viewOnDogechain); - // Connect actions connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); connect(typeWidget, SIGNAL(activated(int)), this, SLOT(chooseType(int))); @@ -149,14 +132,6 @@ TransactionView::TransactionView(QWidget *parent) : connect(view, SIGNAL(doubleClicked(QModelIndex)), this, SIGNAL(doubleClicked(QModelIndex))); connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); - - connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(copyAddress())); - connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); - connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); - connect(copyTxIDAction, SIGNAL(triggered()), this, SLOT(copyTxID())); - connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); - connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); - connect(viewOnDogechain, SIGNAL(triggered()), this, SLOT(viewOnDogechain())); } void TransactionView::setModel(WalletModel *model) @@ -302,9 +277,21 @@ void TransactionView::exportClicked() void TransactionView::contextualMenu(const QPoint &point) { QModelIndex index = transactionView->indexAt(point); - if(index.isValid()) + if ( index.isValid() ) { + contextMenu = new QMenu(); + contextMenu->addAction(tr("Copy address"), this, SLOT(copyAddress())); + contextMenu->addAction(tr("Copy label"), this, SLOT(copyLabel())); + contextMenu->addAction(tr("Copy amount"), this, SLOT(copyAmount())); + contextMenu->addAction(tr("Copy transaction ID"), this, SLOT(copyTxID())); + contextMenu->addSeparator(); + contextMenu->addAction(tr("Edit label"), this, SLOT(editLabel())); + contextMenu->addAction(tr("Show transaction details"), this, SLOT(showDetails())); + contextMenu->addSeparator(); + contextMenu->addAction(tr("Show transaction on Dogechain"), this, SLOT(viewOnDogechain())); + contextMenu->exec(QCursor::pos()); + delete contextMenu; } }