Пример #1
0
 def __init__(self):
     self.startingDir = QDir.rootPath()
     self.dialog = QFileDialog()
     self.dialog.setFileMode(QFileDialog.FileMode())
     #self.rootdir = self.dialog.getExistingDirectory(None, 'Choose directory', self.startingDir)
     self.rootdir = QDir.rootPath()
     super(DirectoryDialog, self).__init__()
Пример #2
0
    def __init__(self):
        '''constructor function of the FiloIO tab.

        '''
        super().__init__()
        # Instance variables
        self.import_folder_path = QDir.rootPath()
        self.export_folder_path = QDir.rootPath()
        # signal indicating if something has been successfuly
        # or unsuccessfully operated

        # define outer sturcture of this tab
        self.fileio_layout = QVBoxLayout()

        # file io tab label
        self.fileio_tab_title_label = QLabel()
        self.fileio_tab_title_label.setFont(QFont('Arial', 10))
        self.fileio_tab_title_label.setText('<b>File IO Tab</b>')
        self.fileio_layout.addWidget(self.fileio_tab_title_label)
        # define the inner structure below the header
        self.fileio_tab_import_layout_grid = QGridLayout()
        # widget 1: fileio select folder widget
        self.fileio_import_select_folder_widgets()
        # widget 2: fileio import csv files from folder widget
        self.fileio_import_file_from_folder_widgets()

        # widget 3: fileio import configuration file widget
        # TODO: Unfinished

        # Import Configuration Parameters
        self.fileio_tab_import_configuration_layout = QVBoxLayout()
        # Import Configuration File PushButton
        self.fileio_tab_import_configuration_pushbutton = \
            QPushButton("Select Config File")
        # Import Configuration Confirm PushButton
        self.fileio_tab_import_config_confirm_pushbutton = \
            QPushButton("Import Config File")
        # Import Configuration State
        self.fileio_tab_import_config_label = QLabel('No Config Imported')
        self.fileio_tab_import_config_label.setAlignment(Qt.AlignCenter)
        # Application adding the import parameter widgets onto the application
        self.fileio_import_addwidget()

        # Output Directory Parameters
        self.fileio_tab_export_title_label = QLabel()
        self.fileio_tab_export_title_label.\
            setFont(QFont('Arial', 10))
        self.fileio_tab_export_title_label.\
            setText('<b>Output Directory Parameters: </b>')
        self.fileio_layout.addWidget(self.fileio_tab_export_title_label)
        # Add in the grid for output
        self.fileio_tab_output_layout_grid = QGridLayout()
        # Add in the widgets for the export parameters
        self.fileio_export_select_folder_widgets()
        # Select directory to output to
        self.fileio_export_addwidget()

        self.setLayout(self.fileio_layout)
Пример #3
0
    def workspace(self, dir):
        """
        处理tree_view显示的工作空间样式
        Parameters
        ----------
        dir : string
            要显示的工作空间的根路径

        """

        if dir:
            # self.tree_view.clear()
            model = QFileSystemModel()
            model.setRootPath(QDir.rootPath())

            model.setNameFilters(self.ext)
            model.setNameFilterDisables(False)

            model.setIconProvider(IconProvider())

            self.tree_view.setModel(model)
            self.tree_view.setRootIndex(model.index(self.dir))

            # 除了文件名那一栏,其他栏全部隐藏
            self.tree_view.setColumnHidden(1, True)
            self.tree_view.setColumnHidden(2, True)
            self.tree_view.setColumnHidden(3, True)
Пример #4
0
    def __init__(self, callback):
        super().__init__()

        directoryFont = QFont()
        directoryFont.setFamily(editor["directoryFont"])
        directoryFont.setPointSize(editor["directoryFontSize"])
        self.open_callback = callback
        self.setFont(directoryFont)
        self.layout = QHBoxLayout()
        self.model = QFileSystemModel()
        self.setModel(self.model)
        self.model.setRootPath(QDir.rootPath())

        self.setIndentation(10)
        self.setAnimated(True)

        self.setSortingEnabled(True)
        self.setWindowTitle("Dir View")
        self.hideColumn(1)
        self.resize(200, 600)
        self.hideColumn(2)
        self.confirmation = MessageBox()
        self.hideColumn(3)
        self.layout.addWidget(self)
        self.doubleClicked.connect(self.openFile)
