예제 #1
0
파일: files.py 프로젝트: bordstein/hamster
def _get_hamster_dir():
    hamster_dir = QDesktopServices.storageLocation(
        QDesktopServices.DataLocation)
    if not os.path.exists(hamster_dir):
        os.makedirs(hamster_dir)
        #TODO catch exception
    return hamster_dir
예제 #2
0
파일: State.py 프로젝트: ra2003/xindex
 def __init__(self, window, *, parent=None):
     super().__init__(parent)
     self.printer = None
     self.user = Username.name()
     self.indexPath = QDesktopServices.storageLocation(
         QDesktopServices.DocumentsLocation)
     self.outputPath = self.importPath = self.indexPath
     self.model = Xix.Model.Model(self.user)
     self.startCount = 0
     self.workTime = 0
     self.entryPanel = None
     self.spellPanel = None
     self.viewAllPanel = None
     self.viewFilteredPanel = None
     self.replacePanel = None
     self.window = window
     self.helpForm = None
     self.saving = False
     self.editors = set()
     self.gotoEids = collections.deque(maxlen=MAX_DYNAMIC_ACTIONS)
     self.mode = ModeKind.NO_INDEX
     self.spell = True
     self.pagesCache = ""
     self.showMessageTime = 10000
     self.initializeDisplayFonts()
    def __init__(self):
        dbus_main_loop = dbus.glib.DBusGMainLoop(set_as_default=True)
        session_bus = dbus.SessionBus(dbus_main_loop)
        bus_name = dbus.service.BusName("com.mikeasoft.statusnet",
                                        bus=session_bus)
        dbus.service.Object.__init__(self,
                                     object_path="/synchronize",
                                     bus_name=bus_name)

        self.app = QCoreApplication(sys.argv)
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        self.client = gconf.client_get_default()
        self.api_path = self.client.get_string(
            '/apps/ControlPanel/Statusnet/api_path')
        self.latest = self.client.get_int(
            '/apps/ControlPanel/Statusnet/latest')
        self.eventService = EventFeedService('statusnet', 'StatusNet')
        self.eventService.local_name = "com.mikeasoft.statusnet.eventcallback"
        self.eventService.DEFAULT_INTF = "com.mikeasoft.statusnet.eventcallback"
        if not self.api_path:
            return
        self.cacheDir = QDesktopServices.storageLocation(
            QDesktopServices.CacheLocation)
        if not os.path.exists(self.cacheDir):
            os.mkdir(self.cacheDir)
        sys.exit(self.app.exec_())
예제 #4
0
 def browseVideos(self):
     self.rootPath = QDesktopServices.storageLocation(
         QDesktopServices.MoviesLocation)
     self.fileSystemModel.setFilter(QDir.AllEntries | QDir.NoDotAndDotDot
                                    | QDir.AllDirs)
     self.view.setRootIndex(self.fileSystemModel.index(self.rootPath))
     self.setWindowTitle(self.tr("Videos"))
예제 #5
0
파일: __init__.py 프로젝트: rajansg/qsh
 def get_config_path(cls):
     config_path = os.path.join(
         QDesktopServices.storageLocation(QDesktopServices.DataLocation),
         "qsh")
     if not os.path.exists(config_path):
         os.makedirs(config_path)
     return os.path.join(config_path, "config")
예제 #6
0
파일: app.py 프로젝트: bwprice/inselect
    def open_file(self, path=None):
        """Opens path, which can be None, the path to an inselect document or
        the path to an image file. If None, the user is prompted to select a
        file.

        * If a .inselect file, the file is opened
        * If an image file for which a .inselect document already exists, the
        .inselect file is opened
        * If a _thumbnail.jpg file corresponding to an existing .inselect file,
        the .inselect file is opened
        * If an image file, a new .inselect file is created and opened
        """
        debug_print(u'MainWindow.open_file [{0}]'.format(path))

        if not path:
            folder = QSettings().value(
                'working_directory',
                QDesktopServices.storageLocation(
                    QDesktopServices.DocumentsLocation))

            filter = u'Inselect documents (*{0});;Images ({1})'
            filter = filter.format(InselectDocument.EXTENSION,
                                   u' '.join(IMAGE_PATTERNS))
            path, selectedFilter = QtGui.QFileDialog.getOpenFileName(
                self, "Open", folder, filter)

        if path:
            # Will be None if user cancelled getOpenFileName
            if not self.close_document():
                # User does not want to close the existing document
                pass
            else:
                path = Path(path)

                if path.suffix in IMAGE_SUFFIXES:
                    # Compute the path to the inselect document (which may or
                    # may not already exist) of the image file
                    doc_of_image = path.name.replace(
                        InselectDocument.THUMBNAIL_SUFFIX, u'')
                    doc_of_image = path.parent / doc_of_image
                    doc_of_image = doc_of_image.with_suffix(
                        InselectDocument.EXTENSION)
                else:
                    doc_of_image = None

                if InselectDocument.EXTENSION == path.suffix:
                    # Open the .inselect document
                    debug_print('Opening inselect document [{0}]'.format(path))
                    self.open_document(path)
                elif doc_of_image and doc_of_image.is_file():
                    # An image file corresponding to an existing .inselect file
                    msg = u'Opening inselect document [{0}] of thumbnail [{1}]'
                    debug_print(msg.format(doc_of_image, path))
                    self.open_document(doc_of_image)
                elif path.suffix in IMAGE_SUFFIXES:
                    msg = u'Creating new inselect document for image [{0}]'
                    debug_print(msg.format(path))
                    self.new_document(path)
                else:
                    raise InselectError('Unknown file type [{0}]'.format(path))
예제 #7
0
    def __init__(self, app):
        super(MainWindow, self).__init__()

        # Window layout - a splitter with the image on the left and controls
        # on the right
        self._image_widget = ImageLabel(self)
        self._controls = Controls(self)
        self._splitter = QSplitter()
        self._splitter.addWidget(self._image_widget)
        self._splitter.addWidget(self._controls)
        self._splitter.setSizes([1200, 600])

        # Main window layout
        self.setCentralWidget(self._splitter)

        # Connect controls to handlers
        self._controls.ok.clicked.connect(self.ok)
        self._controls.cancel.clicked.connect(self.cancel)
        self._controls.inbox.choose_directory.clicked.connect(
            self.choose_inbox)
        self._controls.processed.choose_directory.clicked.connect(
            self.choose_processed)

        # Directories
        mydocuments = QDesktopServices.storageLocation(
            QDesktopServices.DocumentsLocation)
        self._inbox = Path(QSettings().value('inbox',
                                             str(Path(mydocuments) / 'inbox')))
        self._processed = Path(QSettings().value(
            'processed', str(Path(mydocuments) / 'processed')))

        self._controls.inbox.set_link(str(self._inbox.as_uri()),
                                      self._inbox.name)
        self._controls.processed.set_link(str(self._processed.as_uri()),
                                          self._processed.name)

        # A stack of Path objects to be processed
        self._pending_files = []

        # The Path currently shown in the UI
        self._under_review = None

        # Watch the inbox directory, if it exists
        self.new_pending_files.connect(self.process_next_pending,
                                       QtCore.Qt.QueuedConnection)

        if self._inbox.is_dir():
            self._watcher = NewFileWatcher(self._inbox, IMAGE_SUFFIXES_RE)
            self._watcher.new_file.connect(self.new_image_file)
        else:
            self._watcher = None

        self.empty_controls()

        # Setup drag-drop handling
        self.setAcceptDrops(True)
        self._controls.installEventFilter(self)
        self._splitter.installEventFilter(self)
예제 #8
0
 def browseMediapath(self):
     self.loadMediaBrowseSettings()
     options = QtGui.QFileDialog.Options()
     if (os.path.isdir(self.mediadirectory)):
         defaultdirectory = self.mediadirectory
     elif (os.path.isdir(QDesktopServices.storageLocation(QDesktopServices.MoviesLocation))):
         defaultdirectory = QDesktopServices.storageLocation(QDesktopServices.MoviesLocation)
     elif (os.path.isdir(QDesktopServices.storageLocation(QDesktopServices.HomeLocation))):
         defaultdirectory = QDesktopServices.storageLocation(QDesktopServices.HomeLocation)
     else:
         defaultdirectory = ""
     browserfilter = "All files (*)"       
     fileName, filtr = QtGui.QFileDialog.getOpenFileName(self,"Browse for media files",defaultdirectory,
             browserfilter, "", options)
     if fileName:
         self.mediapathTextbox.setText(os.path.normpath(fileName))
         self.mediadirectory = os.path.dirname(fileName)
         self.saveMediaBrowseSettings()
예제 #9
0
 def browseMediapath(self):
     self.loadMediaBrowseSettings()
     options = QtGui.QFileDialog.Options()
     if (os.path.isdir(self.mediadirectory)):
         defaultdirectory = self.mediadirectory
     elif (os.path.isdir(QDesktopServices.storageLocation(QDesktopServices.MoviesLocation))):
         defaultdirectory = QDesktopServices.storageLocation(QDesktopServices.MoviesLocation)
     elif (os.path.isdir(QDesktopServices.storageLocation(QDesktopServices.HomeLocation))):
         defaultdirectory = QDesktopServices.storageLocation(QDesktopServices.HomeLocation)
     else:
         defaultdirectory = ""
     browserfilter = "All Files (*)"       
     fileName, filtr = QtGui.QFileDialog.getOpenFileName(self,"Browse for media files",defaultdirectory,
             browserfilter, "", options)
     if fileName:
         self.mediapathTextbox.setText(fileName)
         self.mediadirectory = os.path.dirname(fileName)
         self.saveMediaBrowseSettings()
예제 #10
0
 def askOpenFile(self):
     if not self.askSaveChanges():
         return
     directory = QDesktopServices.storageLocation(
         QDesktopServices.DocumentsLocation)
     filename, selected_filter = QFileDialog.getOpenFileName(
         self, self.trUtf8(b'Open file'), directory)
     if filename:
         self.load(filename)
예제 #11
0
    def __init__(self, app):
        super(MainWindow, self).__init__()

        # Window layout - a splitter with the image on the left and controls
        # on the right
        self._image_widget = ImageLabel(self)
        self._controls = Controls(self)
        self._splitter = QSplitter()
        self._splitter.addWidget(self._image_widget)
        self._splitter.addWidget(self._controls)
        self._splitter.setSizes([1200, 600])

        # Main window layout
        self.setCentralWidget(self._splitter)

        # Connect controls to handlers
        self._controls.ok.clicked.connect(self.ok)
        self._controls.cancel.clicked.connect(self.cancel)
        self._controls.inbox.choose_directory.clicked.connect(self.choose_inbox)
        self._controls.processed.choose_directory.clicked.connect(self.choose_processed)

        # Directories
        mydocuments = QDesktopServices.storageLocation(
            QDesktopServices.DocumentsLocation)
        self._inbox = Path(QSettings().value('inbox',
            str(Path(mydocuments) / 'inbox')))
        self._processed = Path(QSettings().value('processed',
            str(Path(mydocuments) / 'processed')))

        self._controls.inbox.set_link(str(self._inbox.as_uri()), self._inbox.name)
        self._controls.processed.set_link(str(self._processed.as_uri()), self._processed.name)

        # A stack of Path objects to be processed
        self._pending_files = []

        # The Path currently shown in the UI
        self._under_review = None

        # Watch the inbox directory, if it exists
        self.new_pending_files.connect(self.process_next_pending,
            QtCore.Qt.QueuedConnection)

        if self._inbox.is_dir():
            self._watcher = NewFileWatcher(self._inbox, IMAGE_SUFFIXES_RE)
            self._watcher.new_file.connect(self.new_image_file)
        else:
            self._watcher = None

        self.empty_controls()

        # Setup drag-drop handling
        self.setAcceptDrops(True)
        self._controls.installEventFilter(self)
        self._splitter.installEventFilter(self)
예제 #12
0
 def askSaveFile(self):
     if self.currentFilename:
         directory = os.path.dirname(self.currentFilename)
     else:
         directory = QDesktopServices.storageLocation(
             QDesktopServices.DocumentsLocation)
     filename, selected_filter = QFileDialog.getSaveFileName(
         self, self.trUtf8(b'Save file'), directory)
     if not filename:
         return False
     return self.saveFile()
예제 #13
0
    def __init__(self):
        self.configpath = os.path.join(QDS.storageLocation(QDS.DataLocation),
                                       PROGRAM_NAME)
        self.configfile = os.path.join(self.configpath, "config.json")

        logger.debug("Loading configuration from: %s" % self.configfile)
        try:
            with open(self.configfile, 'r') as handle:
                self.values = json.load(handle)
            logger.debug("Configuration loaded")
        except:
            logger.error("Failed to load configuration file!")
            self.values = {}
예제 #14
0
    def __init__(self):
        self.configpath = os.path.join(QDS.storageLocation(QDS.DataLocation), "n9rpn")
        self.configfile = os.path.join(self.configpath, "config.json")

        logger.debug("Loading configuration from: %s" % self.configfile)
        try:
            with open(self.configfile, 'r') as handle:
                self.values = json.load(handle)
            logger.debug("Configuration loaded")
        except:
            logger.error("Failed to load configuration file!")
            self.values = {'stack': [],
                           'format': "%0.4f",
                           'grad': 0,
                           'statistics': [0, 0, 0, 0, 0, 0, ]}
예제 #15
0
파일: path.py 프로젝트: ewerybody/siding
def appdata():
    """
    Return the path that application data should be stored in. This acts a bit
    special on Windows machines as Qt doesn't return the right path itself.
    """
    if os.name == "nt":
        path = os.getenv("APPDATA")
        app = QCoreApplication.instance()
        if app:
            if app.organizationName():
                path = os.path.join(path, app.organizationName())
            if app.applicationName():
                path = os.path.join(path, app.applicationName())
        return path

    return QDesktopServices.storageLocation(QDesktopServices.DataLocation)
예제 #16
0
파일: path.py 프로젝트: sl5net/a2
def appdata():
    """
    Return the path that application data should be stored in. This acts a bit
    special on Windows machines as Qt doesn't return the right path itself.
    """
    if os.name == 'nt':
        path = os.getenv('APPDATA')
        app = QCoreApplication.instance()
        if app:
            if app.organizationName():
                path = os.path.join(path, app.organizationName())
            if app.applicationName():
                path = os.path.join(path, app.applicationName())
        return path

    return QDesktopServices.storageLocation(QDesktopServices.DataLocation)
예제 #17
0
    def _make_backup_of_existing_file(cls, original_file_path):
        # We ask Qt for a suitable directory on the platform for user data.
        # On Windows it will resolve to something like:
        # C:\Users\<user_namer>\AppData\Local\python\qtlayoutbuilder\
        # Each file is timestamped like this:
        # archived_input-20170417-003554.txt

        dir_for_archive_copy = path.join(
            QDesktopServices.storageLocation(QDesktopServices.DataLocation),
            'qtlayoutbuilder')
        if not os.path.exists(dir_for_archive_copy):
            os.makedirs(dir_for_archive_copy)
        timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
        archive_fname = path.join(dir_for_archive_copy,
                                  'archived_input-' + timestamp + '.txt')
        shutil.copyfile(original_file_path, archive_fname)
        return dir_for_archive_copy, archive_fname
    def _on_export(self):
        if len(self.test.array) == 0:
            QMessageBox.warning(self, self.tr("IrregularVerbsTestGenerator"),
                                self.tr("You need to generate a test first !"))
            return

        export_file, export_format = QFileDialog.getSaveFileName(
            self, 
            self.tr("Save test"),
            QDesktopServices.storageLocation(QDesktopServices.DesktopLocation),
            self.tr("Xls file (*.xls)"))
        
        if not export_file:
            return

        include_solutions = self.mIncludeSolutions.isChecked()
        export_file = "{0}.xls".format(os.path.splitext(export_file)[0])
        _export_test_to_xls_file(self.test, export_file, include_solutions)
예제 #19
0
파일: profile.py 프로젝트: sl5net/a2
def get_data_path():
    """
    Returns the path that application data should be stored in. This acts a bit
    special on Windows machines, using the APPDATA environment variable to
    ensure things go to AppData\Roaming and not AppData\Local.
    """
    if os.name == 'nt':
        qapp = QCoreApplication.instance()
        path = os.getenv('APPDATA')

        if qapp.organizationName():
            path = os.path.join(path, qapp.organizationName())

        if qapp.applicationName():
            path = os.path.join(path, qapp.applicationName())

        return path

    return QDesktopServices.storageLocation(QDesktopServices.DataLocation)
