本文整理汇总了Python中TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog.close_dialog方法的典型用法代码示例。如果您正苦于以下问题:Python ConfirmationDialog.close_dialog方法的具体用法?Python ConfirmationDialog.close_dialog怎么用?Python ConfirmationDialog.close_dialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog
的用法示例。
在下文中一共展示了ConfirmationDialog.close_dialog方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SubscribedChannelsPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import close_dialog [as 别名]
class SubscribedChannelsPage(QWidget):
"""
This page shows all the channels that the user has subscribed to.
"""
def __init__(self):
QWidget.__init__(self)
self.dialog = None
self.request_mgr = None
def initialize(self):
self.window().add_subscription_button.clicked.connect(self.on_add_subscription_clicked)
def load_subscribed_channels(self):
self.window().subscribed_channels_list.set_data_items([(LoadingListItem, None)])
self.request_mgr = TriblerRequestManager()
self.request_mgr.perform_request("channels/subscribed", self.received_subscribed_channels)
def received_subscribed_channels(self, results):
if not results:
return
self.window().subscribed_channels_list.set_data_items([])
items = []
if len(results['subscribed']) == 0:
self.window().subscribed_channels_list.set_data_items(
[(LoadingListItem, "You are not subscribed to any channel.")])
return
for result in results['subscribed']:
items.append((ChannelListItem, result))
self.window().subscribed_channels_list.set_data_items(items)
def on_add_subscription_clicked(self):
self.dialog = ConfirmationDialog(self, "Add subscribed channel",
"Please enter the identifier of the channel you want to subscribe to below. "
"It can take up to a minute before the channel is visible in your list of "
"subscribed channels.",
[('ADD', BUTTON_TYPE_NORMAL), ('CANCEL', BUTTON_TYPE_CONFIRM)],
show_input=True)
self.dialog.dialog_widget.dialog_input.setPlaceholderText('Channel identifier')
self.dialog.button_clicked.connect(self.on_subscription_added)
self.dialog.show()
def on_subscription_added(self, action):
if action == 0:
self.request_mgr = TriblerRequestManager()
self.request_mgr.perform_request("channels/subscribed/%s" % self.dialog.dialog_widget.dialog_input.text(),
self.on_channel_subscribed, method='PUT')
self.dialog.close_dialog()
self.dialog = None
def on_channel_subscribed(self, _):
pass
示例2: SettingsPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import close_dialog [as 别名]
class SettingsPage(QWidget):
"""
This class is responsible for displaying and adjusting the settings present in Tribler.
"""
def __init__(self):
QWidget.__init__(self)
self.settings = None
self.settings_request_mgr = None
self.trustchain_request_mgr = None
self.saved_dialog = None
self.empty_tokens_barcode_dialog = None
self.empty_partial_tokens_dialog = None
self.confirm_empty_tokens_dialog = None
def initialize_settings_page(self):
self.window().settings_tab.initialize()
self.window().settings_tab.clicked_tab_button.connect(self.clicked_tab_button)
self.window().settings_save_button.clicked.connect(self.save_settings)
self.window().download_location_chooser_button.clicked.connect(self.on_choose_download_dir_clicked)
self.window().watch_folder_chooser_button.clicked.connect(self.on_choose_watch_dir_clicked)
self.window().channel_autocommit_checkbox.stateChanged.connect(self.on_channel_autocommit_checkbox_changed)
self.window().family_filter_checkbox.stateChanged.connect(self.on_family_filter_checkbox_changed)
self.window().developer_mode_enabled_checkbox.stateChanged.connect(self.on_developer_mode_checkbox_changed)
self.window().use_monochrome_icon_checkbox.stateChanged.connect(self.on_use_monochrome_icon_checkbox_changed)
self.window().download_settings_anon_checkbox.stateChanged.connect(self.on_anon_download_state_changed)
self.window().fully_empty_tokens_button.clicked.connect(self.confirm_fully_empty_tokens)
self.window().partially_empty_tokens_button.clicked.connect(self.partially_empty_tokens)
self.window().log_location_chooser_button.clicked.connect(self.on_choose_log_dir_clicked)
self.update_stacked_widget_height()
def confirm_fully_empty_tokens(self):
self.confirm_empty_tokens_dialog = ConfirmationDialog(self, "Empty tokens into another account",
"Are you sure you want to empty ALL bandwidth tokens "
"into another account? "
"Warning: one-way action that cannot be revered",
[
('EMPTY', BUTTON_TYPE_CONFIRM),
('CANCEL', BUTTON_TYPE_NORMAL)
])
self.confirm_empty_tokens_dialog.button_clicked.connect(self.on_confirm_fully_empty_tokens)
self.confirm_empty_tokens_dialog.show()
def on_confirm_fully_empty_tokens(self, action):
self.confirm_empty_tokens_dialog.close_dialog()
self.confirm_empty_tokens_dialog = None
if action == 0:
self.trustchain_request_mgr = TriblerRequestManager()
self.trustchain_request_mgr.perform_request("trustchain/bootstrap", self.on_emptying_tokens)
def partially_empty_tokens(self):
self.empty_partial_tokens_dialog = ConfirmationDialog(self, "Empty tokens into another account",
"Specify the amount of bandwidth tokens to empty into "
"another account below:",
[
('EMPTY', BUTTON_TYPE_CONFIRM),
('CANCEL', BUTTON_TYPE_NORMAL)
], show_input=True)
self.empty_partial_tokens_dialog.dialog_widget.dialog_input.setPlaceholderText(
'Please enter the amount of tokens in MB')
self.empty_partial_tokens_dialog.dialog_widget.dialog_input.setFocus()
self.empty_partial_tokens_dialog.button_clicked.connect(self.confirm_partially_empty_tokens)
self.empty_partial_tokens_dialog.show()
def confirm_partially_empty_tokens(self, action):
tokens = self.empty_partial_tokens_dialog.dialog_widget.dialog_input.text()
self.empty_partial_tokens_dialog.close_dialog()
self.empty_partial_tokens_dialog = None
if action == 0:
try:
tokens = int(float(tokens))
except ValueError:
ConfirmationDialog.show_error(self.window(), "Wrong input", "The provided amount is not a number")
return
self.confirm_empty_tokens_dialog = ConfirmationDialog(self, "Empty tokens into another account",
"Are you sure you want to empty %d bandwidth tokens "
"into another account? "
"Warning: one-way action that cannot be revered" %
tokens,
[
('EMPTY', BUTTON_TYPE_NORMAL),
('CANCEL', BUTTON_TYPE_CONFIRM)
])
self.confirm_empty_tokens_dialog.button_clicked.connect(
lambda action2: self.on_confirm_partially_empty_tokens(action2, tokens))
self.confirm_empty_tokens_dialog.show()
def on_confirm_partially_empty_tokens(self, action, tokens):
self.confirm_empty_tokens_dialog.close_dialog()
self.confirm_empty_tokens_dialog = None
if action == 0:
self.trustchain_request_mgr = TriblerRequestManager()
self.trustchain_request_mgr.perform_request("trustchain/bootstrap?amount=%d" % (tokens * MEBIBYTE),
self.on_emptying_tokens)
#.........这里部分代码省略.........
示例3: DownloadsPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import close_dialog [as 别名]
#.........这里部分代码省略.........
if selected_item and \
self.window().video_player_page.active_infohash != selected_item[0].download_info["infohash"]:
self.window().video_player_page.play_media_item(selected_item[0].download_info["infohash"], -1)
def on_download_stopped(self, json_result):
if json_result and "modified" in json_result:
for selected_item in self.selected_items:
if selected_item.download_info["infohash"] == json_result["infohash"]:
selected_item.download_info['status'] = "DLSTATUS_STOPPED"
selected_item.update_item()
self.on_download_item_clicked()
def on_remove_download_clicked(self):
self.dialog = ConfirmationDialog(self, "Remove download", "Are you sure you want to remove this download?",
[('remove download', BUTTON_TYPE_NORMAL),
('remove download + data', BUTTON_TYPE_NORMAL),
('cancel', BUTTON_TYPE_CONFIRM)])
self.dialog.button_clicked.connect(self.on_remove_download_dialog)
self.dialog.show()
def on_remove_download_dialog(self, action):
if action != 2:
for selected_item in self.selected_items:
infohash = selected_item.download_info["infohash"]
# Reset video player if necessary before doing the actual request
if self.window().video_player_page.active_infohash == infohash:
self.window().video_player_page.reset_player()
self.request_mgr = TriblerRequestManager()
self.request_mgr.perform_request("downloads/%s" % infohash, self.on_download_removed,
method='DELETE', data="remove_data=%d" % action)
self.dialog.close_dialog()
self.dialog = None
def on_download_removed(self, json_result):
if json_result and "removed" in json_result:
self.load_downloads()
self.window().download_details_widget.hide()
def on_force_recheck_download(self):
for selected_item in self.selected_items:
infohash = selected_item.download_info["infohash"]
self.request_mgr = TriblerRequestManager()
self.request_mgr.perform_request("downloads/%s" % infohash, self.on_forced_recheck,
method='PATCH', data='state=recheck')
def on_forced_recheck(self, result):
if result and "modified" in result:
for selected_item in self.selected_items:
if selected_item.download_info["infohash"] == result["infohash"]:
selected_item.download_info['status'] = "DLSTATUS_HASHCHECKING"
selected_item.update_item()
self.on_download_item_clicked()
def change_anonymity(self, hops):
for selected_item in self.selected_items:
infohash = selected_item.download_info["infohash"]
self.request_mgr = TriblerRequestManager()
self.request_mgr.perform_request("downloads/%s" % infohash, lambda _: None,
method='PATCH', data='anon_hops=%d' % hops)
def on_explore_files(self):
for selected_item in self.selected_items:
path = os.path.normpath(os.path.join(self.window().tribler_settings['download_defaults']['saveas'],
示例4: MarketOrdersPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import close_dialog [as 别名]
class MarketOrdersPage(QWidget):
"""
This page displays orders in the decentralized market in Tribler.
"""
def __init__(self):
QWidget.__init__(self)
self.request_mgr = None
self.initialized = False
self.selected_item = None
self.dialog = None
self.wallets = {}
def initialize_orders_page(self, wallets):
if not self.initialized:
self.window().orders_back_button.setIcon(QIcon(get_image_path('page_back.png')))
self.window().market_orders_list.sortItems(0, Qt.AscendingOrder)
self.window().market_orders_list.customContextMenuRequested.connect(self.on_right_click_order)
self.initialized = True
self.wallets = wallets
self.load_orders()
def load_orders(self):
self.window().market_orders_list.clear()
self.request_mgr = TriblerRequestManager()
self.request_mgr.perform_request("market/orders", self.on_received_orders)
def on_received_orders(self, orders):
if not orders:
return
for order in orders["orders"]:
if self.wallets:
asset1_prec = self.wallets[order["assets"]["first"]["type"]]["precision"]
asset2_prec = self.wallets[order["assets"]["second"]["type"]]["precision"]
item = OrderWidgetItem(self.window().market_orders_list, order, asset1_prec, asset2_prec)
self.window().market_orders_list.addTopLevelItem(item)
def on_right_click_order(self, pos):
item_clicked = self.window().market_orders_list.itemAt(pos)
if not item_clicked:
return
self.selected_item = item_clicked
if self.selected_item.order['status'] == 'open': # We can only cancel an open order
menu = TriblerActionMenu(self)
cancel_action = QAction('Cancel order', self)
cancel_action.triggered.connect(self.on_cancel_order_clicked)
menu.addAction(cancel_action)
menu.exec_(self.window().market_orders_list.mapToGlobal(pos))
def on_cancel_order_clicked(self):
self.dialog = ConfirmationDialog(self, "Cancel order",
"Are you sure you want to cancel the order with id %s?" %
self.selected_item.order['order_number'],
[('NO', BUTTON_TYPE_NORMAL), ('YES', BUTTON_TYPE_CONFIRM)])
self.dialog.button_clicked.connect(self.on_confirm_cancel_order)
self.dialog.show()
def on_confirm_cancel_order(self, action):
if action == 1:
self.request_mgr = TriblerRequestManager()
self.request_mgr.perform_request("market/orders/%s/cancel" % self.selected_item.order['order_number'],
self.on_order_cancelled, method='POST')
self.dialog.close_dialog()
self.dialog = None
def on_order_cancelled(self, response):
if not response:
return
self.load_orders()
示例5: CreateTorrentPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import close_dialog [as 别名]
class CreateTorrentPage(QWidget):
"""
The CreateTorrentPage is the page where users can create torrent files so they can be added to their channel.
"""
def __init__(self):
QWidget.__init__(self)
self.channel_identifier = None
self.request_mgr = None
self.dialog = None
self.selected_item_index = -1
self.initialized = False
def initialize(self):
self.window().create_torrent_name_field.setText('')
self.window().create_torrent_description_field.setText('')
self.window().create_torrent_files_list.clear()
self.window().seed_after_adding_checkbox.setChecked(True)
self.window().edit_channel_create_torrent_progress_label.hide()
if not self.initialized:
self.window().manage_channel_create_torrent_back.setIcon(QIcon(get_image_path('page_back.png')))
self.window().create_torrent_files_list.customContextMenuRequested.connect(self.on_right_click_file_item)
self.window().manage_channel_create_torrent_back.clicked.connect(self.on_create_torrent_manage_back_clicked)
self.window().create_torrent_choose_files_button.clicked.connect(self.on_choose_files_clicked)
self.window().create_torrent_choose_dir_button.clicked.connect(self.on_choose_dir_clicked)
self.window().edit_channel_create_torrent_button.clicked.connect(self.on_create_clicked)
self.initialized = True
def on_create_torrent_manage_back_clicked(self):
self.window().edit_channel_details_stacked_widget.setCurrentIndex(PAGE_EDIT_CHANNEL_TORRENTS)
def on_choose_files_clicked(self):
filenames, _ = QFileDialog.getOpenFileNames(self.window(), "Please select the files", QDir.homePath())
for filename in filenames:
self.window().create_torrent_files_list.addItem(filename)
def on_choose_dir_clicked(self):
chosen_dir = QFileDialog.getExistingDirectory(self.window(), "Please select the directory containing the files",
"", QFileDialog.ShowDirsOnly)
if len(chosen_dir) == 0:
return
files = []
for path, _, dir_files in os.walk(chosen_dir):
for filename in dir_files:
files.append(os.path.join(path, filename))
self.window().create_torrent_files_list.clear()
for filename in files:
self.window().create_torrent_files_list.addItem(filename)
def on_create_clicked(self):
if self.window().create_torrent_files_list.count() == 0:
self.dialog = ConfirmationDialog(self, "Notice", "You should add at least one file to your torrent.",
[('CLOSE', BUTTON_TYPE_NORMAL)])
self.dialog.button_clicked.connect(self.on_dialog_ok_clicked)
self.dialog.show()
return
self.window().edit_channel_create_torrent_button.setEnabled(False)
files_list = []
for ind in xrange(self.window().create_torrent_files_list.count()):
file_str = self.window().create_torrent_files_list.item(ind).text()
files_list.append(file_str)
name = self.window().create_torrent_name_field.text()
description = self.window().create_torrent_description_field.toPlainText()
post_data = {
"name": name,
"description": description,
"files": files_list
}
url = "createtorrent?download=1" if self.window().seed_after_adding_checkbox.isChecked() else "createtorrent"
self.request_mgr = TriblerRequestManager()
self.request_mgr.perform_request(url, self.on_torrent_created, data=post_data, method='POST')
# Show creating torrent text
self.window().edit_channel_create_torrent_progress_label.show()
def on_dialog_ok_clicked(self, _):
self.dialog.close_dialog()
self.dialog = None
def on_torrent_created(self, result):
if not result:
return
self.window().edit_channel_create_torrent_button.setEnabled(True)
if 'torrent' in result:
self.add_torrent_to_channel(result['torrent'])
def add_torrent_to_channel(self, torrent):
self.request_mgr = TriblerRequestManager()
self.request_mgr.perform_request("mychannel/torrents", self.on_torrent_to_channel_added,
data={"torrent": torrent}, method='PUT')
#.........这里部分代码省略.........
示例6: EditChannelPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import close_dialog [as 别名]
#.........这里部分代码省略.........
def add_torrent_to_channel(self, filename):
with open(filename, "rb") as torrent_file:
torrent_content = urllib.quote_plus(base64.b64encode(torrent_file.read()))
editchannel_request_mgr = TriblerRequestManager()
editchannel_request_mgr.perform_request("channels/discovered/%s/torrents" %
self.channel_overview['identifier'],
self.on_torrent_to_channel_added, method='PUT',
data='torrent=%s' % torrent_content)
def on_add_torrent_browse_file(self):
filename = QFileDialog.getOpenFileName(self, "Please select the .torrent file", "", "Torrent files (*.torrent)")
if len(filename[0]) == 0:
return
self.add_torrent_to_channel(filename[0])
def on_add_torrent_from_url(self):
self.dialog = ConfirmationDialog(self, "Add torrent from URL/magnet link",
"Please enter the URL/magnet link in the field below:",
[('ADD', BUTTON_TYPE_NORMAL), ('CANCEL', BUTTON_TYPE_CONFIRM)],
show_input=True)
self.dialog.dialog_widget.dialog_input.setPlaceholderText('URL/magnet link')
self.dialog.button_clicked.connect(self.on_torrent_from_url_dialog_done)
self.dialog.show()
def on_torrent_from_url_dialog_done(self, action):
if action == 0:
url = urllib.quote_plus(self.dialog.dialog_widget.dialog_input.text())
self.editchannel_request_mgr = TriblerRequestManager()
self.editchannel_request_mgr.perform_request("channels/discovered/%s/torrents/%s" %
(self.channel_overview['identifier'], url),
self.on_torrent_to_channel_added, method='PUT')
self.dialog.close_dialog()
self.dialog = None
def on_torrent_to_channel_added(self, result):
if not result:
return
if 'added' in result:
self.load_channel_torrents()
def on_create_torrent_from_files(self):
self.window().edit_channel_details_create_torrent.initialize(self.channel_overview['identifier'])
self.window().edit_channel_details_stacked_widget.setCurrentIndex(PAGE_EDIT_CHANNEL_CREATE_TORRENT)
def on_playlist_torrents_back_clicked(self):
self.window().edit_channel_details_stacked_widget.setCurrentIndex(PAGE_EDIT_CHANNEL_PLAYLISTS)
def on_playlist_item_clicked(self, item):
playlist_info = item.data(Qt.UserRole)
if not playlist_info:
return
self.window().edit_channel_playlist_torrents_list.set_data_items([])
self.window().edit_channel_details_playlist_torrents_header.setText("Torrents in '%s'" % playlist_info['name'])
self.window().edit_channel_playlist_torrents_back.setIcon(QIcon(get_image_path('page_back.png')))
self.viewing_playlist = playlist_info
self.update_playlist_torrent_list()
self.window().edit_channel_details_stacked_widget.setCurrentIndex(PAGE_EDIT_CHANNEL_PLAYLIST_TORRENTS)
def update_playlist_list(self):
self.playlists['playlists'].sort(key=lambda torrent: len(torrent['torrents']), reverse=True)
items = []
示例7: TriblerWindow
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import close_dialog [as 别名]
#.........这里部分代码省略.........
self.move(pos)
self.resize(size)
self.show()
def update_tray_icon(self, use_monochrome_icon):
if not QSystemTrayIcon.isSystemTrayAvailable() or not self.tray_icon:
return
if use_monochrome_icon:
self.tray_icon.setIcon(QIcon(QPixmap(get_image_path('monochrome_tribler.png'))))
else:
self.tray_icon.setIcon(QIcon(QPixmap(get_image_path('tribler.png'))))
self.tray_icon.show()
def delete_tray_icon(self):
if self.tray_icon:
try:
self.tray_icon.deleteLater()
except RuntimeError:
# The tray icon might have already been removed when unloading Qt.
# This is due to the C code actually being asynchronous.
logging.debug("Tray icon already removed, no further deletion necessary.")
self.tray_icon = None
def on_low_storage(self):
"""
Dealing with low storage space available. First stop the downloads and the core manager and ask user to user to
make free space.
:return:
"""
self.downloads_page.stop_loading_downloads()
self.core_manager.stop(False)
close_dialog = ConfirmationDialog(self.window(), "<b>CRITICAL ERROR</b>",
"You are running low on disk space (<100MB). Please make sure to have "
"sufficient free space available and restart Tribler again.",
[("Close Tribler", BUTTON_TYPE_NORMAL)])
close_dialog.button_clicked.connect(lambda _: self.close_tribler())
close_dialog.show()
def on_torrent_finished(self, torrent_info):
self.tray_show_message("Download finished", "Download of %s has finished." % torrent_info["name"])
def show_loading_screen(self):
self.top_menu_button.setHidden(True)
self.left_menu.setHidden(True)
self.token_balance_widget.setHidden(True)
self.settings_button.setHidden(True)
self.add_torrent_button.setHidden(True)
self.top_search_bar.setHidden(True)
self.stackedWidget.setCurrentIndex(PAGE_LOADING)
def tray_set_tooltip(self, message):
"""
Set a tooltip message for the tray icon, if possible.
:param message: the message to display on hover
"""
if self.tray_icon:
try:
self.tray_icon.setToolTip(message)
except RuntimeError as e:
logging.error("Failed to set tray tooltip: %s", str(e))
def tray_show_message(self, title, message):
"""
示例8: EditChannelPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import close_dialog [as 别名]
#.........这里部分代码省略.........
self.load_my_torrents()
self.window().edit_channel_details_stacked_widget.setCurrentIndex(PAGE_EDIT_CHANNEL_TORRENTS)
def load_my_torrents(self):
self.controller.model.reset()
self.controller.perform_query(first=1, last=50) # Load the first 50 torrents
def on_create_channel_intro_button_clicked(self):
self.window().create_channel_form.show()
self.window().create_channel_intro_button_container.hide()
self.window().create_new_channel_intro_label.setText("Please enter your channel details below.")
def on_export_mdblob(self):
export_dir = QFileDialog.getExistingDirectory(self, "Please select the destination directory", "",
QFileDialog.ShowDirsOnly)
if len(export_dir) == 0:
return
# Show confirmation dialog where we specify the name of the file
mdblob_name = self.channel_overview["public_key"]
dialog = ConfirmationDialog(self, "Export mdblob file",
"Please enter the name of the channel metadata file:",
[('SAVE', BUTTON_TYPE_NORMAL), ('CANCEL', BUTTON_TYPE_CONFIRM)],
show_input=True)
def on_export_download_dialog_done(action):
if action == 0:
dest_path = os.path.join(export_dir, dialog.dialog_widget.dialog_input.text())
request_mgr = TriblerRequestManager()
request_mgr.download_file("channels/discovered/%s/mdblob" % mdblob_name,
lambda data: on_export_download_request_done(dest_path, data))
dialog.close_dialog()
def on_export_download_request_done(dest_path, data):
try:
torrent_file = open(dest_path, "wb")
torrent_file.write(data)
torrent_file.close()
except IOError as exc:
ConfirmationDialog.show_error(self.window(),
"Error when exporting file",
"An error occurred when exporting the torrent file: %s" % str(exc))
else:
self.window().tray_show_message("Torrent file exported", "Torrent file exported to %s" % dest_path)
dialog.dialog_widget.dialog_input.setPlaceholderText('Channel file name')
dialog.dialog_widget.dialog_input.setText("%s.mdblob" % mdblob_name)
dialog.dialog_widget.dialog_input.setFocus()
dialog.button_clicked.connect(on_export_download_dialog_done)
dialog.show()
# Torrent removal-related methods
def on_torrents_remove_selected_clicked(self):
selected_items = self.controller.table_view.selectedIndexes()
num_selected = len(selected_items)
if num_selected == 0:
return
selected_infohashes = [self.model.data_items[row][u'infohash'] for row in
set([index.row() for index in selected_items])]
self.dialog = ConfirmationDialog(self, "Remove %s selected torrents" % len(selected_infohashes),
"Are you sure that you want to remove %s selected torrents "
"from your channel?" % len(selected_infohashes),
[('CONFIRM', BUTTON_TYPE_NORMAL), ('CANCEL', BUTTON_TYPE_CONFIRM)])