Permalink
Browse files

[AD-486] Display wallet id in GUI (#380)

Problem: VTY UI displays wallet ids (HdRootId), that can be usable as
stable identifiers in some knit commands, more convenient than UI
indices. QT UI does not display them.

Solution: Make QT UI display wallet ids as tooltips on wallet names.
  • Loading branch information...
maksbotan committed Jan 10, 2019
1 parent 670b0e0 commit 74215fb52e550440b07e8a47d8dab6d505c5f177
@@ -53,6 +53,10 @@ you understand what you are doing.
When an account is selected you can open its settings by clicking the "Account settings" button in
the wallet pane. A dialog will open where you can change your account's name or delete it.
If you hover your mouse over wallet's name in the right pane, you will see a tooltip with wallet's
internal stable database id. You can use that id in several knit commands, such as `send` or `new-account`.
To copy that id to clipboard just right-click on the wallet name.
## Blockchain operations
Wallet pane has two buttons for working with the blockchain — "SEND" and "REQUEST". Both will
@@ -358,6 +358,7 @@ walletSelectionToInfo uiwd UiWalletSelection{..} =
wallet UiWalletData{..} =
UiWalletInfo
{ uwiLabel = Just _uwdName
, uwiWalletId = formatHdRootId _uwdId
, uwiWalletIdx = uwsWalletIdx
, uwiBalance = balance _uwdBalance
, uwiAccounts = account <$> V.toList _uwdAccounts
@@ -262,6 +262,7 @@ data UiCurrency = ADA | Lovelace
-- Display info for entities on all HD-wallet tree levels
data UiWalletInfo = UiWalletInfo
{ uwiLabel :: !(Maybe Text)
, uwiWalletId :: !Text
, uwiWalletIdx :: !Word
, uwiBalance :: !(Text, UiCurrency)
, uwiAccounts :: ![UiAccountInfo]
@@ -11,15 +11,20 @@ import Data.Text (toUpper)
import Control.Lens (makeLensesWith)
import Graphics.UI.Qtah.Signal (connect_)

import Graphics.UI.Qtah.Core.Types (QtCursorShape(..))
import Graphics.UI.Qtah.Core.Types (QtCursorShape(..), QtMouseButton(..))
import Graphics.UI.Qtah.Widgets.QSizePolicy (QSizePolicyPolicy(..))

import qualified Graphics.UI.Qtah.Core.QEvent as QEvent
import qualified Graphics.UI.Qtah.Core.QItemSelectionModel as QItemSelectionModel
import qualified Graphics.UI.Qtah.Core.QObject as QObject
import qualified Graphics.UI.Qtah.Event as Event
import qualified Graphics.UI.Qtah.Gui.QClipboard as QClipboard
import qualified Graphics.UI.Qtah.Gui.QCursor as QCursor
import qualified Graphics.UI.Qtah.Gui.QIcon as QIcon
import qualified Graphics.UI.Qtah.Gui.QMouseEvent as QMouseEvent
import qualified Graphics.UI.Qtah.Gui.QStandardItemModel as QStandardItemModel
import qualified Graphics.UI.Qtah.Widgets.QAbstractButton as QAbstractButton
import qualified Graphics.UI.Qtah.Widgets.QApplication as QApplication
import qualified Graphics.UI.Qtah.Widgets.QBoxLayout as QBoxLayout
import qualified Graphics.UI.Qtah.Widgets.QHBoxLayout as QHBoxLayout
import qualified Graphics.UI.Qtah.Widgets.QInputDialog as QInputDialog
@@ -166,6 +171,17 @@ initWalletInfo langFace uiWalletFace itemModel selectionModel = do
connect_ sendButton QAbstractButton.clickedSignal $
sendButtonClicked langFace uiWalletFace WalletInfo{..}

clipboard <- QApplication.clipboard

void $ Event.onEvent itemNameLabel $ \(ev :: QMouseEvent.QMouseEvent) -> do
evType <- QEvent.eventType ev
button <- QMouseEvent.button ev
when (evType == QEvent.MouseButtonRelease && button == RightButton) $ do
toolTip <- QWidget.toolTip itemNameLabel
unless (null toolTip) $
QClipboard.setText clipboard toolTip
return False

return (walletInfo, WalletInfo{..})

data WalletInfoEvent
@@ -186,10 +202,14 @@ handleWalletInfoEvent UiLangFace{..} ev = do
WalletInfo{..} <- ask
lift $ case ev of
WalletInfoSelectionChange selectionInfo -> do
let (itemName, (balance, unit), item) =
let (itemName, (balance, unit), item, tooltip) =
case selectionInfo of
UiSelectionWallet UiWalletInfo{..} -> (uwiLabel, uwiBalance, WIWallet uwiWalletIdx uwiAccounts)
UiSelectionAccount uaci@UiAccountInfo{..} -> (uaciLabel, uaciBalance, WIAccount uaciWalletIdx uaci)
UiSelectionWallet UiWalletInfo{..} ->
(uwiLabel, uwiBalance, WIWallet uwiWalletIdx uwiAccounts, uwiWalletId)
UiSelectionAccount uaci@UiAccountInfo{..} ->
(uaciLabel, uaciBalance, WIAccount uaciWalletIdx uaci, "")

QWidget.setToolTip itemNameLabel $ toString tooltip

QLabel.setText itemNameLabel . toString . toUpper . fromMaybe "" $ itemName
QLabel.setText balanceLabel $ toString $ formatBalance balance unit

0 comments on commit 74215fb

Please sign in to comment.