Exemple #1
0
    def refresh_state(self, state):

        self.state = state

        if state == cirrus_objects.FileState.CLOUD_ONLY:
            self.setIcon(cirrus_io.get_icon("cloud_only.png"))
            self.setToolTip(
                "File saved on cloud only\nClick to download the latest version."
            )

        elif state == cirrus_objects.FileState.METADATA_DESYNC:
            self.setIcon(cirrus_io.get_icon("cloud_meta_desync.png"))
            self.setToolTip(
                "Warning: metadata desyncronized or missing\nDownload the latest version of the file to refresh the metadata."
            )

        elif state == cirrus_objects.FileState.LOCAL_ONLY:
            self.setIcon(cirrus_io.get_icon("cloud_close.png"))
            self.setToolTip(
                "File saved only locally\nClick on save button to save it on the cloud."
            )

        elif state == cirrus_objects.FileState.CLOUD_AND_LOCAL_NOT_LATEST:
            self.setIcon(cirrus_io.get_icon("cloud_checkmark_not_latest.png"))
            self.setToolTip(
                "Local version of the file is not the latest\nClick to download the latest version.\nRight-click to get older versions."
            )

        else:
            self.setIcon(cirrus_io.get_icon("cloud_checkmark.png"))
            self.setToolTip(
                "File is up to date locally and on the cloud.\nRight-click to get older versions."
            )
