Skip to content

Commit

Permalink
Display wallets in the tree main window (from WalletsGui.xml file)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulEU committed May 13, 2014
1 parent 18a275b commit 80d2da0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 38 deletions.
30 changes: 23 additions & 7 deletions KeyhoteeMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,7 @@ KeyhoteeMainWindow::KeyhoteeMainWindow(const TKeyhoteeApplication& mainApp) :
_sent_root = _mailboxes_root->child(Sent);
_spam_root = _mailboxes_root->child(Spam);

const QList<WalletsGui::Data>& _walletsData = _walletsGui->getData();

_wallets_root->setExpanded(true);
for (size_t i = 0; i < _walletsData.size(); i++)
{
_walletItems.push_back(_wallets_root->child(i));
}
setupWallets();

auto app = bts::application::instance();
auto profile = app->get_profile();
Expand Down Expand Up @@ -1415,3 +1409,25 @@ void KeyhoteeMainWindow::onOptions()

options_dialog->show();
}

void KeyhoteeMainWindow::setupWallets()
{
const QList<WalletsGui::Data>& _walletsData = _walletsGui->getData();

_wallets_root->setExpanded(true);
for (int i = 0; i < _walletsData.size(); i++)
{
auto walletItem = new QTreeWidgetItem(_wallets_root, (QTreeWidgetItem::ItemType)WalletItem);

walletItem->setText(0, _walletsData[i].name);
// _walletsData[i].url);

QString path = _walletsData[i].iconPath;
/// delete illegal character " from path
path.replace("\"", "");
walletItem->setIcon(0, QIcon(path));

_walletItems.push_back(walletItem);
_wallets_root->addChild(walletItem);
}
}
7 changes: 7 additions & 0 deletions KeyhoteeMainWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ private slots:
void processResponse(const TAuthorizationMessage& msg, const TStoredMailMessage& header);
void loadStoredRequests(bts::bitchat::message_db_ptr request_db);

/** Load wallets data from WalletsGui.xml file and initialize Wallets tree.
* User can edit and add new wallets to WalletsGui.xml file.
* WalletsGui.xml file exists in the ../Keyhotee.exe directory.
* If WalletsGui.xml file doesn't exist Application copy it from resource ":Wallets/DefaultWallets.xml"
*/
void setupWallets();

/// Class attributes:

QTreeWidgetItem* _identities_root;
Expand Down
27 changes: 0 additions & 27 deletions KeyhoteeMainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -231,33 +231,6 @@
</color>
</brush>
</property>
<item>
<property name="text">
<string>Bitcoin</string>
</property>
<property name="icon">
<iconset resource="Keyhotee.qrc">
<normaloff>:/images/bitcoin.png</normaloff>:/images/bitcoin.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>BitShares</string>
</property>
<property name="icon">
<iconset resource="Keyhotee.qrc">
<normaloff>:/images/bitshares.png</normaloff>:/images/bitshares.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Litecoin</string>
</property>
<property name="icon">
<iconset resource="Keyhotee.qrc">
<normaloff>:/images/litecoin128.png</normaloff>:/images/litecoin128.png</iconset>
</property>
</item>
</item>
<item>
<property name="text">
Expand Down
3 changes: 2 additions & 1 deletion TreeWidgetCustom.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ enum SidebarItemTypes
IdentityItem = 1000 + 2,
MailboxItem = 1000 + 3,
ContactItem = 1000 + 4,
RequestItem = 1000 + 5
RequestItem = 1000 + 5,
WalletItem = 1000 + 6
};

class TreeWidgetCustom : public QTreeWidget
Expand Down
6 changes: 3 additions & 3 deletions Wallets/DefaultWallets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<wallets version="1.0">
<wallet name="Bitcoin">
<url>https://Invictus/Bitcoin</url>
<icon>":images/bitcoin.png"</icon> <!-- path to icon -->
<icon>:images/bitcoin.png</icon> <!-- path to icon -->
</wallet>
<wallet name="BitShares">
<url>https://Invictus/BitShares</url>
<icon>":images/bitshares.png"</icon>
<icon>:images/bitshares.png</icon>
</wallet>
<wallet name="Litecoin">
<url>https://Invictus/Litecoin</url>
<icon>":images/litecoin128.png"</icon>
<icon>:images/litecoin128.png</icon>
</wallet>
</wallets>

0 comments on commit 80d2da0

Please sign in to comment.