本文整理汇总了Python中TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog.show方法的典型用法代码示例。如果您正苦于以下问题:Python ConfirmationDialog.show方法的具体用法?Python ConfirmationDialog.show怎么用?Python ConfirmationDialog.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog
的用法示例。
在下文中一共展示了ConfirmationDialog.show方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SubscribedChannelsPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [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: show_error
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [as 别名]
def show_error(self, error_text):
main_text = "An error occurred during the request:\n\n%s" % error_text
error_dialog = ConfirmationDialog(TriblerRequestManager.window, "Request error",
main_text, [('CLOSE', BUTTON_TYPE_NORMAL)])
def on_close():
error_dialog.close_dialog()
error_dialog.button_clicked.connect(on_close)
error_dialog.show()
示例3: on_low_storage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [as 别名]
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()
示例4: on_export_mdblob
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [as 别名]
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["identifier"]
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()
示例5: SettingsPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [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)
#.........这里部分代码省略.........
示例6: DownloadsPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [as 别名]
class DownloadsPage(QWidget):
"""
This class is responsible for managing all items on the downloads page.
The downloads page shows all downloads and specific details about a download.
"""
received_downloads = pyqtSignal(object)
def __init__(self):
QWidget.__init__(self)
self.export_dir = None
self.filter = DOWNLOADS_FILTER_ALL
self.download_widgets = {} # key: infohash, value: QTreeWidgetItem
self.downloads = None
self.downloads_timer = QTimer()
self.downloads_timeout_timer = QTimer()
self.downloads_last_update = 0
self.selected_items = None
self.dialog = None
self.downloads_request_mgr = TriblerRequestManager()
self.request_mgr = None
self.loading_message_widget = None
def showEvent(self, QShowEvent):
"""
When the downloads tab is clicked, we want to update the downloads list immediately.
"""
super(DownloadsPage, self).showEvent(QShowEvent)
self.stop_loading_downloads()
self.schedule_downloads_timer(True)
def initialize_downloads_page(self):
self.window().downloads_tab.initialize()
self.window().downloads_tab.clicked_tab_button.connect(self.on_downloads_tab_button_clicked)
self.window().start_download_button.clicked.connect(self.on_start_download_clicked)
self.window().stop_download_button.clicked.connect(self.on_stop_download_clicked)
self.window().remove_download_button.clicked.connect(self.on_remove_download_clicked)
self.window().play_download_button.clicked.connect(self.on_play_download_clicked)
self.window().downloads_list.itemSelectionChanged.connect(self.on_download_item_clicked)
self.window().downloads_list.customContextMenuRequested.connect(self.on_right_click_item)
self.window().download_details_widget.initialize_details_widget()
self.window().download_details_widget.hide()
self.window().downloads_filter_input.textChanged.connect(self.on_filter_text_changed)
self.window().downloads_list.header().resizeSection(12, 146)
if not self.window().vlc_available:
self.window().play_download_button.setHidden(True)
def on_filter_text_changed(self, text):
self.window().downloads_list.clearSelection()
self.window().download_details_widget.hide()
self.update_download_visibility()
def start_loading_downloads(self):
self.window().downloads_list.setSelectionMode(QAbstractItemView.NoSelection)
self.loading_message_widget = QTreeWidgetItem()
self.window().downloads_list.addTopLevelItem(self.loading_message_widget)
self.window().downloads_list.setItemWidget(self.loading_message_widget, 2,
LoadingListItem(self.window().downloads_list))
self.schedule_downloads_timer(now=True)
def schedule_downloads_timer(self, now=False):
self.downloads_timer = QTimer()
self.downloads_timer.setSingleShot(True)
self.downloads_timer.timeout.connect(self.load_downloads)
self.downloads_timer.start(0 if now else 1000)
self.downloads_timeout_timer = QTimer()
self.downloads_timeout_timer.setSingleShot(True)
self.downloads_timeout_timer.timeout.connect(self.on_downloads_request_timeout)
self.downloads_timeout_timer.start(16000)
def on_downloads_request_timeout(self):
self.downloads_request_mgr.cancel_request()
self.schedule_downloads_timer()
def stop_loading_downloads(self):
self.downloads_timer.stop()
self.downloads_timeout_timer.stop()
def load_downloads(self):
url = "downloads?get_pieces=1"
if self.window().download_details_widget.currentIndex() == 3:
url += "&get_peers=1"
elif self.window().download_details_widget.currentIndex() == 1:
url += "&get_files=1"
if not self.isHidden() or (time.time() - self.downloads_last_update > 30):
# Update if the downloads page is visible or if we haven't updated for longer than 30 seconds
self.downloads_last_update = time.time()
priority = "LOW" if self.isHidden() else "HIGH"
self.downloads_request_mgr.cancel_request()
self.downloads_request_mgr = TriblerRequestManager()
self.downloads_request_mgr.perform_request(url, self.on_received_downloads, priority=priority)
#.........这里部分代码省略.........
示例7: MarketOrdersPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [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()
示例8: CreateTorrentPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [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')
#.........这里部分代码省略.........
示例9: EditChannelPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [as 别名]
#.........这里部分代码省略.........
self.channel_overview = overview["mychannel"]
if "chant" in self.channel_overview:
self.window().edit_channel_playlists_button.setHidden(True)
self.window().edit_channel_rss_feeds_button.setHidden(True)
self.window().label_7.setText(chant_welcome_text)
self.window().export_channel_button.setHidden(False)
self.window().edit_channel_name_label.setText("My channel")
self.window().edit_channel_overview_name_label.setText(self.channel_overview["name"])
self.window().edit_channel_description_label.setText(self.channel_overview["description"])
self.window().edit_channel_identifier_label.setText(self.channel_overview["identifier"])
self.window().edit_channel_name_edit.setText(self.channel_overview["name"])
self.window().edit_channel_description_edit.setText(self.channel_overview["description"])
self.window().edit_channel_stacked_widget.setCurrentIndex(1)
def load_channel_torrents(self):
self.window().edit_channel_torrents_list.set_data_items([(LoadingListItem, None)])
self.editchannel_request_mgr = TriblerRequestManager()
self.editchannel_request_mgr.perform_request("channels/discovered/%s/torrents?disable_filter=1" %
self.channel_overview["identifier"], self.initialize_with_torrents)
def initialize_with_torrents(self, torrents):
if not torrents:
return
self.window().edit_channel_torrents_list.set_data_items([])
self.window().dirty_channel_widget.setHidden(not("chant_dirty" in torrents and torrents["chant_dirty"]))
items = []
for result in torrents['torrents']:
items.append((ChannelTorrentListItem, result,
{"show_controls": True, "on_remove_clicked": self.on_torrent_remove_clicked}))
self.window().edit_channel_torrents_list.set_data_items(items)
def load_channel_playlists(self):
self.window().edit_channel_playlists_list.set_data_items([(LoadingListItem, None)])
self.editchannel_request_mgr = TriblerRequestManager()
self.editchannel_request_mgr.perform_request("channels/discovered/%s/playlists?disable_filter=1" %
self.channel_overview["identifier"],
self.initialize_with_playlists)
def initialize_with_playlists(self, playlists):
if not playlists:
return
self.playlists_loaded.emit(playlists)
self.playlists = playlists
self.window().edit_channel_playlists_list.set_data_items([])
self.update_playlist_list()
viewing_playlist_index = self.get_index_of_viewing_playlist()
if viewing_playlist_index != -1:
self.viewing_playlist = self.playlists['playlists'][viewing_playlist_index]
self.update_playlist_torrent_list()
def load_channel_rss_feeds(self):
self.editchannel_request_mgr = TriblerRequestManager()
self.editchannel_request_mgr.perform_request("channels/discovered/%s/rssfeeds" %
self.channel_overview["identifier"],
self.initialize_with_rss_feeds)
def initialize_with_rss_feeds(self, rss_feeds):
if not rss_feeds:
return
示例10: MyChannelPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [as 别名]
#.........这里部分代码省略.........
self.my_channel_torrents_export_button = self.findChild(QToolButton, "my_channel_torrents_export_button")
self.my_channel_torrents_export_button.clicked.connect(self.on_torrents_export_clicked)
# Tab bar buttons
self.channel_settings_tab = self.findChild(QWidget, "channel_settings_tab")
self.channel_settings_tab.initialize()
self.channel_settings_tab.clicked_tab_button.connect(self.clicked_tab_button)
# add some dummy items to rss feeds list
for i in range(0, 10):
item = QTreeWidgetItem(self.my_channel_rss_feeds_list)
item.setText(0, "http://fancyurl.com/rss_feed.xml")
self.my_channel_rss_feeds_list.addTopLevelItem(item)
def load_my_channel_overview(self):
self.mychannel_request_mgr = TriblerRequestManager()
self.mychannel_request_mgr.get_my_channel_overview(self.initialize_with_overview)
def initialize_with_overview(self, overview):
self.my_channel_overview = overview
self.my_channel_name_label.setText(overview["name"])
self.my_channel_description_label.setText(overview["description"])
self.my_channel_identifier_label.setText(overview["identifier"])
self.my_channel_name_input.setText(overview["name"])
self.my_channel_description_input.setText(overview["description"])
def load_my_channel_torrents(self):
self.mychannel_request_mgr = TriblerRequestManager()
self.mychannel_request_mgr.get_my_channel_torrents(self.initialize_with_torrents)
def initialize_with_torrents(self, torrents):
self.my_channel_torrents_list.clear()
for torrent in torrents:
item = QTreeWidgetItem(self.my_channel_torrents_list)
item.setText(0, torrent["name"])
item.setText(1, str(torrent["added"]))
self.my_channel_torrents_list.addTopLevelItem(item)
def load_my_channel_rss_feeds(self):
self.mychannel_request_mgr = TriblerRequestManager()
self.mychannel_request_mgr.get_my_channel_rss_feeds(self.initialize_with_rss_feeds)
def initialize_with_rss_feeds(self, rss_feeds):
self.my_channel_rss_feeds_list.clear()
for feed in rss_feeds:
item = QTreeWidgetItem(self.my_channel_rss_feeds_list)
item.setText(0, feed["url"])
self.my_channel_rss_feeds_list.addTopLevelItem(item)
def on_torrents_remove_selected_clicked(self):
num_selected = len(self.my_channel_torrents_list.selectedItems())
if num_selected == 0:
return
self.dialog = ConfirmationDialog(self, "Remove %s selected torrents" % num_selected,
"Are you sure that you want to remove %s selected torrents from your channel?" % num_selected)
self.dialog.button_clicked.connect(self.on_torrents_remove_selected_action)
self.dialog.show()
def on_torrents_remove_all_clicked(self):
self.dialog = ConfirmationDialog(self.window(), "Remove all torrents",
"Are you sure that you want to remove all torrents from your channel? You cannot undo this action.")
self.dialog.button_clicked.connect(self.on_torrents_remove_all_action)
self.dialog.show()
def on_torrents_export_clicked(self):
selected_dir = QFileDialog.getExistingDirectory(self, "Choose a directory to export the torrent files to")
# TODO Martijn: actually export the .torrent files
def on_torrents_remove_selected_action(self, result):
self.dialog.setParent(None)
self.dialog = None
def on_torrents_remove_all_action(self, result):
self.dialog.setParent(None)
self.dialog = None
def clicked_tab_button(self, tab_button_name):
if tab_button_name == "my_channel_overview_button":
self.my_channel_details_stacked_widget.setCurrentIndex(PAGE_MY_CHANNEL_OVERVIEW)
elif tab_button_name == "my_channel_settings_button":
self.my_channel_details_stacked_widget.setCurrentIndex(PAGE_MY_CHANNEL_SETTINGS)
elif tab_button_name == "my_channel_torrents_button":
self.my_channel_details_stacked_widget.setCurrentIndex(PAGE_MY_CHANNEL_TORRENTS)
self.load_my_channel_torrents()
elif tab_button_name == "my_channel_playlists_button":
self.my_channel_details_stacked_widget.setCurrentIndex(PAGE_MY_CHANNEL_PLAYLISTS)
elif tab_button_name == "my_channel_rss_feeds_button":
self.my_channel_details_stacked_widget.setCurrentIndex(PAGE_MY_CHANNEL_RSS_FEEDS)
self.load_my_channel_rss_feeds()
def on_create_channel_intro_button_clicked(self):
self.create_channel_form.show()
self.create_channel_intro_button_container.hide()
self.create_new_channel_intro_label.setText("Please enter your channel details below.")
示例11: TriblerWindow
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [as 别名]
class TriblerWindow(QMainWindow):
resize_event = pyqtSignal()
escape_pressed = pyqtSignal()
tribler_crashed = pyqtSignal(str)
received_search_completions = pyqtSignal(object)
def on_exception(self, *exc_info):
if self.exception_handler_called:
# We only show one feedback dialog, even when there are two consecutive exceptions.
return
self.exception_handler_called = True
exception_text = "".join(traceback.format_exception(*exc_info))
logging.error(exception_text)
self.tribler_crashed.emit(exception_text)
self.delete_tray_icon()
# Stop the download loop
self.downloads_page.stop_loading_downloads()
# Add info about whether we are stopping Tribler or not
os.environ['TRIBLER_SHUTTING_DOWN'] = str(self.core_manager.shutting_down)
if not self.core_manager.shutting_down:
self.core_manager.stop(stop_app_on_shutdown=False)
self.setHidden(True)
if self.debug_window:
self.debug_window.setHidden(True)
dialog = FeedbackDialog(self, exception_text, self.core_manager.events_manager.tribler_version,
self.start_time)
dialog.show()
def __init__(self, core_args=None, core_env=None, api_port=None):
QMainWindow.__init__(self)
QCoreApplication.setOrganizationDomain("nl")
QCoreApplication.setOrganizationName("TUDelft")
QCoreApplication.setApplicationName("Tribler")
QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
self.gui_settings = QSettings()
api_port = api_port or int(get_gui_setting(self.gui_settings, "api_port", DEFAULT_API_PORT))
dispatcher.update_worker_settings(port=api_port)
self.navigation_stack = []
self.tribler_started = False
self.tribler_settings = None
self.debug_window = None
self.core_manager = CoreManager(api_port)
self.pending_requests = {}
self.pending_uri_requests = []
self.download_uri = None
self.dialog = None
self.new_version_dialog = None
self.start_download_dialog_active = False
self.request_mgr = None
self.search_request_mgr = None
self.search_suggestion_mgr = None
self.selected_torrent_files = []
self.vlc_available = True
self.has_search_results = False
self.last_search_query = None
self.last_search_time = None
self.start_time = time.time()
self.exception_handler_called = False
self.token_refresh_timer = None
self.shutdown_timer = None
self.add_torrent_url_dialog_active = False
sys.excepthook = self.on_exception
uic.loadUi(get_ui_file_path('mainwindow.ui'), self)
TriblerRequestManager.window = self
self.tribler_status_bar.hide()
self.token_balance_widget.mouseReleaseEvent = self.on_token_balance_click
def on_state_update(new_state):
self.loading_text_label.setText(new_state)
self.core_manager.core_state_update.connect(on_state_update)
self.magnet_handler = MagnetHandler(self.window)
QDesktopServices.setUrlHandler("magnet", self.magnet_handler, "on_open_magnet_link")
self.debug_pane_shortcut = QShortcut(QKeySequence("Ctrl+d"), self)
self.debug_pane_shortcut.activated.connect(self.clicked_menu_button_debug)
self.import_torrent_shortcut = QShortcut(QKeySequence("Ctrl+o"), self)
self.import_torrent_shortcut.activated.connect(self.on_add_torrent_browse_file)
self.add_torrent_url_shortcut = QShortcut(QKeySequence("Ctrl+i"), self)
self.add_torrent_url_shortcut.activated.connect(self.on_add_torrent_from_url)
# Remove the focus rect on OS X
for widget in self.findChildren(QLineEdit) + self.findChildren(QListWidget) + self.findChildren(QTreeWidget):
widget.setAttribute(Qt.WA_MacShowFocusRect, 0)
#.........这里部分代码省略.........
示例12: EditChannelPage
# 需要导入模块: from TriblerGUI.dialogs.confirmationdialog import ConfirmationDialog [as 别名]
# 或者: from TriblerGUI.dialogs.confirmationdialog.ConfirmationDialog import show [as 别名]
#.........这里部分代码省略.........
channel_name = self.window().edit_channel_name_edit.text()
channel_description = self.window().edit_channel_description_edit.toPlainText()
post_data = {
"name": channel_name,
"description": channel_description
}
self.editchannel_request_mgr = TriblerRequestManager()
self.editchannel_request_mgr.perform_request("mychannel", self.on_channel_edited,
data=post_data, method='POST')
def on_channel_edited(self, result):
if not result:
return
if 'modified' in result:
self.window().edit_channel_name_label.setText(self.window().edit_channel_name_edit.text())
self.window().edit_channel_description_label.setText(
self.window().edit_channel_description_edit.toPlainText())
def clicked_tab_button(self, tab_button_name):
if tab_button_name == "edit_channel_overview_button":
self.window().edit_channel_details_stacked_widget.setCurrentIndex(PAGE_EDIT_CHANNEL_OVERVIEW)
elif tab_button_name == "edit_channel_settings_button":
self.window().edit_channel_details_stacked_widget.setCurrentIndex(PAGE_EDIT_CHANNEL_SETTINGS)
elif tab_button_name == "edit_channel_torrents_button":
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: