Example #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)
Example #2
0
File: tfm.py Project: tmahlburg/tfm
 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()
Example #3
0
File: tfm.py Project: tmahlburg/tfm
 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.')
Example #4
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 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'
            )
Example #6
0
 def _read_bookmarks(self):
     bookmark_file_name = os.path.join(
         QDir.toNativeSeparators(_config_dir()), _bookmark_file)
     if os.path.exists(bookmark_file_name):
         print('Reading {}...'.format(bookmark_file_name))
         return jsons.load(open(bookmark_file_name))
     return _default_bookmarks
Example #7
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())
Example #8
0
    def __init__(self, previewImage, fileName):
        super(ImageView, self).__init__()

        self.fileName = fileName

        mainLayout = QVBoxLayout(self)
        self.imageLabel = QLabel()
        self.imageLabel.setPixmap(QPixmap.fromImage(previewImage))
        mainLayout.addWidget(self.imageLabel)

        topLayout = QHBoxLayout()
        self.fileNameLabel = QLabel(QDir.toNativeSeparators(fileName))
        self.fileNameLabel.setTextInteractionFlags(Qt.TextBrowserInteraction)

        topLayout.addWidget(self.fileNameLabel)
        topLayout.addStretch()
        copyButton = QPushButton("Copy")
        copyButton.setToolTip("Copy file name to clipboard")
        topLayout.addWidget(copyButton)
        copyButton.clicked.connect(self.copy)
        launchButton = QPushButton("Launch")
        launchButton.setToolTip("Launch image viewer")
        topLayout.addWidget(launchButton)
        launchButton.clicked.connect(self.launch)
        mainLayout.addLayout(topLayout)
Example #9
0
File: data.py Project: clpi/isutils
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))
Example #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)
Example #11
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()
Example #12
0
    def changeFolder(self, button):
        fname = QFileDialog.getExistingDirectory(self, 'Open f', '/home')

        if fname:
            # Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.
            # On Windows, toNativeSeparators("c:/winnt/system32") returns
            # "c:\winnt\system32".
            fname = QDir.toNativeSeparators(fname)

        if os.path.isdir(fname):
            self.download_folder_lineEdit.setText(fname)
 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))
Example #14
0
    def set_settings_object(self, settings):
        settings.setFallbacksEnabled(self.fallbacks_action.isChecked())
        self.settings_tree.set_settings_object(settings)

        self.refresh_action.setEnabled(True)
        self.auto_refresh_action.setEnabled(True)

        nice_name = QDir.fromNativeSeparators(settings.fileName())
        nice_name = nice_name.split('/')[-1]

        if not settings.isWritable():
            nice_name += " (read only)"

        self.setWindowTitle("{} - Settings Editor".format(nice_name))
Example #15
0
def handle_args(args: List[str]) -> str:
    """
    Handles the given arguments, determining the starting dir.

    :param args: List of arguments given to the application.
    :type args: List[str]
    :return: The directory to start the application with.
    :rtype: str
    """
    if len(args) > 1:
        if os.path.isdir(args[1]):
            return os.path.abspath(args[1])
        if QUrl(args[1]).isValid() and os.path.isdir(QUrl(args[1]).path()):
            return os.path.abspath(QUrl(args[1]).path())
    return QDir.homePath()
Example #16
0
    def downloadFolderPushButtonClicked(self, button):

        download_path = str(
            self.persepolis_setting.value('settings/download_path'))
        fname = QFileDialog.getExistingDirectory(self, 'Select a directory',
                                                 download_path)

        if fname:
            # Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system.
            # On Windows, toNativeSeparators("c:/winnt/system32") returns
            # "c:\winnt\system32".
            fname = QDir.toNativeSeparators(fname)
            self.download_folder_lineEdit.setText(fname)
            self.persepolis_setting.setValue('settings/download_path',
                                             str(fname))
 def _update_tool_tip(self):
     path = self._download_item.path()
     tool_tip = "{}\n{}".format(self._download_item.url().toString(),
                                QDir.toNativeSeparators(path))
     total_bytes = self._download_item.totalBytes()
     if total_bytes > 0:
         tool_tip += "\n{}K".format(total_bytes / 1024)
     state = self.state()
     if state == QWebEngineDownloadItem.DownloadRequested:
         tool_tip += "\n(requested)"
     elif state == QWebEngineDownloadItem.DownloadInProgress:
         tool_tip += "\n(downloading)"
     elif state == QWebEngineDownloadItem.DownloadCompleted:
         tool_tip += "\n(completed)"
     elif state == QWebEngineDownloadItem.DownloadCancelled:
         tool_tip += "\n(cancelled)"
     else:
         tool_tip += "\n(interrupted)"
     self.setToolTip(tool_tip)