예제 #20
0
파일: profile.py 프로젝트: gitter-badger/a2
def get_data_path():
    """
    Returns the path that application data should be stored in. This acts a bit
    special on Windows machines, using the APPDATA environment variable to
    ensure things go to AppData\Roaming and not AppData\Local.
    """
    if os.name == 'nt':
        qapp = QCoreApplication.instance()
        path = os.getenv('APPDATA')

        if qapp.organizationName():
            path = os.path.join(path, qapp.organizationName())

        if qapp.applicationName():
            path = os.path.join(path, qapp.applicationName())

        return path

    return QDesktopServices.storageLocation(QDesktopServices.DataLocation)
예제 #21
0
파일: profile.py 프로젝트: sl5net/a2
def ensure_paths():
    """ Ensure cache_path, profile_path, and root_path are set. """
    global cache_path
    global profile_path
    global root_path

    if not root_path:
        root_path = os.path.abspath(os.path.dirname(sys.argv[0]))

    if not profile_path:
        # The profile path is a bit trickier than the root path, since it can
        # move depending on the portability flag.
        if portable:
            path = root_path
        else:
            path = os.path.abspath(get_data_path())

        # Add the Profiles/<profile> bit to the profile path, and ensure the
        # path actually exists.
        path = os.path.join(path, u'Profiles', name)
        if not os.path.exists(path):
            os.makedirs(path)

        profile_path = path

    if not cache_path:
        # The cache path is like the profile path, in that it varies based on
        # the portability flag.
        if portable:
            path = os.path.join(root_path, u'cache')
        else:
            path = QDesktopServices.storageLocation(
                QDesktopServices.CacheLocation)

        # Add the Profiles/<profile> bit to the cache path, and ensure the path
        # actually exists.
        path = os.path.join(path, u'Profiles', name)
        if not os.path.exists(path):
            os.makedirs(path)

        cache_path = path
예제 #22
0
파일: profile.py 프로젝트: gitter-badger/a2
def ensure_paths():
    """ Ensure cache_path, profile_path, and root_path are set. """
    global cache_path
    global profile_path
    global root_path

    if not root_path:
        root_path = os.path.abspath(os.path.dirname(sys.argv[0]))

    if not profile_path:
        # The profile path is a bit trickier than the root path, since it can
        # move depending on the portability flag.
        if portable:
            path = root_path
        else:
            path = os.path.abspath(get_data_path())

        # Add the Profiles/<profile> bit to the profile path, and ensure the
        # path actually exists.
        path = os.path.join(path, u'Profiles', name)
        if not os.path.exists(path):
            os.makedirs(path)

        profile_path = path

    if not cache_path:
        # The cache path is like the profile path, in that it varies based on
        # the portability flag.
        if portable:
            path = os.path.join(root_path, u'cache')
        else:
            path = QDesktopServices.storageLocation(
                QDesktopServices.CacheLocation)

        # Add the Profiles/<profile> bit to the cache path, and ensure the path
        # actually exists.
        path = os.path.join(path, u'Profiles', name)
        if not os.path.exists(path):
            os.makedirs(path)

        cache_path = path
	def __init__(self):
		dbus_main_loop = dbus.glib.DBusGMainLoop(set_as_default=True)
		session_bus = dbus.SessionBus(dbus_main_loop)
		bus_name = dbus.service.BusName("com.mikeasoft.statusnet", bus=session_bus)
		dbus.service.Object.__init__(self, object_path="/synchronize", bus_name=bus_name)

		self.app = QCoreApplication(sys.argv)
		signal.signal(signal.SIGINT, signal.SIG_DFL)

		self.client = gconf.client_get_default()
		self.api_path = self.client.get_string('/apps/ControlPanel/Statusnet/api_path')
		self.latest = self.client.get_int('/apps/ControlPanel/Statusnet/latest')
		self.eventService = EventFeedService('statusnet', 'StatusNet')
		self.eventService.local_name = "com.mikeasoft.statusnet.eventcallback"
		self.eventService.DEFAULT_INTF = "com.mikeasoft.statusnet.eventcallback"
		if not self.api_path:
			return
		self.cacheDir = QDesktopServices.storageLocation(QDesktopServices.CacheLocation)
		if not os.path.exists(self.cacheDir):
			os.mkdir(self.cacheDir)
		sys.exit(self.app.exec_())