Пример #5
0
    def selectExecutable(self, widget, param):
        _ = get_app()._tr

        # Fallback default to user home
        startpath = QDir.rootPath()

        # Start at directory of old setting, if it exists, or walk up the
        # path until we encounter a directory that does exist and start there
        if "setting" in param and param["setting"]:
            prev_val = self.s.get(param["setting"])
            while prev_val and not os.path.exists(prev_val):
                prev_val = os.path.dirname(prev_val)
            if prev_val and os.path.exists(prev_val):
                startpath = prev_val

        fileName = QFileDialog.getOpenFileName(
            self,
            _("Select executable file"),
            startpath)[0]
        if fileName:
            if platform.system() == "Darwin":
                # Check for Mac specific app-bundle executable file (if any)
                appBundlePath = os.path.join(fileName, 'Contents', 'MacOS')
                if os.path.exists(os.path.join(appBundlePath, 'blender')):
                    fileName = os.path.join(appBundlePath, 'blender')
                elif os.path.exists(os.path.join(appBundlePath, 'Blender')):
                    fileName = os.path.join(appBundlePath, 'Blender')
                elif os.path.exists(os.path.join(appBundlePath, 'Inkscape')):
                    fileName = os.path.join(appBundlePath, 'Inkscape')

            self.s.set(param["setting"], fileName)
            widget.setText(fileName)
Пример #6
0
 def __init__(self, callback, app=None, palette=None):
     super().__init__()
     directoryFont = QFont()
     self.app = app
     self.palette = palette
     directoryFont.setFamily(editor["directoryFont"])
     directoryFont.setPointSize(editor["directoryFontSize"])
     self.open_callback = callback
     self.setContextMenuPolicy(Qt.CustomContextMenu)
     self.customContextMenuRequested.connect(self.openMenu)
     self.setFont(directoryFont)
     self.layout = QHBoxLayout()
     self.model = QFileSystemModel()
     self.setModel(self.model)
     self.model.setRootPath(QDir.rootPath())
     self.setMaximumWidth(300)
     self.setIndentation(10)
     self.setAnimated(True)
     self.newFile()
     self.setSortingEnabled(True)
     self.setWindowTitle("Dir View")
     self.hideColumn(1)
     self.resize(200, 600)
     self.hideColumn(2)
     self.confirmation = MessageBox()
     self.hideColumn(3)
     # self.layout.addWidget(self)
     self.doubleClicked.connect(self.openFile)
Пример #7
0
    def __init__(self, model, view):
        super(ClientCtrl, self).__init__(view)
        self.model = model
        self.view = view

        self.mode = ClientMode.PORT

        self.local_cur_path = QDir.rootPath()
        self.remote_cur_path = '/'
        self.remote_file_size = {}

        # process pool
        self.running_proc = {}
        self.finished_proc = []

        # local path system
        # self.view.localSite.setText(self.local_cur_path)
        self.view.localSite.setText("/Users/liqi17thu/Desktop")
        self.model.localFileModel.setRootPath(self.local_cur_path)
        self.view.localFileView.setModel(self.model.localFileModel)
        self.view.localFileView.header().setSectionResizeMode(
            0, QHeaderView.Stretch)
        for col in range(1, 4):
            self.view.localFileView.header().setSectionResizeMode(
                col, QHeaderView.ResizeToContents)

        # signal slots
        self.view.PORT.clicked.connect(self.setPort)
        self.view.PASV.clicked.connect(self.setPasv)
        self.view.connect.clicked.connect(self.login)
        self.view.exit.clicked.connect(self.exit)

        self.view.localFileView.selectionModel().selectionChanged.connect(
            self.sync_local_path)
        self.view.localSiteBtn.clicked.connect(self.change_local_site)
        self.view.localCreateDir.clicked.connect(self.create_local_dir)
        self.view.localRename.clicked.connect(self.local_rename)
        self.view.localDelete.clicked.connect(self.local_delete)

        self.view.remoteFileWidget.selectionModel().selectionChanged.connect(
            self.sync_remote_path)
        self.view.remoteRename.clicked.connect(self.remote_rename)
        self.view.remoteDelete.clicked.connect(self.remote_delete)
        self.view.remoteSiteBtn.clicked.connect(self.change_remote_site)
        self.view.remoteCreateDir.clicked.connect(self.create_remote_dir)

        self.view.upload.clicked.connect(self.upload)
        self.view.download.clicked.connect(self.download)

        self.refresh_transferring_signal.connect(
            self.refresh_transferring_processing)
        self.refresh_finished_signal.connect(self.refresh_finished_processing)
        self.update_single_transfer.connect(
            self.update_single_transfer_process)
        self.insert_response_signal.connect(
            self.view.responses.insertPlainText)