Exemple #2
0
    def __init__(self, parent=None):
        super(MainWidget, self).__init__(parent=parent)

        cirrus_plugin_parser.get_plugin()

        self.setProperty("houdiniStyle", IS_HOUDINI)
        self.setObjectName("mainFrame")
        self.setWindowFlags(QtCore.Qt.Tool)
        self.setObjectName("Vault")
        self.setWindowTitle("Vault")

        self.pathbar = None
        self.panels = {}
        self.cur_panel = None
        self.root_panel = None
        self.plug_manager_w = None
        self.project_getter = None

        self.main_layout = QtWidgets.QVBoxLayout()
        self.main_layout.setSpacing(0)
        self.main_layout.setContentsMargins(1, 1, 1, 1)
        self.main_layout.setAlignment(QtCore.Qt.AlignTop)

        self.main_menu = QtWidgets.QMenuBar(self)
        self.main_menu.setFixedHeight(25)
        self.file_menu = self.main_menu.addMenu("File")

        self.open_proj_act = QtWidgets.QAction("Open a project", self)
        self.open_proj_act.setIcon(cirrus_io.get_icon("folder_open.svg"))
        self.open_proj_act.triggered.connect(self.init_root)
        self.close_proj_act = QtWidgets.QAction("Close Project", self)
        self.close_proj_act.setIcon(cirrus_io.get_icon("close.svg"))
        self.close_proj_act.triggered.connect(self.close_project)
        self.download_proj_act = QtWidgets.QAction("Download a project", self)
        self.download_proj_act.triggered.connect(self.get_project)
        self.download_proj_act.setIcon(cirrus_io.get_icon("inbox.svg"))
        self.file_menu.addAction(self.open_proj_act)
        self.file_menu.addAction(self.close_proj_act)
        self.file_menu.addAction(self.download_proj_act)
        self.options_menu = self.main_menu.addMenu("Options")
        self.auto_check_state_act = QtWidgets.QAction("Auto Check Files State",
                                                      self)
        self.auto_check_state_act.setCheckable(True)
        self.options_menu.addAction(self.auto_check_state_act)
        self.options_menu.addSeparator()
        self.open_plug_manager_act = QtWidgets.QAction("Plugin Manager", self)
        self.open_plug_manager_act.setIcon(cirrus_io.get_icon("plugin.svg"))
        self.open_plug_manager_act.triggered.connect(self.open_plugin_manager)
        self.options_menu.addAction(self.open_plug_manager_act)
        self.refresh_plugins_act = QtWidgets.QAction("Refresh Plugins", self)
        self.refresh_plugins_act.setIcon(cirrus_io.get_icon("reload.svg"))
        self.refresh_plugins_act.triggered.connect(self.refresh_plugins)
        self.options_menu.addAction(self.refresh_plugins_act)

        self.main_layout.addWidget(self.main_menu)

        self.init_button = ProjectSelector(self)
        self.main_layout.addWidget(self.init_button)

        self.setLayout(self.main_layout)
    def __init__(self, name="", model=None, method="", parent=None):
        super(_OnIconMenuEntry, self).__init__(parent=parent)

        self.name = name

        self.top_ui = parent
        main_layout = QtWidgets.QHBoxLayout()
        main_layout.setAlignment(QtCore.Qt.AlignLeft)

        self.name_input = QtWidgets.QLineEdit(name)
        self.name_input.setStyleSheet("background-color: transparent")
        self.name_input.textChanged.connect(self.refresh_menu_data)
        main_layout.addWidget(self.name_input)

        a = QtWidgets.QLabel("")
        a.setPixmap(cirrus_io.get_icon("arrow_right.svg").pixmap(22, 22))
        main_layout.addWidget(a)

        self.method_input = QtWidgets.QComboBox()
        self.method_input.setModel(model)
        self.method_input.setCurrentText(method)
        self.method_input.currentIndexChanged.connect(self.refresh_menu_data)
        main_layout.addWidget(self.method_input)

        del_btn = QtWidgets.QPushButton("")
        del_btn.setIcon(cirrus_io.get_icon("close.svg"))
        del_btn.setFixedWidth(22)
        del_btn.setFixedHeight(22)
        del_btn.setFlat(True)
        del_btn.setIconSize(QtCore.QSize(22, 22))
        del_btn.clicked.connect(self.remove_me)
        main_layout.addWidget(del_btn)

        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)
    def data(self, index, role):

        r = index.row()
        val = self.__methods[r]

        if role == QtCore.Qt.ToolTipRole:

            if val == "Create":
                return "Create a new method"

            if val == "None":
                return "Set the current method to None"

            return "Method '" + val + "' code."

        if role == QtCore.Qt.DecorationRole:

            if val == "Create":
                ico = cirrus_io.get_icon("add.svg")
                return ico

            if val == "None":
                ico = cirrus_io.get_icon("close.svg")
                return ico

            ico = cirrus_io.get_icon(""arrow_right.svg")
            return ico

        if role == QtCore.Qt.DisplayRole:
            return val
    def __init__(self, plugin_settings, parent=None):
        super(PluginEntries, self).__init__(parent=parent)

        self.plugin_manager = parent

        self.plugin_settings = plugin_settings
        self.plugins = self.plugin_settings.plugins
        self.selected_plugin = ""

        self.setProperty("houdiniStyle", True)
        self.plugin_names = [n.get_plugin_name() for n in self.plugins]

        main_layout = QtWidgets.QHBoxLayout()
        main_layout.setAlignment(QtCore.Qt.AlignLeft)

        main_layout.addWidget(QtWidgets.QLabel("Plugin: "))

        self._adding_item = False
        self._removing_plugin = False
        self.plugins_combo = QtWidgets.QComboBox()
        self.plugins_combo.addItems(self.plugin_names)
        self.plugins_combo.addItem(cirrus_io.get_icon("add.svg"), "Create")

        main_layout.addWidget(self.plugins_combo)

        main_layout.addWidget(QtWidgets.QLabel("Executable(s):"))
        self.p_fam_executables = ExecutablesEntry()
        self.p_fam_executables.outsgn.connect(self.update_executable)
        main_layout.addWidget(self.p_fam_executables)

        add_cur_exe_btn = QtWidgets.QPushButton("")
        add_cur_exe_btn.setFixedHeight(32)
        add_cur_exe_btn.setFixedWidth(32)
        add_cur_exe_btn.setIcon(cirrus_io.get_icon("down.svg"))
        add_cur_exe_btn.setIconSize(QtCore.QSize(25, 25))
        add_cur_exe_btn.setToolTip("Add current running executable to the list")
        add_cur_exe_btn.clicked.connect(self.add_cur_exec)
        main_layout.addWidget(add_cur_exe_btn)

        remove_plugin_btn = QtWidgets.QPushButton("")
        remove_plugin_btn.setFixedHeight(32)
        remove_plugin_btn.setFixedWidth(32)
        remove_plugin_btn.setIcon(cirrus_io.get_icon("close.svg"))
        remove_plugin_btn.setIconSize(QtCore.QSize(25, 25))
        remove_plugin_btn.setToolTip("Remove selected plugin")
        remove_plugin_btn.clicked.connect(self.remove_plugin)
        main_layout.addWidget(remove_plugin_btn)

        main_layout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(main_layout)

        self.plugins_combo.currentIndexChanged.connect(self.update_selected_plugin)
        self.selected_plugin = self.plugins_combo.currentText()
        self.update_selected_plugin()
Exemple #6
0
    def __init__(self, parent=None):
        super(ProjectSelector, self).__init__(parent=parent)

        self.main_ui = parent

        main_layout = QtWidgets.QVBoxLayout()
        self.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                           QtWidgets.QSizePolicy.Expanding)
        main_layout.setAlignment(QtCore.Qt.AlignCenter)

        self.open_project_button = QtWidgets.QPushButton(" Open a project")
        self.open_project_button.setIconSize(QtCore.QSize(64, 64))
        self.open_project_button.setIcon(cirrus_io.get_icon("folder_open.svg"))
        self.open_project_button.clicked.connect(self.main_ui.init_root)
        self.open_project_button.setFlat(True)
        self.open_project_button.setStyleSheet(
            """QPushButton{background-color: transparent}
                                                  QPushButton:hover{background-color: rgba(90, 90, 185, 80)}"""
        )
        self.open_project_button.setContentsMargins(10, 10, 10, 10)
        main_layout.addWidget(self.open_project_button)

        self.history_layout = QtWidgets.QVBoxLayout()
        main_layout.addLayout(self.history_layout)

        self.setLayout(main_layout)

        self.init_history()
