def __init__(self, parent, title, main_text, buttons, show_input=False, checkbox_text=None): DialogContainer.__init__(self, parent) uic.loadUi(get_ui_file_path('buttonsdialog.ui'), self.dialog_widget) self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) self.dialog_widget.dialog_title_label.setText(title) self.dialog_widget.dialog_main_text_label.setText(main_text) self.dialog_widget.dialog_main_text_label.adjustSize() self.checkbox = self.dialog_widget.checkbox if not show_input: self.dialog_widget.dialog_input.setHidden(True) else: connect(self.dialog_widget.dialog_input.returnPressed, lambda: self.button_clicked.emit(0)) if not checkbox_text: self.dialog_widget.checkbox.setHidden(True) else: self.dialog_widget.checkbox.setText(checkbox_text) hspacer_left = QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Fixed) self.dialog_widget.dialog_button_container.layout().addSpacerItem(hspacer_left) self.buttons = [] for index in range(len(buttons)): self.create_button(index, *buttons[index]) hspacer_right = QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Fixed) self.dialog_widget.dialog_button_container.layout().addSpacerItem(hspacer_right) if hasattr(self.window(), 'escape_pressed'): connect(self.window().escape_pressed, self.close_dialog) self.on_main_window_resize()
def __init__(self, parent): QWidget.__init__(self, parent) uic.loadUi(get_ui_file_path('video_info_popup.ui'), self) self.setWindowFlags(Qt.Window | Qt.FramelessWindowHint) self.setAttribute(Qt.WA_TranslucentBackground)
def __init__(self, parent): QTabWidget.__init__(self, parent) uic.loadUi(get_ui_file_path('torrent_details_container.ui'), self) self.torrent_info = None self._logger = logging.getLogger("TriberGUI") self.torrent_detail_name_label = None self.torrent_detail_infohash_label = None self.torrent_detail_category_label = None self.torrent_detail_size_label = None self.torrent_detail_health_label = None self.torrent_detail_trackers_list = None self.check_health_button = None self.copy_magnet_button = None self.is_health_checking = False self.index = QModelIndex() self.healthcheck_timer = QTimer() self.healthcheck_timer.setSingleShot(True) self.healthcheck_timer.timeout.connect(self.on_check_health_clicked) self.currentChanged.connect(self.on_tab_changed) self.rest_request1 = None self.rest_request2 = None
def __init__(self, parent: QWidget, infohash: str) -> None: DialogContainer.__init__(self, parent, left_right_margin=400) self.index: Optional[QModelIndex] = None self.infohash = infohash uic.loadUi(get_ui_file_path('add_tags_dialog.ui'), self.dialog_widget) self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) connect(self.dialog_widget.close_button.clicked, self.close_dialog) connect(self.dialog_widget.save_button.clicked, self.on_save_tags_button_clicked) connect(self.dialog_widget.edit_tags_input.enter_pressed, lambda: self.on_save_tags_button_clicked(None)) connect(self.dialog_widget.edit_tags_input.escape_pressed, self.close_dialog) self.dialog_widget.edit_tags_input.setFocus() self.dialog_widget.error_text_label.hide() self.dialog_widget.suggestions_container.hide() # Fetch suggestions TriblerNetworkRequest(f"tags/{infohash}/suggestions", self.on_received_suggestions) self.update_window()
def __init__(self, parent): DialogContainer.__init__(self, parent) uic.loadUi(get_ui_file_path('createtorrentdialog.ui'), self.dialog_widget) self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) connect(self.dialog_widget.btn_cancel.clicked, self.close_dialog) connect(self.dialog_widget.create_torrent_choose_files_button.clicked, self.on_choose_files_clicked) connect(self.dialog_widget.create_torrent_choose_dir_button.clicked, self.on_choose_dir_clicked) connect(self.dialog_widget.btn_create.clicked, self.on_create_clicked) connect( self.dialog_widget.create_torrent_files_list. customContextMenuRequested, self.on_right_click_file_item) self.dialog_widget.create_torrent_files_list.clear() connect(self.dialog_widget.save_directory_chooser.clicked, self.on_select_save_directory) self.dialog_widget.edit_channel_create_torrent_progress_label.setText( "") self.dialog_widget.file_export_dir.setText(os.path.expanduser("~")) self.dialog_widget.adjustSize() self.on_main_window_resize() self.name = None self.rest_request1 = None self.rest_request2 = None
def __init__(self, parent): DialogContainer.__init__(self, parent) uic.loadUi(get_ui_file_path('trustexplanation.ui'), self.dialog_widget) self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) self.dialog_widget.close_button.clicked.connect(self.close_dialog) self.update_window()
def __init__(self, parent): DialogContainer.__init__(self, parent) uic.loadUi(get_ui_file_path('addtochanneldialog.ui'), self.dialog_widget) self.dialog_widget.btn_cancel.clicked.connect(self.close_dialog) self.dialog_widget.btn_confirm.clicked.connect(self.on_confirm_clicked) self.dialog_widget.btn_new_channel.clicked.connect( self.on_create_new_channel_clicked) self.dialog_widget.btn_new_folder.clicked.connect( self.on_create_new_folder_clicked) self.confirm_clicked_callback = None self.root_requests_list = [] self.channels_tree = {} self.id2wt_mapping = {0: self.dialog_widget.channels_tree_wt} self.dialog_widget.channels_tree_wt.itemExpanded.connect( self.on_item_expanded) self.dialog_widget.channels_tree_wt.setHeaderLabels(['Name']) self.on_main_window_resize()
def __init__(self, parent, is_ask, asset1_type, asset2_type, wallets): DialogContainer.__init__(self, parent) self.is_ask = is_ask self.price = 0.0 self.price_type = asset2_type self.quantity = -1 self.quantity_type = asset1_type self.wallets = wallets # These asset amount values are only set when the order has been verified on the GUI side self.asset1_amount = 0 self.asset2_amount = 0 uic.loadUi(get_ui_file_path('newmarketorderdialog.ui'), self.dialog_widget) self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) self.dialog_widget.error_text_label.hide() if is_ask: self.dialog_widget.new_order_title_label.setText( 'Sell %s for %s' % (asset1_type, asset2_type)) else: self.dialog_widget.new_order_title_label.setText( 'Buy %s for %s' % (asset1_type, asset2_type)) self.dialog_widget.quantity_label.setText("Volume (%s):" % asset1_type) self.dialog_widget.price_label.setText("Price per unit (%s / %s):" % (asset2_type, asset1_type)) self.dialog_widget.create_button.clicked.connect( self.on_create_clicked) self.dialog_widget.cancel_button.clicked.connect( lambda: self.button_clicked.emit(0)) self.update_window()
from tribler_gui.tribler_action_menu import TriblerActionMenu from tribler_gui.tribler_request_manager import TriblerNetworkRequest from tribler_gui.utilities import connect, disconnect, get_image_path, get_ui_file_path from tribler_gui.widgets.tablecontentmodel import ( ChannelContentModel, DiscoveredChannelsModel, PersonalChannelsModel, SearchResultsModel, SimplifiedPersonalChannelsModel, ) from tribler_gui.widgets.triblertablecontrollers import ContentTableViewController CHANNEL_COMMIT_DELAY = 30000 # milliseconds CATEGORY_SELECTOR_ITEMS = ("All", "Channels") + ContentCategories.long_names widget_form, widget_class = uic.loadUiType(get_ui_file_path('torrents_list.ui')) # pylint: disable=too-many-instance-attributes, too-many-public-methods class ChannelContentsWidget(AddBreadcrumbOnShowMixin, widget_form, widget_class): def __init__(self, parent=None): super(widget_class, self).__init__(parent=parent) # FIXME!!! This is a dumb workaround for a bug(?) in PyQT bindings in Python 3.7 # When more than a single instance of a class is created, every next setupUi # triggers connectSlotsByName error. There are some reports that it is specific to # 3.7 and there is a fix in the 10.08.2019 PyQt bindings snapshot. try: self.setupUi(self) except SystemError: pass # ! ACHTUNG !
import time import uuid from dataclasses import dataclass, field from PyQt5 import uic from tribler_core.components.metadata_store.db.serialization import CHANNEL_TORRENT, COLLECTION_NODE, REGULAR_TORRENT from tribler_core.utilities.utilities import Query, to_fts_query from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin from tribler_gui.tribler_request_manager import TriblerNetworkRequest from tribler_gui.utilities import connect, get_ui_file_path, tr from tribler_gui.widgets.tablecontentmodel import SearchResultsModel widget_form, widget_class = uic.loadUiType( get_ui_file_path('search_results.ui')) def format_search_loading_label(search_request): data = { "total_peers": len(search_request.peers), "num_complete_peers": len(search_request.peers_complete), "num_remote_results": len(search_request.remote_results), } return (tr("Remote responses: %(num_complete_peers)i / %(total_peers)i" "\nNew remote results received: %(num_remote_results)i") % data) @dataclass class SearchRequest:
from tribler_gui.tribler_action_menu import TriblerActionMenu from tribler_gui.tribler_request_manager import TriblerNetworkRequest from tribler_gui.utilities import connect, disconnect, get_image_path, get_ui_file_path, tr from tribler_gui.widgets.tablecontentmodel import ( ChannelContentModel, ChannelPreviewModel, DiscoveredChannelsModel, PersonalChannelsModel, SearchResultsModel, SimplifiedPersonalChannelsModel, ) from tribler_gui.widgets.triblertablecontrollers import ContentTableViewController CHANNEL_COMMIT_DELAY = 30000 # milliseconds widget_form, widget_class = uic.loadUiType( get_ui_file_path('torrents_list.ui')) # pylint: disable=too-many-instance-attributes, too-many-public-methods class ChannelContentsWidget(AddBreadcrumbOnShowMixin, widget_form, widget_class): def __init__(self, parent=None): widget_class.__init__(self, parent=parent) # ACHTUNG! This is a dumb workaround for a bug(?) in PyQT bindings in Python 3.7 # When more than a single instance of a class is created, every next setupUi # triggers connectSlotsByName error. There are some reports that it is specific to # 3.7 and there is a fix in the 10.08.2019 PyQt bindings snapshot. try: self.setupUi(self) except SystemError:
def __init__(self, core_args=None, core_env=None, api_port=None, api_key=None): QMainWindow.__init__(self) self._logger = logging.getLogger(self.__class__.__name__) QCoreApplication.setOrganizationDomain("nl") QCoreApplication.setOrganizationName("TUDelft") QCoreApplication.setApplicationName("Tribler") self.setWindowIcon(QIcon(QPixmap(get_image_path('tribler.png')))) self.gui_settings = QSettings('nl.tudelft.tribler') api_port = api_port or int(get_gui_setting(self.gui_settings, "api_port", DEFAULT_API_PORT)) api_key = api_key or get_gui_setting(self.gui_settings, "api_key", hexlify(os.urandom(16)).encode('utf-8')) self.gui_settings.setValue("api_key", api_key) api_port = get_first_free_port(start=api_port, limit=100) request_manager.port, request_manager.key = api_port, api_key self.tribler_started = False self.tribler_settings = None # TODO: move version_id to tribler_common and get core version in the core crash message self.tribler_version = version_id self.debug_window = None self.error_handler = ErrorHandler(self) self.core_manager = CoreManager(api_port, api_key, self.error_handler) self.pending_requests = {} self.pending_uri_requests = [] self.download_uri = None self.dialog = None self.create_dialog = None self.chosen_dir = None self.new_version_dialog = None self.start_download_dialog_active = False self.selected_torrent_files = [] self.has_search_results = False self.last_search_query = None self.last_search_time = None self.start_time = time.time() self.token_refresh_timer = None self.shutdown_timer = None self.add_torrent_url_dialog_active = False sys.excepthook = self.error_handler.gui_error 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) connect(self.core_manager.core_state_update, 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) connect(self.debug_pane_shortcut.activated, self.clicked_menu_button_debug) self.import_torrent_shortcut = QShortcut(QKeySequence("Ctrl+o"), self) connect(self.import_torrent_shortcut.activated, self.on_add_torrent_browse_file) self.add_torrent_url_shortcut = QShortcut(QKeySequence("Ctrl+i"), self) connect(self.add_torrent_url_shortcut.activated, self.on_add_torrent_from_url) connect(self.top_search_bar.clicked, self.clicked_search_bar) # 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) self.menu_buttons = [ self.left_menu_button_downloads, self.left_menu_button_discovered, self.left_menu_button_trust_graph, self.left_menu_button_popular, ] hide_xxx = get_gui_setting(self.gui_settings, "family_filter", True, is_bool=True) self.search_results_page.initialize_content_page(hide_xxx=hide_xxx) self.search_results_page.channel_torrents_filter_input.setHidden(True) self.settings_page.initialize_settings_page() self.downloads_page.initialize_downloads_page() self.loading_page.initialize_loading_page() self.discovering_page.initialize_discovering_page() self.discovered_page.initialize_content_page(hide_xxx=hide_xxx) self.popular_page.initialize_content_page(hide_xxx=hide_xxx) self.trust_page.initialize_trust_page() self.trust_graph_page.initialize_trust_graph() self.stackedWidget.setCurrentIndex(PAGE_LOADING) # Create the system tray icon if QSystemTrayIcon.isSystemTrayAvailable(): self.tray_icon = QSystemTrayIcon() use_monochrome_icon = get_gui_setting(self.gui_settings, "use_monochrome_icon", False, is_bool=True) self.update_tray_icon(use_monochrome_icon) # Create the tray icon menu menu = self.create_add_torrent_menu() show_downloads_action = QAction('Show downloads', self) connect(show_downloads_action.triggered, self.clicked_menu_button_downloads) token_balance_action = QAction('Show token balance', self) connect(token_balance_action.triggered, lambda _: self.on_token_balance_click(None)) quit_action = QAction('Quit Tribler', self) connect(quit_action.triggered, self.close_tribler) menu.addSeparator() menu.addAction(show_downloads_action) menu.addAction(token_balance_action) menu.addSeparator() menu.addAction(quit_action) self.tray_icon.setContextMenu(menu) else: self.tray_icon = None self.left_menu_button_debug.setHidden(True) 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) # Set various icons self.top_menu_button.setIcon(QIcon(get_image_path('menu.png'))) self.search_completion_model = QStringListModel() completer = QCompleter() completer.setModel(self.search_completion_model) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.item_delegate = QStyledItemDelegate() completer.popup().setItemDelegate(self.item_delegate) completer.popup().setStyleSheet( """ QListView { background-color: #404040; } QListView::item { color: #D0D0D0; padding-top: 5px; padding-bottom: 5px; } QListView::item:hover { background-color: #707070; } """ ) self.top_search_bar.setCompleter(completer) # Toggle debug if developer mode is enabled self.window().left_menu_button_debug.setHidden( not get_gui_setting(self.gui_settings, "debug", False, is_bool=True) ) # Start Tribler self.core_manager.start(core_args=core_args, core_env=core_env) connect(self.core_manager.events_manager.torrent_finished, self.on_torrent_finished) connect(self.core_manager.events_manager.new_version_available, self.on_new_version_available) connect(self.core_manager.events_manager.tribler_started, self.on_tribler_started) connect(self.core_manager.events_manager.low_storage_signal, self.on_low_storage) connect(self.core_manager.events_manager.tribler_shutdown_signal, self.on_tribler_shutdown_state_update) connect(self.core_manager.events_manager.config_error_signal, self.on_config_error_signal) # Install signal handler for ctrl+c events def sigint_handler(*_): self.close_tribler() signal.signal(signal.SIGINT, sigint_handler) # Resize the window according to the settings center = QApplication.desktop().availableGeometry(self).center() pos = self.gui_settings.value("pos", QPoint(center.x() - self.width() * 0.5, center.y() - self.height() * 0.5)) size = self.gui_settings.value("size", self.size()) self.move(pos) self.resize(size) self.show() self.add_to_channel_dialog = AddToChannelDialog(self.window()) self.add_torrent_menu = self.create_add_torrent_menu() self.add_torrent_button.setMenu(self.add_torrent_menu) self.channels_menu_list = self.findChild(ChannelsMenuListWidget, "channels_menu_list") connect(self.channels_menu_list.itemClicked, self.open_channel_contents_page) # The channels content page is only used to show subscribed channels, so we always show xxx # contents in it. connect( self.core_manager.events_manager.node_info_updated, lambda data: self.channels_menu_list.reload_if_necessary([data]), ) connect(self.left_menu_button_new_channel.clicked, self.create_new_channel)
from tribler_gui.error_handler import ErrorHandler from tribler_gui.tribler_action_menu import TriblerActionMenu from tribler_gui.tribler_request_manager import TriblerNetworkRequest, TriblerRequestManager, request_manager from tribler_gui.utilities import ( connect, disconnect, get_gui_setting, get_image_path, get_ui_file_path, is_dir_writable, ) from tribler_gui.widgets.channelsmenulistwidget import ChannelsMenuListWidget from tribler_gui.widgets.tablecontentmodel import DiscoveredChannelsModel, PopularTorrentsModel, SearchResultsModel from tribler_gui.widgets.triblertablecontrollers import sanitize_for_fts, to_fts_query fc_loading_list_item, _ = uic.loadUiType(get_ui_file_path('loading_list_item.ui')) class MagnetHandler(QObject): def __init__(self, window): QObject.__init__(self) self.window = window @pyqtSlot(QUrl) def on_open_magnet_link(self, url): self.window.start_download_from_uri(url) class TriblerWindow(QMainWindow): resize_event = pyqtSignal() escape_pressed = pyqtSignal()
def __init__(self, settings, tribler_version): self._logger = logging.getLogger(self.__class__.__name__) QMainWindow.__init__(self) self.cpu_plot = None self.memory_plot = None self.initialized_cpu_plot = False self.initialized_memory_plot = False self.cpu_plot_timer = None self.memory_plot_timer = None self.tribler_version = tribler_version self.profiler_enabled = False self.toggling_profiler = False uic.loadUi(get_ui_file_path('debugwindow.ui'), self) self.setWindowTitle("Tribler debug pane") self.window().dump_memory_core_button.clicked.connect(lambda: self.on_memory_dump_button_clicked(True)) self.window().dump_memory_gui_button.clicked.connect(lambda: self.on_memory_dump_button_clicked(False)) self.window().toggle_profiler_button.clicked.connect(self.on_toggle_profiler_button_clicked) self.window().debug_tab_widget.setCurrentIndex(0) self.window().ipv8_tab_widget.setCurrentIndex(0) self.window().tunnel_tab_widget.setCurrentIndex(0) self.window().dht_tab_widget.setCurrentIndex(0) self.window().system_tab_widget.setCurrentIndex(0) self.window().debug_tab_widget.currentChanged.connect(self.tab_changed) self.window().ipv8_tab_widget.currentChanged.connect(self.ipv8_tab_changed) self.window().tunnel_tab_widget.currentChanged.connect(self.tunnel_tab_changed) self.window().dht_tab_widget.currentChanged.connect(self.dht_tab_changed) self.window().events_tree_widget.itemClicked.connect(self.on_event_clicked) self.window().system_tab_widget.currentChanged.connect(self.system_tab_changed) self.load_general_tab() self.window().open_files_tree_widget.header().setSectionResizeMode(0, QHeaderView.Stretch) # Enable/disable tabs, based on settings self.window().debug_tab_widget.setTabEnabled(2, settings and settings['trustchain']['enabled']) self.window().debug_tab_widget.setTabEnabled(3, settings and settings['ipv8']['enabled']) self.window().system_tab_widget.setTabEnabled(3, settings and settings['resource_monitor']['enabled']) self.window().system_tab_widget.setTabEnabled(4, settings and settings['resource_monitor']['enabled']) # Refresh logs self.window().log_refresh_button.clicked.connect(lambda: self.load_logs_tab()) self.window().log_tab_widget.currentChanged.connect(lambda index: self.load_logs_tab()) # IPv8 statistics enabled? self.ipv8_statistics_enabled = settings['ipv8']['statistics'] # Libtorrent tab self.init_libtorrent_tab() # Position to center frame_geometry = self.frameGeometry() screen = QDesktopWidget().screenNumber(QDesktopWidget().cursor().pos()) center_point = QDesktopWidget().screenGeometry(screen).center() frame_geometry.moveCenter(center_point) self.move(frame_geometry.topLeft()) # Refresh timer self.refresh_timer = None self.rest_request = None self.ipv8_health_widget = None
def __init__(self, parent, exception_text, tribler_version, start_time): QDialog.__init__(self, parent) uic.loadUi(get_ui_file_path('feedback_dialog.ui'), self) self.setWindowTitle("Unexpected error") self.selected_item_index = 0 self.tribler_version = tribler_version # Qt 5.2 does not have the setPlaceholderText property if hasattr(self.comments_text_edit, "setPlaceholderText"): self.comments_text_edit.setPlaceholderText("Comments (optional)") def add_item_to_info_widget(key, value): item = QTreeWidgetItem(self.env_variables_list) item.setText(0, key) item.setText(1, value) self.error_text_edit.setPlainText(exception_text.rstrip()) self.cancel_button.clicked.connect(self.on_cancel_clicked) self.send_report_button.clicked.connect(self.on_send_clicked) # Add machine information to the tree widget add_item_to_info_widget('os.getcwd', '%s' % os.getcwd()) add_item_to_info_widget('sys.executable', '%s' % sys.executable) add_item_to_info_widget('os', os.name) add_item_to_info_widget('platform', sys.platform) add_item_to_info_widget('platform.details', platform.platform()) add_item_to_info_widget('platform.machine', platform.machine()) add_item_to_info_widget('python.version', sys.version) add_item_to_info_widget('indebug', str(__debug__)) add_item_to_info_widget('tribler_uptime', "%s" % (time.time() - start_time)) for argv in sys.argv: add_item_to_info_widget('sys.argv', '%s' % argv) for path in sys.path: add_item_to_info_widget('sys.path', '%s' % path) for key in os.environ.keys(): add_item_to_info_widget('os.environ', '%s: %s' % (key, os.environ[key])) # Add recent requests to feedback dialog request_ind = 1 for request, status_code in sorted(tribler_performed_requests, key=lambda rq: rq[0].time)[-30:]: add_item_to_info_widget( 'request_%d' % request_ind, '%s %s %s (time: %s, code: %s)' % (request.url, request.method, request.raw_data, request.time, status_code), ) request_ind += 1 # Add recent events to feedback dialog events_ind = 1 for event, event_time in received_events[:30][::-1]: add_item_to_info_widget( 'event_%d' % events_ind, '%s (time: %s)' % (json.dumps(event), event_time)) events_ind += 1 # Users can remove specific lines in the report self.env_variables_list.customContextMenuRequested.connect( self.on_right_click_item)
from PyQt5 import QtCore, uic from PyQt5.QtCore import QDir, pyqtSignal, pyqtSlot from PyQt5.QtGui import QIcon, QImage, QPixmap from PyQt5.QtNetwork import QNetworkRequest from PyQt5.QtWidgets import QFileDialog, QPushButton from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin from tribler_gui.dialogs.confirmationdialog import ConfirmationDialog from tribler_gui.i18n import tr from tribler_gui.tribler_request_manager import TriblerNetworkRequest from tribler_gui.utilities import connect, get_image_path, get_ui_file_path widget_form, widget_class = uic.loadUiType( get_ui_file_path('channel_description.ui')) EDIT_BUTTON = "edit_mode_button" PREVIEW_BUTTON = "preview_mode_button" EDIT_BUTTON_NUM = 0 PREVIEW_BUTTON_NUM = 1 DEFAULT_THUMBNAIL_PIXMAP = QPixmap(get_image_path('chan_thumb.png')) CREATE_THUMBNAIL_TEXT = tr( "Click this to add \n channel thumbnail \n (max. 1MB JPG/PNG)") PREVIEW_PAGE = 0 EDIT_PAGE = 1 class FloatingButtonWidget(QPushButton):
def __init__(self, parent): QWidget.__init__(self, parent) uic.loadUi(get_ui_file_path('qtbug.ui'), self)
def __init__(self, parent, download_uri): DialogContainer.__init__(self, parent) torrent_name = download_uri if torrent_name.startswith('file:'): torrent_name = torrent_name[5:] elif torrent_name.startswith('magnet:'): torrent_name = unquote_plus(torrent_name) self.download_uri = download_uri self.has_metainfo = False self.metainfo_fetch_timer = None self.metainfo_retries = 0 uic.loadUi(get_ui_file_path('startdownloaddialog.ui'), self.dialog_widget) self.dialog_widget.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) connect(self.dialog_widget.browse_dir_button.clicked, self.on_browse_dir_clicked) connect(self.dialog_widget.cancel_button.clicked, lambda _: self.button_clicked.emit(0)) connect(self.dialog_widget.download_button.clicked, self.on_download_clicked) connect(self.dialog_widget.select_all_files_button.clicked, self.on_all_files_selected_clicked) connect(self.dialog_widget.deselect_all_files_button.clicked, self.on_all_files_deselected_clicked) connect(self.dialog_widget.loading_files_label.clicked, self.on_reload_torrent_info) connect(self.dialog_widget.anon_download_checkbox.clicked, self.on_reload_torrent_info) self.dialog_widget.destination_input.setStyleSheet(""" QComboBox { background-color: #444; border: none; color: #C0C0C0; padding: 4px; } QComboBox::drop-down { width: 20px; border: 1px solid #999; border-radius: 2px; } QComboBox QAbstractItemView { selection-background-color: #707070; color: #C0C0C0; } QComboBox::down-arrow { width: 12px; height: 12px; image: url('%s'); } """ % get_image_path('down_arrow_input.png')) # self.dialog_widget.add_to_channel_checkbox.setStyleSheet(get_checkbox_style()) checkbox_style = get_checkbox_style() for checkbox in [ self.dialog_widget.add_to_channel_checkbox, self.dialog_widget.safe_seed_checkbox, self.dialog_widget.anon_download_checkbox, ]: checkbox.setStyleSheet(checkbox_style) if self.window().tribler_settings: # Set the most recent download locations in the QComboBox current_settings = get_gui_setting(self.window().gui_settings, "recent_download_locations", "") if len(current_settings) > 0: recent_locations = [ unhexlify(url).decode('utf-8') for url in current_settings.split(",") ] self.dialog_widget.destination_input.addItems(recent_locations) else: self.dialog_widget.destination_input.setCurrentText( self.window().tribler_settings['download_defaults'] ['saveas']) self.dialog_widget.torrent_name_label.setText(torrent_name) connect(self.dialog_widget.anon_download_checkbox.stateChanged, self.on_anon_download_state_changed) self.dialog_widget.anon_download_checkbox.setChecked( self.window().tribler_settings['download_defaults'] ['anonymity_enabled']) self.dialog_widget.safe_seed_checkbox.setChecked( self.window().tribler_settings['download_defaults'] ['safeseeding_enabled']) self.dialog_widget.add_to_channel_checkbox.setChecked( self.window().tribler_settings['download_defaults'] ['add_download_to_channel']) self.dialog_widget.safe_seed_checkbox.setEnabled( self.dialog_widget.anon_download_checkbox.isChecked()) self.perform_files_request() self.dialog_widget.files_list_view.setHidden(True) self.dialog_widget.download_files_container.setHidden(True) self.dialog_widget.adjustSize() self.on_anon_download_state_changed(None) self.on_main_window_resize() self.rest_request = None
disconnect, get_gui_setting, get_image_path, get_ui_file_path, is_dir_writable, ) from tribler_gui.widgets.channelsmenulistwidget import ChannelsMenuListWidget from tribler_gui.widgets.tablecontentmodel import DiscoveredChannelsModel, PopularTorrentsModel, SearchResultsModel from tribler_gui.widgets.triblertablecontrollers import ( PopularContentTableViewController, sanitize_for_fts, to_fts_query, ) fc_loading_list_item, _ = uic.loadUiType( get_ui_file_path('loading_list_item.ui')) class MagnetHandler(QObject): def __init__(self, window): QObject.__init__(self) self.window = window @pyqtSlot(QUrl) def on_open_magnet_link(self, url): self.window.start_download_from_uri(url) class TriblerWindow(QMainWindow): resize_event = pyqtSignal() escape_pressed = pyqtSignal()
def __init__( # pylint: disable=too-many-arguments, too-many-locals self, parent, exception_text, tribler_version, start_time, sentry_event=None, error_reporting_requires_user_consent=True, stop_application_on_close=True, additional_tags=None, ): QDialog.__init__(self, parent) uic.loadUi(get_ui_file_path('feedback_dialog.ui'), self) self.setWindowTitle(tr("Unexpected error")) self.selected_item_index = 0 self.tribler_version = tribler_version self.sentry_event = sentry_event self.scrubber = SentryScrubber() self.stop_application_on_close = stop_application_on_close self.additional_tags = additional_tags # Qt 5.2 does not have the setPlaceholderText property if hasattr(self.comments_text_edit, "setPlaceholderText"): placeholder = tr( "What were you doing before this crash happened? " "This information will help Tribler developers to figure out and fix the issue quickly." ) self.comments_text_edit.setPlaceholderText(placeholder) def add_item_to_info_widget(key, value): item = QTreeWidgetItem(self.env_variables_list) item.setText(0, key) scrubbed_value = self.scrubber.scrub_text(value) item.setText(1, scrubbed_value) stacktrace = self.scrubber.scrub_text(exception_text.rstrip()) self.error_text_edit.setPlainText(stacktrace) connect(self.cancel_button.clicked, self.on_cancel_clicked) connect(self.send_report_button.clicked, self.on_send_clicked) # Add machine information to the tree widget add_item_to_info_widget('os.getcwd', f'{os.getcwd()}') add_item_to_info_widget('sys.executable', f'{sys.executable}') add_item_to_info_widget('os', os.name) add_item_to_info_widget('platform', sys.platform) add_item_to_info_widget('platform.details', platform.platform()) add_item_to_info_widget('platform.machine', platform.machine()) add_item_to_info_widget('python.version', sys.version) add_item_to_info_widget('indebug', str(__debug__)) add_item_to_info_widget('tribler_uptime', f"{time.time() - start_time}") for argv in sys.argv: add_item_to_info_widget('sys.argv', f'{argv}') for path in sys.path: add_item_to_info_widget('sys.path', f'{path}') for key in os.environ.keys(): add_item_to_info_widget('os.environ', f'{key}: {os.environ[key]}') # Add recent requests to feedback dialog request_ind = 1 for request, status_code in sorted(tribler_performed_requests, key=lambda rq: rq[0].time)[-30:]: add_item_to_info_widget( 'request_%d' % request_ind, '%s %s %s (time: %s, code: %s)' % (request.url, request.method, request.raw_data, request.time, status_code), ) request_ind += 1 # Add recent events to feedback dialog events_ind = 1 for event, event_time in received_events[:30][::-1]: add_item_to_info_widget('event_%d' % events_ind, f'{json.dumps(event)} (time: {event_time})') events_ind += 1 # Users can remove specific lines in the report connect(self.env_variables_list.customContextMenuRequested, self.on_right_click_item) self.send_automatically = FeedbackDialog.can_send_automatically(error_reporting_requires_user_consent) if self.send_automatically: self.stop_application_on_close = True self.on_send_clicked(True)