Пример #8
0
 def __init__(self, parent=None):
     super(TreeView, self).__init__(parent)
     self.parent = parent
     self.__model = QFileSystemModel()
     self.__model.setRootPath(QDir.rootPath())
     self.setModel(self.__model)
     self.current_select_path = None
     self.doubleClicked.connect(self.open)
     self.srcFileName = None
     self.srcPath = None
     self.destPath = None
     self.CUT_FLAG = False
     self.projectPath = None
     self.PATH_FLAG = 1
Пример #9
0
    def onFolderViewExpanded(self, proxyIndex):
        if self._refreshing:
            expandedPath = self.fileModel.filePath(
                self.proxyFileModel.mapToSource(proxyIndex))
            if expandedPath == QDir.rootPath():
                currentPath = self.get_current_selected_folder()
                if not currentPath:
                    currentPath = self._state.get_video_path()

                index = self.fileModel.index(str(currentPath))

                self.ui.folderView.scrollTo(
                    self.proxyFileModel.mapFromSource(index))
                self._refreshing = False
Пример #10
0
    def initUI(self):
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)

        self.model = QFileSystemModel()
        self.model.setRootPath(QDir.rootPath())
        self.model.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot)
        self.tree = QTreeView()
        self.tree.setModel(self.model)
        self.tree.hideColumn(1)
        self.tree.hideColumn(2)
        self.tree.hideColumn(3)

        self.tree.setAnimated(False)
        self.tree.setIndentation(20)
        self.tree.setSortingEnabled(True)

        self.tree.setWindowTitle("Dir View")
        self.tree.resize(640, 480)

        self.fileModel = QFileSystemModel()
        self.fileModel.setRootPath(QDir.rootPath())
        self.list = QTableView()
        self.list.setModel(self.fileModel)
        self.list.setShowGrid(False)
        self.list.verticalHeader().setVisible(False)
        self.list.setSelectionBehavior(QTableView().SelectRows)

        self.tree.clicked.connect(self.onClicked)

        windowLayout = QHBoxLayout()
        windowLayout.addWidget(self.tree)
        windowLayout.addWidget(self.list)
        self.setLayout(windowLayout)

        self.show()
Пример #11
0
    def onFolderViewExpanded(self, proxyIndex):
        if self._refreshing:
            expandedPath = self.fileModel.filePath(
                self.proxyFileModel.mapToSource(proxyIndex))
            if expandedPath == QDir.rootPath():
                currentPath = self.get_current_selected_folder()
                if not currentPath:
                    settings = QSettings()
                    currentPath = settings.value('mainwindow/workingDirectory',
                                                 QDir.homePath())

                index = self.fileModel.index(currentPath)

                self.ui.folderView.scrollTo(
                    self.proxyFileModel.mapFromSource(index))
                self._refreshing = False
Пример #12
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent=parent)

        self.setFixedSize(300, 250)

        layout = QVBoxLayout()

        model = QFileSystemModel()
        model.setRootPath(QDir.currentPath())

        list = QListView()
        list.setModel(model)
        list.setRootIndex(model.index(
            QDir.rootPath()))  # фильтруем данные из модели!!!

        layout.addWidget(list)
        self.setLayout(layout)
Пример #13
0
    def __init__(self):
        """
        create directory tree
        """
        super().__init__()

        self.layout = QHBoxLayout(self)

        self.model = QFileSystemModel()
        self.setModel(self.model)
        self.model.setRootPath(QDir.rootPath())

        self.setIndentation(10)

        for i in range(1, 4):
            self.hideColumn(i)

        self.doubleClicked.connect(self.double_click)
Пример #14
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.model = QFileSystemModel()
     self.model.setRootPath(QDir.rootPath())
     self.tree = QTreeView()
     self.tree.setModel(self.model)
     path = expanduser("~")
     self.tree.setRootIndex(self.model.index(path))
     self.tree.doubleClicked.connect(self.open_file)
     self.tree.setSortingEnabled(True)
     header = self.tree.header()
     header.setSectionResizeMode(3)
     self.tree.setContextMenuPolicy(Qt.CustomContextMenu)
     self.tree.customContextMenuRequested.connect(self.context_menu)
     dockwidget = QDockWidget("File Explorer")
     dockwidget.setWidget(self.tree)
     dockwidget.setAllowedAreas(Qt.LeftDockWidgetArea)
     window.addDockWidget(Qt.LeftDockWidgetArea, dockwidget)
     view_menu.addAction(dockwidget.toggleViewAction())