Exemple #7
0
    def __init__(self, name="", path="", parent=None):
        super(PanelFolder, self).__init__(parent=parent)

        self.panel = parent

        self.path = path
        self.name = name

        self.setToolTip("Path: " + str(self.path))

        self.setAutoFillBackground(True)
        self.setObjectName("panelFolder")
        self.setFixedHeight(45)
        self.main_layout = QtWidgets.QHBoxLayout()
        self.main_layout.setSpacing(5)
        self.main_layout.setAlignment(QtCore.Qt.AlignLeft
                                      | QtCore.Qt.AlignHCenter)
        self.ico = QtWidgets.QPushButton("")
        self.ico.setFlat(True)
        self.ico.setObjectName("folderIco")
        self.ico.setFixedHeight(28)
        self.ico.setIconSize(QtCore.QSize(26, 26))
        self.ico.setStyleSheet("background-color: transparent;border: 0px")
        self.ico.setIcon(cirrus_io.get_icon("folder.svg"))
        self.main_layout.addWidget(self.ico)
        self.label = QtWidgets.QLabel(name)
        self.label.setObjectName("panelFolderLabel")
        self.main_layout.addWidget(self.label)
        self.setLayout(self.main_layout)
        self.setContentsMargins(15, 0, 0, 0)
        self.init_buttons()
    def __init__(self, parent=None):
        super(PluginManager, self).__init__(parent=parent)

        self.main_ui = parent

        self.setProperty("houdiniStyle", True)
        self.setWindowTitle("Plugin Manager")
        self.setWindowIcon(cirrus_io.get_icon("plugin.svg"))

        self.plugins = {}

        self.plugin_settings = cirrus_plugin_settings.PluginSettings(plugin_manager=self)

        cw = QtWidgets.QWidget()
        main_layout = QtWidgets.QVBoxLayout()
        main_layout.setAlignment(QtCore.Qt.AlignTop)
        self.plugin_infos_layout = QtWidgets.QVBoxLayout()
        self.plugin_infos_layout.setAlignment(QtCore.Qt.AlignTop)

        self.plugin_entries = PluginEntries(self.plugin_settings, self)
        main_layout.addWidget(self.plugin_entries)
        main_layout.addLayout(self.plugin_infos_layout)

        cw.setLayout(main_layout)
        self.setCentralWidget(cw)
Exemple #9
0
    def __init__(self, parent=None):
        super(PathBarDelimiter, self).__init__(parent=parent)

        self.setObjectName("navBarDelimiter")

        self.setFixedHeight(24)
        self.setFixedWidth(24)
        self.setContentsMargins(0, 0, 0, 0)
        self.setPixmap(
            cirrus_io.get_icon("pathbar_delimiter.png").pixmap(22, 22))
Exemple #10
0
    def init_buttons(self):

        file_extension = self.path.split('.')[-1]
        icon = ICONS + "file_types/" + file_extension + ".svg"
        if not os.path.exists(icon):
            self.ico.setIcon(cirrus_io.get_icon("document.svg"))
        else:
            self.ico.setIcon(QtGui.QIcon(icon))
        self.ico.setObjectName("fileIco")

        self.activity_progress = QtWidgets.QProgressBar()
        self.activity_progress.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                             QtWidgets.QSizePolicy.Minimum)
        self.activity_progress.setVisible(False)
        self.activity_progress.setStyleSheet("""QProgressBar {
                                                border: 0px;
                                                color: #cbcbcb;
                                 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                                             stop: 0 #3d3d3d, stop: 1.0 #303030);}
                                              QProgressBar::chunk {
                                 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                                             stop: 0 #437db9, stop: 1.0 #4b89ca);
                                                width: 20px;}""")
        self.main_layout.addWidget(self.activity_progress)

        self.activity_upload_ico = QtWidgets.QLabel()
        self.activity_upload_ico.setObjectName("activityWidget")
        self.activity_upload_ico.setFixedHeight(29)
        self.activity_upload_ico.setFixedWidth(29)
        self.upload_movie = QtGui.QMovie(ICONS + "upload.gif", parent=self)
        self.activity_upload_ico.setMovie(self.upload_movie)
        self.activity_upload_ico.setVisible(False)
        self.main_layout.addWidget(self.activity_upload_ico)

        self.activity_download_ico = QtWidgets.QLabel()
        self.activity_download_ico.setObjectName("activityWidget")
        self.activity_download_ico.setFixedHeight(29)
        self.activity_download_ico.setFixedWidth(29)
        self.download_movie = QtGui.QMovie(ICONS + "download.gif", parent=self)
        self.activity_download_ico.setMovie(self.download_movie)
        self.activity_download_ico.setVisible(False)
        self.main_layout.addWidget(self.activity_download_ico)

        self.buttons_layout = QtWidgets.QHBoxLayout()
        self.buttons_layout.addStretch(1)
        self.buttons_layout.setAlignment(QtCore.Qt.AlignRight)

        self.file_buttons = PanelFileButtons(self, state=self.state)
        self.buttons_layout.addWidget(self.file_buttons)

        self.main_layout.addLayout(self.buttons_layout)

        self.plugin = None
        self.init_plugin()
