Beispiel #1
0
 def newFolder(self):
     (folderName, ok) = QInputDialog.getText(self, self.tr("Folder Name"), self.tr("Folder Name: "))
     if ok and folderName:
         index = self.tree.selectionModel().currentIndex()
         selection = self.files.filePath(index)
         if QFileInfo(selection).isDir():
             QDir(selection).mkdir(folderName)
         else:
             QDir(snippetPath).mkdir(folderName)
Beispiel #2
0
class DataView(object):
    uifile = QDir(os.path.dirname(os.path.realpath(__file__)))

    def setupUi(self, Form):
        if not Form.objectName():
            Form.setObjectName(u"Form")
        Form.resize(529, 777)
        self.verticalLayout = QVBoxLayout(Form)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.stepsLayout = QVBoxLayout()
        self.stepsLayout.setSpacing(10)
        self.stepsLayout.setObjectName(u"stepsLayout")
        self.stepsLayout.setSizeConstraint(QLayout.SetMaximumSize)
        self.stepsLayout.setContentsMargins(0, 0, 0, 0)

        self.verticalLayout.addLayout(self.stepsLayout)

        self.retranslateUi(Form)

        QMetaObject.connectSlotsByName(Form)

    # setupUi

    def retranslateUi(self, form):
        form.setWindowTitle(
            QCoreApplication.translate(b"dataPane", b"dataPane", None))
    def open_file_btn(self):
        name = QtWidgets.QFileDialog.getOpenFileName(
            self,
            'Open File',
            dir=QDir("../mockapp").absolutePath(),
            filter="Python file (*.py)")
        if not name[0]: return
        self.core.analyse_file(name[0])
        self.data = self.core.get_data
        if self.core.check_if_exists():
            self.dump_output_helper()
            self.ui.config_label.setText(
                'Found ATG config file in directory and loaded previously choices'
            )
            self.create_combo_box_items()
            return

        if self.data and isinstance(self.data, dict):
            self.ui.path_line.setText(name[0])
            self.ui.stackedWidget.setCurrentWidget(self.ui.processing)
            FunctionsUi.reset_styling(self, "btn_processing")
            self.ui.btn_processing.setStyleSheet(
                FunctionsUi.select_menu(self.ui.btn_processing.styleSheet()))
            self.create_combo_box_items()

        else:
            self.ui.error_msg_label.setText(
                'Please select a Python File that has Classes with methods or functions, and they have some arguments'
            )
Beispiel #4
0
class CropOp(OpUi, QWidget):

    uifile = QDir(os.path.dirname(os.path.realpath(__file__)))

    def __init__(self, parent: QWidget | None) -> None:
        QWidget.__init__(self, parent)
        UiLoad().loadUi("crop.ui", self, parent)
        self.load_ui()
        self.load_widgets()

    def load_ui(self):
        pass

    def load_widgets(self):
        self.cropSpinX: QSpinBox
        self.cropSpinY: QSpinBox
        self.cropSpinW: QSpinBox
        self.cropSpinH: QSpinBox

    def op(self) -> Crop:
        return Crop(
            # apply_to=apply_to,
            # all_steps=all_steps,
            # demo=demo,
            x=self.cropSpinX.value(),
            y=self.cropSpinY.value(),
            width=self.cropSpinW.value(),
            height=self.cropSpinH.value())
Beispiel #5
0
    def run(self):
        """
        Main logic. Pastes the files from the clipboard to the target path.
        """
        if self.clipboard.mimeData().hasUrls():
            self.signals.started.emit()

            path_list = self.get_paths_from_clipboard()

            cut = (collections.Counter(path_list) == collections.Counter(
                self.marked_to_cut))

            path_list = self.recurse_dirs(path_list)

            files_copied = 0
            maximum = self.count_files(path_list)
            self.signals.ready.emit(maximum)

            base_path = self.get_base_path(path_list)

            # copy files to new location
            for path in path_list:
                if self.is_canceled:
                    break

                new_path = os.path.join(self.target_path,
                                        path.replace(base_path, ''))
                if (os.path.isdir(path) and not QDir().exists(new_path)):
                    QDir().mkpath(new_path)
                elif (QFile().exists(path) and not QFile().exists(new_path)):
                    if (QFile().copy(path, new_path)):
                        files_copied += 1
                        self.signals.progress.emit(files_copied)
                        self.signals.progress_message.emit('Pasting file ' +
                                                           str(files_copied) +
                                                           ' of ' +
                                                           str(maximum) +
                                                           '...')
                    else:
                        raise OSError
            # removed cut files
            if cut:
                for file_path in path_list:
                    if (not QFile().remove(file_path)):
                        raise OSError
        self.signals.finished.emit()