Пример #15
0
 def initUI(self):
     self.setWindowTitle(self.title)
     self.setGeometry(self.left, self.top, self.width, self.height)
     self.model = QFileSystemModel()
     self.model.setRootPath(QDir.rootPath())
     self.tree = QTreeView()
     self.tree.setModel(self.model)
     self.tree.setRootIndex(self.model.index(config['rgb_img_path']))
     self.tree.setAnimated(False)
     self.tree.setIndentation(20)
     self.tree.setSortingEnabled(True)
     self.tree.setWindowTitle("Dir View")
     self.tree.resize(640, 480)
     self.tree.doubleClicked.connect(self.plot)
     windowLayout = QVBoxLayout()
     windowLayout.addWidget(self.tree)
     self.setLayout(windowLayout)
     self.m = PlotCanvas(self, width=5, height=4)
     self.m.move(640, 0)
     self.show()
Пример #16
0
    def initUI(self):

        self.central_widget = QWidget()
        self.setCentralWidget(self.central_widget)

        self.folderLayout = QWidget()

        self.pathRoot = QDir.rootPath()

        self.dirmodel = QFileSystemModel(self)
        self.dirmodel.setRootPath(QDir.currentPath())

        self.indexRoot = self.dirmodel.index(self.dirmodel.rootPath())

        self.folder_view = QTreeView()
        self.folder_view.setDragEnabled(True)
        self.folder_view.setModel(self.dirmodel)
        self.folder_view.setRootIndex(self.indexRoot)

        self.selectionModel = self.folder_view.selectionModel()

        self.left_layout = QVBoxLayout()
        self.left_layout.addWidget(self.folder_view)

        self.folderLayout.setLayout(self.left_layout)

        splitter_filebrowser = QSplitter(Qt.Horizontal)
        splitter_filebrowser.addWidget(self.folderLayout)
        splitter_filebrowser.addWidget(Figure_Canvas(self))
        splitter_filebrowser.setStretchFactor(1, 1)

        hbox = QHBoxLayout(self)
        hbox.addWidget(splitter_filebrowser)

        self.centralWidget().setLayout(hbox)

        self.setWindowTitle('Simple drag & drop')
        self.setGeometry(0, 0, 1000, 500)
Пример #17
0
 def __init__(self):
     super().__init__()
     self.setupUi(self)
     try:
         QToolTip.setFont(QFont('SansSerif', 10))
     except Exception:
         pass
     self.add_folder_button.clicked.connect(self.button_first_clicked)
     self.add_folder_button.setToolTip(
         "create <b>archive</b>\nfrom <b>folder</b>")
     self.extarct_button.clicked.connect(self.button_third_clicked)
     self.extarct_button.setToolTip("<b>archive</b> unpacking")
     self.add_file_button.clicked.connect(self.button_second_clicked)
     self.add_file_button.setToolTip(
         "create <b>archive</b>\nfrom <b>file</b>")
     self.update_inf_button.clicked.connect(self.update_recent_arcs)
     self.model = QFileSystemModel()
     self.model.setRootPath(QDir.rootPath())
     self.treeView.setModel(self.model)
     self.treeView.setColumnWidth(0, 200)
     self.treeView.setAnimated(True)
     self.treeView.setRootIndex(self.model.index(QDir.homePath()))
     self.treeView.clicked.connect(self.arc_once_clicked)
     self.treeView.doubleClicked.connect(self.arc_double_clicked)
     self.file = ""
     self.show_recent_arcs()
     view_action = QAction("&View archive content", self)
     view_action.setShortcut("Ctrl+Shift+A")
     view_action.setStatusTip("Shows the contents of the archive")
     view_action.triggered.connect(self.view_archive)
     archive_menu = self.menubar.addMenu('&Archive')
     archive_menu.addAction(view_action)
     exit_action = QAction("&Exit", self)
     exit_action.setShortcut("Ctrl+Shift+E")
     exit_action.setStatusTip("Exit from app")
     exit_action.triggered.connect(qApp.exit)
     archive_menu.addAction(exit_action)