Exemple #11
0
    def end_state_refreshing(self, state, metadata):

        self.activity.stop()
        self.activity.setVisible(False)

        self.is_on_cloud_button.refresh_state(state)

        self.metadata = metadata
        self.state = state

        self.save_to_cloud_button.setVisible(True)
        self.is_on_cloud_button.setVisible(True)
        self.lock_button.setVisible(True)
        self.infos_button.setVisible(True)
        self.refresh_button.setVisible(True)

        lock_user = metadata.get("user", "")
        lock_message = metadata.get("lock_message", "No message")
        lock_time = metadata.get("lock_time", "No Timestamp")

        if lock_user == "":
            self.is_locked = cirrus_objects.FileLockState.UNLOCKED
            self.lock_button.setIcon(cirrus_io.get_icon("notlocked.png"))
            self.lock_button.setToolTip("File not locked")

        elif lock_user == cirrus_objects.ObjectMetadata.get_user_uid():
            self.is_locked = cirrus_objects.FileLockState.SELF_LOCKED
            self.lock_button.setIcon(cirrus_io.get_icon("lock_self.png"))
            tooltip = ("File locked by: " + lock_user + '\n'
                       "Message: " + lock_message + '\n'
                       "Locked since: " + lock_time + "")
            self.lock_button.setToolTip(tooltip)
        else:
            self.is_locked = cirrus_objects.FileLockState.LOCKED
            self.lock_button.setIcon(cirrus_io.get_icon("locked.png"))
            tooltip = ("File locked by: " + lock_user + '\n'
                       "Message: " + lock_message + '\n'
                       "Locked since: " + lock_time + "")
            self.lock_button.setToolTip(tooltip)

        self.state_fetcher = None
    def __init__(self, values, parent=None, existing_entries=[]):
        super(FileBindingsInput, self).__init__(parent=parent)

        self.setWindowTitle("Edit file bindings")

        self.validated = False
        self.entries_values = values
        self.existing_entries = existing_entries

        main_layout = QtWidgets.QVBoxLayout()
        main_layout.setAlignment(QtCore.Qt.AlignTop)

        entries_layout = QtWidgets.QHBoxLayout()
        entries_layout.setAlignment(QtCore.Qt.AlignLeft)

        entries_layout.addWidget(QtWidgets.QLabel("Entries (separated by a coma ','):"))
        self.entries = QtWidgets.QLineEdit(values)
        entries_layout.addWidget(self.entries)
        main_layout.addLayout(entries_layout)

        btn_layout = QtWidgets.QHBoxLayout()

        valid_btn = QtWidgets.QPushButton("Ok")
        valid_btn.setIcon(cirrus_io.get_icon("checkmark.svg"))
        valid_btn.setIconSize(QtCore.QSize(22, 22))
        valid_btn.clicked.connect(self.valid)
        btn_layout.addWidget(valid_btn)

        cancel_btn = QtWidgets.QPushButton("Cancel")
        cancel_btn.setIcon(cirrus_io.get_icon("close.svg"))
        cancel_btn.setIconSize(QtCore.QSize(22, 22))
        cancel_btn.clicked.connect(self.close)
        btn_layout.addWidget(cancel_btn)

        main_layout.addLayout(btn_layout)

        self.setLayout(main_layout)
Exemple #13
0
    def append_version(self, date, size, is_latest, version_id, delete_marker,
                       message, user):

        self.table.setRowCount(self.n_items + 1)

        # latest
        time_lbl = QtWidgets.QLabel(str(date.ctime()))
        time_lbl.setContentsMargins(2, 2, 2, 2)
        time_lbl.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
        self.table.setCellWidget(self.n_items, 0, time_lbl)

        # comment
        if message != "None":
            message = message + '\n(user: '******'{0:.3f} Mb'.format(size * 0.000001)
        size_lbl = QtWidgets.QLabel(s)
        size_lbl.setContentsMargins(2, 2, 2, 2)
        size_lbl.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
        self.table.setCellWidget(self.n_items, 2, size_lbl)

        # get
        get_btn = QtWidgets.QPushButton("")
        get_btn.setFlat(True)
        get_btn.setStyleSheet("""QPushButton{background: transparent}""")
        get_btn.setIcon(cirrus_io.get_icon("download.svg"))

        get_btn.setIconSize(QtCore.QSize(26, 26))
        get_btn.clicked.connect(lambda v=version_id: self.download_version(v))
        self.table.setCellWidget(self.n_items, 3, get_btn)

        self.table.resizeColumnsToContents()
        self.table.resizeRowsToContents()
        self.n_items += 1
Exemple #14
0
    def end_progress(self, mode):

        if mode == 0:
            self.upload_movie.stop()
            self.activity_upload_ico.setVisible(False)
        else:
            self.activity_download_ico.setVisible(False)
            self.download_movie.stop()

        self.activity_progress.setValue(0)
        self.activity_progress.setVisible(False)
        self.file_buttons.enable_buttons(True)

        ico = cirrus_io.get_icon("cloud_checkmark.png")
        self.file_buttons.is_on_cloud_button.setIcon(ico)

        self.file_buttons.refresh_state()

        # check if a plugin is loaded, if yes, execute the "on_get" method of the plugin
        if self.plugin:
            if mode == 0:
                self.plugin.exec_on_save(path=self.local_file_path)
            else:
                self.plugin.exec_on_get(path=self.local_file_path)