Beispiel #6
0
 def action_go_event(self):
     """
     Changes the current dir to the one, that is given in the adress bar.
     """
     next_dir = QDir(self.adressbar.text())
     if (next_dir.isAbsolute() and next_dir.exists()):
         next_path = next_dir.path()
         self.update_current_path(next_path)
     else:
         dialog = utility.message_dialog('The path entered does not exist.',
                                         QMessageBox.Warning)
         dialog.exec()
Beispiel #7
0
 def action_up_event(self):
     """
     Changes the current dir to one dir up in the hierarchy
     """
     dir_up = QDir(self.current_path)
     if (dir_up.cdUp()):
         next_path = dir_up.path()
         self.update_current_path(next_path)
     else:
         logging.warning('There is no directory above the one you are in.'
                         + ' This message should not occur, because the'
                         + ' button triggering this should be deactivated'
                         + ' Please report this issue.')
Beispiel #8
0
    def createLanguageMenu(self):
        langPath = get_app_path() + Setup.LANG_PATH + os.sep

        langDirectory = QDir(langPath)
        for language_file in langDirectory.entryList(['*.qm']):
            language_code = language_file.split('.')[0]
            language = QLocale.languageToString(QLocale(language_code).language())
            language_icon = QIcon(langPath + language_code + '.png')
            action = QAction(language_icon, language, self)
            action.setCheckable(True)
            action.setData(language_code)
            self.menuLanguage.addAction(action)
            self.langGroup.addAction(action)
 def before_render(self):
     self.set(
         "fileOutput",
         os.path.join(self.get("fileOutputDir"),
                      self.get("fileOutputName")))
     # create temporary file name guaranteed to be unique
     temp_file = QTemporaryFile(
         os.path.join(QDir().tempPath(), APPLICATION,
                      "XXXXXX.{}".format(self.get("fileOutputName"))))
     temp_file.setAutoRemove(False)
     temp_file.open(QIODevice.WriteOnly)
     temp_file.close()
     self.set("tempFileOutput", temp_file.fileName())
     self.set("songDuration", str(self.get_duration_ms() / 1000))
Beispiel #10
0
 def write_bookmarks(self):
     if not self._modified:
         return
     dir_path = _config_dir()
     native_dir_path = QDir.toNativeSeparators(dir_path)
     dir = QFileInfo(dir_path)
     if not dir.isDir():
         print('Creating {}...'.format(native_dir_path))
         if not QDir(dir.absolutePath()).mkpath(dir.fileName()):
             warnings.warn('Cannot create {}.'.format(native_dir_path),
                           RuntimeWarning)
             return
     serialized_model = _serialize_model(self._model, dir_path)
     bookmark_file_name = os.path.join(native_dir_path, _bookmark_file)
     print('Writing {}...'.format(bookmark_file_name))
     with open(bookmark_file_name, 'w') as bookmark_file:
         jsons.dump(serialized_model, bookmark_file, indent=4)