Example #18
0
File: tfm.py Project: tmahlburg/tfm
    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
Example #19
0
File: tfm.py Project: tmahlburg/tfm
 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()
    def create_itemview_tabwidget(self):
        result = QTabWidget()
        init_widget(result, "bottomLeftTabWidget")
        result.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Ignored)

        tree_view = QTreeView()
        init_widget(tree_view, "treeView")
        filesystem_model = QFileSystemModel(tree_view)
        filesystem_model.setRootPath(QDir.rootPath())
        tree_view.setModel(filesystem_model)

        table_widget = QTableWidget()
        init_widget(table_widget, "tableWidget")
        table_widget.setRowCount(10)
        table_widget.setColumnCount(10)

        list_model = QStandardItemModel(0, 1, result)

        list_model.appendRow(QStandardItem(QIcon(DIR_OPEN_ICON), "Directory"))
        list_model.appendRow(QStandardItem(QIcon(COMPUTER_ICON), "Computer"))

        list_view = QListView()
        init_widget(list_view, "listView")
        list_view.setModel(list_model)

        icon_mode_listview = QListView()
        init_widget(icon_mode_listview, "iconModeListView")

        icon_mode_listview.setViewMode(QListView.IconMode)
        icon_mode_listview.setModel(list_model)

        result.addTab(embed_into_hbox_layout(tree_view), "Tree View")
        result.addTab(embed_into_hbox_layout(table_widget), "Table")
        result.addTab(embed_into_hbox_layout(list_view), "List")
        result.addTab(embed_into_hbox_layout(icon_mode_listview),
                      "Icon Mode List")
        return result
    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()
Example #22
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))
Example #23
0
File: tfm.py Project: tmahlburg/tfm
 def action_home_event(self):
     """
     Changes the current dir to the users $HOME.
     """
     next_path = QDir().homePath()
     self.update_current_path(next_path)
Example #24
0
File: tfm.py Project: tmahlburg/tfm
    def __init__(self, args: List[str]):
        """
        At the moment the very, very long initialization of the main window,
        setting up everything.

        :param default_path: Use a user defined path as entrypoint. If it's
                             empty, the home directory of the current user will
                             be used.
        :type default_path: str
        """
        super(tfm, self).__init__()
        self.setupUi(self)
        self.setWindowIcon(QIcon.fromTheme('system-file-manager'))

        self.clipboard = QApplication.clipboard()
        self.marked_to_cut = []

        self.back_stack = stack()
        self.forward_stack = stack()

        self.config_dir = os.path.join(
            QStandardPaths.writableLocation(
                QStandardPaths().ConfigLocation),
            type(self).__name__)

        self.current_path = utility.handle_args(args)
        self.default_path = self.current_path

        self.threadpool = QThreadPool()

        # MAIN VIEW #
        # set up QFileSystemModel
        self.filesystem = QFileSystemModel()
        self.filesystem.setRootPath(self.current_path)
        self.filesystem.setReadOnly(False)

        # connect QFileSystemModel to View
        self.table_view.setModel(self.filesystem)
        self.table_view.setRootIndex(
            self.filesystem.index(self.current_path))

        # set up header
        self.horizontal_header = self.table_view.horizontalHeader()
        self.horizontal_header.setSectionsMovable(True)
        # name
        self.horizontal_header.resizeSection(0, 200)
        # size
        self.horizontal_header.resizeSection(1, 100)
        # type
        self.horizontal_header.resizeSection(2, 100)

        # FS TREE #
        # create seperate FileSystemModel for the fs tree
        self.fs_tree_model = QFileSystemModel()
        self.fs_tree_model.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot)
        self.fs_tree_model.setRootPath(QDir.rootPath())

        # connect model to view
        self.fs_tree.setModel(self.fs_tree_model)
        # hide unneeded columns
        for column in range(1, self.fs_tree.header().count()):
            self.fs_tree.hideColumn(column)
        # expand root item
        self.fs_tree.expand(self.fs_tree_model.index(0, 0))

        # BOOKMARKS #
        self.bookmarks = bm(path_to_bookmark_file=os.path.join(self.config_dir,
                                                               'bookmarks'))
        self.bookmark_view.setModel(self.bookmarks)

        # MOUNTS #
        self.udev_context = Context()
        self.mounts = mounts_model(context=self.udev_context)
        self.mounts_view.setModel(self.mounts)
        udev_monitor = Monitor.from_netlink(self.udev_context)
        udev_monitor.filter_by(subsystem='block', device_type='partition')
        udev_observer = MonitorObserver(udev_monitor,
                                        self.devices_changed)
        udev_observer.start()

        # STATUSBAR #
        # TODO: dir info
        self.item_info = QLabel()
        # self.dir_info = QLabel()
        self.part_info = QLabel()
        self.statusbar.addPermanentWidget(self.item_info)
        # self.statusbar.addPermanentWidget(self.dir_info)
        self.statusbar.addPermanentWidget(self.part_info)

        self.part_info.setText(utility.part_info(self.current_path))

        # TOOLBAR #
        # initially disable back/forward navigation
        self.action_back.setEnabled(False)
        self.action_forward.setEnabled(False)

        # main menu
        self.main_menu = QMenu()
        self.main_menu.addAction(self.action_show_hidden)

        self.menu_button = QToolButton()
        self.menu_button.setMenu(self.main_menu)
        self.menu_button.setPopupMode(QToolButton().InstantPopup)
        self.menu_button.setDefaultAction(self.action_menu)

        self.toolbar.insertWidget(self.action_back, self.menu_button)

        # adress bar
        self.adressbar = QLineEdit()
        self.adressbar.setText(self.current_path)
        self.toolbar.insertWidget(self.action_go, self.adressbar)

        # menu for new file or directory
        self.new_menu = QMenu()
        self.new_menu.addAction(self.action_new_dir)
        self.new_menu.addAction(self.action_new_file)

        self.new_button = QToolButton()
        self.new_button.setMenu(self.new_menu)
        self.new_button.setPopupMode(QToolButton().MenuButtonPopup)
        self.new_button.setDefaultAction(self.action_new_dir)

        self.toolbar.insertWidget(self.action_back, self.new_button)

        self.connect_actions_to_events()
        self.set_shortcuts()
        self.set_icons()
        self.set_context_menus()