예제 #24
0
    def __init__(self, parent=None, flags=Qt.Widget):
        super(FileBrowser, self).__init__(parent, flags)

        self.gallery = QDocumentGallery(self)
        self.fileSystemModel = QFileSystemModel(self)

        self.rootPath = QDesktopServices.storageLocation(QDesktopServices.HomeLocation)
        self.fileSystemModel.setRootPath(self.rootPath)

        self.view = QListView()
        self.view.setModel(self.fileSystemModel)
        self.view.activated.connect(self.activated)

        self.setCentralWidget(self.view)

        self.menuBar().addAction(self.tr("Documents"), self.browseDocuments)
        self.menuBar().addAction(self.tr("Audio"), self.browseAudio)
        self.menuBar().addAction(self.tr("Images"), self.browseImages)
        self.menuBar().addAction(self.tr("Videos"), self.browseVideos)

        self.browseDocuments()
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.test = Test()

        # Copy the default irv file into app data directory if necessary
        data_path = QDesktopServices.storageLocation(QDesktopServices.DataLocation)
        if not os.path.exists(data_path):
            os.makedirs(data_path)
        verbs_file_path = os.path.join(data_path, VERBS_FILE)
        if not os.path.exists(verbs_file_path):
            shutil.copy(os.path.join(QApplication.applicationDirPath(), VERBS_FILE), 
                        verbs_file_path)

        format_file_path = os.path.join(data_path, FORMAT_FILE)
        if not os.path.exists(format_file_path):
            shutil.copy(os.path.join(QApplication.applicationDirPath(), FORMAT_FILE), 
                        format_file_path)

        # Load verbs informations
        workbook = xlrd.open_workbook(verbs_file_path)
        self.levels_list = []
        self.levels_dict = {}
        for sheet in workbook.sheets():
            verbs = []
            for i in range(sheet.nrows):
                verb = Verb(sheet.row(i)[0].value, sheet.row(i)[1].value,
                            sheet.row(i)[2].value, sheet.row(i)[3].value)
                verbs.append(verb)
            self.levels_list.append(sheet.name)
            self.levels_dict[sheet.name] = Level(verbs)

        self.mClassList.currentIndexChanged.connect(self._on_level_selected_changed)
        for level in self.levels_list:
            self.mClassList.addItem(level, level)
        self.mGenerate.clicked.connect(self._on_generate)
        self.mExport.clicked.connect(self._on_export)
        self.mActionExport.triggered.connect(self._on_export)
        self.mActionEditVerbsList.triggered.connect(self._on_edit_verbs_list)
        self.mActionEditExportStyle.triggered.connect(self._on_edit_export_style)
예제 #26
0
    def addFiles(self):
        files, _ = QFileDialog.getOpenFileNames(
            self, self.tr("Select Music Files"),
            QDesktopServices.storageLocation(QDesktopServices.MusicLocation),
            self.tr("Media Files (*.mp3 *.mp4 *.aac)")
        )
        if not files:
            return

        for mediafile in files:
            title = "unknown"
            artist, album, year = "", "", ""
            try:
                tag = EasyID3(mediafile)
                title = tag['title'][0]
                artist = tag['artist'][0]
                album = tag['album'][0]
                year = tag['date'][0]
            except:
                pass


            titleItem = QTableWidgetItem(title)
            titleItem.setFlags(titleItem.flags() ^ Qt.ItemIsEditable)
            artistItem = QTableWidgetItem(artist)
            artistItem.setFlags(artistItem.flags() ^ Qt.ItemIsEditable)
            albumItem = QTableWidgetItem(album)
            albumItem.setFlags(albumItem.flags() ^ Qt.ItemIsEditable)
            yearItem = QTableWidgetItem(year)
            yearItem.setFlags(yearItem.flags() ^ Qt.ItemIsEditable)

            currentRow = self.musicTable.rowCount()
            self.musicTable.insertRow(currentRow)
            self.musicTable.setItem(currentRow, 0, titleItem)
            self.musicTable.setItem(currentRow, 1, artistItem)
            self.musicTable.setItem(currentRow, 2, albumItem)
            self.musicTable.setItem(currentRow, 3, yearItem)
        self.engine.play_list_add(files)
        self.play_action()