Beispiel #11
0
    def update_current_path(self,
                            next_path: str,
                            skip_stack=False,
                            reset_forward_stack=True):
        """
        Updates the current path to the value given in next_path. It also
        updates the UI accordingly and changes the forward an backward
        stacks, if needed.

        :param next_path: The path to the directory that should become the next
                          dir.
        :type next_path: str
        :param skip_stack: This determines wether the stack handling should be
                           skipped. Default value is False.
        :type skip_stack: bool
        :param reset_forward_stack: This determines wether the forward stack
                                    should be reset or not. Default is True
        :type reset_forward_stack: bool
        """
        self.filesystem.setRootPath(next_path)
        self.table_view.setRootIndex(
            self.filesystem.index(next_path))
        self.table_view.setCurrentIndex(
            self.filesystem.index(self.current_path))
        self.adressbar.setText(next_path)
        self.part_info.setText(utility.part_info(next_path))
        # disable up navigation if in fs root
        if (next_path == QDir().rootPath()):
            self.action_up.setEnabled(False)
        else:
            self.action_up.setEnabled(True)
        # handle back stack
        if (not skip_stack):
            if (self.back_stack.empty()
                    or self.back_stack.top() != self.current_path):
                self.back_stack.push(self.current_path)
                # reenable back navigation
                self.action_back.setEnabled(True)
        if (reset_forward_stack):
            self.forward_stack.drop()
            self.action_forward.setEnabled(False)
        self.current_path = next_path
Beispiel #12
0
 def action_new_dir_event(self):
     """
     Prompts the user for a dir name and creates one with that name in the
     current directory.
     """
     dir_name, ok = QInputDialog().getText(self,
                                           'Create new directory',
                                           'Directory name:')
     if (ok):
         if (dir_name):
             if not QDir().mkpath(os.path.join(self.current_path,
                                               dir_name)):
                 dialog = utility.message_dialog('Directory could not be'
                                                 + ' created.',
                                                 QMessageBox.Critical)
                 dialog.exec()
         else:
             dialog = utility.message_dialog('Please enter a name for the '
                                             + 'new directory.',
                                             QMessageBox.Warning)
             dialog.exec()
Beispiel #13
0
def clean_up_images():
    temp_dir = QDir("{}/{}".format(QDir().tempPath(), APPLICATION))
    temp_dir.setNameFilters(["*.cover"])
    for file in temp_dir.entryList():
        temp_dir.remove(file)
Beispiel #14
0
 def action_home_event(self):
     """
     Changes the current dir to the users $HOME.
     """
     next_path = QDir().homePath()
     self.update_current_path(next_path)
    def __init__(self, item_type, songs=None, **kwargs):

        # metadata values
        # can be any type
        self.metadata = {}

        # application values
        # always strings
        self.dict = {}
        app_fields = SONG_FIELDS if item_type == TreeWidgetType.SONG else ALBUM_FIELDS
        for field in (set(kwargs.keys()) | app_fields):
            # set all mandatory settings to their defaults if not
            # specified in the parameters
            # and any extra settings specified in the parameters
            if field in kwargs:
                self.dict[field] = kwargs[field]
            else:
                # set to default setting
                self.dict[field] = get_setting(field)

            if field == 'coverArt' and self.dict[field] in QRC_TO_FILE_PATH:
                # convert resource path to real file path for ffmpeg
                self.dict[field] = QRC_TO_FILE_PATH[get_setting(field)]

        # add song metadata
        if item_type == TreeWidgetType.SONG:
            try:
                metadata = audio_metadata.load(self.dict['song_path'])

                if get_setting(
                        'extractCoverArt') == SETTINGS_VALUES.CheckBox.CHECKED:
                    # extract cover art if it exists
                    if metadata.pictures and len(metadata.pictures) > 0:
                        bytes = QByteArray(metadata.pictures[0].data)
                        cover = QTemporaryFile(
                            os.path.join(QDir().tempPath(), APPLICATION,
                                         "XXXXXX.cover"))
                        cover.setAutoRemove(False)
                        cover.open(QIODevice.WriteOnly)
                        cover.write(bytes)
                        cover.close()
                        self.set_value('coverArt', cover.fileName())

                self.metadata = flatten_metadata(metadata)

            except Exception as e:
                logging.warning(e)
                logging.warning(self.dict['song_path'])
        else:
            # album gets metadata from children
            # song metadata is stored as song.<key>
            # e.g. song.tags.album would be the album name
            #
            # we will only get metadata from one song
            # because the album shouldn't care about
            # the varying metadata values for the songs
            # such as title or track number
            for song in songs:
                if song.has_metadata():
                    for key, value in song.to_dict().items():
                        key = "song.{}".format(key)
                        self.metadata[key] = value
                    break

        self.update_fields()