Пример #18
0
    def __init__(self, rootdir=QDir.rootPath()):
        QWidget.__init__(self)
        self.treeview = QTreeView()
        self.listview = QListView()
        self.path = rootdir
        self.filename = ''
        self.filepath = rootdir
        self.canvas = None
        self.col_selector = None

        self.header = ''
        self.xcol = [1]
        self.ycol = [1]
        self.ncols = 0

        self.dirModel = QFileSystemModel()
        self.dirModel.setRootPath(self.path)
        self.dirModel.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)

        self.fileModel = QFileSystemModel()
        self.fileModel.setRootPath(self.filepath)
        self.fileModel.setFilter(QDir.NoDotAndDotDot | QDir.Files)
        self.fileModel.setNameFilters(['*.txt'])
        self.fileModel.setNameFilterDisables(0)

        self.treeview.setModel(self.dirModel)
        self.listview.setModel(self.fileModel)
        for i in [1, 2, 3]: self.treeview.setColumnHidden(i, True)
        self.treeview.setHeaderHidden(True)

        self.treeview.setRootIndex(self.dirModel.index(self.path))
        self.listview.setRootIndex(self.fileModel.index(self.path))

        self.treeview.clicked.connect(self.on_clicked)
        self.listview.selectionModel().currentChanged.connect(self.file_selected)
        self.listview.selectionModel().currentChanged.connect(lambda: self.canvas.update_plot(self))
        self.listview.selectionModel().currentChanged.connect(lambda: self.col_selector.update_range(self.ncols))
Пример #19
0
    def __init__(self):

        # init user interface:
        super(TextRenamer, self).__init__()
        self.show()
        self.ui = uic.loadUi('textRenamer.ui', self)

        # TODO: remember last used path
        self.path = QDir.rootPath()

        # Set up files and folder views
        self.foldersModel = QFileSystemModel()
        self.foldersModel.setRootPath(self.path)
        self.foldersModel.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)

        self.filesModel = QFileSystemModel()
        self.filesModel.setFilter(QDir.NoDotAndDotDot | QDir.Files)

        self.ui.folderView.setModel(self.foldersModel)
        self.ui.filesView.setModel(self.filesModel)

        # Remove all columns but the folder name
        self.ui.folderView.setRootIndex(self.foldersModel.index(self.path))
        self.ui.folderView.hideColumn(1)
        self.ui.folderView.hideColumn(2)
        self.ui.folderView.hideColumn(3)

        # Set path for start
        self.ui.filesView.setRootIndex(self.filesModel.index(self.path))

        # Event handlers:
        self.ui.renameButton.clicked.connect(self.renameFiles)
        self.ui.folderView.clicked.connect(self.openFolder)
        self.filesModel.directoryLoaded.connect(self.loadedFolder)
        self.ui.extensionCheckbox.stateChanged.connect(
            self.extensionCheckboxChanged)
Пример #20
0
    def setup_ui(self):
        self.ui.setupUi(self)

        self.ui.splitter.setSizes([600, 1000])
        self.ui.splitter.setChildrenCollapsible(False)

        # Set up folder view

        self.fileModel = QFileSystemModel(self)
        self.fileModel.setFilter(QDir.AllDirs | QDir.Dirs | QDir.Drives
                                 | QDir.NoDotAndDotDot | QDir.Readable
                                 | QDir.Executable | QDir.Writable)
        self.fileModel.iconProvider().setOptions(
            QFileIconProvider.DontUseCustomDirectoryIcons)
        self.fileModel.setRootPath(QDir.rootPath())
        self.fileModel.directoryLoaded.connect(self.onFileModelDirectoryLoaded)

        self.proxyFileModel = QSortFilterProxyModel(self)
        self.proxyFileModel.setSortRole(Qt.DisplayRole)
        self.proxyFileModel.setSourceModel(self.fileModel)
        self.proxyFileModel.sort(0, Qt.AscendingOrder)
        self.proxyFileModel.setSortCaseSensitivity(Qt.CaseInsensitive)
        self.ui.folderView.setModel(self.proxyFileModel)

        self.ui.folderView.setHeaderHidden(True)
        self.ui.folderView.hideColumn(3)
        self.ui.folderView.hideColumn(2)
        self.ui.folderView.hideColumn(1)

        self.ui.folderView.expanded.connect(self.onFolderViewExpanded)
        self.ui.folderView.clicked.connect(self.onFolderTreeClicked)
        self.ui.buttonFind.clicked.connect(self.onButtonFind)
        self.ui.buttonRefresh.clicked.connect(self.onButtonRefresh)

        # Setup and disable buttons
        self.ui.buttonFind.setEnabled(False)
        self.ui.buttonSearchSelectFolder.setEnabled(False)
        self.ui.buttonSearchSelectVideos.setEnabled(False)

        # Set up introduction
        self.showInstructions()

        # Set unknown  text here instead of `retranslate()` because widget translates itself
        self.ui.filterLanguageForVideo.set_unknown_text(_('All languages'))
        self.ui.filterLanguageForVideo.set_selected_language(
            UnknownLanguage.create_generic())
        self.ui.filterLanguageForVideo.selected_language_changed.connect(
            self.on_language_combobox_filter_change)

        # Set up video view
        self.videoModel = VideoModel(self)
        self.videoModel.connect_treeview(self.ui.videoView)
        self.ui.videoView.setHeaderHidden(True)
        self.ui.videoView.clicked.connect(self.onClickVideoTreeView)
        self.ui.videoView.selectionModel().currentChanged.connect(
            self.onSelectVideoTreeView)
        self.ui.videoView.customContextMenuRequested.connect(self.onContext)
        self.ui.videoView.setUniformRowHeights(True)
        self.videoModel.dataChanged.connect(self.subtitlesCheckedChanged)
        self.language_filter_change.connect(
            self.videoModel.on_filter_languages_change)

        self.ui.buttonSearchSelectVideos.clicked.connect(
            self.onButtonSearchSelectVideos)
        self.ui.buttonSearchSelectFolder.clicked.connect(
            self.onButtonSearchSelectFolder)
        self.ui.buttonDownload.clicked.connect(self.onButtonDownload)
        self.ui.buttonPlay.clicked.connect(self.onButtonPlay)
        self.ui.buttonIMDB.clicked.connect(self.onViewOnlineInfo)
        self.ui.videoView.setContextMenuPolicy(Qt.CustomContextMenu)

        self.ui.buttonPlay.setEnabled(False)

        # Drag and Drop files to the videoView enabled
        # FIXME: enable drag events for videoView (and instructions view)
        self.ui.videoView.__class__.dragEnterEvent = self.dragEnterEvent
        self.ui.videoView.__class__.dragMoveEvent = self.dragEnterEvent
        self.ui.videoView.__class__.dropEvent = self.dropEvent
        self.ui.videoView.setAcceptDrops(1)

        self.retranslate()