Exemple #15
0
    def __init__(self, parent=None):
        super(ProjectGetter, self).__init__(parent=parent)

        self.setProperty("houdiniStyle", IS_HOUDINI)

        self.mainui = parent

        self.setWindowTitle("Get Project From Cloud")
        self.setWindowIcon(cirrus_io.get_icon("inbox.svg"))
        self.setFixedHeight(170)

        init_connection()
        self.client = ConnectionInfos.get("s3_client")
        self.resource = ConnectionInfos.get("s3_resource")

        self.worker = None
        self.prj_path = ""

        cw = QtWidgets.QWidget()
        main_layout = QtWidgets.QVBoxLayout()
        main_layout.setAlignment(QtCore.Qt.AlignTop)

        # project to load
        prj_list_layout = QtWidgets.QHBoxLayout()
        prj_list_layout.setSpacing(31)
        prj_list_layout.setAlignment(QtCore.Qt.AlignLeft)
        prj_list_layout.addWidget(QtWidgets.QLabel("Project:"))
        self.project_list = QtWidgets.QComboBox()
        self.project_list.addItems(self.list_bucket())
        prj_list_layout.addWidget(self.project_list)
        main_layout.addLayout(prj_list_layout)

        # local path
        self.local_path = ""
        tgt_folder_layout = QtWidgets.QHBoxLayout()
        tgt_folder_layout.addWidget(QtWidgets.QLabel("Local Folder:"))
        self.local_folder_input = QtWidgets.QLineEdit()
        self.local_folder_input.setMinimumWidth(350)
        self.local_folder_input.textChanged.connect(
            self.update_local_folder_input)
        tgt_folder_layout.addWidget(self.local_folder_input)
        self.pick_folder_btn = QtWidgets.QPushButton("...")
        self.pick_folder_btn.clicked.connect(self.get_local_dir)
        tgt_folder_layout.addWidget(self.pick_folder_btn)
        main_layout.addLayout(tgt_folder_layout)

        # progress bars
        self.nelements_lbl = QtWidgets.QLabel("-")
        main_layout.addWidget(self.nelements_lbl)
        self.elements_progress = QtWidgets.QProgressBar()
        self.elements_progress.setStyleSheet("""QProgressBar {
                                                border: 1px solid black;
                                                color: #cbcbcb;
                                 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                                             stop: 0 #3d3d3d, stop: 1.0 #303030);}
                                              QProgressBar::chunk {
                                 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                                             stop: 0 #437db9, stop: 1.0 #4b89ca);
                                                width: 20px;}""")
        main_layout.addWidget(self.elements_progress)

        self.start_btn = QtWidgets.QPushButton("Start")
        self.start_btn.setIconSize(QtCore.QSize(32, 32))
        self.start_btn.setIcon(cirrus_io.get_icon("checkmark.svg"))
        self.start_btn.clicked.connect(self.start_download)

        self.cancel_btn = QtWidgets.QPushButton("Cancel")
        self.cancel_btn.setIconSize(QtCore.QSize(32, 32))
        self.cancel_btn.setIcon(cirrus_io.get_icon("close.svg"))
        self.cancel_btn.setVisible(False)
        self.cancel_btn.clicked.connect(self.cancel_download)

        main_layout.addWidget(self.start_btn)
        main_layout.addWidget(self.cancel_btn)

        cw.setLayout(main_layout)
        self.setCentralWidget(cw)
Exemple #16
0
    def __init__(self, parent, state=cirrus_objects.FileState.NONE):
        super(PanelFileButtons, self).__init__(parent=parent)

        self.panelfile = parent
        self.metadata = None
        self.state_fetcher = None
        self.state = state
        self.local_file_path = self.panelfile.local_file_path
        self.is_locked = cirrus_objects.FileLockState.UNLOCKED

        self.buttons_layout = QtWidgets.QHBoxLayout()

        self.activity = ActivityWidget()
        self.activity.setFixedHeight(26)
        self.buttons_layout.addWidget(self.activity)
        self.activity.stop()
        self.activity.setVisible(False)

        self.save_to_cloud_button = QtWidgets.QPushButton("")
        self.save_to_cloud_button.setObjectName("flatButton")
        self.save_to_cloud_button.setIcon(cirrus_io.get_icon("cloud_save.png"))
        self.save_to_cloud_button.setIconSize(QtCore.QSize(26, 26))
        self.save_to_cloud_button.setFixedSize(QtCore.QSize(28, 28))
        self.save_to_cloud_button.setToolTip(
            "Press this button to save the file to the cloud\n"
            "You must lock the file first")
        self.save_to_cloud_button.clicked.connect(self.panelfile.save_to_cloud)
        self.buttons_layout.addWidget(self.save_to_cloud_button)

        self.is_on_cloud_button = GetFileFromCloudButton(self.panelfile,
                                                         self.state,
                                                         parent=self)
        self.is_on_cloud_button.panelfile = self.panelfile
        self.is_on_cloud_button.setIconSize(QtCore.QSize(26, 26))
        self.is_on_cloud_button.setFixedSize(QtCore.QSize(28, 28))
        self.buttons_layout.addWidget(self.is_on_cloud_button)

        self.lock_button = QtWidgets.QPushButton("")
        self.lock_button.setObjectName("flatButton")
        self.lock_button.setIcon(cirrus_io.get_icon("notlocked.png"))
        self.lock_button.setIconSize(QtCore.QSize(26, 26))
        self.lock_button.setFixedSize(QtCore.QSize(28, 28))
        self.lock_button.clicked.connect(self.lock_file)
        self.buttons_layout.addWidget(self.lock_button)

        self.infos_button = QtWidgets.QPushButton("")
        self.infos_button.setObjectName("flatButton")
        self.infos_button.setIcon(cirrus_io.get_icon("info.svg"))
        self.infos_button.setIconSize(QtCore.QSize(26, 26))
        self.infos_button.setFixedSize(QtCore.QSize(28, 28))
        self.infos_button.clicked.connect(self.open_infos)
        self.buttons_layout.addWidget(self.infos_button)

        self.refresh_button = QtWidgets.QPushButton("")
        self.refresh_button.setIconSize(QtCore.QSize(26, 26))
        self.refresh_button.setFixedSize(QtCore.QSize(28, 28))
        self.refresh_button.setObjectName("flatButton")
        self.refresh_button.setToolTip("Refresh current file metadata")
        self.refresh_button.setIcon(cirrus_io.get_icon("reload.svg"))
        self.refresh_button.clicked.connect(self.refresh_state)
        self.buttons_layout.addWidget(self.refresh_button)

        self.setLayout(self.buttons_layout)

        self.refresh_state()
