def qInitResources(): QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
def setupUi(self, SimpleNewItemWidget): SimpleNewItemWidget.setObjectName("SimpleNewItemWidget") SimpleNewItemWidget.resize(182, 46) self.horizontalLayout_2 = QtGui.QHBoxLayout(SimpleNewItemWidget) self.horizontalLayout_2.setSpacing(8) self.horizontalLayout_2.setContentsMargins(20, 0, 0, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.verticalLayout_3 = QtGui.QVBoxLayout() self.verticalLayout_3.setObjectName("verticalLayout_3") self.user_thumb = UserThumbnail(SimpleNewItemWidget) self.user_thumb.setMinimumSize(QtCore.QSize(30, 30)) self.user_thumb.setMaximumSize(QtCore.QSize(30, 30)) self.user_thumb.setText("") self.user_thumb.setPixmap( QtGui.QPixmap( ":/tk_framework_qtwidgets.activity_stream/default_user.png")) self.user_thumb.setScaledContents(True) self.user_thumb.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop) self.user_thumb.setObjectName("user_thumb") self.verticalLayout_3.addWidget(self.user_thumb) self.horizontalLayout_2.addLayout(self.verticalLayout_3) self.frame = QtGui.QFrame(SimpleNewItemWidget) self.frame.setFrameShape(QtGui.QFrame.StyledPanel) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName("frame") self.verticalLayout_2 = QtGui.QVBoxLayout(self.frame) self.verticalLayout_2.setObjectName("verticalLayout_2") self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.header_left = QtGui.QLabel(self.frame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.header_left.sizePolicy().hasHeightForWidth()) self.header_left.setSizePolicy(sizePolicy) self.header_left.setText("") self.header_left.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.header_left.setWordWrap(True) self.header_left.setObjectName("header_left") self.horizontalLayout.addWidget(self.header_left) self.date = QtGui.QLabel(self.frame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.date.sizePolicy().hasHeightForWidth()) self.date.setSizePolicy(sizePolicy) self.date.setText("") self.date.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTop | QtCore.Qt.AlignTrailing) self.date.setWordWrap(True) self.date.setObjectName("date") self.horizontalLayout.addWidget(self.date) self.horizontalLayout.setStretch(0, 1) self.verticalLayout.addLayout(self.horizontalLayout) self.verticalLayout_2.addLayout(self.verticalLayout) self.horizontalLayout_2.addWidget(self.frame) self.horizontalLayout_2.setStretch(1, 1) self.retranslateUi(SimpleNewItemWidget) QtCore.QMetaObject.connectSlotsByName(SimpleNewItemWidget)
class Worker(QtCore.QThread): work_completed = QtCore.Signal(str, dict) work_failure = QtCore.Signal(str, str) def __init__(self, app, parent=None): QtCore.QThread.__init__(self, parent) self._execute_tasks = True self._app = app self._queue_mutex = QtCore.QMutex() self._queue = [] self._receivers = {} def stop(self): """ Stops the worker, run this before shutdown """ self._execute_tasks = False def clear(self): """ Empties the queue """ self._queue_mutex.lock() try: self._queue = [] finally: self._queue_mutex.unlock() def queue_work(self, worker_fn, params, asap=False): """ Queues up some work. Returns a unique identifier to identify this item """ uid = uuid.uuid4().hex work = {"id": uid, "fn": worker_fn, "params": params} self._queue_mutex.lock() try: if asap: # first in the queue self._queue.insert(0, work) else: self._queue.append(work) finally: self._queue_mutex.unlock() return uid ############################################################################################ # def run(self): while self._execute_tasks: self._queue_mutex.lock() try: queue_len = len(self._queue) finally: self._queue_mutex.unlock() if queue_len == 0: # polling. TODO: replace with semaphor! self.msleep(200) else: # pop queue self._queue_mutex.lock() try: item_to_process = self._queue.pop(0) finally: self._queue_mutex.unlock() data = None try: data = item_to_process["fn"](item_to_process["params"]) except Exception, e: if self._execute_tasks: self.work_failure.emit(item_to_process["id"], "An error occured: %s" % e) else: if self._execute_tasks: self.work_completed.emit(item_to_process["id"], data)
def setupUi(self, ShotgunListWidget): ShotgunListWidget.setObjectName("ShotgunListWidget") ShotgunListWidget.resize(355, 105) self.horizontalLayout = QtGui.QHBoxLayout(ShotgunListWidget) self.horizontalLayout.setSpacing(1) self.horizontalLayout.setContentsMargins(8, 4, 8, 4) self.horizontalLayout.setObjectName("horizontalLayout") self.box = QtGui.QFrame(ShotgunListWidget) self.box.setFrameShape(QtGui.QFrame.StyledPanel) self.box.setFrameShadow(QtGui.QFrame.Raised) self.box.setObjectName("box") self.horizontalLayout_2 = QtGui.QHBoxLayout(self.box) self.horizontalLayout_2.setSpacing(10) self.horizontalLayout_2.setContentsMargins(4, 8, 4, 8) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.thumbnail = QtGui.QLabel(self.box) self.thumbnail.setMinimumSize(QtCore.QSize(96, 75)) self.thumbnail.setMaximumSize(QtCore.QSize(96, 75)) self.thumbnail.setText("") self.thumbnail.setPixmap( QtGui.QPixmap( ":/tk-framework-qtwidgets/shotgun_widget/rect_512x400.png")) self.thumbnail.setScaledContents(True) self.thumbnail.setObjectName("thumbnail") self.horizontalLayout_2.addWidget(self.thumbnail) self.data_layout = QtGui.QVBoxLayout() self.data_layout.setSpacing(3) self.data_layout.setObjectName("data_layout") self.corner_layout = QtGui.QHBoxLayout() self.corner_layout.setSpacing(5) self.corner_layout.setObjectName("corner_layout") self.left_corner = QtGui.QLabel(self.box) self.left_corner.setObjectName("left_corner") self.corner_layout.addWidget(self.left_corner) self.right_corner = QtGui.QLabel(self.box) self.right_corner.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.right_corner.setObjectName("right_corner") self.corner_layout.addWidget(self.right_corner) self.button = QtGui.QToolButton(self.box) self.button.setPopupMode(QtGui.QToolButton.InstantPopup) self.button.setToolButtonStyle(QtCore.Qt.ToolButtonTextOnly) self.button.setObjectName("button") self.corner_layout.addWidget(self.button) self.data_layout.addLayout(self.corner_layout) self.body = QtGui.QLabel(self.box) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.body.sizePolicy().hasHeightForWidth()) self.body.setSizePolicy(sizePolicy) self.body.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.body.setObjectName("body") self.data_layout.addWidget(self.body) self.horizontalLayout_2.addLayout(self.data_layout) self.horizontalLayout.addWidget(self.box) self.retranslateUi(ShotgunListWidget) QtCore.QMetaObject.connectSlotsByName(ShotgunListWidget)
def setupUi(self, ListItemWidget): ListItemWidget.setObjectName("ListItemWidget") ListItemWidget.resize(355, 105) self.horizontalLayout_3 = QtGui.QHBoxLayout(ListItemWidget) self.horizontalLayout_3.setSpacing(1) self.horizontalLayout_3.setContentsMargins(8, 4, 8, 4) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.box = QtGui.QFrame(ListItemWidget) self.box.setFrameShape(QtGui.QFrame.NoFrame) self.box.setObjectName("box") self.horizontalLayout_2 = QtGui.QHBoxLayout(self.box) self.horizontalLayout_2.setSpacing(10) self.horizontalLayout_2.setContentsMargins(4, 8, 4, 8) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.thumbnail = QtGui.QLabel(self.box) self.thumbnail.setMinimumSize(QtCore.QSize(96, 75)) self.thumbnail.setMaximumSize(QtCore.QSize(96, 75)) self.thumbnail.setText("") self.thumbnail.setPixmap( QtGui.QPixmap(":/tk_multi_infopanel/rect_512x400.png")) self.thumbnail.setScaledContents(True) self.thumbnail.setAlignment(QtCore.Qt.AlignCenter) self.thumbnail.setObjectName("thumbnail") self.horizontalLayout_2.addWidget(self.thumbnail) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setSpacing(3) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setSpacing(5) self.horizontalLayout.setObjectName("horizontalLayout") self.list_item_top_left = QtGui.QLabel(self.box) self.list_item_top_left.setObjectName("list_item_top_left") self.horizontalLayout.addWidget(self.list_item_top_left) self.list_item_top_right = QtGui.QLabel(self.box) self.list_item_top_right.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.list_item_top_right.setObjectName("list_item_top_right") self.horizontalLayout.addWidget(self.list_item_top_right) self.button = QtGui.QPushButton(self.box) self.button.setMaximumSize(QtCore.QSize(16, 16)) self.button.setIconSize(QtCore.QSize(10, 10)) self.button.setObjectName("button") self.horizontalLayout.addWidget(self.button) self.verticalLayout.addLayout(self.horizontalLayout) self.list_item_body = QtGui.QLabel(self.box) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.list_item_body.sizePolicy().hasHeightForWidth()) self.list_item_body.setSizePolicy(sizePolicy) self.list_item_body.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.list_item_body.setWordWrap(True) self.list_item_body.setObjectName("list_item_body") self.verticalLayout.addWidget(self.list_item_body) self.horizontalLayout_2.addLayout(self.verticalLayout) self.horizontalLayout_3.addWidget(self.box) self.retranslateUi(ListItemWidget) QtCore.QMetaObject.connectSlotsByName(ListItemWidget)
def setupUi(self, NoteWidget): NoteWidget.setObjectName("NoteWidget") NoteWidget.resize(357, 166) self.horizontalLayout_2 = QtGui.QHBoxLayout(NoteWidget) self.horizontalLayout_2.setSpacing(0) self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setContentsMargins(-1, -1, 8, -1) self.verticalLayout_2.setObjectName("verticalLayout_2") self.user_thumb = UserThumbnail(NoteWidget) self.user_thumb.setMinimumSize(QtCore.QSize(50, 50)) self.user_thumb.setMaximumSize(QtCore.QSize(50, 50)) self.user_thumb.setText("") self.user_thumb.setPixmap( QtGui.QPixmap( ":/tk_framework_qtwidgets.activity_stream/default_user.png")) self.user_thumb.setScaledContents(True) self.user_thumb.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignTop) self.user_thumb.setObjectName("user_thumb") self.verticalLayout_2.addWidget(self.user_thumb) spacerItem = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_2.addItem(spacerItem) self.horizontalLayout_2.addLayout(self.verticalLayout_2) self.frame = QtGui.QFrame(NoteWidget) self.frame.setFrameShape(QtGui.QFrame.StyledPanel) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName("frame") self.verticalLayout = QtGui.QVBoxLayout(self.frame) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.header_left = QtGui.QLabel(self.frame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.header_left.sizePolicy().hasHeightForWidth()) self.header_left.setSizePolicy(sizePolicy) self.header_left.setText("") self.header_left.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.header_left.setWordWrap(True) self.header_left.setObjectName("header_left") self.horizontalLayout.addWidget(self.header_left) self.date = QtGui.QLabel(self.frame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.date.sizePolicy().hasHeightForWidth()) self.date.setSizePolicy(sizePolicy) self.date.setText("") self.date.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTop | QtCore.Qt.AlignTrailing) self.date.setWordWrap(True) self.date.setObjectName("date") self.horizontalLayout.addWidget(self.date) self.verticalLayout.addLayout(self.horizontalLayout) self.links = QtGui.QLabel(self.frame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.links.sizePolicy().hasHeightForWidth()) self.links.setSizePolicy(sizePolicy) self.links.setText("") self.links.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.links.setWordWrap(True) self.links.setObjectName("links") self.verticalLayout.addWidget(self.links) self.content = QtGui.QLabel(self.frame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.content.sizePolicy().hasHeightForWidth()) self.content.setSizePolicy(sizePolicy) self.content.setText("") self.content.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.content.setWordWrap(True) self.content.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse | QtCore.Qt.TextSelectableByMouse) self.content.setObjectName("content") self.verticalLayout.addWidget(self.content) self.reply_layout = QtGui.QVBoxLayout() self.reply_layout.setSpacing(0) self.reply_layout.setContentsMargins(0, 0, -1, -1) self.reply_layout.setObjectName("reply_layout") self.verticalLayout.addLayout(self.reply_layout) self.horizontalLayout_2.addWidget(self.frame) self.retranslateUi(NoteWidget) QtCore.QMetaObject.connectSlotsByName(NoteWidget)
def sizeHint(self, style_options, model_index): return QtCore.QSize( 175, 2 * ProjectWidget.MARGIN + ProjectWidget.ICON_SIZE.height())
class ProjectWidget(QtGui.QFrame): """ Simple widget that shows a project's thumbnail and name. """ MARGIN = 5 ICON_SIZE = QtCore.QSize(32, 32) def __init__(self, parent=None): QtGui.QFrame.__init__(self, parent) # initialize the UI # simple frame with a thumbnail and a label self.setObjectName("frame") self.setFrameStyle(self.NoFrame) self.setContentsMargins(self.MARGIN, self.MARGIN, self.MARGIN, self.MARGIN) self.label = QtGui.QLabel(self) self.label.setAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft) self.label.setWordWrap(True) self.thumbnail = QtGui.QLabel(self) self.thumbnail.setScaledContents(True) self.layout = QtGui.QHBoxLayout(self) self.layout.addWidget(self.thumbnail) self.layout.addWidget(self.label) self.layout.setStretchFactor(self.label, 1) self.layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.layout) self.setVisible(False) self.set_selected(False) def set_thumbnail(self, pixmap): scaled = pixmap.scaled(self.ICON_SIZE, QtCore.Qt.KeepAspectRatio) self.thumbnail.setPixmap(scaled) def set_text(self, label): metrics = QtGui.QFontMetrics(self.label.font()) elided = metrics.elidedText(label, QtCore.Qt.ElideMiddle, self.label.width()) self.label.setText(elided) self.setToolTip(label) def set_selected(self, selected): """ Update the styling to reflect if the widget is selected or not """ if selected: p = QtGui.QPalette() highlight_col = p.color(QtGui.QPalette.Active, QtGui.QPalette.Highlight) transp_highlight_str = "rgba(%s, %s, %s, 25%%)" % \ (highlight_col.red(), highlight_col.green(), highlight_col.blue()) highlight_str = "rgb(%s, %s, %s)" % \ (highlight_col.red(), highlight_col.green(), highlight_col.blue()) # make a border around the cell self.setStyleSheet("""#frame { border-width: 2px; border-color: %s; border-style: solid; background-color: %s; } """ % (highlight_str, transp_highlight_str)) else: self.setStyleSheet("""#frame { border-width: 2px; border-color: transparent; border-style: solid; }""")
def __init__(self, parent=None): SystrayWindow.__init__(self, parent) # initialize member variables self.current_project = None self.__activation_hotkey = None self.__pipeline_configuration_separator = None self._settings_manager = settings.UserSettings( sgtk.platform.current_bundle()) # setup the window self.ui = desktop_window.Ui_DesktopWindow() self.ui.setupUi(self) self.project_overlay = overlay_widget.ShotgunOverlayWidget( self.ui.project_commands) self.setup_project_widget = SetupProject(self.ui.project_commands) self.setup_project_widget.setup_finished.connect( self._on_setup_finished) self.update_project_config_widget = UpdateProjectConfig( self.ui.project_commands) self.update_project_config_widget.update_finished.connect( self._on_update_finished) self.setup_new_os_widget = SetupNewOS(self.ui.project_commands) # setup systray behavior self.set_content_layout(self.ui.border_layout) self.set_drag_widgets([self.ui.header, self.ui.footer]) self.systray_state_changed.connect(self.handle_systray_state_changed) QtGui.QApplication.instance().setQuitOnLastWindowClosed(False) # Setup header buttons self.ui.apps_button.setProperty("active", True) self.ui.apps_button.style().unpolish(self.ui.apps_button) self.ui.apps_button.style().polish(self.ui.apps_button) engine = sgtk.platform.current_engine() connection = engine.get_current_user().create_sg_connection() # Setup the console self.__console = Console() self.__console_handler = ConsoleLogHandler(self.__console) engine.add_logging_handler(self.__console_handler) # User menu ########################### user = engine.get_current_login() current_user = connection.find_one("HumanUser", [["id", "is", user["id"]]], ["image", "name"]) self._current_user_id = user["id"] thumbnail_url = current_user.get("image") if thumbnail_url is not None: (_, thumbnail_file) = tempfile.mkstemp(suffix=".jpg") try: shotgun.download_url(connection, thumbnail_url, thumbnail_file) pixmap = QtGui.QPixmap(thumbnail_file) self.ui.user_button.setIcon(QtGui.QIcon(pixmap)) except Exception: # if it fails for any reason, that's alright pass finally: try: os.remove(thumbnail_file) except Exception: pass # populate user menu self.user_menu = QtGui.QMenu(self) name_action = self.user_menu.addAction(current_user["name"]) url_action = self.user_menu.addAction( connection.base_url.split("://")[1]) self.user_menu.addSeparator() self.user_menu.addAction(self.ui.actionPin_to_Menu) self.user_menu.addAction(self.ui.actionKeep_on_Top) self.user_menu.addAction(self.ui.actionShow_Console) self.user_menu.addAction(self.ui.actionRefresh_Projects) about_action = self.user_menu.addAction("About...") self.user_menu.addSeparator() self.user_menu.addAction(self.ui.actionSign_Out) self.user_menu.addAction(self.ui.actionQuit) name_action.triggered.connect(self.open_site_in_browser) url_action.triggered.connect(self.open_site_in_browser) about_action.triggered.connect(self.handle_about) QtGui.QApplication.instance().aboutToQuit.connect( self.handle_quit_action) self.ui.actionPin_to_Menu.triggered.connect(self.toggle_pinned) self.ui.actionKeep_on_Top.triggered.connect(self.toggle_keep_on_top) self.ui.actionShow_Console.triggered.connect( self.__console.show_and_raise) self.ui.actionRefresh_Projects.triggered.connect( self.handle_project_refresh_action) self.ui.actionSign_Out.triggered.connect(self.sign_out) self.ui.actionQuit.triggered.connect(self.handle_quit_action) self.ui.user_button.setMenu(self.user_menu) # Initialize the model to track project commands self._project_command_model = ProjectCommandModel(self) self._project_command_proxy = ProjectCommandProxyModel(self) self._project_command_proxy.setSourceModel(self._project_command_model) self._project_command_proxy.sort(0) self.ui.project_commands.setModel(self._project_command_proxy) # limit how many recent commands are shown self._project_command_proxy.set_recents_limit(6) self._project_command_delegate = ProjectCommandDelegate( self.ui.project_commands) self.ui.project_commands.setItemDelegate( self._project_command_delegate) self.ui.project_commands.expanded_changed.connect( self.handle_project_command_expanded_changed) # fix for floating delegate bug # see discussion at https://stackoverflow.com/questions/15331256 self.ui.project_commands.verticalScrollBar().valueChanged.connect( self.ui.project_commands.updateEditorGeometries) self._project_command_model.command_triggered.connect( engine._handle_button_command_triggered) # load and initialize cached projects self._project_model = SgProjectModel(self, self.ui.projects) self._project_proxy = SgProjectModelProxy(self) # hook up sorting/filtering GUI self._project_proxy.setSourceModel(self._project_model) self._project_proxy.sort(0) self.ui.projects.setModel(self._project_proxy) # tell our project view to use a custom delegate to produce widgets self._project_delegate = \ SgProjectDelegate(self.ui.projects, QtCore.QSize(130, 150)) self.ui.projects.setItemDelegate(self._project_delegate) # handle project selection change self._project_selection_model = self.ui.projects.selectionModel() self._project_selection_model.selectionChanged.connect( self._on_project_selection) # handle project data updated self._project_model.data_refreshed.connect( self._handle_project_data_changed) self.ui.actionProject_Filesystem_Folder.triggered.connect( self.on_project_filesystem_folder_triggered) # setup project search self._search_x_icon = QtGui.QIcon(":/tk-desktop/icon_inbox_clear.png") self._search_magnifier_icon = QtGui.QIcon( ":/tk-desktop/search_transparent.png") self.ui.search_button.clicked.connect(self.search_button_clicked) self.ui.search_text.textChanged.connect(self.search_text_changed) self.search_button_clicked() self.project_carat_up = QtGui.QIcon(":tk-desktop/up_carat.png") self.project_carat_down = QtGui.QIcon(":tk-desktop/down_carat.png") self.down_arrow = QtGui.QIcon(":tk-desktop/down_arrow.png") self.right_arrow = QtGui.QIcon(":tk-desktop/right_arrow.png") self.ui.project_arrow.clicked.connect( self._on_back_to_projects_clicked) self.clear_app_uis() self.ui.shotgun_button.clicked.connect(self.open_site_in_browser) self.ui.shotgun_button.setToolTip("Open Shotgun in browser.\n%s" % connection.base_url) self._project_model.thumbnail_updated.connect( self.handle_project_thumbnail_updated) self._load_settings()
def setupUi(self, ReplyWidget): ReplyWidget.setObjectName("ReplyWidget") ReplyWidget.resize(287, 142) self.horizontalLayout_2 = QtGui.QHBoxLayout(ReplyWidget) self.horizontalLayout_2.setSpacing(0) self.horizontalLayout_2.setContentsMargins(0, 10, 0, 2) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setSpacing(0) self.verticalLayout_2.setContentsMargins(-1, -1, 8, -1) self.verticalLayout_2.setObjectName("verticalLayout_2") self.user_thumb = UserThumbnail(ReplyWidget) self.user_thumb.setMinimumSize(QtCore.QSize(30, 30)) self.user_thumb.setMaximumSize(QtCore.QSize(30, 30)) self.user_thumb.setText("") self.user_thumb.setPixmap(QtGui.QPixmap(":/tk_framework_qtwidgets.activity_stream/default_user.png")) self.user_thumb.setScaledContents(True) self.user_thumb.setAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignTop) self.user_thumb.setObjectName("user_thumb") self.verticalLayout_2.addWidget(self.user_thumb) spacerItem = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Ignored) self.verticalLayout_2.addItem(spacerItem) self.verticalLayout_2.setStretch(1, 1) self.horizontalLayout_2.addLayout(self.verticalLayout_2) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setSpacing(3) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.header_left = QtGui.QLabel(ReplyWidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.header_left.sizePolicy().hasHeightForWidth()) self.header_left.setSizePolicy(sizePolicy) self.header_left.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) self.header_left.setWordWrap(True) self.header_left.setObjectName("header_left") self.horizontalLayout.addWidget(self.header_left) self.date = QtGui.QLabel(ReplyWidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.date.sizePolicy().hasHeightForWidth()) self.date.setSizePolicy(sizePolicy) self.date.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTop|QtCore.Qt.AlignTrailing) self.date.setWordWrap(True) self.date.setObjectName("date") self.horizontalLayout.addWidget(self.date) self.verticalLayout.addLayout(self.horizontalLayout) self.reply = QtGui.QLabel(ReplyWidget) self.reply.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.reply.setWordWrap(True) self.reply.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextSelectableByMouse) self.reply.setObjectName("reply") self.verticalLayout.addWidget(self.reply) self.verticalLayout.setStretch(1, 1) self.horizontalLayout_2.addLayout(self.verticalLayout) self.horizontalLayout_2.setStretch(1, 1) self.retranslateUi(ReplyWidget) QtCore.QMetaObject.connectSlotsByName(ReplyWidget)
def _set_window_mask(self): """ set the window mask when pinned to the systray """ if self.state == self.STATE_WINDOWED: self.__content_layout.setContentsMargins(0, 0, 0, 0) self.clearMask() return # temp bitmap to store the mask bmp = QtGui.QBitmap(self.size()) # create and configure the painter self.painter = QtGui.QPainter(bmp) self.painter.setRenderHint(QtGui.QPainter.HighQualityAntialiasing, True) # figure out what side to draw the anchor on side = self._guess_toolbar_side() # mask out from the top margin of the border_layout rect = self.rect() # make sure there is room to draw the anchor anchor_height = self.__bottom_anchor.height() if self.__content_layout is not None: if side == self.DOCK_TOP: mask = rect.adjusted(0, anchor_height, 0, 0) self.__content_layout.setContentsMargins( 0, anchor_height, 0, 0) elif side == self.DOCK_LEFT: mask = rect.adjusted(anchor_height, 0, 0, 0) self.__content_layout.setContentsMargins( anchor_height, 0, 0, 0) elif side == self.DOCK_RIGHT: mask = rect.adjusted(0, 0, -anchor_height, 0) self.__content_layout.setContentsMargins( 0, 0, -anchor_height, 0) elif side == self.DOCK_BOTTOM: mask = rect.adjusted(0, 0, 0, -anchor_height) self.__content_layout.setContentsMargins( 0, 0, 0, anchor_height) else: raise ValueError("Unknown value for side: %s" % side) self.painter.fillRect(rect, QtCore.Qt.white) self.painter.setBrush(QtCore.Qt.black) self.painter.drawRoundedRect(mask, self.__corner_radius, self.__corner_radius) if self.state == self.STATE_PINNED: # add back in the anchor triangle points = [] mask_center = mask.center() if side == self.DOCK_TOP: anchor_pixmap = self.__top_anchor anchor_center = anchor_pixmap.rect().center() points.append(QtCore.QPoint(mask_center.x(), rect.top())) points.append( QtCore.QPoint(mask_center.x() - anchor_height, mask.top())) points.append( QtCore.QPoint(mask_center.x() + anchor_height, mask.top())) elif side == self.DOCK_LEFT: anchor_pixmap = self.__left_anchor anchor_center = anchor_pixmap.rect().center() points.append(QtCore.QPoint(rect.left(), mask_center.y())) points.append( QtCore.QPoint(mask.left(), mask_center.y() - anchor_center.y())) points.append( QtCore.QPoint(mask.left(), mask_center.y() + anchor_center.y())) elif side == self.DOCK_RIGHT: anchor_pixmap = self.__right_anchor anchor_center = anchor_pixmap.rect().center() points.append( QtCore.QPoint(mask.right(), mask_center.y() + anchor_center.y())) points.append( QtCore.QPoint(mask.right(), mask_center.y() - anchor_center.y())) points.append(QtCore.QPoint(rect.right(), mask_center.y())) elif side == self.DOCK_BOTTOM: anchor_pixmap = self.__bottom_anchor anchor_center = anchor_pixmap.rect().center() points.append( QtCore.QPoint(mask_center.x() - anchor_height, mask.bottom())) points.append( QtCore.QPoint(mask_center.x() + anchor_height, mask.bottom())) points.append(QtCore.QPoint(mask_center.x(), rect.bottom())) else: raise ValueError("Unknown value for side: %s" % side) self.painter.drawPolygon(points) # need to end the painter to make sure that its resources get # garbage collected before the bitmap to avoid a crash self.painter.end() # finally set the window mask to the bitmap self.setMask(bmp) self.__anchor_side = side
class SystrayWindow(QtGui.QMainWindow): """ Generic system tray window. A Qt main window that pins to a system tray icon and can be dragged """ # constants to track what state the window is in STATE_PINNED = 0 STATE_WINDOWED = 1 DOCK_TOP = 0 DOCK_LEFT = 1 DOCK_RIGHT = 2 DOCK_BOTTOM = 3 # signal that is emitted when the system tray state changes systray_state_changed = QtCore.Signal(int) class ApplicationEventFilter(QtCore.QObject): """ Internal class to handle hiding window on App deactivate """ def __init__(self, window, parent=None): QtCore.QObject.__init__(self, parent) self._window = window def eventFilter(self, obj, event): if event.type() == QtCore.QEvent.ApplicationDeactivate: if self._window.state == SystrayWindow.STATE_PINNED: self._window.hide() if osutils is not None: osutils.make_app_background() return QtCore.QObject.eventFilter(self, obj, event) def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.__logger = logging.getLogger("tk-desktop.systray") if sys.platform == "darwin": self.setAttribute(QtCore.Qt.WA_MacNoShadow) self.filter = self.ApplicationEventFilter(self) QtGui.QApplication.instance().installEventFilter(self.filter) self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint) self.__state = None # pinned or windowed self.__anchor_side = None # which side the anchor is currently pinned on self.__content_layout = None # layout whose margin will be set to contain the anchor self.__mouse_down_pos = None # track position when dragging self.__mouse_down_global = None # track global position when dragging # setup the anchor self.__bottom_anchor = QtGui.QPixmap(":/tk-desktop/anchor_arrow.png") self.__top_anchor = self.__bottom_anchor.transformed( QtGui.QTransform(1, 0, 0, -1, 0, 0)) self.__right_anchor = self.__bottom_anchor.transformed( QtGui.QTransform(0, 1, 1, 0, 0, 0)) self.__left_anchor = self.__bottom_anchor.transformed( QtGui.QTransform(0, 1, -1, 0, 0, 0)) # radius for rounded corners self.__corner_radius = 4 # widgets that will trigger the drag to move behavior self.__drag_widgets = [] # create the system tray icon self.systray = ShotgunSystemTrayIcon(self) self.systray.show() # hook up handler for when the systray is clicked self.systray.clicked.connect(self.systray_clicked) # Customize behavior ########################### def set_drag_widgets(self, widgets): """ Set the list of widgets that can be dragged to move the window """ self.__drag_widgets = widgets[:] def set_corner_radius(self, value): """ set the radius to use for rounding the window corners """ self.__corner_radius = value def set_content_layout(self, value): """ set the layout to use to provide a margin for the anchor """ self.__content_layout = value # Change pin state ########################### @property def state(self): """ return the current state of the window """ return self.__state @state.setter def state(self, value): """ set the current state of the window """ # if state isn't changing do not do anything if self.__state == value: return # update tracker variable self.__state = value if self.__state == self.STATE_PINNED: self._set_window_mask() self.__move_to_systray() self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint) if osutils is not None: osutils.make_app_background() elif self.__state == self.STATE_WINDOWED: self._set_window_mask() self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.FramelessWindowHint) self.show() if osutils is None: self.raise_() else: osutils.make_app_foreground() else: raise ValueError("Unknown value for state: %s" % value) self.systray_state_changed.emit(self.__state) def toggle_pinned(self): if self.state == self.STATE_PINNED: self.state = self.STATE_WINDOWED elif self.state == self.STATE_WINDOWED: self._pin_to_menu() def _pin_to_menu(self, animated=True): # figure out start and end positions for the window self.systray.show() QtGui.QApplication.instance().processEvents() systray_geo = self.systray.geometry() self.__logger.debug("systray_geo: %s" % systray_geo) if animated: final = QtCore.QRect(systray_geo.center().x(), systray_geo.bottom(), 5, 5) start = self.geometry() # setup the animation to shrink the window to the systray # parent the anim to self to keep it from being garbage collected anim = QtCore.QPropertyAnimation(self, "geometry", self) anim.setDuration(300) anim.setStartValue(start) anim.setEndValue(final) anim.setEasingCurve(QtCore.QEasingCurve.InQuad) # when the anim is finished, call the post handler def post_close_animation(): self.hide() self.setGeometry(start) self.state = self.STATE_PINNED anim.finished.connect(post_close_animation) # run the animation anim.start() else: # not animated self.hide() self.state = self.STATE_PINNED # Drag to move behavior ########################### def mousePressEvent(self, event): """ Handle mouse press to track the start of a drag from the pinned window header """ if any([elem.underMouse() for elem in self.__drag_widgets]): # only trigger on left click if event.buttons() == QtCore.Qt.LeftButton: # clicked on a drag element, track position for possible drag self.__mouse_down_pos = event.pos() self.__mouse_down_global = QtGui.QCursor.pos() # propagate event event.ignore() def mouseReleaseEvent(self, event): """ Handle mouse release to switch to window mode if there has been a long enough drag """ # only do something if we are dragging if self.__mouse_down_pos is None: event.ignore() return # if we have moved more than threshold then trigger a switch to windowed mode if self.state == self.STATE_PINNED: delta = QtGui.QCursor.pos() - self.__mouse_down_global if delta.manhattanLength() > QtGui.QApplication.startDragDistance( ): self.state = self.STATE_WINDOWED # clear cached positions self.__mouse_down_pos = None self.__mouse_down_global = None # propagate event event.ignore() def mouseMoveEvent(self, event): """ Handle mouse moves to move the window with the mouse if we are dragging """ if self.__mouse_down_pos is not None: # move window to track mouse self.move(self.mapToParent(event.pos() - self.__mouse_down_pos)) # propagate event event.ignore() # Pinned behavior ########################### def __move_to_systray(self): """ update the window position to be centered under the system tray icon """ geo = self.systray.geometry() self.__logger.debug("__move_to_systray: systray_geo: %s" % geo) side = self._guess_toolbar_side() if side != self.__class__: # anchor needs to be updated self._set_window_mask() if side == self.DOCK_TOP: x = geo.x() + (geo.width() - self.rect().width()) / 2.0 pos = QtCore.QPoint(x, geo.y() + geo.height()) elif side == self.DOCK_LEFT: y = geo.y() + (geo.height() - self.rect().height()) / 2.0 pos = QtCore.QPoint(geo.x() + geo.width(), y) elif side == self.DOCK_RIGHT: y = geo.y() + (geo.height() - self.rect().height()) / 2.0 pos = QtCore.QPoint(geo.x() - self.rect().width(), y) elif side == self.DOCK_BOTTOM: x = geo.x() + (geo.width() - self.rect().width()) / 2.0 pos = QtCore.QPoint(x, geo.y() - self.rect().height() - geo.height()) else: raise ValueError("Unknown value for side: %s" % side) self.move(pos) def systray_clicked(self): """ handler for single click on the system tray """ self.toggle_activate() def toggle_activate(self): # toggle visibility when clicked active = self.isActiveWindow() or (self.windowFlags() & QtCore.Qt.WindowStaysOnTopHint) hidden = self.isHidden() if hidden: # hidden, show and bring to the top if self.state == self.STATE_PINNED: self.__move_to_systray() self.show() self.raise_() self.activateWindow() if osutils is not None: osutils.make_app_foreground() elif active: # shown and topmost, hide self.hide() if osutils is not None: osutils.make_app_background() else: # shown and not topmost, just bring to the top self.raise_() self.activateWindow() if osutils is not None: osutils.activate_application() # Update the window mask ############################ def _guess_toolbar_side(self): """ guess which side of the screen the toolbar is on """ pos = self.systray.geometry().center() desktop = QtGui.QApplication.instance().desktop() screen_geometry = desktop.screenGeometry(pos) # Get dist from each edge of the screen top_dist = pos.y() - screen_geometry.top() bottom_dist = screen_geometry.bottom() - pos.y() left_dist = pos.x() - screen_geometry.left() right_dist = screen_geometry.right() - pos.x() # Get minimum distance from horizontal and vertical screen edges. # This determines the orientation of the menu. v_dist = min(map(abs, (top_dist, bottom_dist))) h_dist = min(map(abs, (left_dist, right_dist))) # Return the nearest edge if h_dist < v_dist: if right_dist < left_dist: return self.DOCK_RIGHT else: return self.DOCK_LEFT else: if top_dist < bottom_dist: return self.DOCK_TOP else: return self.DOCK_BOTTOM def _set_window_mask(self): """ set the window mask when pinned to the systray """ if self.state == self.STATE_WINDOWED: self.__content_layout.setContentsMargins(0, 0, 0, 0) self.clearMask() return # temp bitmap to store the mask bmp = QtGui.QBitmap(self.size()) # create and configure the painter self.painter = QtGui.QPainter(bmp) self.painter.setRenderHint(QtGui.QPainter.HighQualityAntialiasing, True) # figure out what side to draw the anchor on side = self._guess_toolbar_side() # mask out from the top margin of the border_layout rect = self.rect() # make sure there is room to draw the anchor anchor_height = self.__bottom_anchor.height() if self.__content_layout is not None: if side == self.DOCK_TOP: mask = rect.adjusted(0, anchor_height, 0, 0) self.__content_layout.setContentsMargins( 0, anchor_height, 0, 0) elif side == self.DOCK_LEFT: mask = rect.adjusted(anchor_height, 0, 0, 0) self.__content_layout.setContentsMargins( anchor_height, 0, 0, 0) elif side == self.DOCK_RIGHT: mask = rect.adjusted(0, 0, -anchor_height, 0) self.__content_layout.setContentsMargins( 0, 0, -anchor_height, 0) elif side == self.DOCK_BOTTOM: mask = rect.adjusted(0, 0, 0, -anchor_height) self.__content_layout.setContentsMargins( 0, 0, 0, anchor_height) else: raise ValueError("Unknown value for side: %s" % side) self.painter.fillRect(rect, QtCore.Qt.white) self.painter.setBrush(QtCore.Qt.black) self.painter.drawRoundedRect(mask, self.__corner_radius, self.__corner_radius) if self.state == self.STATE_PINNED: # add back in the anchor triangle points = [] mask_center = mask.center() if side == self.DOCK_TOP: anchor_pixmap = self.__top_anchor anchor_center = anchor_pixmap.rect().center() points.append(QtCore.QPoint(mask_center.x(), rect.top())) points.append( QtCore.QPoint(mask_center.x() - anchor_height, mask.top())) points.append( QtCore.QPoint(mask_center.x() + anchor_height, mask.top())) elif side == self.DOCK_LEFT: anchor_pixmap = self.__left_anchor anchor_center = anchor_pixmap.rect().center() points.append(QtCore.QPoint(rect.left(), mask_center.y())) points.append( QtCore.QPoint(mask.left(), mask_center.y() - anchor_center.y())) points.append( QtCore.QPoint(mask.left(), mask_center.y() + anchor_center.y())) elif side == self.DOCK_RIGHT: anchor_pixmap = self.__right_anchor anchor_center = anchor_pixmap.rect().center() points.append( QtCore.QPoint(mask.right(), mask_center.y() + anchor_center.y())) points.append( QtCore.QPoint(mask.right(), mask_center.y() - anchor_center.y())) points.append(QtCore.QPoint(rect.right(), mask_center.y())) elif side == self.DOCK_BOTTOM: anchor_pixmap = self.__bottom_anchor anchor_center = anchor_pixmap.rect().center() points.append( QtCore.QPoint(mask_center.x() - anchor_height, mask.bottom())) points.append( QtCore.QPoint(mask_center.x() + anchor_height, mask.bottom())) points.append(QtCore.QPoint(mask_center.x(), rect.bottom())) else: raise ValueError("Unknown value for side: %s" % side) self.painter.drawPolygon(points) # need to end the painter to make sure that its resources get # garbage collected before the bitmap to avoid a crash self.painter.end() # finally set the window mask to the bitmap self.setMask(bmp) self.__anchor_side = side
def setupUi(self, Browser): Browser.setObjectName("Browser") Browser.resize(489, 293) self.verticalLayout = QtGui.QVBoxLayout(Browser) self.verticalLayout.setSpacing(0) self.verticalLayout.setContentsMargins(2, 2, 2, 2) self.verticalLayout.setObjectName("verticalLayout") self.browser_header = QtGui.QGroupBox(Browser) self.browser_header.setMinimumSize(QtCore.QSize(0, 44)) self.browser_header.setMaximumSize(QtCore.QSize(16777215, 44)) self.browser_header.setStyleSheet( "#browser_header {\n" "border: none;\n" "background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(97, 97, 97, 255), stop:1 rgba(49, 49, 49, 255))\n" "}") self.browser_header.setTitle("") self.browser_header.setObjectName("browser_header") self.horizontalLayout_2 = QtGui.QHBoxLayout(self.browser_header) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.label = QtGui.QLabel(self.browser_header) self.label.setObjectName("label") self.horizontalLayout_2.addWidget(self.label) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.search = QtGui.QLineEdit(self.browser_header) self.search.setMinimumSize(QtCore.QSize(150, 0)) self.search.setMaximumSize(QtCore.QSize(150, 16777215)) self.search.setStyleSheet("border-width: 1px; \n" "background-image: url(:/res/search.png);\n" "background-repeat: no-repeat;\n" "background-position: center left;\n" "border-style: inset; \n" "border-color: #535353; \n" "border-radius: 9px; \n" "padding-left: 15px") self.search.setObjectName("search") self.horizontalLayout_2.addWidget(self.search) self.verticalLayout.addWidget(self.browser_header) self.scroll_area = QtGui.QScrollArea(Browser) self.scroll_area.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.scroll_area.setWidgetResizable(True) self.scroll_area.setObjectName("scroll_area") self.scrollAreaWidgetContents = QtGui.QWidget() self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 483, 155)) self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") self.verticalLayout_4 = QtGui.QVBoxLayout( self.scrollAreaWidgetContents) self.verticalLayout_4.setSpacing(0) self.verticalLayout_4.setContentsMargins(4, 4, 4, 4) self.verticalLayout_4.setObjectName("verticalLayout_4") self.scroll_area_layout = QtGui.QVBoxLayout() self.scroll_area_layout.setSpacing(0) self.scroll_area_layout.setObjectName("scroll_area_layout") self.verticalLayout_4.addLayout(self.scroll_area_layout) spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_4.addItem(spacerItem1) self.scroll_area.setWidget(self.scrollAreaWidgetContents) self.verticalLayout.addWidget(self.scroll_area) self.message_overlay = QtGui.QGroupBox(Browser) self.message_overlay.setTitle("") self.message_overlay.setObjectName("message_overlay") self.horizontalLayout_3 = QtGui.QHBoxLayout(self.message_overlay) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.status_message = QtGui.QLabel(self.message_overlay) self.status_message.setLayoutDirection(QtCore.Qt.LeftToRight) self.status_message.setAlignment(QtCore.Qt.AlignCenter) self.status_message.setWordWrap(True) self.status_message.setObjectName("status_message") self.horizontalLayout_3.addWidget(self.status_message) self.verticalLayout.addWidget(self.message_overlay) self.load_overlay = QtGui.QGroupBox(Browser) self.load_overlay.setTitle("") self.load_overlay.setObjectName("load_overlay") self.horizontalLayout = QtGui.QHBoxLayout(self.load_overlay) self.horizontalLayout.setObjectName("horizontalLayout") self.progress_bar = QtGui.QLabel(self.load_overlay) self.progress_bar.setLayoutDirection(QtCore.Qt.LeftToRight) self.progress_bar.setText("") self.progress_bar.setPixmap(QtGui.QPixmap(":/res/progress_bar_1.png")) self.progress_bar.setAlignment(QtCore.Qt.AlignCenter) self.progress_bar.setObjectName("progress_bar") self.horizontalLayout.addWidget(self.progress_bar) self.verticalLayout.addWidget(self.load_overlay) self.retranslateUi(Browser) QtCore.QMetaObject.connectSlotsByName(Browser)
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(784, 483) Dialog.setStyleSheet( "#Dialog {\n" "background-image: url(:/tk_framework_shotgunutils.help_screen/bg.png); \n" "}\n" "\n" "") self.horizontalLayout_2 = QtGui.QHBoxLayout(Dialog) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.verticalLayout_3 = QtGui.QVBoxLayout() self.verticalLayout_3.setObjectName("verticalLayout_3") self.label = QtGui.QLabel(Dialog) self.label.setMinimumSize(QtCore.QSize(34, 0)) self.label.setMaximumSize(QtCore.QSize(34, 16777215)) self.label.setText("") self.label.setObjectName("label") self.verticalLayout_3.addWidget(self.label) self.left_arrow = QtGui.QToolButton(Dialog) self.left_arrow.setMinimumSize(QtCore.QSize(34, 34)) self.left_arrow.setFocusPolicy(QtCore.Qt.ClickFocus) self.left_arrow.setStyleSheet( "QToolButton{\n" "background-image: url(:/tk_framework_shotgunutils.help_screen/left_arrow.png);\n" "border: none;\n" "background-color: none;\n" "}\n" "\n" "\n" "QToolButton:hover{\n" "background-image: url(:/tk_framework_shotgunutils.help_screen/left_arrow_hover.png);\n" "}\n" "\n" "QToolButton:Pressed {\n" "background-image: url(:/tk_framework_shotgunutils.help_screen/left_arrow_pressed.png);\n" "}\n" "") self.left_arrow.setText("") self.left_arrow.setAutoRaise(True) self.left_arrow.setObjectName("left_arrow") self.verticalLayout_3.addWidget(self.left_arrow) self.label_2 = QtGui.QLabel(Dialog) self.label_2.setMinimumSize(QtCore.QSize(34, 0)) self.label_2.setMaximumSize(QtCore.QSize(34, 16777215)) self.label_2.setText("") self.label_2.setObjectName("label_2") self.verticalLayout_3.addWidget(self.label_2) self.horizontalLayout_2.addLayout(self.verticalLayout_3) self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") self.groupBox = QtGui.QGroupBox(Dialog) self.groupBox.setStyleSheet("#groupBox {\n" "background-color: rgba(0,0,0,50);\n" "\n" "}") self.groupBox.setTitle("") self.groupBox.setObjectName("groupBox") self.verticalLayout = QtGui.QVBoxLayout(self.groupBox) self.verticalLayout.setContentsMargins(2, 2, 2, 2) self.verticalLayout.setObjectName("verticalLayout") self.stackedWidget = QtGui.QStackedWidget(self.groupBox) self.stackedWidget.setObjectName("stackedWidget") self.verticalLayout.addWidget(self.stackedWidget) self.verticalLayout_2.addWidget(self.groupBox) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") spacerItem = QtGui.QSpacerItem(248, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.view_documentation = QtGui.QToolButton(Dialog) self.view_documentation.setObjectName("view_documentation") self.horizontalLayout.addWidget(self.view_documentation) self.close = QtGui.QToolButton(Dialog) self.close.setObjectName("close") self.horizontalLayout.addWidget(self.close) self.verticalLayout_2.addLayout(self.horizontalLayout) self.horizontalLayout_2.addLayout(self.verticalLayout_2) self.verticalLayout_4 = QtGui.QVBoxLayout() self.verticalLayout_4.setObjectName("verticalLayout_4") self.label_3 = QtGui.QLabel(Dialog) self.label_3.setMinimumSize(QtCore.QSize(34, 0)) self.label_3.setMaximumSize(QtCore.QSize(34, 16777215)) self.label_3.setText("") self.label_3.setObjectName("label_3") self.verticalLayout_4.addWidget(self.label_3) self.right_arrow = QtGui.QToolButton(Dialog) self.right_arrow.setMinimumSize(QtCore.QSize(34, 34)) self.right_arrow.setFocusPolicy(QtCore.Qt.ClickFocus) self.right_arrow.setStyleSheet( "QToolButton{\n" "background-image: url(:/tk_framework_shotgunutils.help_screen/right_arrow.png);\n" "border: none;\n" "background-color: none;\n" "}\n" "\n" "\n" "QToolButton:hover{\n" "background-image: url(:/tk_framework_shotgunutils.help_screen/right_arrow_hover.png);\n" "}\n" "\n" "QToolButton:Pressed {\n" "background-image: url(:/tk_framework_shotgunutils.help_screen/right_arrow_pressed.png);\n" "}\n" "") self.right_arrow.setText("") self.right_arrow.setAutoRaise(True) self.right_arrow.setObjectName("right_arrow") self.verticalLayout_4.addWidget(self.right_arrow) self.label_4 = QtGui.QLabel(Dialog) self.label_4.setMinimumSize(QtCore.QSize(34, 0)) self.label_4.setMaximumSize(QtCore.QSize(34, 16777215)) self.label_4.setText("") self.label_4.setObjectName("label_4") self.verticalLayout_4.addWidget(self.label_4) self.horizontalLayout_2.addLayout(self.verticalLayout_4) self.retranslateUi(Dialog) self.stackedWidget.setCurrentIndex(-1) QtCore.QMetaObject.connectSlotsByName(Dialog)
def paintEvent(self, event): """ Render the UI. """ if self._mode == self.MODE_OFF: return painter = QtGui.QPainter() painter.begin(self) try: # set up semi transparent backdrop painter.setRenderHint(QtGui.QPainter.Antialiasing) overlay_color = QtGui.QColor("#1B1B1B") painter.setBrush(QtGui.QBrush(overlay_color)) painter.setPen(QtGui.QPen(overlay_color)) painter.drawRect(0, 0, painter.device().width(), painter.device().height()) # now draw different things depending on mode if self._mode == self.MODE_SPIN: # show the spinner painter.translate((painter.device().width() / 2) - 40, (painter.device().height() / 2) - 40) pen = QtGui.QPen(QtGui.QColor("#424141")) pen.setWidth(3) painter.setPen(pen) painter.drawPixmap(QtCore.QPoint(8, 24), self._sg_icon) r = QtCore.QRectF(0.0, 0.0, 80.0, 80.0) start_angle = (0 + self._spin_angle) * 4 * 16 span_angle = 340 * 16 painter.drawArc(r, start_angle, span_angle) elif self._mode == self.MODE_INFO_TEXT: # show text in the middle pen = QtGui.QPen(QtGui.QColor("#888888")) painter.setPen(pen) text_rect = QtCore.QRect(0, 0, painter.device().width(), painter.device().height()) text_flags = QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter | QtCore.Qt.TextWordWrap painter.drawText(text_rect, text_flags, self._message) elif self._mode == self.MODE_ERROR: # show error text in the center pen = QtGui.QPen(QtGui.QColor("#C8534A")) painter.setPen(pen) text_rect = QtCore.QRect(0, 0, painter.device().width(), painter.device().height()) text_flags = QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter | QtCore.Qt.TextWordWrap painter.drawText(text_rect, text_flags, self._message) elif self._mode == self.MODE_INFO_PIXMAP: # draw image painter.translate((painter.device().width() / 2) - (self._message_pixmap.width() / 2), (painter.device().height() / 2) - (self._message_pixmap.height() / 2)) painter.drawPixmap(QtCore.QPoint(0, 0), self._message_pixmap) finally: painter.end()
class PublishResultForm(QtGui.QWidget): """ Implementation of the main publish UI """ close = QtCore.Signal() def __init__(self, parent=None): """ Construction """ QtGui.QWidget.__init__(self, parent) self._status = True self._errors = [] # set up the UI from .ui.publish_result_form import Ui_PublishResultForm self._ui = Ui_PublishResultForm() self._ui.setupUi(self) self._ui.close_btn.clicked.connect(self._on_close) self._update_ui() # @property def __get_status(self): return self._status # @status.setter def __set_status(self, value): self._status = value self._update_ui() status = property(__get_status, __set_status) # @property def __get_errors(self): return self._errors # @errors.setter def __set_errors(self, value): self._errors = value self._update_ui() errors = property(__get_errors, __set_errors) def _on_close(self): self.close.emit() def _update_ui(self): self._ui.status_icon.setPixmap( QtGui.QPixmap([":/res/failure.png", ":/res/success.png"][self._status])) self._ui.status_title.setText(["Failure!", "Success"][self._status]) details = "" if self._status: details = ("Your Publish has successfully completed. Your " "work has been shared, your scene has been " "versioned up and your mates have been notified!") else: details = "\n\n".join(self._errors) self._ui.status_details.setText(details)
def setupUi(self, TaskWidget): TaskWidget.setObjectName("TaskWidget") TaskWidget.resize(383, 107) self.horizontalLayout = QtGui.QHBoxLayout(TaskWidget) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setObjectName("horizontalLayout") self.background = QtGui.QFrame(TaskWidget) self.background.setAcceptDrops(True) self.background.setStyleSheet("#background {\n" " border-bottom-style: solid;\n" " border-bottom-width: 1px;\n" " border-bottom-color: rgb(64,64,64);\n" "}\n" "\n" "#background[selected=false] {\n" " background-color: rgb(0, 0, 0,0);\n" "}\n" "\n" "#background[selected=true] {\n" " background-color: rgb(0, 178, 236);\n" "}\n" "\n" "/*Font colour for all QLabels in form*/\n" "#background[selected=false] QLabel {\n" "}\n" "\n" "#background[selected=true] QLabel {\n" " color: rgb(255,255,255);\n" "}") self.background.setFrameShape(QtGui.QFrame.NoFrame) self.background.setFrameShadow(QtGui.QFrame.Plain) self.background.setLineWidth(0) self.background.setProperty("selected", True) self.background.setObjectName("background") self.horizontalLayout_2 = QtGui.QHBoxLayout(self.background) self.horizontalLayout_2.setSpacing(6) self.horizontalLayout_2.setContentsMargins(10, 10, 10, 10) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.thumbnail = QtGui.QLabel(self.background) self.thumbnail.setMinimumSize(QtCore.QSize(100, 60)) self.thumbnail.setMaximumSize(QtCore.QSize(100, 60)) self.thumbnail.setStyleSheet("#thumbnail {\n" "background-color: rgb(32,32, 32);\n" "}") self.thumbnail.setText("") self.thumbnail.setObjectName("thumbnail") self.horizontalLayout_2.addWidget(self.thumbnail) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setSpacing(2) self.verticalLayout.setObjectName("verticalLayout") spacerItem = QtGui.QSpacerItem(3, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.horizontalLayout_1 = QtGui.QHBoxLayout() self.horizontalLayout_1.setSpacing(6) self.horizontalLayout_1.setObjectName("horizontalLayout_1") self.project_icon = QtGui.QLabel(self.background) self.project_icon.setText("") self.project_icon.setObjectName("project_icon") self.horizontalLayout_1.addWidget(self.project_icon) self.project_label = QtGui.QLabel(self.background) self.project_label.setObjectName("project_label") self.horizontalLayout_1.addWidget(self.project_label) self.horizontalLayout_1.setStretch(1, 1) self.verticalLayout.addLayout(self.horizontalLayout_1) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setSpacing(6) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.entity_icon = QtGui.QLabel(self.background) self.entity_icon.setText("") self.entity_icon.setObjectName("entity_icon") self.horizontalLayout_3.addWidget(self.entity_icon) self.entity_label = QtGui.QLabel(self.background) self.entity_label.setObjectName("entity_label") self.horizontalLayout_3.addWidget(self.entity_label) self.horizontalLayout_3.setStretch(1, 1) self.verticalLayout.addLayout(self.horizontalLayout_3) self.horizontalLayout_4 = QtGui.QHBoxLayout() self.horizontalLayout_4.setSpacing(6) self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.task_icon = QtGui.QLabel(self.background) self.task_icon.setText("") self.task_icon.setObjectName("task_icon") self.horizontalLayout_4.addWidget(self.task_icon) self.task_label = QtGui.QLabel(self.background) self.task_label.setObjectName("task_label") self.horizontalLayout_4.addWidget(self.task_label) self.horizontalLayout_4.setStretch(1, 1) self.verticalLayout.addLayout(self.horizontalLayout_4) self.horizontalLayout_5 = QtGui.QHBoxLayout() self.horizontalLayout_5.setSpacing(6) self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.timelog_icon = QtGui.QLabel(self.background) self.timelog_icon.setText("") self.timelog_icon.setObjectName("timelog_icon") self.horizontalLayout_5.addWidget(self.timelog_icon) self.timelog_label = QtGui.QLabel(self.background) self.timelog_label.setObjectName("timelog_label") self.horizontalLayout_5.addWidget(self.timelog_label) self.horizontalLayout_5.setStretch(1, 1) self.verticalLayout.addLayout(self.horizontalLayout_5) self.other_label = QtGui.QLabel(self.background) self.other_label.setObjectName("other_label") self.verticalLayout.addWidget(self.other_label) spacerItem1 = QtGui.QSpacerItem(3, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem1) self.verticalLayout.setStretch(0, 1) self.verticalLayout.setStretch(6, 1) self.horizontalLayout_2.addLayout(self.verticalLayout) self.horizontalLayout_2.setStretch(1, 1) self.horizontalLayout.addWidget(self.background) self.retranslateUi(TaskWidget) QtCore.QMetaObject.connectSlotsByName(TaskWidget)
def setupUi(self, SaveAsForm): SaveAsForm.setObjectName("SaveAsForm") SaveAsForm.resize(510, 294) SaveAsForm.setMinimumSize(QtCore.QSize(510, 0)) SaveAsForm.setMaximumSize(QtCore.QSize(16777215, 16777215)) SaveAsForm.setFocusPolicy(QtCore.Qt.ClickFocus) self.verticalLayout = QtGui.QVBoxLayout(SaveAsForm) self.verticalLayout.setSpacing(4) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setSpacing(16) self.verticalLayout_2.setContentsMargins(12, 12, 12, 4) self.verticalLayout_2.setObjectName("verticalLayout_2") self.header_frame = QtGui.QFrame(SaveAsForm) self.header_frame.setStyleSheet("#header_frame {\n" "border-style: solid;\n" "border-radius: 3;\n" "border-width: 1;\n" "border-color: rgb(32,32,32);\n" "}") self.header_frame.setFrameShape(QtGui.QFrame.StyledPanel) self.header_frame.setFrameShadow(QtGui.QFrame.Raised) self.header_frame.setObjectName("header_frame") self.horizontalLayout_2 = QtGui.QHBoxLayout(self.header_frame) self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.label_2 = QtGui.QLabel(self.header_frame) self.label_2.setMinimumSize(QtCore.QSize(80, 80)) self.label_2.setMaximumSize(QtCore.QSize(80, 80)) self.label_2.setText("") self.label_2.setPixmap(QtGui.QPixmap(":/res/save_as_icon.png")) self.label_2.setScaledContents(False) self.label_2.setAlignment(QtCore.Qt.AlignCenter) self.label_2.setObjectName("label_2") self.horizontalLayout_2.addWidget(self.label_2) self.header_label = QtGui.QLabel(self.header_frame) self.header_label.setWordWrap(True) self.header_label.setObjectName("header_label") self.horizontalLayout_2.addWidget(self.header_label) self.verticalLayout_2.addWidget(self.header_frame) self.gridLayout = QtGui.QGridLayout() self.gridLayout.setHorizontalSpacing(16) self.gridLayout.setVerticalSpacing(10) self.gridLayout.setObjectName("gridLayout") self.name_layout = QtGui.QHBoxLayout() self.name_layout.setContentsMargins(4, -1, -1, -1) self.name_layout.setObjectName("name_layout") self.name_edit = QtGui.QLineEdit(SaveAsForm) self.name_edit.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.name_edit.setFrame(True) self.name_edit.setObjectName("name_edit") self.name_layout.addWidget(self.name_edit) self.reset_version_cb = QtGui.QCheckBox(SaveAsForm) self.reset_version_cb.setObjectName("reset_version_cb") self.name_layout.addWidget(self.reset_version_cb) self.gridLayout.addLayout(self.name_layout, 0, 1, 1, 1) self.name_label = QtGui.QLabel(SaveAsForm) self.name_label.setMinimumSize(QtCore.QSize(0, 0)) self.name_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) self.name_label.setIndent(4) self.name_label.setObjectName("name_label") self.gridLayout.addWidget(self.name_label, 0, 0, 1, 1) self.filename_preview_label = QtGui.QLabel(SaveAsForm) self.filename_preview_label.setIndent(4) self.filename_preview_label.setObjectName("filename_preview_label") self.gridLayout.addWidget(self.filename_preview_label, 1, 1, 1, 1) self.path_preview_edit = QtGui.QTextEdit(SaveAsForm) self.path_preview_edit.setEnabled(True) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.path_preview_edit.sizePolicy().hasHeightForWidth()) self.path_preview_edit.setSizePolicy(sizePolicy) self.path_preview_edit.setMinimumSize(QtCore.QSize(0, 0)) self.path_preview_edit.setMaximumSize(QtCore.QSize(16777215, 60)) self.path_preview_edit.setFocusPolicy(QtCore.Qt.NoFocus) self.path_preview_edit.setStyleSheet("QTextEdit {\n" "background-color: rgb(0,0,0,0);\n" "border-style: none;\n" "}") self.path_preview_edit.setFrameShape(QtGui.QFrame.NoFrame) self.path_preview_edit.setFrameShadow(QtGui.QFrame.Plain) self.path_preview_edit.setLineWidth(0) self.path_preview_edit.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.path_preview_edit.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.path_preview_edit.setReadOnly(True) self.path_preview_edit.setAcceptRichText(True) self.path_preview_edit.setObjectName("path_preview_edit") self.gridLayout.addWidget(self.path_preview_edit, 2, 1, 1, 1) self.preview_label = QtGui.QLabel(SaveAsForm) self.preview_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) self.preview_label.setIndent(4) self.preview_label.setObjectName("preview_label") self.gridLayout.addWidget(self.preview_label, 1, 0, 1, 1) self.label_6 = QtGui.QLabel(SaveAsForm) self.label_6.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.label_6.setMargin(4) self.label_6.setIndent(0) self.label_6.setObjectName("label_6") self.gridLayout.addWidget(self.label_6, 2, 0, 1, 1) self.gridLayout.setColumnStretch(1, 1) self.verticalLayout_2.addLayout(self.gridLayout) self.verticalLayout.addLayout(self.verticalLayout_2) spacerItem = QtGui.QSpacerItem(20, 1, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.break_line = QtGui.QFrame(SaveAsForm) self.break_line.setFrameShape(QtGui.QFrame.HLine) self.break_line.setFrameShadow(QtGui.QFrame.Sunken) self.break_line.setObjectName("break_line") self.verticalLayout.addWidget(self.break_line) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setContentsMargins(12, 8, 12, 12) self.horizontalLayout_3.setObjectName("horizontalLayout_3") spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem1) self.cancel_btn = QtGui.QPushButton(SaveAsForm) self.cancel_btn.setObjectName("cancel_btn") self.horizontalLayout_3.addWidget(self.cancel_btn) self.continue_btn = QtGui.QPushButton(SaveAsForm) self.continue_btn.setDefault(True) self.continue_btn.setObjectName("continue_btn") self.horizontalLayout_3.addWidget(self.continue_btn) self.verticalLayout.addLayout(self.horizontalLayout_3) self.verticalLayout.setStretch(1, 1) self.retranslateUi(SaveAsForm) QtCore.QMetaObject.connectSlotsByName(SaveAsForm) SaveAsForm.setTabOrder(self.name_edit, self.reset_version_cb) SaveAsForm.setTabOrder(self.reset_version_cb, self.cancel_btn) SaveAsForm.setTabOrder(self.cancel_btn, self.continue_btn) SaveAsForm.setTabOrder(self.continue_btn, self.path_preview_edit)
class TrayWidget(QtGui.QWidget): """ This class is typically used in conjunction with a QT View and the ShotgunDelegate class. This has been hacked up at the moment to be just a thumbnail scroller. """ clicked = QtCore.Signal(int) def __init__(self, parent): """ Constructor """ QtGui.QWidget.__init__(self, parent) # set up the UI self.ui = Ui_TrayWidget() self.ui.setupUi(self) # make sure this widget isn't shown WHY???? self.setVisible(False) self.hintSize = None self.parent = parent def set_actions(self, actions): """ Adds a list of QActions to add to the actions menu for this widget. """ # print "TRAY WIDGET set_actions" pass def set_selected(self, selected, in_mini_cut=False): """ Adjust the style sheet to indicate selection or not, """ if selected: self.ui.thumbnail.setStyleSheet( "QLabel { border: 2px solid rgb(40,136,175); }") else: self.ui.thumbnail.setStyleSheet( "QLabel { border: 0px solid rgb(37,38,41); }") def set_thumbnail(self, pixmap): """ Set a thumbnail given the current pixmap. """ self.ui.thumbnail.setPixmap(pixmap) self.resize(pixmap.size()) if pixmap.height() < 74: self.parent.resize(self.parent.width(), 74) else: self.parent.resize(self.parent.width(), pixmap.height()) def set_text(self, header, body): """ Populate the lines of text in the widget """ pass def sizeHint(self): # = QtCore.QSize(self.ui.thumbnail.width() * 2, self.ui.thumbnail.height()*2) # return s # return QtCore.QSize(96, 54) #self.parent.resize(self.parent.width(), 74) return self.ui.thumbnail.size()
def setupUi(self, TrustForm): TrustForm.setObjectName("TrustForm") TrustForm.resize(500, 178) self.verticalLayout_3 = QtGui.QVBoxLayout(TrustForm) self.verticalLayout_3.setSpacing(2) self.verticalLayout_3.setContentsMargins(0, 0, 0, 0) self.verticalLayout_3.setObjectName("verticalLayout_3") self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setSpacing(12) self.horizontalLayout.setContentsMargins(12, 12, 12, 8) self.horizontalLayout.setObjectName("horizontalLayout") self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") self.warning_label = QtGui.QLabel(TrustForm) self.warning_label.setMinimumSize(QtCore.QSize(0, 0)) self.warning_label.setMaximumSize(QtCore.QSize(64, 64)) self.warning_label.setText("") self.warning_label.setObjectName("warning_label") self.verticalLayout_2.addWidget(self.warning_label) spacerItem = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_2.addItem(spacerItem) self.horizontalLayout.addLayout(self.verticalLayout_2) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setSpacing(-1) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.msg_label = QtGui.QLabel(TrustForm) self.msg_label.setWordWrap(True) self.msg_label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) self.msg_label.setObjectName("msg_label") self.verticalLayout.addWidget(self.msg_label) self.trust_cb = QtGui.QCheckBox(TrustForm) self.trust_cb.setObjectName("trust_cb") self.verticalLayout.addWidget(self.trust_cb) self.horizontalLayout.addLayout(self.verticalLayout) self.horizontalLayout.setStretch(1, 1) self.verticalLayout_3.addLayout(self.horizontalLayout) spacerItem1 = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_3.addItem(spacerItem1) self.break_line = QtGui.QFrame(TrustForm) self.break_line.setFrameShape(QtGui.QFrame.HLine) self.break_line.setFrameShadow(QtGui.QFrame.Sunken) self.break_line.setObjectName("break_line") self.verticalLayout_3.addWidget(self.break_line) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setContentsMargins(12, 8, 12, 12) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.details_btn = QtGui.QPushButton(TrustForm) self.details_btn.setObjectName("details_btn") self.horizontalLayout_3.addWidget(self.details_btn) spacerItem2 = QtGui.QSpacerItem(0, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem2) self.cancel_btn = QtGui.QPushButton(TrustForm) self.cancel_btn.setMinimumSize(QtCore.QSize(90, 0)) self.cancel_btn.setObjectName("cancel_btn") self.horizontalLayout_3.addWidget(self.cancel_btn) self.ok_btn = QtGui.QPushButton(TrustForm) self.ok_btn.setMinimumSize(QtCore.QSize(90, 0)) self.ok_btn.setDefault(True) self.ok_btn.setObjectName("ok_btn") self.horizontalLayout_3.addWidget(self.ok_btn) self.verticalLayout_3.addLayout(self.horizontalLayout_3) self.verticalLayout_3.setStretch(1, 1) self.retranslateUi(TrustForm) QtCore.QMetaObject.connectSlotsByName(TrustForm)
def setupUi(self, PublishForm): PublishForm.setObjectName("PublishForm") PublishForm.resize(794, 549) PublishForm.setAutoFillBackground(False) self.verticalLayout = QtGui.QVBoxLayout(PublishForm) self.verticalLayout.setSpacing(20) self.verticalLayout.setObjectName("verticalLayout") self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setContentsMargins(0, -1, -1, -1) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.verticalLayout_3 = QtGui.QVBoxLayout() self.verticalLayout_3.setSpacing(0) self.verticalLayout_3.setObjectName("verticalLayout_3") self.primary_icon_label = QtGui.QLabel(PublishForm) self.primary_icon_label.setMinimumSize(QtCore.QSize(80, 80)) self.primary_icon_label.setMaximumSize(QtCore.QSize(80, 80)) self.primary_icon_label.setBaseSize(QtCore.QSize(32, 32)) self.primary_icon_label.setText("") self.primary_icon_label.setPixmap(QtGui.QPixmap(":/res/default_header.png")) self.primary_icon_label.setScaledContents(False) self.primary_icon_label.setAlignment(QtCore.Qt.AlignCenter) self.primary_icon_label.setObjectName("primary_icon_label") self.verticalLayout_3.addWidget(self.primary_icon_label) spacerItem = QtGui.QSpacerItem(20, 0, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_3.addItem(spacerItem) self.verticalLayout_3.setStretch(1, 1) self.horizontalLayout_2.addLayout(self.verticalLayout_3) self.verticalLayout_2 = QtGui.QVBoxLayout() self.verticalLayout_2.setSpacing(6) self.verticalLayout_2.setContentsMargins(1, 1, 1, 1) self.verticalLayout_2.setObjectName("verticalLayout_2") self.primary_details_label = QtGui.QLabel(PublishForm) self.primary_details_label.setStyleSheet("#primary_details_label {\n" "}") self.primary_details_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) self.primary_details_label.setMargin(0) self.primary_details_label.setObjectName("primary_details_label") self.verticalLayout_2.addWidget(self.primary_details_label) self.primary_error_label = QtGui.QLabel(PublishForm) self.primary_error_label.setMinimumSize(QtCore.QSize(0, 0)) self.primary_error_label.setStyleSheet("") self.primary_error_label.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.primary_error_label.setWordWrap(True) self.primary_error_label.setMargin(0) self.primary_error_label.setObjectName("primary_error_label") self.verticalLayout_2.addWidget(self.primary_error_label) self.verticalLayout_2.setStretch(1, 1) self.horizontalLayout_2.addLayout(self.verticalLayout_2) self.horizontalLayout_2.setStretch(1, 1) self.verticalLayout.addLayout(self.horizontalLayout_2) self.pages = QtGui.QStackedWidget(PublishForm) self.pages.setObjectName("pages") self.publish_details = PublishDetailsForm() self.publish_details.setObjectName("publish_details") self.pages.addWidget(self.publish_details) self.publish_progress = PublishProgressForm() self.publish_progress.setObjectName("publish_progress") self.pages.addWidget(self.publish_progress) self.publish_result = PublishResultForm() self.publish_result.setObjectName("publish_result") self.pages.addWidget(self.publish_result) self.verticalLayout.addWidget(self.pages) self.verticalLayout.setStretch(1, 1) self.retranslateUi(PublishForm) self.pages.setCurrentIndex(1) QtCore.QMetaObject.connectSlotsByName(PublishForm)
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.setWindowModality(QtCore.Qt.ApplicationModal) Dialog.resize(806, 453) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(Dialog.sizePolicy().hasHeightForWidth()) Dialog.setSizePolicy(sizePolicy) self.gridLayout = QtGui.QGridLayout(Dialog) self.gridLayout.setObjectName("gridLayout") self.textBrowser = QtGui.QTextBrowser(Dialog) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.textBrowser.sizePolicy().hasHeightForWidth()) self.textBrowser.setSizePolicy(sizePolicy) self.textBrowser.setMaximumSize(QtCore.QSize(16777215, 50)) self.textBrowser.setObjectName("textBrowser") self.gridLayout.addWidget(self.textBrowser, 4, 2, 1, 1) self.HelpBtn = QtGui.QPushButton(Dialog) self.HelpBtn.setObjectName("HelpBtn") self.gridLayout.addWidget(self.HelpBtn, 4, 0, 1, 1) self.line = QtGui.QFrame(Dialog) self.line.setFrameShape(QtGui.QFrame.HLine) self.line.setFrameShadow(QtGui.QFrame.Sunken) self.line.setObjectName("line") self.gridLayout.addWidget(self.line, 3, 2, 1, 1) self.treeView = QtGui.QTreeView(Dialog) self.treeView.setObjectName("treeView") self.gridLayout.addWidget(self.treeView, 0, 2, 2, 1) self.ApplicationBtnLayout = QtGui.QVBoxLayout() self.ApplicationBtnLayout.setSizeConstraint( QtGui.QLayout.SetNoConstraint) self.ApplicationBtnLayout.setObjectName("ApplicationBtnLayout") self.gridLayout.addLayout(self.ApplicationBtnLayout, 0, 0, 2, 1) self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(783, 489) self.horizontalLayout_2 = QtGui.QHBoxLayout(Dialog) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.central_stackedWidget = QtGui.QStackedWidget(Dialog) self.central_stackedWidget.setObjectName("central_stackedWidget") self.submit_page = QtGui.QWidget() self.submit_page.setObjectName("submit_page") self.horizontalLayout_4 = QtGui.QHBoxLayout(self.submit_page) self.horizontalLayout_4.setObjectName("horizontalLayout_4") self.verticalLayout_7 = QtGui.QVBoxLayout() self.verticalLayout_7.setSpacing(4) self.verticalLayout_7.setObjectName("verticalLayout_7") self.items_title_label = QtGui.QLabel(self.submit_page) self.items_title_label.setStyleSheet("#items_title_label {\n" "font-size: 14px\n" "}") self.items_title_label.setIndent(4) self.items_title_label.setObjectName("items_title_label") self.verticalLayout_7.addWidget(self.items_title_label) self.renders_stacked_widget = QtGui.QStackedWidget(self.submit_page) self.renders_stacked_widget.setStyleSheet("") self.renders_stacked_widget.setObjectName("renders_stacked_widget") self.renders_page = QtGui.QWidget() self.renders_page.setObjectName("renders_page") self.horizontalLayout_7 = QtGui.QHBoxLayout(self.renders_page) self.horizontalLayout_7.setSpacing(0) self.horizontalLayout_7.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_7.setObjectName("horizontalLayout_7") self.task_scroll = QtGui.QScrollArea(self.renders_page) self.task_scroll.setStyleSheet("#task_scroll {\n" "border-style: solid;\n" "border-width: 1px;\n" "border-radius: 2px;\n" "border-color: rgb(32,32,32);\n" "}") self.task_scroll.setWidgetResizable(True) self.task_scroll.setObjectName("task_scroll") self.contents = QtGui.QWidget() self.contents.setGeometry(QtCore.QRect(0, 0, 359, 419)) self.contents.setObjectName("contents") self.task_scroll.setWidget(self.contents) self.horizontalLayout_7.addWidget(self.task_scroll) self.renders_stacked_widget.addWidget(self.renders_page) self.no_renders_page = QtGui.QWidget() self.no_renders_page.setStyleSheet("") self.no_renders_page.setObjectName("no_renders_page") self.verticalLayout_2 = QtGui.QVBoxLayout(self.no_renders_page) self.verticalLayout_2.setSpacing(0) self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.verticalLayout_2.setObjectName("verticalLayout_2") self.no_renders_frame = QtGui.QFrame(self.no_renders_page) self.no_renders_frame.setStyleSheet("#no_publishes_frame {\n" "border-style: solid;\n" "border-width: 1px;\n" "border-radius: 2px;\n" "border-color: rgb(32,32,32);\n" "}") self.no_renders_frame.setFrameShape(QtGui.QFrame.StyledPanel) self.no_renders_frame.setFrameShadow(QtGui.QFrame.Raised) self.no_renders_frame.setObjectName("no_renders_frame") self.verticalLayout_3 = QtGui.QVBoxLayout(self.no_renders_frame) self.verticalLayout_3.setSpacing(0) self.verticalLayout_3.setContentsMargins(0, 0, 0, 0) self.verticalLayout_3.setObjectName("verticalLayout_3") spacerItem = QtGui.QSpacerItem(0, 88, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_3.addItem(spacerItem) self.horizontalLayout_9 = QtGui.QHBoxLayout() self.horizontalLayout_9.setObjectName("horizontalLayout_9") spacerItem1 = QtGui.QSpacerItem(0, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_9.addItem(spacerItem1) self.label_6 = QtGui.QLabel(self.no_renders_frame) self.label_6.setAlignment(QtCore.Qt.AlignCenter) self.label_6.setWordWrap(True) self.label_6.setObjectName("label_6") self.horizontalLayout_9.addWidget(self.label_6) spacerItem2 = QtGui.QSpacerItem(0, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_9.addItem(spacerItem2) self.verticalLayout_3.addLayout(self.horizontalLayout_9) spacerItem3 = QtGui.QSpacerItem(0, 88, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_3.addItem(spacerItem3) self.verticalLayout_2.addWidget(self.no_renders_frame) self.renders_stacked_widget.addWidget(self.no_renders_page) self.verticalLayout_7.addWidget(self.renders_stacked_widget) self.horizontalLayout_4.addLayout(self.verticalLayout_7) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setSpacing(4) self.verticalLayout.setObjectName("verticalLayout") self.info_title_label = QtGui.QLabel(self.submit_page) self.info_title_label.setStyleSheet("#info_title_label {\n" "font-size: 14px\n" "}") self.info_title_label.setIndent(4) self.info_title_label.setObjectName("info_title_label") self.verticalLayout.addWidget(self.info_title_label) self.groupBox = QtGui.QGroupBox(self.submit_page) self.groupBox.setTitle("") self.groupBox.setFlat(False) self.groupBox.setCheckable(False) self.groupBox.setObjectName("groupBox") self.gridLayout = QtGui.QGridLayout(self.groupBox) self.gridLayout.setContentsMargins(-1, 12, -1, -1) self.gridLayout.setObjectName("gridLayout") self.verticalLayout.addWidget(self.groupBox) spacerItem4 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem4) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") spacerItem5 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem5) self.cancel_btn = QtGui.QPushButton(self.submit_page) self.cancel_btn.setMinimumSize(QtCore.QSize(80, 0)) self.cancel_btn.setObjectName("cancel_btn") self.horizontalLayout.addWidget(self.cancel_btn) self.submit_btn = QtGui.QPushButton(self.submit_page) self.submit_btn.setObjectName("submit_btn") self.horizontalLayout.addWidget(self.submit_btn) self.verticalLayout.addLayout(self.horizontalLayout) self.horizontalLayout_4.addLayout(self.verticalLayout) self.central_stackedWidget.addWidget(self.submit_page) self.progress_page = QtGui.QWidget() self.progress_page.setObjectName("progress_page") self.verticalLayout_10 = QtGui.QVBoxLayout(self.progress_page) self.verticalLayout_10.setObjectName("verticalLayout_10") self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName("horizontalLayout_3") spacerItem6 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem6) self.verticalLayout_9 = QtGui.QVBoxLayout() self.verticalLayout_9.setSpacing(6) self.verticalLayout_9.setObjectName("verticalLayout_9") spacerItem7 = QtGui.QSpacerItem(20, 97, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_9.addItem(spacerItem7) self.title = QtGui.QLabel(self.progress_page) self.title.setStyleSheet("#title {\n" "font-size: 24px;\n" "}") self.title.setObjectName("title") self.verticalLayout_9.addWidget(self.title) self.progress_details = QtGui.QLabel(self.progress_page) self.progress_details.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.progress_details.setWordWrap(False) self.progress_details.setObjectName("progress_details") self.verticalLayout_9.addWidget(self.progress_details) spacerItem8 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_9.addItem(spacerItem8) self.verticalLayout_9.setStretch(0, 2) self.verticalLayout_9.setStretch(3, 3) self.horizontalLayout_3.addLayout(self.verticalLayout_9) spacerItem9 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem9) self.horizontalLayout_3.setStretch(0, 1) self.horizontalLayout_3.setStretch(1, 5) self.horizontalLayout_3.setStretch(2, 1) self.verticalLayout_10.addLayout(self.horizontalLayout_3) self.central_stackedWidget.addWidget(self.progress_page) self.success_page = QtGui.QWidget() self.success_page.setObjectName("success_page") self.verticalLayout_8 = QtGui.QVBoxLayout(self.success_page) self.verticalLayout_8.setObjectName("verticalLayout_8") spacerItem10 = QtGui.QSpacerItem(20, 134, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_8.addItem(spacerItem10) self.horizontalLayout_6 = QtGui.QHBoxLayout() self.horizontalLayout_6.setObjectName("horizontalLayout_6") spacerItem11 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_6.addItem(spacerItem11) self.verticalLayout_5 = QtGui.QVBoxLayout() self.verticalLayout_5.setObjectName("verticalLayout_5") self.status_icon = QtGui.QLabel(self.success_page) self.status_icon.setMinimumSize(QtCore.QSize(80, 80)) self.status_icon.setMaximumSize(QtCore.QSize(80, 80)) self.status_icon.setBaseSize(QtCore.QSize(32, 32)) self.status_icon.setText("") self.status_icon.setPixmap(QtGui.QPixmap(":/res/success.png")) self.status_icon.setScaledContents(False) self.status_icon.setAlignment(QtCore.Qt.AlignCenter) self.status_icon.setObjectName("status_icon") self.verticalLayout_5.addWidget(self.status_icon) spacerItem12 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_5.addItem(spacerItem12) self.horizontalLayout_6.addLayout(self.verticalLayout_5) self.verticalLayout_6 = QtGui.QVBoxLayout() self.verticalLayout_6.setSpacing(0) self.verticalLayout_6.setObjectName("verticalLayout_6") self.success_status_title = QtGui.QLabel(self.success_page) font = QtGui.QFont() font.setPointSize(18) self.success_status_title.setFont(font) self.success_status_title.setStyleSheet("") self.success_status_title.setObjectName("success_status_title") self.verticalLayout_6.addWidget(self.success_status_title) self.success_details = QtGui.QLabel(self.success_page) self.success_details.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.success_details.setWordWrap(True) self.success_details.setTextInteractionFlags( QtCore.Qt.LinksAccessibleByMouse | QtCore.Qt.TextSelectableByMouse) self.success_details.setObjectName("success_details") self.verticalLayout_6.addWidget(self.success_details) self.verticalLayout_6.setStretch(1, 1) self.horizontalLayout_6.addLayout(self.verticalLayout_6) spacerItem13 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_6.addItem(spacerItem13) self.horizontalLayout_6.setStretch(2, 3) self.horizontalLayout_6.setStretch(3, 1) self.verticalLayout_8.addLayout(self.horizontalLayout_6) spacerItem14 = QtGui.QSpacerItem(20, 134, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_8.addItem(spacerItem14) self.horizontalLayout_5 = QtGui.QHBoxLayout() self.horizontalLayout_5.setObjectName("horizontalLayout_5") spacerItem15 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_5.addItem(spacerItem15) self.success_close_btn = QtGui.QPushButton(self.success_page) self.success_close_btn.setObjectName("success_close_btn") self.horizontalLayout_5.addWidget(self.success_close_btn) self.verticalLayout_8.addLayout(self.horizontalLayout_5) self.central_stackedWidget.addWidget(self.success_page) self.failure_page = QtGui.QWidget() self.failure_page.setObjectName("failure_page") self.verticalLayout_19 = QtGui.QVBoxLayout(self.failure_page) self.verticalLayout_19.setObjectName("verticalLayout_19") spacerItem16 = QtGui.QSpacerItem(20, 134, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_19.addItem(spacerItem16) self.horizontalLayout_15 = QtGui.QHBoxLayout() self.horizontalLayout_15.setObjectName("horizontalLayout_15") spacerItem17 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_15.addItem(spacerItem17) self.verticalLayout_17 = QtGui.QVBoxLayout() self.verticalLayout_17.setObjectName("verticalLayout_17") self.status_icon_3 = QtGui.QLabel(self.failure_page) self.status_icon_3.setMinimumSize(QtCore.QSize(80, 80)) self.status_icon_3.setMaximumSize(QtCore.QSize(80, 80)) self.status_icon_3.setBaseSize(QtCore.QSize(32, 32)) self.status_icon_3.setText("") self.status_icon_3.setPixmap(QtGui.QPixmap(":/res/failure.png")) self.status_icon_3.setScaledContents(False) self.status_icon_3.setAlignment(QtCore.Qt.AlignCenter) self.status_icon_3.setObjectName("status_icon_3") self.verticalLayout_17.addWidget(self.status_icon_3) spacerItem18 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_17.addItem(spacerItem18) self.horizontalLayout_15.addLayout(self.verticalLayout_17) self.verticalLayout_18 = QtGui.QVBoxLayout() self.verticalLayout_18.setSpacing(0) self.verticalLayout_18.setObjectName("verticalLayout_18") self.failure_status_title = QtGui.QLabel(self.failure_page) font = QtGui.QFont() font.setPointSize(18) self.failure_status_title.setFont(font) self.failure_status_title.setStyleSheet("") self.failure_status_title.setObjectName("failure_status_title") self.verticalLayout_18.addWidget(self.failure_status_title) self.failure_details = QtGui.QLabel(self.failure_page) self.failure_details.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) self.failure_details.setWordWrap(True) self.failure_details.setTextInteractionFlags( QtCore.Qt.LinksAccessibleByMouse | QtCore.Qt.TextSelectableByMouse) self.failure_details.setObjectName("failure_details") self.verticalLayout_18.addWidget(self.failure_details) self.verticalLayout_18.setStretch(1, 1) self.horizontalLayout_15.addLayout(self.verticalLayout_18) spacerItem19 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_15.addItem(spacerItem19) self.horizontalLayout_15.setStretch(2, 3) self.horizontalLayout_15.setStretch(3, 1) self.verticalLayout_19.addLayout(self.horizontalLayout_15) spacerItem20 = QtGui.QSpacerItem(20, 134, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout_19.addItem(spacerItem20) self.horizontalLayout_14 = QtGui.QHBoxLayout() self.horizontalLayout_14.setObjectName("horizontalLayout_14") spacerItem21 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_14.addItem(spacerItem21) self.failure_close_btn = QtGui.QPushButton(self.failure_page) self.failure_close_btn.setObjectName("failure_close_btn") self.horizontalLayout_14.addWidget(self.failure_close_btn) self.verticalLayout_19.addLayout(self.horizontalLayout_14) self.central_stackedWidget.addWidget(self.failure_page) self.horizontalLayout_2.addWidget(self.central_stackedWidget) self.retranslateUi(Dialog) self.central_stackedWidget.setCurrentIndex(0) self.renders_stacked_widget.setCurrentIndex(1) QtCore.QMetaObject.connectSlotsByName(Dialog)
def setupUi(self, ItemWidget): ItemWidget.setObjectName("ItemWidget") ItemWidget.resize(290, 45) ItemWidget.setMinimumSize(QtCore.QSize(0, 45)) self.verticalLayout = QtGui.QVBoxLayout(ItemWidget) self.verticalLayout.setSpacing(0) self.verticalLayout.setContentsMargins(2, 2, 2, 2) self.verticalLayout.setObjectName("verticalLayout") self.frame = QtGui.QFrame(ItemWidget) self.frame.setFrameShape(QtGui.QFrame.StyledPanel) self.frame.setFrameShadow(QtGui.QFrame.Raised) self.frame.setObjectName("frame") self.horizontalLayout = QtGui.QHBoxLayout(self.frame) self.horizontalLayout.setSpacing(8) self.horizontalLayout.setContentsMargins(4, 2, 2, 2) self.horizontalLayout.setObjectName("horizontalLayout") self.expand_indicator = QtGui.QToolButton(self.frame) self.expand_indicator.setMinimumSize(QtCore.QSize(16, 16)) self.expand_indicator.setMaximumSize(QtCore.QSize(16, 16)) self.expand_indicator.setText("") icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/tk_multi_publish2/down_arrow.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.expand_indicator.setIcon(icon) self.expand_indicator.setObjectName("expand_indicator") self.horizontalLayout.addWidget(self.expand_indicator) self.icon = QtGui.QLabel(self.frame) self.icon.setMinimumSize(QtCore.QSize(32, 32)) self.icon.setMaximumSize(QtCore.QSize(30, 30)) self.icon.setText("") self.icon.setScaledContents(True) self.icon.setObjectName("icon") self.horizontalLayout.addWidget(self.icon) self.header = QtGui.QLabel(self.frame) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.header.sizePolicy().hasHeightForWidth()) self.header.setSizePolicy(sizePolicy) self.header.setObjectName("header") self.horizontalLayout.addWidget(self.header) self.handle_stack = QtGui.QStackedWidget(self.frame) self.handle_stack.setMinimumSize(QtCore.QSize(22, 22)) self.handle_stack.setMaximumSize(QtCore.QSize(22, 22)) self.handle_stack.setObjectName("handle_stack") self.drag = QtGui.QWidget() self.drag.setObjectName("drag") self.horizontalLayout_2 = QtGui.QHBoxLayout(self.drag) self.horizontalLayout_2.setSpacing(0) self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.drag_handle = QtGui.QLabel(self.drag) self.drag_handle.setMinimumSize(QtCore.QSize(16, 16)) self.drag_handle.setMaximumSize(QtCore.QSize(16, 16)) self.drag_handle.setCursor(QtCore.Qt.OpenHandCursor) self.drag_handle.setText("") self.drag_handle.setPixmap( QtGui.QPixmap(":/tk_multi_publish2/drag_handle.png")) self.drag_handle.setScaledContents(True) self.drag_handle.setObjectName("drag_handle") self.horizontalLayout_2.addWidget(self.drag_handle) self.handle_stack.addWidget(self.drag) self.lock = QtGui.QWidget() self.lock.setObjectName("lock") self.horizontalLayout_3 = QtGui.QHBoxLayout(self.lock) self.horizontalLayout_3.setSpacing(0) self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.locked_handle = QtGui.QLabel(self.lock) self.locked_handle.setMinimumSize(QtCore.QSize(16, 16)) self.locked_handle.setMaximumSize(QtCore.QSize(16, 16)) self.locked_handle.setText("") self.locked_handle.setScaledContents(True) self.locked_handle.setObjectName("locked_handle") self.horizontalLayout_3.addWidget(self.locked_handle) self.handle_stack.addWidget(self.lock) self.horizontalLayout.addWidget(self.handle_stack) self.status = QtGui.QToolButton(self.frame) self.status.setMinimumSize(QtCore.QSize(30, 30)) self.status.setMaximumSize(QtCore.QSize(30, 30)) icon1 = QtGui.QIcon() icon1.addPixmap( QtGui.QPixmap(":/tk_multi_publish2/status_validate.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.status.setIcon(icon1) self.status.setIconSize(QtCore.QSize(24, 24)) self.status.setObjectName("status") self.horizontalLayout.addWidget(self.status) self.checkbox = QtGui.QCheckBox(self.frame) self.checkbox.setText("") self.checkbox.setObjectName("checkbox") self.horizontalLayout.addWidget(self.checkbox) self.horizontalLayout.setStretch(2, 10) self.verticalLayout.addWidget(self.frame) self.retranslateUi(ItemWidget) self.handle_stack.setCurrentIndex(1) QtCore.QMetaObject.connectSlotsByName(ItemWidget)
class Worker(QtCore.QThread): """ Background worker class """ # Indicates that this worker class has been fixed to stop # gc of QThread from resulting in a crash. This happens # when the mutex object had been gc'd but the thread is # still trying to access it - the fix is to wait for the # thread to terminate before returning from 'stop()' _SGTK_IMPLEMENTS_QTHREAD_CRASH_FIX_ = True work_completed = QtCore.Signal(str, object) work_failure = QtCore.Signal(str, str) def __init__(self, app, parent=None): """ Construction """ QtCore.QThread.__init__(self, parent) self._execute_tasks = True self._app = app self._queue_mutex = Lock() self._queue = [] self._receivers = {} self._wait_condition = Condition(self._queue_mutex) def stop(self, wait_for_completion=True): """ Stops the worker, run this before shutdown """ with self._queue_mutex: self._execute_tasks = False self._wait_condition.notifyAll() if wait_for_completion: self.wait() def clear(self): """ Empties the queue """ with self._queue_mutex: self._queue = [] def queue_work(self, worker_fn, params, asap=False): """ Queues up some work. Returns a unique identifier to identify this item """ uid = uuid.uuid4().hex work = {"id": uid, "fn": worker_fn, "params": params} with self._queue_mutex: if asap: # first in the queue self._queue.insert(0, work) else: self._queue.append(work) self._wait_condition.notifyAll() return uid ############################################################################################ # def run(self): while self._execute_tasks: # get the next item to process: item_to_process = None with self._queue_mutex: if len(self._queue) == 0: # wait for some more work - this unlocks the mutex # until the wait condition is signalled where it # will then attempt to obtain a lock before returning self._wait_condition.wait() if len(self._queue) == 0: # still nothing in the queue! continue item_to_process = self._queue.pop(0) if not self._execute_tasks: break # ok, have something to do so lets do it: data = None try: # process the item: data = item_to_process["fn"](item_to_process["params"]) except Exception as e: if self._execute_tasks: self.work_failure.emit(item_to_process["id"], "An error occured: %s" % e) else: if self._execute_tasks: self.work_completed.emit(item_to_process["id"], data)
def qCleanupResources(): QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
class WorkFilesForm(QtGui.QWidget): """ Primary work area UI """ # signals - note, 'object' is used to avoid # issues with PyQt when None is passed open_publish = QtCore.Signal(object, object, bool) #FileItem, FileItem, bool open_workfile = QtCore.Signal(object, object, bool) #FileItem, FileItem, bool open_previous_publish = QtCore.Signal(object) #FileItem open_previous_workfile = QtCore.Signal(object) #FileItem new_file = QtCore.Signal() show_in_fs = QtCore.Signal() show_in_shotgun = QtCore.Signal(object) #FileItem def __init__(self, app, handler, parent=None): """ Construction """ QtGui.QWidget.__init__(self, parent) self._app = app self._handler = handler # set up the UI from .ui.work_files_form import Ui_WorkFilesForm self._ui = Ui_WorkFilesForm() self._ui.setupUi(self) # patch up the lines to be the same colour as the font: clr = QtGui.QApplication.palette().color(QtGui.QPalette.Text) rgb_str = "rgb(%d,%d,%d)" % (clr.red(), clr.green(), clr.blue()) self._ui.project_line.setStyleSheet( "#project_line{background-color: %s;}" % rgb_str) self._ui.entity_line.setStyleSheet( "#entity_line{background-color: %s;}" % rgb_str) self._ui.task_line.setStyleSheet("#task_line{background-color: %s;}" % rgb_str) ss = "{font-size: 14pt; border-style: dashed; border-width: 2px; border-radius: 3px; border-color: %s;}" % rgb_str self._ui.no_project_label.setStyleSheet("#no_project_label %s" % ss) self._ui.no_task_label.setStyleSheet("#no_task_label %s" % ss) self._ui.no_entity_label.setStyleSheet("#no_entity_label %s" % ss) # set up the work area depending on if it's possible to change it: if self._handler.can_change_work_area(): # update the style sheet for the work area form so it # becomes highlighted when hovering over it # test for lightness ahead of use to stay compatible with Qt 4.6.2 if hasattr(clr, 'lightness'): clr = QtGui.QApplication.palette().color(QtGui.QPalette.Window) clr = clr.lighter() if clr.lightness() < 128 else clr.darker() ss = self._ui.work_area_frame.styleSheet() ss = "%s #work_area_frame:hover {background-color: rgb(%d,%d,%d);}" % ( ss, clr.red(), clr.green(), clr.blue()) self._ui.work_area_frame.setStyleSheet(ss) self._ui.work_area_frame.setCursor(QtCore.Qt.PointingHandCursor) self._ui.work_area_frame.setToolTip("Click to Change Work Area...") self._ui.no_change_frame.setVisible(False) self._ui.work_area_frame.mousePressEvent = self._on_work_area_mouse_press_event else: self._ui.work_area_frame.setCursor(QtCore.Qt.ArrowCursor) self._ui.work_area_frame.setToolTip( "The Work Area is locked and cannot be changed") self._ui.no_change_frame.setVisible(True) # connect up controls: self._ui.show_in_fs_label.mousePressEvent = self._on_show_in_fs_mouse_press_event self._ui.filter_combo.currentIndexChanged.connect( self._on_filter_selection_changed) self._ui.open_file_btn.clicked.connect(self._on_open_file) self._ui.new_file_btn.clicked.connect(self._on_new_file) self._ui.file_list.action_requested.connect(self._on_open_file) self._ui.file_list.selection_changed.connect( self._on_file_selection_changed) self._ui.file_list.set_app(self._app) self._ui.file_list.open_previous_workfile.connect( self._on_open_previous_workfile) self._ui.file_list.open_previous_publish.connect( self._on_open_previous_publish) self._ui.file_list.view_in_shotgun.connect(self._on_view_in_shotgun) # set up the work area: ctx = self._handler.get_current_work_area() self._set_work_area(ctx) self._on_file_selection_changed() @property def filter(self): return self._get_current_filter() def _on_view_in_shotgun(self, file): self.show_in_shotgun.emit(file) def _on_show_in_fs_mouse_press_event(self, event): """ Emit event when the user clicks the show in file system link: """ self.show_in_fs.emit() def closeEvent(self, e): """ Ensure everything is cleaned up when the widget is closed """ self._ui.file_list.destroy() return QtGui.QWidget.closeEvent(self, e) def _on_open_file(self): """ """ # get the currently selected work file work_file = self._ui.file_list.selected_work_file published_file = self._ui.file_list.selected_published_file current_filter = self._get_current_filter() if not current_filter: return if current_filter.mode == FileFilter.WORKFILES_MODE: self.open_workfile.emit(work_file, published_file, False) else: # current_filter.mode == FileFilter.PUBLISHES_MODE: self.open_publish.emit(published_file, work_file, False) def _on_open_previous_workfile(self, file): """ """ self.open_previous_workfile.emit(file) def _on_open_previous_publish(self, file): """ """ self.open_previous_publish.emit(file) def _on_new_file(self): """ """ self.new_file.emit() def _set_work_area(self, ctx): """ Set the current work area to the specified context. """ self._app.log_debug( "Setting the work area in the File Manager UI") # to %s..." % ctx) # update work area info: self._app.log_debug(" - Updating Work Area") self._update_work_area(ctx) # update the filter menu: self._app.log_debug(" - Updating Filter menu") self._update_filter_menu() # finally, update file list: self._app.log_debug(" - Refreshing File List") self._refresh_file_list() # update new button enabled state can_do_new = self._handler.can_do_new_file() self._ui.new_file_btn.setEnabled(can_do_new) self._app.log_debug( "Finished setting the work area in the File Manager UI!") def _on_work_area_mouse_press_event(self, event): """ Event triggered when mouse is pressed in the work area form """ new_ctx = self._handler.select_work_area() if new_ctx: self._set_work_area(new_ctx[0]) def _refresh_file_list(self): """ Refresh the file list based on the current filter """ # get the file filter: filter = self._get_current_filter() if not filter: return # hide/show the show-in-filesystem link: self._ui.show_in_fs_label.setVisible(filter.show_in_file_system) # clear and reload list: self._ui.file_list.clear() self._ui.file_list.load({"handler": self._handler, "filter": filter}) self._on_file_selection_changed() def _on_filter_selection_changed(self, idx): """ Called when the filter is changed """ self._refresh_file_list() def _on_file_selection_changed(self): """ """ something_selected = ( self._ui.file_list.selected_published_file is not None or self._ui.file_list.selected_work_file is not None) self._ui.open_file_btn.setEnabled(something_selected) def _update_filter_menu(self): """ Update the list of users to display work files for """ # get list of filters from handler: filters = self._handler.get_file_filters() # get selected filter: previous_filter = self._get_current_filter() # clear menu: self._ui.filter_combo.clear() # add back in filters: selected_idx = 0 separator_count = 0 for filter in filters: if filter == "separator": # special 'filter' signifying a separator should be added # - don't add it yet though in case there aren't any more # non separator items following! separator_count += 1 continue if not filter.menu_label: # filter doesn't have a menu label - bad! continue # add any separators: while separator_count > 0: separator_count -= 1 self._ui.filter_combo.insertSeparator( self._ui.filter_combo.count()) # see if this is the previously selected filter: if filter == previous_filter: selected_idx = self._ui.filter_combo.count() # add filter: self._ui.filter_combo.addItem(filter.menu_label, filter) # set the current index: self._ui.filter_combo.setCurrentIndex(selected_idx) def _get_current_filter(self): """ Get the current filter """ filter = None idx = self._ui.filter_combo.currentIndex() if idx >= 0: filter = self._ui.filter_combo.itemData(idx) # convert from QVariant object if itemData is returned as such if hasattr(QtCore, "QVariant") and isinstance( filter, QtCore.QVariant): filter = filter.toPyObject() return filter def _update_work_area(self, ctx): """ A lot of this should be done in a worker thread! """ if ctx and ctx.project: # context has a project - that's something at least! self._ui.project_pages.setCurrentWidget(self._ui.project_page) # get additional details: sg_details = {} try: sg_details = self._app.shotgun.find_one( "Project", [["id", "is", ctx.project["id"]]], ["sg_description", "image", "code"]) except: pass # header: project_name = ctx.project.get("name") or sg_details.get("code") self._ui.project_label.setText("Project: %s" % (project_name or "-")) self._ui.project_frame.setToolTip("%s" % (project_name or "")) # thumbnail: project_thumbnail = QtGui.QPixmap() project_img_url = sg_details.get("image") if project_img_url: thumbnail_path = self._download_thumbnail(project_img_url) if thumbnail_path: project_thumbnail = QtGui.QPixmap(thumbnail_path) self._set_thumbnail(self._ui.project_thumbnail, project_thumbnail) # description: desc = sg_details.get( "sg_description" ) or "<i>No description was entered for this Project</i>" self._ui.project_description.setText(desc) if ctx.entity: # work area defined - yay! self._ui.entity_pages.setCurrentWidget(self._ui.entity_page) self._ui.entity_pages.setVisible(True) # get any extra fields that have been defined for this entity type. This will be a dictionary # of label:field pairs for the current entity type: extra_fields = self._app.get_setting( "sg_entity_type_extra_display_fields", {}).get(ctx.entity["type"], {}) # get additional details: sg_details = {} try: sg_details = self._app.shotgun.find_one( ctx.entity["type"], [["project", "is", ctx.project], ["id", "is", ctx.entity["id"]]], ["description", "image", "code"] + extra_fields.values()) except: pass # header: entity_type_name = tank.util.get_entity_type_display_name( self._app.tank, ctx.entity.get("type")) entity_name = ctx.entity.get("name") or sg_details.get("code") self._ui.entity_label.setText( "%s: %s" % (entity_type_name, entity_name or "-")) self._ui.entity_frame.setToolTip("%s" % (entity_name or "")) # thumbnail: entity_thumbnail = QtGui.QPixmap() entity_img_url = sg_details.get("image") if entity_img_url: thumbnail_path = self._download_thumbnail(entity_img_url) if thumbnail_path: entity_thumbnail = QtGui.QPixmap(thumbnail_path) self._set_thumbnail(self._ui.entity_thumbnail, entity_thumbnail) # description including the display of extra fields: extra_info = ", ".join([ "%s: %s" % (label, str(sg_details.get(field))) for label, field in extra_fields.iteritems() ]) desc = "" if extra_info: desc += "(%s)<br>" % extra_info desc += sg_details.get("description") or ( "<i>No description was entered for this %s</i>" % entity_type_name) self._ui.entity_description.setText(desc) # task: if ctx.task: # have a task - double yay!! self._ui.task_pages.setCurrentWidget(self._ui.task_page) self._ui.task_pages.setVisible(True) # get additional details: sg_details = {} try: sg_details = self._app.shotgun.find_one( "Task", [["project", "is", ctx.project], ["id", "is", ctx.task["id"]]], ["task_assignees", "step.Step.code", "content"]) except Exception, e: pass # header: task_name = ctx.task.get("name") or sg_details.get( "content") self._ui.task_label.setText("Task: %s" % (task_name or "-")) self._ui.task_frame.setToolTip("%s" % (task_name or "")) # thumbnail: task_thumbnail = QtGui.QPixmap() task_assignees = sg_details.get("task_assignees", []) if len(task_assignees) > 0: user_id = task_assignees[0]["id"] sg_user_details = {} try: sg_user_details = self._app.shotgun.find_one( "HumanUser", [["id", "is", user_id]], ["image"]) except Exception, e: pass if sg_user_details: img_url = sg_user_details.get("image") if img_url: thumbnail_path = self._download_thumbnail( img_url) if thumbnail_path: task_thumbnail = QtGui.QPixmap( thumbnail_path) self._set_thumbnail(self._ui.task_thumbnail, task_thumbnail) # details assignees = [] for assignee in sg_details.get("task_assignees", []): name = assignee.get("name") if name: assignees.append(name) assignees_str = ", ".join(assignees) if assignees else "-" step_str = sg_details.get("step.Step.code") if step_str is None: step_str = "-" self._ui.task_description.setText( "Assigned to: %s<br>Pipeline Step: %s" % (assignees_str, step_str)) else: # task not chosen if not self._handler.can_change_work_area(): self._ui.task_pages.setVisible(False) else: self._ui.task_pages.setCurrentWidget( self._ui.no_task_page) else:
def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(836, 487) self.horizontalLayout = QtGui.QHBoxLayout(Dialog) self.horizontalLayout.setObjectName("horizontalLayout") self.context_overview_tab_widget = QtGui.QTabWidget(Dialog) self.context_overview_tab_widget.setTabPosition(QtGui.QTabWidget.South) self.context_overview_tab_widget.setObjectName( "context_overview_tab_widget") self.tab = QtGui.QWidget() self.tab.setObjectName("tab") self.verticalLayout_4 = QtGui.QVBoxLayout(self.tab) self.verticalLayout_4.setObjectName("verticalLayout_4") self.context_browser = ContextBrowserWidget(self.tab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.context_browser.sizePolicy().hasHeightForWidth()) self.context_browser.setSizePolicy(sizePolicy) self.context_browser.setMinimumSize(QtCore.QSize(380, 0)) self.context_browser.setObjectName("context_browser") self.verticalLayout_4.addWidget(self.context_browser) self.label_4 = QtGui.QLabel(self.tab) self.label_4.setWordWrap(True) self.label_4.setObjectName("label_4") self.verticalLayout_4.addWidget(self.label_4) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/res/icon_task.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.context_overview_tab_widget.addTab(self.tab, icon, "") self.tab_2 = QtGui.QWidget() self.tab_2.setObjectName("tab_2") self.verticalLayout_2 = QtGui.QVBoxLayout(self.tab_2) self.verticalLayout_2.setObjectName("verticalLayout_2") self.app_browser = AppBrowserWidget(self.tab_2) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.app_browser.sizePolicy().hasHeightForWidth()) self.app_browser.setSizePolicy(sizePolicy) self.app_browser.setMinimumSize(QtCore.QSize(380, 0)) self.app_browser.setObjectName("app_browser") self.verticalLayout_2.addWidget(self.app_browser) self.label_2 = QtGui.QLabel(self.tab_2) self.label_2.setWordWrap(True) self.label_2.setObjectName("label_2") self.verticalLayout_2.addWidget(self.label_2) icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(":/res/logo_color_16.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.context_overview_tab_widget.addTab(self.tab_2, icon1, "") self.tab_3 = QtGui.QWidget() self.tab_3.setObjectName("tab_3") self.verticalLayout_3 = QtGui.QVBoxLayout(self.tab_3) self.verticalLayout_3.setObjectName("verticalLayout_3") self.environment_browser = EnvironmentBrowserWidget(self.tab_3) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.environment_browser.sizePolicy().hasHeightForWidth()) self.environment_browser.setSizePolicy(sizePolicy) self.environment_browser.setMinimumSize(QtCore.QSize(380, 0)) self.environment_browser.setObjectName("environment_browser") self.verticalLayout_3.addWidget(self.environment_browser) self.label_3 = QtGui.QLabel(self.tab_3) self.label_3.setWordWrap(True) self.label_3.setObjectName("label_3") self.verticalLayout_3.addWidget(self.label_3) icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(":/res/cog_white.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.context_overview_tab_widget.addTab(self.tab_3, icon2, "") self.horizontalLayout.addWidget(self.context_overview_tab_widget) self.verticalLayout = QtGui.QVBoxLayout() self.verticalLayout.setSpacing(5) self.verticalLayout.setObjectName("verticalLayout") self.label = QtGui.QLabel(Dialog) self.label.setText("") self.label.setPixmap(QtGui.QPixmap(":/res/tank_logo.png")) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.jump_to_fs = QtGui.QPushButton(Dialog) self.jump_to_fs.setObjectName("jump_to_fs") self.verticalLayout.addWidget(self.jump_to_fs) self.reload_apps = QtGui.QPushButton(Dialog) self.reload_apps.setObjectName("reload_apps") self.verticalLayout.addWidget(self.reload_apps) self.support = QtGui.QPushButton(Dialog) self.support.setObjectName("support") self.verticalLayout.addWidget(self.support) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.close = QtGui.QPushButton(Dialog) self.close.setObjectName("close") self.verticalLayout.addWidget(self.close) self.horizontalLayout.addLayout(self.verticalLayout) self.retranslateUi(Dialog) self.context_overview_tab_widget.setCurrentIndex(0) QtCore.QMetaObject.connectSlotsByName(Dialog)
def sizeHint(self, style_options, model_index): text = model_index.data(SgProjectModel.DISPLAY_NAME_ROLE) height = ThumbWidget.height_for_width(self._size.width(), text) return QtCore.QSize(self._size.width(), height)
def setupUi(self, NavigationWidget): NavigationWidget.setObjectName("NavigationWidget") NavigationWidget.resize(119, 38) self.horizontalLayout = QtGui.QHBoxLayout(NavigationWidget) self.horizontalLayout.setSpacing(0) self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.horizontalLayout.setObjectName("horizontalLayout") spacerItem = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setSpacing(2) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.nav_home_btn = QtGui.QToolButton(NavigationWidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.nav_home_btn.sizePolicy().hasHeightForWidth()) self.nav_home_btn.setSizePolicy(sizePolicy) self.nav_home_btn.setMinimumSize(QtCore.QSize(39, 36)) self.nav_home_btn.setMaximumSize(QtCore.QSize(39, 36)) self.nav_home_btn.setBaseSize(QtCore.QSize(0, 0)) self.nav_home_btn.setStyleSheet( "#nav_home_btn{\n" " border: none;\n" " background-color: none;\n" " background-repeat: no-repeat;\n" " background-position: center center;\n" " background-image: url(:/tk-multi-workfiles2/home.png);\n" "}\n" "\n" "#nav_home_btn:disabled{\n" " background-image: url(:/tk-multi-workfiles2/home_disabled.png);\n" "}\n" "\n" "#nav_home_btn:hover{\n" "background-image: url(:/tk-multi-workfiles2/home_hover.png);\n" "}\n" "\n" "#nav_home_btn:Pressed {\n" "background-image: url(:/tk-multi-workfiles2/home_pressed.png);\n" "}\n" "") self.nav_home_btn.setText("") self.nav_home_btn.setObjectName("nav_home_btn") self.horizontalLayout_2.addWidget(self.nav_home_btn) self.nav_prev_btn = QtGui.QToolButton(NavigationWidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.nav_prev_btn.sizePolicy().hasHeightForWidth()) self.nav_prev_btn.setSizePolicy(sizePolicy) self.nav_prev_btn.setMinimumSize(QtCore.QSize(34, 36)) self.nav_prev_btn.setMaximumSize(QtCore.QSize(34, 36)) self.nav_prev_btn.setBaseSize(QtCore.QSize(0, 0)) self.nav_prev_btn.setStyleSheet( "#nav_prev_btn{\n" " border: none;\n" " background-color: none;\n" " background-repeat: no-repeat;\n" " background-position: center center;\n" " background-image: url(:/tk-multi-workfiles2/left_arrow.png);\n" "}\n" "\n" "#nav_prev_btn:disabled{\n" " background-image: url(:/tk-multi-workfiles2/left_arrow_disabled.png);\n" "}\n" "\n" "#nav_prev_btn:hover{\n" "background-image: url(:/tk-multi-workfiles2/left_arrow_hover.png);\n" "}\n" "\n" "#nav_prev_btn:Pressed {\n" "background-image: url(:/tk-multi-workfiles2/left_arrow_pressed.png);\n" "}\n" "") self.nav_prev_btn.setText("") self.nav_prev_btn.setObjectName("nav_prev_btn") self.horizontalLayout_2.addWidget(self.nav_prev_btn) self.nav_next_btn = QtGui.QToolButton(NavigationWidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.nav_next_btn.sizePolicy().hasHeightForWidth()) self.nav_next_btn.setSizePolicy(sizePolicy) self.nav_next_btn.setMinimumSize(QtCore.QSize(34, 36)) self.nav_next_btn.setMaximumSize(QtCore.QSize(34, 36)) self.nav_next_btn.setBaseSize(QtCore.QSize(0, 0)) self.nav_next_btn.setStyleSheet( "#nav_next_btn{\n" " border: none;\n" " background-color: none;\n" " background-repeat: no-repeat;\n" " background-position: center center;\n" " background-image: url(:/tk-multi-workfiles2/right_arrow.png);\n" "}\n" "\n" "#nav_next_btn:disabled{\n" " background-image: url(:/tk-multi-workfiles2/right_arrow_disabled.png);\n" "}\n" "\n" "#nav_next_btn:hover{\n" "background-image: url(:/tk-multi-workfiles2/right_arrow_hover.png);\n" "}\n" "\n" "#nav_next_btn:Pressed {\n" "background-image: url(:/tk-multi-workfiles2/right_arrow_pressed.png);\n" "}\n" "") self.nav_next_btn.setText("") self.nav_next_btn.setObjectName("nav_next_btn") self.horizontalLayout_2.addWidget(self.nav_next_btn) self.horizontalLayout.addLayout(self.horizontalLayout_2) spacerItem1 = QtGui.QSpacerItem(0, 0, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.horizontalLayout.setStretch(0, 1) self.horizontalLayout.setStretch(2, 1) self.retranslateUi(NavigationWidget) QtCore.QMetaObject.connectSlotsByName(NavigationWidget)