Пример #21
0
 def browseGetFile(self):
     file, _ = QFileDialog.getOpenFileName(self, 'Single File',
                                           QDir.rootPath(), '*.txt')
     self.inputLineEdit.setText(file)
Пример #22
0
    def __init__(self, parent):
        super(QWidget, self).__init__(parent)
        self.parent = parent
        self.setFixedWidth(400)
        self.layout = QVBoxLayout(self)

        # Инициализация вкладок
        self.tabs = QTabWidget()

        # init first tab
        self.directory_viewer = QTreeView()

        self.cur_item = None

        path = QDir.rootPath()
        self.dirModel = QFileSystemModel()
        self.dirModel.setRootPath(QDir.rootPath())
        self.dirModel.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)

        self.fileModel = QFileSystemModel()
        self.fileModel.setFilter(QDir.NoDotAndDotDot | QDir.Files)

        self.directory_viewer.setModel(self.dirModel)
        self.directory_viewer.setRootIndex(self.dirModel.index(path))

        self.directory_viewer.clicked.connect(self.parent.on_clicked_directory)

        self.tabs.addTab(self.directory_viewer, 'Directory')

        # init photo album creator and viewer
        self.album_viewer = QListWidget()

        self.dict_albums = {}  # key - name album, value list path photo path

        self.album_viewer.setViewMode(QListWidget.IconMode)
        self.album_viewer.setResizeMode(QListWidget.Adjust)
        self.album_viewer.setMovement(QListView.Static)

        self.tabs.addTab(self.album_viewer, 'Album viewer')

        self.album_viewer.itemClicked.connect(self.on_clicked_album)

        self.layout.addWidget(self.tabs)

        # init btn for manage photo album directory

        self.search_btn = QPushButton(self)
        self.search_btn.resize(QSize(28, 28))
        self.search_btn.setIconSize(QSize(28, 28))
        self.search_btn.setIcon(QIcon('image/search.png'))
        self.search_btn.clicked.connect(self.open_find_widget)

        self.add_album = QPushButton(self)
        self.add_album.resize(QSize(28, 28))
        self.add_album.setIconSize(QSize(28, 28))
        self.add_album.setIcon(QIcon('image/add_album.png'))
        self.add_album.clicked.connect(self.add_album_widget)

        self.edit_album = QPushButton(self)
        self.edit_album.resize(QSize(28, 28))
        self.edit_album.setIconSize(QSize(40, 44))
        self.edit_album.setIcon(QIcon('image/edit_folder.png'))
        self.edit_album.clicked.connect(self.edit_album_f)

        self.del_album = QPushButton(self)
        self.del_album.resize(QSize(28, 28))
        self.del_album.setIconSize(QSize(28, 28))
        self.del_album.setIcon(QIcon('image/delete_folder.png'))
        self.del_album.clicked.connect(self.del_album_f)

        self.cluster_widget = ClusterWidget(list(self.dict_albums.keys()),
                                            parent=self)

        self.btn_cluster = QPushButton(self)
        self.btn_cluster.resize(QSize(28, 28))
        self.btn_cluster.setIconSize(QSize(28, 28))
        self.btn_cluster.setIcon(QIcon('image/cluster.png'))
        self.btn_cluster.clicked.connect(self.show_cluster_widget)

        # init widgets edit and add, del album

        self.add_album_w = AddAlbum(self)
        self.edit_album_w = None

        self.search_widget = SearchWidget(self)
        self.cluster_creator = None

        self.setLayout(self.layout)