Exemple #17
0
    def lock_file(self):

        Logger.Log.debug("Refresh state before locking file")
        state, metadata = cirrus_io.refresh_state(self.local_file_path)
        self.end_state_refreshing(state, metadata)

        # if not on cloud, you can't lock the file
        if self.state == cirrus_objects.FileState.LOCAL_ONLY:
            Logger.Log.debug("Trying to lock a local-only file: " +
                             self.local_file_path)
            QtWidgets.QMessageBox.warning(
                self, "Error", ("Trying to lock a local-only file,\n"
                                "Send the object on the cloud first."))
            return

        if self.state == cirrus_objects.FileState.CLOUD_ONLY:
            Logger.Log.debug("Trying to lock a cloud-only file: " +
                             self.local_file_path)
            QtWidgets.QMessageBox.warning(
                self, "Error",
                ("Trying to lock a cloud-only file,\n"
                 "Get the latest version from the cloud first."))
            return

        if self.is_locked == cirrus_objects.FileLockState.LOCKED:
            QtWidgets.QMessageBox.warning(self, "Error", "File already locked")
            return

        if self.is_locked == cirrus_objects.FileLockState.SELF_LOCKED:

            ico = QtWidgets.QMessageBox.Warning
            confirm_msg = "Do you want to unlock the file ?"
            ask = QtWidgets.QMessageBox(ico, "Confirm", confirm_msg,
                                        buttons = QtWidgets.QMessageBox.StandardButton.Yes|\
                                                  QtWidgets.QMessageBox.StandardButton.No,
                                        parent=self)
            geo = ask.frameGeometry()

            ask.move(QtGui.QCursor.pos() - (geo.topRight() * 3))
            ask.setStyleSheet("""QMessageBox{background-color: #3e5975}
                                 QFrame{background-color: #3e5975}
                                 QLabel{background-color: #3e5975}""")
            if ask.exec_() == QtWidgets.QMessageBox.StandardButton.No:
                return

            toggle = False
        else:
            toggle = True

        lock_message = ""

        if toggle:
            ask_lock_message = cirrus_widgets_inputs.MessageInput(
                False, True, self)
            ask_lock_message.exec_()
            lock_message = ask_lock_message.message
            if ask_lock_message.cancel:
                return

        m = cirrus_io.lock_object(object_path=self.local_file_path,
                                  toggle=toggle,
                                  lock_message=lock_message)

        if toggle:
            self.is_locked = cirrus_objects.FileLockState.SELF_LOCKED
            tooltip = ("File locked by: " + m.get("user", "") + '\n'
                       "Message: " + m.get("lock_message", "No Message") + '\n'
                       "Locked since: " + m.get("lock_time", "No timestamp") +
                       "")
            self.lock_button.setIcon(cirrus_io.get_icon("lock_self.png"))
            self.lock_button.setToolTip(tooltip)
        else:
            self.is_locked = cirrus_objects.FileLockState.UNLOCKED
            self.lock_button.setIcon(cirrus_io.get_icon("notlocked.png"))
            self.lock_button.setToolTip("File not locked")

        if self.panelfile.plugin:
            self.panelfile.plugin.exec_on_lock(path=self.local_file_path)
    def __init__(self, plugin_infos, parent=None):
        super(PluginInfos, self).__init__(parent=parent)

        self.unsaved_changes = False
        self.plugin_manager = parent

        self.plugin_infos = plugin_infos
        self.bindings = {}
        self.methods = {}
        self.script_code = self.plugin_infos.script_code
        self.creating_new_method = False
        self.creating_binding = False
        self.cur_selected_method = ""

        r = self.plugin_infos.get("files,uid", level="bindings")
        if r:
            for files, uid in r:
                self.bindings[', '.join(files)] = uid
                self.methods[', '.join(files)] = self.plugin_infos.get("methods",
                                                                       level="bindings",
                                                                       uid=uid)
        # methods available data
        li = []
        if self.script_code:
            li = [v for v in self.script_code.iterkeys()]
            li.append("Create")
            li.append("None")
        else:
            li = ["Create", "None"]
        self.method_list = MethodListModel(methods=li)

        self.main_layout = QtWidgets.QVBoxLayout()
        self.main_layout.setAlignment(QtCore.Qt.AlignTop)

        self.file_bindings_lay = QtWidgets.QHBoxLayout()
        self.file_bindings_lay.setAlignment(QtCore.Qt.AlignLeft)
        self.file_bindings_lay.addWidget(QtWidgets.QLabel("File Bindings:"))

        self.file_bindings_combo = QtWidgets.QComboBox()
        self.file_bindings_combo.addItems([v for v in self.bindings.iterkeys()])
        self.file_bindings_combo.addItem(cirrus_io.get_icon("add.svg"), "Create")
        self.file_bindings_combo.currentIndexChanged.connect(self.update_selected_binding)
        self.file_bindings_lay.addWidget(self.file_bindings_combo)
        
        edit_files_btn = QtWidgets.QPushButton("")
        edit_files_btn.setFixedHeight(32)
        edit_files_btn.setFixedWidth(32)
        edit_files_btn.setIcon(cirrus_io.get_icon("edit.svg"))
        edit_files_btn.setIconSize(QtCore.QSize(25, 25))
        edit_files_btn.setToolTip("Edit files list")
        edit_files_btn.clicked.connect(self.edit_file_bindings)
        self.file_bindings_lay.addWidget(edit_files_btn)

        delete_files_bindings_btn = QtWidgets.QPushButton("")
        delete_files_bindings_btn.setFixedHeight(32)
        delete_files_bindings_btn.setFixedWidth(32)
        delete_files_bindings_btn.setIcon(cirrus_io.get_icon("close.svg"))
        delete_files_bindings_btn.setIconSize(QtCore.QSize(25, 25))
        delete_files_bindings_btn.setToolTip("Delete selected files binding.")
        delete_files_bindings_btn.clicked.connect(self.delete_files_binding)
        self.file_bindings_lay.addWidget(delete_files_bindings_btn)

        self.main_layout.addLayout(self.file_bindings_lay)

        actions_lay = QtWidgets.QHBoxLayout()
        actions_lay.setAlignment(QtCore.Qt.AlignLeft)
        actions_lay.addWidget(QtWidgets.QLabel("Action:"))

        self.actions_combo = QtWidgets.QComboBox()
        self.actions_combo.addItem(cirrus_io.get_icon("cloud_checkmark.png"), "On Get")
        self.actions_combo.addItem(cirrus_io.get_icon("cloud_save.png"), "On Save")
        self.actions_combo.addItem(cirrus_io.get_icon("lock_self.png"), "On Lock")
        self.actions_combo.addItem(cirrus_io.get_icon("txt.svg"), "On Icon Clicked")
        self.actions_combo.currentIndexChanged.connect(self.update_selected_action)
        actions_lay.addWidget(self.actions_combo)
        
        self.main_layout.addLayout(actions_lay)

        self.assigned_method_name = QtWidgets.QLabel("Assigned Method: None")
        self.main_layout.addWidget(self.assigned_method_name)

        # init first menu entries for current binding
        self.menu_entries_lay = QtWidgets.QVBoxLayout()
        self.menu_entries_lay.setAlignment(QtCore.Qt.AlignTop)
        self.menu_entries_lay.setContentsMargins(0, 0, 0, 0)
        self.menu_entries_dict = {}
        menu_entries = OnIconMenuEntries(self.method_list, parent=self)
        menu_entries.setVisible(False)
        cur_binding = self.file_bindings_combo.currentText()
        methods = self.methods.get(cur_binding)
        cur_meth = methods.get("on_icon_clicked")
        if cur_meth:
            for k, v in cur_meth.iteritems():
                menu_entries.append_entry(k, v, False)

        self.menu_entries_dict[self.file_bindings_combo.currentText()] = menu_entries
        self.menu_entries_lay.addWidget(menu_entries)
        self.main_layout.addLayout(self.menu_entries_lay)

        methods_lay = QtWidgets.QHBoxLayout()
        methods_lay.setAlignment(QtCore.Qt.AlignLeft)

        methods_lay.addWidget(QtWidgets.QLabel("Methods available:"))
        self.methods_combo = QtWidgets.QComboBox()
        methods_lay.addWidget(self.methods_combo)
        self.methods_combo.setModel(self.method_list)

        apply_method_btn = QtWidgets.QPushButton("")
        apply_method_btn.setFixedHeight(32)
        apply_method_btn.setFixedWidth(32)
        apply_method_btn.setIcon(cirrus_io.get_icon("publish.svg"))
        apply_method_btn.setIconSize(QtCore.QSize(25, 25))
        apply_method_btn.setToolTip("Apply method to selected action.")
        apply_method_btn.clicked.connect(self.apply_method)
        methods_lay.addWidget(apply_method_btn)

        save_method_code_btn = QtWidgets.QPushButton("")
        save_method_code_btn.setFixedHeight(32)
        save_method_code_btn.setFixedWidth(32)
        save_method_code_btn.setIcon(cirrus_io.get_icon("save.svg"))
        save_method_code_btn.setIconSize(QtCore.QSize(25, 25))
        save_method_code_btn.setToolTip("Save method code.")
        save_method_code_btn.clicked.connect(self.save_method_code)
        methods_lay.addWidget(save_method_code_btn)

        delete_method_btn = QtWidgets.QPushButton("")
        delete_method_btn.setFixedHeight(32)
        delete_method_btn.setFixedWidth(32)
        delete_method_btn.setIcon(cirrus_io.get_icon("close.svg"))
        delete_method_btn.setIconSize(QtCore.QSize(25, 25))
        delete_method_btn.setToolTip("Delete method.")
        delete_method_btn.clicked.connect(self.delete_method)
        methods_lay.addWidget(delete_method_btn)

        self.main_layout.addLayout(methods_lay)
        
        self.code_editor = CodeEditor()
        self.main_layout.addWidget(self.code_editor)
        self.methods_combo.currentIndexChanged.connect(self.update_selected_method)

        self.save_plugin_btn = QtWidgets.QPushButton("Save Current Plugin")
        self.save_plugin_btn.setIcon(cirrus_io.get_icon("save.svg"))
        self.save_plugin_btn.setIconSize(QtCore.QSize(22, 22))
        self.save_plugin_btn.clicked.connect(self.save_plugin)
        self.main_layout.addWidget(self.save_plugin_btn)

        self.update_selected_action()
        self.update_selected_method()

        self.setLayout(self.main_layout)
    def __init__(self, data, parent=None):
        super(MethodDeletionWarning, self).__init__(parent=parent)

        self.VALID = False

        self.setWindowTitle("Warning")
        main_layout = QtWidgets.QVBoxLayout()

        sub_layout = QtWidgets.QHBoxLayout()
        sub_layout.setAlignment(QtCore.Qt.AlignLeft)

        risk = QtWidgets.QLabel("")
        risk.setPixmap(cirrus_io.get_icon("risk.svg").pixmap(64, 64))
        risk.setFixedWidth(64)
        risk.setFixedHeight(64)
        sub_layout.addWidget(risk)

        warning_layout = QtWidgets.QVBoxLayout()
        warning_layout.setAlignment(QtCore.Qt.AlignTop)
        warning_layout.addWidget(QtWidgets.QLabel(("One or more bindings use this method !"
                                                   " Delete the method anyway ?")))
        warning_layout.addWidget(QtWidgets.QLabel("Binding(s) involved:"))

        for k, v in data.iteritems():

            _lay = QtWidgets.QHBoxLayout()
            
            _lbl = QtWidgets.QLabel("")
            _lbl.setContentsMargins(15, 0, 0, 0)
            _lbl.setPixmap(cirrus_io.get_icon("white_list.svg").pixmap(24, 24))
            _lbl.setFixedWidth(39)

            _lay.addWidget(_lbl)
            _lay.addWidget(QtWidgets.QLabel(k))

            warning_layout.addLayout(_lay)

            _lay2 = QtWidgets.QHBoxLayout()
            
            _lbl2 = QtWidgets.QLabel("")
            _lbl2.setContentsMargins(30, 0, 0, 0)
            _lbl2.setPixmap(cirrus_io.get_icon("arrow_right.svg").pixmap(16, 16))
            _lbl2.setFixedWidth(46)

            _lay2.addWidget(_lbl2)
            _lay2.addWidget(QtWidgets.QLabel(', '.join(v[1:])))

            warning_layout.addLayout(_lay2)
            warning_layout.addWidget(QtWidgets.QLabel(""))

        sub_layout.addLayout(warning_layout)
        main_layout.addLayout(sub_layout)

        btn_layout = QtWidgets.QHBoxLayout()
        self.accept_btn = QtWidgets.QPushButton("Yes, Delete Method")
        self.accept_btn.setIcon(cirrus_io.get_icon("checkmark.svg"))
        self.accept_btn.setIconSize(QtCore.QSize(26, 26))
        self.accept_btn.clicked.connect(self.valid_act)
        btn_layout.addWidget(self.accept_btn)

        self.cancel_btn = QtWidgets.QPushButton("Cancel")
        self.cancel_btn.setIcon(cirrus_io.get_icon("close.svg"))
        self.cancel_btn.setIconSize(QtCore.QSize(26, 26))
        self.cancel_btn.clicked.connect(self.close)
        btn_layout.addWidget(self.cancel_btn)

        main_layout.addLayout(btn_layout)
        self.setLayout(main_layout)