예제 #27
0
    def addFiles(self):
        files, _ = QFileDialog.getOpenFileNames(
            self, self.tr("Select Music Files"),
            QDesktopServices.storageLocation(QDesktopServices.MusicLocation),
            self.tr("Media Files (*.mp3 *.mp4 *.aac)")
        )
        if not files:
            return

        for mediafile in files:
            title = "unknown"
            artist, album, year = "", "", ""
            try:
                tag = EasyID3(mediafile)
                title = tag['title'][0]
                artist = tag['artist'][0]
                album = tag['album'][0]
                year = tag['date'][0]
            except:
                pass


            titleItem = QTableWidgetItem(title)
            titleItem.setFlags(titleItem.flags() ^ Qt.ItemIsEditable)
            artistItem = QTableWidgetItem(artist)
            artistItem.setFlags(artistItem.flags() ^ Qt.ItemIsEditable)
            albumItem = QTableWidgetItem(album)
            albumItem.setFlags(albumItem.flags() ^ Qt.ItemIsEditable)
            yearItem = QTableWidgetItem(year)
            yearItem.setFlags(yearItem.flags() ^ Qt.ItemIsEditable)

            currentRow = self.musicTable.rowCount()
            self.musicTable.insertRow(currentRow)
            self.musicTable.setItem(currentRow, 0, titleItem)
            self.musicTable.setItem(currentRow, 1, artistItem)
            self.musicTable.setItem(currentRow, 2, albumItem)
            self.musicTable.setItem(currentRow, 3, yearItem)
        self.engine.play_list_add(files)
        self.play_action()
예제 #28
0
    def __init__(self, parent=None, flags=Qt.Widget):
        super(FileBrowser, self).__init__(parent, flags)

        self.gallery = QDocumentGallery(self)
        self.fileSystemModel = QFileSystemModel(self)

        self.rootPath = QDesktopServices.storageLocation(
            QDesktopServices.HomeLocation)
        self.fileSystemModel.setRootPath(self.rootPath)

        self.view = QListView()
        self.view.setModel(self.fileSystemModel)
        self.view.activated.connect(self.activated)

        self.setCentralWidget(self.view)

        self.menuBar().addAction(self.tr("Documents"), self.browseDocuments)
        self.menuBar().addAction(self.tr("Audio"), self.browseAudio)
        self.menuBar().addAction(self.tr("Images"), self.browseImages)
        self.menuBar().addAction(self.tr("Videos"), self.browseVideos)

        self.browseDocuments()
예제 #29
0
파일: path.py 프로젝트: ewerybody/siding
def cache():
    """ Return a path for writing temporary files. """
    return QDesktopServices.storageLocation(QDesktopServices.CacheLocation)
예제 #30
0
파일: __init__.py 프로젝트: fedosov/qsh
	def get_config_path(cls):
		config_path = os.path.join(QDesktopServices.storageLocation(QDesktopServices.DataLocation), "qsh")
		if not os.path.exists(config_path):
			os.makedirs(config_path)
		return os.path.join(config_path, "config")
예제 #31
0
파일: profile.py 프로젝트: gitter-badger/a2
def get_home():
    """ Returns the path to the user's home directory. """
    return QDesktopServices.storageLocation(QDesktopServices.HomeLocation)
예제 #32
0
파일: path.py 프로젝트: sl5net/a2
def home():
    """ Return the path to the user's home directory. """
    return QDesktopServices.storageLocation(QDesktopServices.HomeLocation)
예제 #33
0
파일: path.py 프로젝트: sl5net/a2
def cache():
    """ Return a path for writing temporary files. """
    return QDesktopServices.storageLocation(QDesktopServices.CacheLocation)
 def _on_edit_export_style(self):
     file_path = os.path.join(
         QDesktopServices.storageLocation(QDesktopServices.DataLocation), 
         FORMAT_FILE)
     QDesktopServices.openUrl(QUrl.fromLocalFile(file_path))