Пример #23
0
    def initUI(self):
        boxlayout = QBoxLayout(QBoxLayout.TopToBottom)
        self.setLayout(boxlayout)

        lblWelcome = QLabel('Welcome to the earthquake simulation system')
        lblWelcome.setFont(gui.QFont("Verdana", 14))
        lblSubtitle = QLabel('Upload your .smc files here')
        lblSubtitle.setFont(gui.QFont("Verdana", 10))

        canvas = Canvas(self, width=10, height=10)

        path = QDir.rootPath()

        treeview = QTreeView()
        listview = QListView()

        dirModel = QFileSystemModel()
        dirModel.setFilter(QDir.NoDotAndDotDot | QDir.AllDirs)
        treeview.setModel(dirModel)

        fileModel = QFileSystemModel()
        fileModel.setFilter(QDir.NoDotAndDotDot | QDir.Files)
        listview.setModel(fileModel)

        treeview.setRootIndex(dirModel.index(path))
        listview.setRootIndex(fileModel.index(path))

        btnUpload = QPushButton('Upload files')
        btnUpload.setFixedSize(100, 40)
        btnUpload.setFont(gui.QFont("Verdana", 10))
        btnUpload.clicked.connect(self.openFileChooser)

        btnSimulate = QPushButton('Simulate')
        btnSimulate.setFixedSize(100, 40)
        btnSimulate.setFont(gui.QFont("Verdana", 10))
        btnSimulate.clicked.connect(self.simulate)

        hbox_FileChooser = QHBoxLayout()
        hbox_FileChooser.addWidget(btnUpload)
        hbox_FileChooser.addWidget(self.lblFileName)

        vbox_treeViews = QVBoxLayout()
        vbox_treeViews.addWidget(treeview)
        vbox_treeViews.addWidget(listview)

        hbox_Graphics = QHBoxLayout()
        hbox_Graphics.addLayout(vbox_treeViews)
        hbox_Graphics.addWidget(canvas)

        boxlayout.addWidget(lblWelcome, 0, cor.Qt.AlignCenter)
        boxlayout.addWidget(lblSubtitle, 0, cor.Qt.AlignCenter)

        boxlayout.addLayout(hbox_FileChooser, 0)
        boxlayout.addWidget(btnSimulate, 0, cor.Qt.AlignCenter)
        boxlayout.setAlignment(cor.Qt.AlignCenter)
        boxlayout.setSpacing(20)
        boxlayout.addLayout(hbox_Graphics, 0)

        btnUpload = QPushButton('Upload files')
        btnUpload.setFixedSize(100, 40)
        btnUpload.setFont(gui.QFont("Verdana", 10))
        btnUpload.clicked.connect(self.openFileChooser)

        self.resize(800, 500)
        self.setWindowTitle('Earthquake Simulator')
        self.show()