Example #25
0
import sys

from PySide6 import QtWidgets
from PySide6.QtCore import QDir
from __feature__ import snake_case, true_property

# Create application
app = QtWidgets.QApplication(sys.argv)

# Load styles
with open('dark_teal.qss', 'r') as file:
    app.style_sheet = file.read()

# Load icons
QDir.add_search_path('icon', 'theme')

# App
window = QtWidgets.QMainWindow()
checkbox = QtWidgets.QCheckBox(window)
checkbox.text = 'CheckBox'
window.show()
app.exec()
Example #26
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)
Example #27
0
    "-r 30 -shortest -vf \"scale='min({videoWidth}, iw)':'min({videoHeight}, ih)':force_original_aspect_ratio=decrease,"
    "pad={videoWidth}:{videoHeight}:-1:-1:color={backgroundColor}\" "
    "-acodec libmp3lame -ab 320k -vcodec libx264 -fflags +shortest -max_interleave_delta 500M \"{tempFileOutput}\""
}

SONG_FIELDS = set(
    ('inputFrameRate', 'backgroundColor', 'videoHeight', 'videoWidth',
     'uploadYouTube', 'coverArt', 'videoDescription', 'videoTags',
     'videoTitle', 'videoVisibility', 'fileOutputDir', 'fileOutputName',
     'playlistName', 'commandString'))
ALBUM_FIELDS = set(
    ('albumPlaylist', 'fileOutputDirAlbum', 'fileOutputNameAlbum',
     'uploadYouTube', 'videoDescriptionAlbum', 'videoTagsAlbum',
     'videoTitleAlbum', 'videoVisibilityAlbum'))

QDir.temp().mkdir(APPLICATION)
QRC_TO_FILE_PATH = {
    ":/image/default.jpg":
    QDir.temp().absoluteFilePath("./{}/qrc_default.jpg".format(APPLICATION))
}

for qrc, file in QRC_TO_FILE_PATH.items():
    # unpack resources so ffmpeg can use them
    QFile.copy(qrc, file)


# clear temp dir on exit
def clean_up_images():
    temp_dir = QDir("{}/{}".format(QDir().tempPath(), APPLICATION))
    temp_dir.setNameFilters(["*.cover"])
    for file in temp_dir.entryList():