def _export_test_to_xls_file(test, filepath, include_solutions):

    # Open format workbook
    format_file_path = os.path.join(
        QDesktopServices.storageLocation(QDesktopServices.DataLocation), 
        FORMAT_FILE)
    f_workbook = xlrd.open_workbook(format_file_path, formatting_info=True)
    f_sheet = f_workbook.sheet_by_index(0)

    # Open destination workbook
    wb = xlwt.Workbook(encoding='utf-8')
    sheet = wb.add_sheet(u"Test")

    # Write header
    title_r_format, title_r_font = _get_cell_format_information(f_workbook, f_sheet, 0)
    title_w_style = _r_format_to_w_format(title_r_format, title_r_font)
    content_r_format, content_r_font = _get_cell_format_information(f_workbook, f_sheet, 1)
    content_w_style = _r_format_to_w_format(content_r_format, content_r_font)
    solution_r_format, solution_r_font = _get_cell_format_information(f_workbook, f_sheet, 2)
    solution_w_style = _r_format_to_w_format(solution_r_format, solution_r_font)
    max_cell_height = max(_get_string_width(title_w_style.font, 'w'), 
                     _get_string_width(content_w_style.font, 'w'))

    max_cell_width = len(u"Participe passé") * max_cell_height
    sheet.write(0, 0, u"Base verbale", title_w_style)
    sheet.write(0, 1, u"Preterit", title_w_style)
    sheet.write(0, 2, u"Participe passé", title_w_style)
    sheet.write(0, 3, u"Traduction", title_w_style)
    sheet.write(0, 4, u"Points", title_w_style)
    sheet.row(0).height = max_cell_height

    # Write test content
    for i in range(len(test.array)):
        for j in range(5):
            if j == test.array[i][0]:
                sheet.write(i+1, test.array[i][0], test.array[i][1], content_w_style)
                max_cell_width = max(max_cell_width, len(test.array[i][1])*max_cell_height)
            else:
                sheet.write(i+1, j, '', content_w_style)
            sheet.row(i+1).height = max_cell_height
    # Resize columns
    for i in range(4):
        sheet.col(i).width = max_cell_width
    
    # Write solutions
    if include_solutions:
        solution_lines = []
        max_line_width = max_cell_width * 5
        for solution in test.solutions:
            width = _get_string_width(solution_w_style.font, " / "+solution)
            if len(solution_lines) == 0 or (_get_string_width(solution_w_style.font, solution_lines[-1])+width) > max_line_width:
                solution_lines.append(solution)
            else:
                solution_lines[-1] += " / "+solution

        current_row = len(test.array)+2
        for line in solution_lines:
            sheet.write_merge(current_row, current_row, 0, 4, line, solution_w_style)
            current_row+=1

    wb.save(filepath)
예제 #36
0
파일: files.py 프로젝트: bordstein/hamster
def _get_hamster_dir():
    hamster_dir = QDesktopServices.storageLocation(QDesktopServices.DataLocation)
    if not os.path.exists(hamster_dir):
        os.makedirs(hamster_dir)
        #TODO catch exception
    return hamster_dir
예제 #37
0
파일: main.py 프로젝트: miurahr/gpslogger
 def __init__(self):
   self.configpath = os.path.join(QDS.storageLocation(QDS.DataLocation),
     "GPS-Logger")
   self.configfile = self.configpath + "/" + self.configfile
   self.load()
예제 #38
0
 def browseVideos(self):
     self.rootPath = QDesktopServices.storageLocation(QDesktopServices.MoviesLocation)
     self.fileSystemModel.setFilter(QDir.AllEntries | QDir.NoDotAndDotDot | QDir.AllDirs)
     self.view.setRootIndex(self.fileSystemModel.index(self.rootPath))
     self.setWindowTitle(self.tr("Videos"))
예제 #39
0
 def last_directory(cls):
     "Path the the most recently used directory"
     return Path(QSettings().value(
         cls.DIRECTORY_KEY,
         QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)
     ))
 def _on_edit_verbs_list(self):
     file_path = os.path.join(
         QDesktopServices.storageLocation(QDesktopServices.DataLocation), 
         VERBS_FILE)
     QDesktopServices.openUrl(QUrl.fromLocalFile(file_path))