Пример #24
0
    def setup_ui(self):
        self.ui.setupUi(self)
        settings = QSettings()

        self.ui.splitter.setSizes([600, 1000])
        self.ui.splitter.setChildrenCollapsible(False)

        # Set up folder view

        lastDir = settings.value("mainwindow/workingDirectory",
                                 QDir.homePath())
        log.debug('Current directory: {currentDir}'.format(currentDir=lastDir))

        self.fileModel = QFileSystemModel(self)
        self.fileModel.setFilter(QDir.AllDirs | QDir.Dirs | QDir.Drives
                                 | QDir.NoDotAndDotDot | QDir.Readable
                                 | QDir.Executable | QDir.Writable)
        self.fileModel.iconProvider().setOptions(
            QFileIconProvider.DontUseCustomDirectoryIcons)
        self.fileModel.setRootPath(QDir.rootPath())
        self.fileModel.directoryLoaded.connect(self.onFileModelDirectoryLoaded)

        self.proxyFileModel = QSortFilterProxyModel(self)
        self.proxyFileModel.setSortRole(Qt.DisplayRole)
        self.proxyFileModel.setSourceModel(self.fileModel)
        self.proxyFileModel.sort(0, Qt.AscendingOrder)
        self.proxyFileModel.setSortCaseSensitivity(Qt.CaseInsensitive)
        self.ui.folderView.setModel(self.proxyFileModel)

        self.ui.folderView.setHeaderHidden(True)
        self.ui.folderView.hideColumn(3)
        self.ui.folderView.hideColumn(2)
        self.ui.folderView.hideColumn(1)

        index = self.fileModel.index(lastDir)
        proxyIndex = self.proxyFileModel.mapFromSource(index)
        self.ui.folderView.scrollTo(proxyIndex)

        self.ui.folderView.expanded.connect(self.onFolderViewExpanded)
        self.ui.folderView.clicked.connect(self.onFolderTreeClicked)
        self.ui.buttonFind.clicked.connect(self.onButtonFind)
        self.ui.buttonRefresh.clicked.connect(self.onButtonRefresh)

        # Set up introduction
        self.showInstructions()

        # Set up video view
        self.ui.filterLanguageForVideo.set_unknown_text(_('All languages'))
        self.ui.filterLanguageForVideo.selected_language_changed.connect(
            self.on_language_combobox_filter_change)
        # self.ui.filterLanguageForVideo.selected_language_changed.connect(self.onFilterLanguageVideo)

        self.videoModel = VideoModel(self)
        self.ui.videoView.setHeaderHidden(True)
        self.ui.videoView.setModel(self.videoModel)
        self.ui.videoView.activated.connect(self.onClickVideoTreeView)
        self.ui.videoView.clicked.connect(self.onClickVideoTreeView)
        self.ui.videoView.customContextMenuRequested.connect(self.onContext)
        self.videoModel.dataChanged.connect(self.subtitlesCheckedChanged)
        self.language_filter_change.connect(
            self.videoModel.on_filter_languages_change)

        self.ui.buttonSearchSelectVideos.clicked.connect(
            self.onButtonSearchSelectVideos)
        self.ui.buttonSearchSelectFolder.clicked.connect(
            self.onButtonSearchSelectFolder)
        self.ui.buttonDownload.clicked.connect(self.onButtonDownload)
        self.ui.buttonPlay.clicked.connect(self.onButtonPlay)
        self.ui.buttonIMDB.clicked.connect(self.onViewOnlineInfo)
        self.ui.videoView.setContextMenuPolicy(Qt.CustomContextMenu)

        # Drag and Drop files to the videoView enabled
        self.ui.videoView.__class__.dragEnterEvent = self.dragEnterEvent
        self.ui.videoView.__class__.dragMoveEvent = self.dragEnterEvent
        self.ui.videoView.__class__.dropEvent = self.dropEvent
        self.ui.videoView.setAcceptDrops(1)

        # FIXME: ok to drop this connect?
        # self.ui.videoView.clicked.connect(self.onClickMovieTreeView)

        self.retranslate()
Пример #25
0
from PyQt5.QtCore import QDir
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QColumnView
from PyQt5.QtWidgets import QFileSystemModel
from PyQt5.QtWidgets import QSplitter
from PyQt5.QtWidgets import QTreeView

if __name__ == '__main__':
    app = QApplication(sys.argv)
    # Splitter to show 2 views in same widget easily.
    splitter = QSplitter()
    # The model.
    model = QFileSystemModel()
    # You can setRootPath to any path.
    model.setRootPath(QDir.rootPath())
    # List of views.
    views = []
    for ViewType in (QColumnView, QTreeView):
        # Create the view in the splitter.
        view = ViewType(splitter)
        # Set the model of the view.
        view.setModel(model)
        # # Set the root index of the view as the user's home directory.
        view.setRootIndex(model.index(QDir.homePath()))
    # Show the splitter.
    splitter.show()
    # Maximize the splitter.
    splitter.showMaximized()
    # Start the main loop.
    sys.exit(app.exec_())
Пример #26
0
 def on_btnDir_rootPath_clicked(self):
     self.__showBtnInfo(self.sender())
     text = QDir.rootPath()
     self.ui.textEdit.appendPlainText(text + "\n")
Пример #27
0
 def get_ffmpeg_bin():
     self.ui.ffmpeg_bin_input.setText(
         QFileDialog.getExistingDirectory(self.MainWindow,
                                          "Set FFmpeg Bin",
                                          QDir.rootPath()))