Beispiel #16
0
class DataLoaded(QWidget):
    def __init__(self, parent: QWidget | None) -> None:
        QWidget.__init__(self, parent)
        UiLoad().loadUi("steps.ui", self, parent)

    uifile = QDir(os.path.dirname(os.path.realpath(__file__)))

    def setupUi(self, dataLoaded):
        if not dataLoaded.objectName():
            dataLoaded.setObjectName("dataLoaded")
        dataLoaded.resize(400, 301)
        self.verticalLayout = QVBoxLayout(dataLoaded)
        self.verticalLayout.setObjectName("verticalLayout")
        self.assetsTabs = QTabWidget(dataLoaded)
        self.assetsTabs.setObjectName("assetsTabs")
        self.assetsTabs.setMinimumSize(QSize(362, 0))
        self.assetsTabs.setMaximumSize(QSize(410, 16777215))
        self.assetsTabs.setMouseTracking(False)
        self.assetsTabs.setLayoutDirection(Qt.LeftToRight)
        self.assetsTabs.setAutoFillBackground(False)
        self.assetsTabs.setTabPosition(QTabWidget.North)
        self.assetsTabs.setTabShape(QTabWidget.Rounded)
        self.assetsTabs.setUsesScrollButtons(False)
        self.assetsTabs.setDocumentMode(False)
        self.assetsTabs.setTabsClosable(False)
        self.assetsTabs.setMovable(False)
        self.assetsTabs.setTabBarAutoHide(False)
        self.demoList = QWidget()
        self.demoList.setObjectName("demoList")
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.demoList.sizePolicy().hasHeightForWidth())
        self.demoList.setSizePolicy(sizePolicy)
        self.verticalLayout_11 = QVBoxLayout(self.demoList)
        self.verticalLayout_11.setObjectName("verticalLayout_11")
        self.verticalLayout_12 = QVBoxLayout()
        self.verticalLayout_12.setObjectName("verticalLayout_12")
        self.horizontalLayout_10 = QHBoxLayout()
        self.horizontalLayout_10.setObjectName("horizontalLayout_10")
        self.browseDemoBtn = QPushButton(self.demoList)
        self.browseDemoBtn.setObjectName("browseDemoBtn")

        self.horizontalLayout_10.addWidget(self.browseDemoBtn)

        self.browseScriptBtn = QPushButton(self.demoList)
        self.browseScriptBtn.setObjectName("browseScriptBtn")

        self.horizontalLayout_10.addWidget(self.browseScriptBtn)

        self.browseAudioBtn = QPushButton(self.demoList)
        self.browseAudioBtn.setObjectName("browseAudioBtn")

        self.horizontalLayout_10.addWidget(self.browseAudioBtn)

        self.verticalLayout_12.addLayout(self.horizontalLayout_10)

        self.verticalLayout_11.addLayout(self.verticalLayout_12)

        self.demoListTreeWidget = QTreeWidget(self.demoList)
        self.demoListTreeWidget.setObjectName("demoListTreeWidget")

        self.verticalLayout_11.addWidget(self.demoListTreeWidget)

        self.horizontalLayout_11 = QHBoxLayout()
        self.horizontalLayout_11.setObjectName("horizontalLayout_11")
        self.infoBtn = QPushButton(self.demoList)
        self.infoBtn.setObjectName("infoBtn")

        self.horizontalLayout_11.addWidget(self.infoBtn)

        self.loadScriptBtn = QPushButton(self.demoList)
        self.loadScriptBtn.setObjectName("loadScriptBtn")

        self.horizontalLayout_11.addWidget(self.loadScriptBtn)

        self.loadAudioBtn = QPushButton(self.demoList)
        self.loadAudioBtn.setObjectName("loadAudioBtn")

        self.horizontalLayout_11.addWidget(self.loadAudioBtn)

        self.removeDemoBtn = QPushButton(self.demoList)
        self.removeDemoBtn.setObjectName("removeDemoBtn")

        self.horizontalLayout_11.addWidget(self.removeDemoBtn)

        self.addDemoBtn = QPushButton(self.demoList)
        self.addDemoBtn.setObjectName("addDemoBtn")

        self.horizontalLayout_11.addWidget(self.addDemoBtn)

        self.verticalLayout_11.addLayout(self.horizontalLayout_11)

        self.assetsTabs.addTab(self.demoList, "")
        self.scriptOverviewTab = QWidget()
        self.scriptOverviewTab.setObjectName("scriptOverviewTab")
        self.verticalLayout_13 = QVBoxLayout(self.scriptOverviewTab)
        self.verticalLayout_13.setObjectName("verticalLayout_13")
        self.scriptListTreeWidget = QListWidget(self.scriptOverviewTab)
        self.scriptListTreeWidget.setObjectName("scriptListTreeWidget")

        self.verticalLayout_13.addWidget(self.scriptListTreeWidget)

        self.assetsTabs.addTab(self.scriptOverviewTab, "")
        self.audioOverviewTab = QWidget()
        self.audioOverviewTab.setObjectName("audioOverviewTab")
        self.verticalLayout_15 = QVBoxLayout(self.audioOverviewTab)
        self.verticalLayout_15.setObjectName("verticalLayout_15")
        self.audioListTreeWidget = QListWidget(self.audioOverviewTab)
        self.audioListTreeWidget.setObjectName("audioListTreeWidget")

        self.verticalLayout_15.addWidget(self.audioListTreeWidget)

        self.assetsTabs.addTab(self.audioOverviewTab, "")

        self.verticalLayout.addWidget(self.assetsTabs)

        self.retranslateUi(dataLoaded)

        self.assetsTabs.setCurrentIndex(0)

        QMetaObject.connectSlotsByName(dataLoaded)

    # setupUi

    def retranslateUi(self, dataLoaded):
        dataLoaded.setWindowTitle(
            QCoreApplication.translate(b"dataLoaded", b"Form", None))
        self.browseDemoBtn.setText(
            QCoreApplication.translate(b"dataLoaded", b"Demo", None))
        self.browseScriptBtn.setText(
            QCoreApplication.translate(b"dataLoaded", b"Script", None))
        self.browseAudioBtn.setText(
            QCoreApplication.translate(b"dataLoaded", b"Audio", None))
        ___qtreewidgetitem = self.demoListTreeWidget.headerItem()
        ___qtreewidgetitem.setText(
            2, QCoreApplication.translate(b"dataLoaded", b"Script", None))
        ___qtreewidgetitem.setText(
            1, QCoreApplication.translate(b"dataLoaded", b"Audio", None))
        ___qtreewidgetitem.setText(
            0, QCoreApplication.translate(b"dataLoaded", b"Demo", None))
        self.infoBtn.setText(
            QCoreApplication.translate(b"dataLoaded", b"Info", None))
        self.loadScriptBtn.setText(
            QCoreApplication.translate(b"dataLoaded", b"Load Script", None))
        self.loadAudioBtn.setText(
            QCoreApplication.translate(b"dataLoaded", b"Load audio", None))
        self.removeDemoBtn.setText(
            QCoreApplication.translate(b"dataLoaded", b"Remove", None))
        self.addDemoBtn.setText(
            QCoreApplication.translate(b"dataLoaded", b"Add Demo", None))
        self.assetsTabs.setTabText(
            self.assetsTabs.indexOf(self.demoList),
            QCoreApplication.translate(b"dataLoaded", b"Demo", None))
        #if QT_CONFIG(tooltip)
        self.assetsTabs.setTabToolTip(
            self.assetsTabs.indexOf(self.demoList),
            QCoreApplication.translate(b"dataLoaded", b"Demo information",
                                       None))
        #endif // QT_CONFIG(tooltip)
        self.assetsTabs.setTabText(
            self.assetsTabs.indexOf(self.scriptOverviewTab),
            QCoreApplication.translate(b"dataLoaded", b"Script", None))
        self.assetsTabs.setTabText(
            self.assetsTabs.indexOf(self.audioOverviewTab),
            QCoreApplication.translate(b"dataLoaded", b"Audio", None))