Ejemplo n.º 1
0
    def __popupAt(self, pos):
        index = self.tableWidget.indexAt(pos)
        if not index.isValid(): return

        menu = QMenu()
        styler = style.Styler()
        styler.initStyle(menu)

        acts = []
        menu_options = ["Delete", "Change type", "Show in Explorer"]
        for opt in menu_options:
            if opt is None:
                menu.addSeparator()
            else:
                action = menu.addAction(opt)
                acts.append(action)
        try:
            ind = acts.index(
                menu.exec_(self.tableWidget.viewport().mapToGlobal(pos)))
            item = self.tableWidget.item(index.row(), 1).text()
            if ind == 0:
                self.attachments.pop(item)
                self.update_files()
            elif ind == 1:
                self.attachments[item] = not self.attachments[item]
                self.update_files()
            elif ind == 2:
                utils.show_dir(item)

        except ValueError:
            pass
Ejemplo n.º 2
0
    def __popupAt(self, pos):
        index = self.tableWidget.indexAt(pos)
        if not index.isValid(): return

        if self.__selected_task_id is not None:
            task = self.conn.task(self.__selected_task_id)
            if task is not None:
                menu_options = [
                    "Start working on this file",
                    "Open without Starting the Task", None, "Link", "Embed",
                    None, "Show in Explorer...", "Copy file path to Clipboard"
                ]
                extra = {"file_path": self.__selected_file_path}
                res = wapp.menu(task,
                                self.tableWidget.viewport().mapToGlobal(pos),
                                menu_options, "menu_file", extra)

                if res is not None and res in menu_options:
                    if res == menu_options[0]:
                        self.startTask()
                    elif res == menu_options[1]:
                        self.openSelectedFile()
                    elif res == menu_options[3]:
                        self.importSelectedFile(True)
                    elif res == menu_options[4]:
                        self.importSelectedFile(False)
                    elif res == menu_options[6]:
                        if self.__selected_file_path is not None:
                            if not utils.show_dir(self.__selected_file_path):
                                wapp.error("File does not exist: {}".format(
                                    self.__selected_file_path))
                    elif res == menu_options[7]:
                        if self.__selected_file_path is not None:
                            capp.copyToClipboard(self.__selected_file_path)
Ejemplo n.º 3
0
	def z_open_task_folder(self):
		task_id = self.config.task_for_file(capp.file_name(self.log))

		task = self.db.task(task_id)
		if task is not None:
			task_paths = self.config.translate(task)
			taskPath = task_paths["publish"] if task_paths.get("publish", None) is not None else task_paths.get("version", None)
			if taskPath is not None:
				return utils.show_dir(taskPath)

		return False
Ejemplo n.º 4
0
def browse():
    try:
        from tentaculo.core import config
        db = connect_db()
        conf = config.Config()
        task_data = cerebro.core.current_task().data()

        task = db.task(task_data[cerebro.aclasses.Task.DATA_ID])
        task_paths = conf.translate(task)
        if task_paths is not None:
            open_path = task_paths["publish"] if len(
                task_paths.get("publish", "")) > 0 else task_paths.get(
                    "version", None)
            opened = utils.show_dir(open_path)
            if not opened:
                cerebro_message("Task folder does not exist!")
        else:
            cerebro_message("Task translation failed!")

    except Exception as e:
        cerebro_message(repr(e))
Ejemplo n.º 5
0
    def __popupAt(self, pos):
        index = self.tableWidget.indexAt(pos)
        if not index.isValid(): return

        taskPath = None
        taskCerebro = None
        if self.task_id is not None:
            task = self.conn.task(self.task_id)
            if task is not None:
                task_paths = self.config.translate(task)
                taskCerebro = task["path"] + task["name"]
                taskPath = task_paths["publish"] if len(
                    task_paths.get("publish", "")) > 0 else task_paths.get(
                        "version", None)

                menu_options = [
                    "Open in Cerebro...", None, "Copy local path to Clipboard",
                    "Show in Explorer..."
                ]
                res = wapp.menu(task,
                                self.tableWidget.viewport().mapToGlobal(pos),
                                menu_options, "menu_task")
                if res is not None:
                    if res in menu_options and len(taskPath) and len(
                            taskCerebro):
                        if res == menu_options[0]:
                            webbrowser.open(
                                utils.string_unicode(
                                    r"cerebro://{0}?tid={1}").format(
                                        taskCerebro, self.task_id))
                        elif res == menu_options[2]:
                            capp.copyToClipboard(taskPath)
                        elif res == menu_options[3]:
                            if not utils.show_dir(taskPath):
                                wapp.error(
                                    "Directory does not exist: {}".format(
                                        taskPath))
                    else:
                        # Hook used - update task data
                        self.refresh.emit()