Exemple #20
0
    def __init__(self,
                 panel_name="",
                 panel_folder_path="",
                 subfolder="",
                 parent=None):
        super(Panel, self).__init__(parent=parent)

        self.main_ui = parent

        self.subfolder = subfolder
        self.fetcher = None
        self.cur_folder_id = 0
        self.panel_name = panel_name

        self.setProperty("houdiniStyle", IS_HOUDINI)
        self.setObjectName("panelBase")
        self.main_layout = QtWidgets.QVBoxLayout()
        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setSpacing(0)
        self.main_layout.setAlignment(QtCore.Qt.AlignTop)

        # panel header
        self.header_layout = QtWidgets.QHBoxLayout()
        self.header = QtWidgets.QFrame()
        self.header.setAutoFillBackground(True)
        self.header.setObjectName("header")
        self.ico = QtWidgets.QLabel("")
        self.ico.setFixedHeight(22)
        self.ico.setStyleSheet("background-color: transparent")
        self.ico.setPixmap(
            cirrus_io.get_icon("folder_open.svg").pixmap(28, 28))

        self.header_layout.addWidget(self.ico)
        lbl = QtWidgets.QLabel(panel_name.split('/')[-1])
        lbl.setObjectName("headerLabel")
        self.header_layout.addWidget(lbl)
        self.header_layout.addStretch(1)

        self.activity_w = ActivityWidget()
        self.activity_w.setVisible(False)
        self.header_layout.addWidget(self.activity_w)

        self.refresh_button = QtWidgets.QPushButton("")
        self.refresh_button.setFixedHeight(28)
        self.refresh_button.setFixedWidth(28)
        self.refresh_button.setIconSize(QtCore.QSize(26, 26))
        self.refresh_button.setObjectName("headerButton")
        self.refresh_button.clicked.connect(
            lambda: self.init_fetching(reset=True))
        self.refresh_button.setToolTip("Refresh current folder state")
        self.refresh_button.setIcon(cirrus_io.get_icon("reload.svg"))
        self.header_layout.addWidget(self.refresh_button)
        self.header.setLayout(self.header_layout)
        self.main_layout.addWidget(self.header)

        # elements
        self.elements = []
        self.element_scroll = QtWidgets.QScrollArea()
        self.element_scroll.setObjectName("elementScroll")
        self.element_scroll.setWidgetResizable(True)
        self.elements_layout = QtWidgets.QVBoxLayout()
        self.elements_layout.setAlignment(QtCore.Qt.AlignTop)
        self.elements_layout.setSpacing(0)
        self.elements_layout.setContentsMargins(0, 0, 0, 0)
        self.elements_widget = QtWidgets.QWidget()
        self.elements_widget.setLayout(self.elements_layout)
        self.element_scroll.setWidget(self.elements_widget)

        self.main_layout.addWidget(self.element_scroll)

        self.setLayout(self.main_layout)

        self.init_fetching()