diff --git a/res/ui/currency_tab.ui b/res/ui/currency_tab.ui index 93e11120b99ba9ce81f6acf8b0b65eb2aee30600..f0381cc05f53774ffb63b1fd3c51f041942e0245 100644 --- a/res/ui/currency_tab.ui +++ b/res/ui/currency_tab.ui @@ -96,6 +96,9 @@ </item> <item> <widget class="QTableView" name="table_history"> + <property name="contextMenuPolicy"> + <enum>Qt::CustomContextMenu</enum> + </property> <attribute name="horizontalHeaderShowSortIndicator" stdset="0"> <bool>true</bool> </attribute> diff --git a/src/cutecoin/core/wallet.py b/src/cutecoin/core/wallet.py index d69a379c9b422e57533723566c0c0ae2115f00e0..785fa332d30db6f1e17efae6ef2e985d90bcbc69 100644 --- a/src/cutecoin/core/wallet.py +++ b/src/cutecoin/core/wallet.py @@ -126,9 +126,6 @@ class Cache(): except NoPeerAvailable: return - self.tx_sent = self.tx_sent[:50] - self.tx_received = self.tx_received[:50] - self.latest_block = current_block diff --git a/src/cutecoin/gui/currency_tab.py b/src/cutecoin/gui/currency_tab.py index 99b304c6d057e88358d585a336880ddfc6578e97..56b7feece34ad73bbad44404800e95010be00e92 100644 --- a/src/cutecoin/gui/currency_tab.py +++ b/src/cutecoin/gui/currency_tab.py @@ -18,6 +18,8 @@ from ..models.txhistory import HistoryTableModel, TxFilterProxyModel from ..models.wallets import WalletsListModel from ..models.wallet import WalletListModel from ..tools.exceptions import NoPeerAvailable +from ..core.wallet import Wallet +from ..core.person import Person class BlockchainWatcher(QObject): @@ -193,14 +195,32 @@ class CurrencyTabWidget(QWidget, Ui_CurrencyTabWidget): # Show the context menu. menu.exec_(self.list_wallets.mapToGlobal(point)) + def history_context_menu(self, point): + index = self.table_history.indexAt(point) + model = self.table_history.model() + if index.row() < model.rowCount(None): + wallet = model.wallets[index.row()] + menu = QMenu(model.data(index, Qt.DisplayRole), self) + + copy_pubkey = QAction("Copy pubkey to clipboard", self) + copy_pubkey.triggered.connect(self.copy_pubkey_to_clipboard) + copy_pubkey.setData(wallet) + + menu.addAction(copy_pubkey) + # Show the context menu. + menu.exec_(self.list_wallets.mapToGlobal(point)) + def rename_wallet(self): index = self.sender().data() self.list_wallets.edit(index) def copy_pubkey_to_clipboard(self): - wallet = self.sender().data() + data = self.sender().data() clipboard = QApplication.clipboard() - clipboard.setText(wallet.pubkey) + if data.__class__ is Wallet: + clipboard.setText(data.pubkey) + elif data.__class__ is Person: + clipboard.setText(data.pubkey) def wallet_changed(self): self.app.save(self.app.current_account) diff --git a/src/cutecoin/gui/mainwindow.py b/src/cutecoin/gui/mainwindow.py index ab7e74bd48a38e3edf3e44d2b962503e71f3d161..7258f4839920b22ff3959aeb9273e9f3d5a4802c 100644 --- a/src/cutecoin/gui/mainwindow.py +++ b/src/cutecoin/gui/mainwindow.py @@ -6,7 +6,8 @@ Created on 1 févr. 2014 from cutecoin.gen_resources.mainwindow_uic import Ui_MainWindow from PyQt5.QtWidgets import QMainWindow, QAction, QFileDialog, QProgressBar, \ QMessageBox, QLabel, QComboBox -from PyQt5.QtCore import QSignalMapper, QModelIndex, QObject, QThread, pyqtSlot, pyqtSignal +from PyQt5.QtCore import QSignalMapper, QModelIndex, QObject, QThread, \ + pyqtSlot, pyqtSignal, QDate, QDateTime, QTimer from PyQt5.QtGui import QIcon from .process_cfg_account import ProcessConfigureAccount from .transfer import TransferMoneyDialog @@ -74,9 +75,14 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.combo_referential.setEnabled(False) self.combo_referential.currentTextChanged.connect(self.referential_changed) - self.status_label = QLabel("", self.statusbar) + self.status_label = QLabel("", self) + + self.label_time = QLabel("", self) + self.statusbar.addPermanentWidget(self.status_label) + self.statusbar.addPermanentWidget(self.label_time) self.statusbar.addPermanentWidget(self.combo_referential) + self.update_time() self.loader_thread = QThread() self.loader = Loader(self.app) @@ -111,6 +117,17 @@ class MainWindow(QMainWindow, Ui_MainWindow): if self.currencies_tabwidget.currentWidget(): self.currencies_tabwidget.currentWidget().referential_changed() + @pyqtSlot() + def update_time(self): + date = QDate.currentDate() + self.label_time.setText("- {0} -".format(date.toString("dd/MM/yyyy"))) + next_day = date.addDays(1) + current_time = QDateTime().toMSecsSinceEpoch() + next_time = QDateTime(next_day).toMSecsSinceEpoch() + timer = QTimer() + timer.timeout.connect(self.update_time) + timer.start(next_time - current_time) + def action_change_account(self, account_name): self.busybar.show() self.status_label.setText("Loading account {0}".format(account_name)) diff --git a/src/cutecoin/models/txhistory.py b/src/cutecoin/models/txhistory.py index a8affe829b16b36cf03b69ca0d68d1ab485baf0c..fb98e82eebb5851a02d135659f9c8be7dfaa20f8 100644 --- a/src/cutecoin/models/txhistory.py +++ b/src/cutecoin/models/txhistory.py @@ -84,7 +84,7 @@ class HistoryTableModel(QAbstractTableModel): try: sender = Person.lookup(pubkey, self.community).name except PersonNotFoundError: - sender = pubkey + sender = "pub:{0}".format(pubkey[:5]) date_ts = self.community.get_block(tx[0]).time date = QDateTime.fromTime_t(date_ts) @@ -109,7 +109,8 @@ class HistoryTableModel(QAbstractTableModel): try: receiver = Person.lookup(pubkey, self.community).name except PersonNotFoundError: - receiver = pubkey + receiver = "pub:{0}".format(pubkey[:5]) + date_ts = self.community.get_block(tx[0]).time date = QDateTime.fromTime_t(date_ts)