1
0

Qt: call create_toolbar in create_list_tab

This commit is contained in:
ThomasV
2023-03-11 15:41:13 +01:00
parent 1a0a52f9b6
commit c595df3972
5 changed files with 18 additions and 11 deletions

View File

@@ -108,6 +108,9 @@ class AddressList(MyTreeView):
self.update()
self.sortByColumn(self.Columns.TYPE, Qt.AscendingOrder)
def create_toolbar(self, config):
return self.create_toolbar_with_buttons(config)
def get_toolbar_buttons(self):
return QLabel(_("Filter:")), self.change_button, self.used_button

View File

@@ -353,7 +353,7 @@ class ChannelsList(MyTreeView):
else:
self.swap_button.setEnabled(False)
def get_toolbar(self):
def create_toolbar(self, config):
h = QHBoxLayout()
self.can_send_label = QLabel('')
h.addWidget(self.can_send_label)

View File

@@ -519,6 +519,9 @@ class HistoryList(MyTreeView, AcceptFileDragDrop):
self.end_button.setText(_('To') + ' ' + self.format_date(self.end_date))
self.hide_rows()
def create_toolbar(self, config):
return self.create_toolbar_with_buttons(config)
def create_toolbar_buttons(self):
self.period_combo = QComboBox()
self.start_button = QPushButton('-')

View File

@@ -1040,16 +1040,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
def create_channels_tab(self):
self.channels_list = ChannelsList(self)
t = self.channels_list.get_toolbar()
return self.create_list_tab(self.channels_list, t)
return self.create_list_tab(self.channels_list)
def create_history_tab(self):
self.history_model = HistoryModel(self)
self.history_list = l = HistoryList(self, self.history_model)
self.history_model.set_view(self.history_list)
l.searchable_list = l
toolbar = l.create_toolbar(self.config)
tab = self.create_list_tab(l, toolbar)
tab = self.create_list_tab(self.history_list)
toolbar_shown = bool(self.config.get('show_toolbar_history', False))
l.show_toolbar(toolbar_shown)
return tab
@@ -1332,13 +1330,14 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
self.utxo_list.refresh_all()
self.utxo_list.selectionModel().clearSelection()
def create_list_tab(self, l, toolbar=None):
def create_list_tab(self, l):
w = QWidget()
w.searchable_list = l
vbox = QVBoxLayout()
w.setLayout(vbox)
#vbox.setContentsMargins(0, 0, 0, 0)
#vbox.setSpacing(0)
toolbar = l.create_toolbar(self.config)
if toolbar:
vbox.addLayout(toolbar)
vbox.addWidget(l)
@@ -1346,11 +1345,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
def create_addresses_tab(self):
from .address_list import AddressList
self.address_list = l = AddressList(self)
toolbar = l.create_toolbar(self.config)
tab = self.create_list_tab(l, toolbar)
self.address_list = AddressList(self)
tab = self.create_list_tab(self.address_list)
toolbar_shown = bool(self.config.get('show_toolbar_addresses', False))
l.show_toolbar(toolbar_shown)
self.address_list.show_toolbar(toolbar_shown)
return tab
def create_utxo_tab(self):

View File

@@ -742,7 +742,10 @@ class MyTreeView(QTreeView):
for row in range(self.model().rowCount()):
self.hide_row(row)
def create_toolbar(self, config=None):
def create_toolbar(self, config):
return
def create_toolbar_with_buttons(self, config=None):
hbox = QHBoxLayout()
buttons = self.get_toolbar_buttons()
for b in buttons: