Example #1
0
 def test_storingLists(self):
     data = (['1', '2', '3',
              'test'], [], ['1'], ['true'], ['foo, bar', 'foo, bar'])
     for l in data:
         writeListToSettings('testList', l, self.settings)
         lnew = readListFromSettings('testList', self.settings)
         self.assertListEqual(lnew, l)
Example #2
0
	def restoreLastOpenedFiles(self):
		for file in readListFromSettings("lastFileList"):
			self.openFileWrapper(file)

		# Show the tab of last opened file
		lastTabIndex = globalSettings.lastTabIndex
		if lastTabIndex >= 0 and lastTabIndex < self.tabWidget.count():
			self.tabWidget.setCurrentIndex(lastTabIndex)
Example #3
0
	def restoreLastOpenedFiles(self):
		for file in readListFromSettings("lastFileList"):
			self.openFileWrapper(file)

		# Show the tab of last opened file
		lastTabIndex = globalSettings.lastTabIndex
		if lastTabIndex >= 0 and lastTabIndex < self.tabWidget.count():
			self.tabWidget.setCurrentIndex(lastTabIndex)
Example #4
0
	def moveToTopOfRecentFileList(self, fileName):
		if fileName:
			files = readListFromSettings("recentFileList")
			if fileName in files:
				files.remove(fileName)
			files.insert(0, fileName)
			if len(files) > 10:
				del files[10:]
			writeListToSettings("recentFileList", files)
Example #5
0
	def moveToTopOfRecentFileList(self, fileName):
		if fileName:
			files = readListFromSettings("recentFileList")
			if fileName in files:
				files.remove(fileName)
			files.insert(0, fileName)
			if len(files) > 10:
				del files[10:]
			writeListToSettings("recentFileList", files)
Example #6
0
	def moveToTopOfRecentFileList(self, fileName):
		if fileName:
			files = readListFromSettings("recentFileList")
			if fileName in files:
				files.remove(fileName)
			files.insert(0, fileName)
			recentCount = globalSettings.recentDocumentsCount
			if len(files) > recentCount:
				del files[recentCount:]
			writeListToSettings("recentFileList", files)
Example #7
0
	def moveToTopOfRecentFileList(self, fileName):
		if fileName:
			files = readListFromSettings("recentFileList")
			if fileName in files:
				files.remove(fileName)
			files.insert(0, fileName)
			recentCount = globalSettings.recentDocumentsCount
			if len(files) > recentCount:
				del files[recentCount:]
			writeListToSettings("recentFileList", files)
Example #8
0
	def updateRecentFiles(self):
		self.menuRecentFiles.clear()
		self.recentFilesActions = []
		filesOld = readListFromSettings("recentFileList")
		files = []
		for f in filesOld:
			if QFile.exists(f):
				files.append(f)
				self.recentFilesActions.append(self.act(f, trig=self.openFunction(f)))
		writeListToSettings("recentFileList", files)
		for action in self.recentFilesActions:
			self.menuRecentFiles.addAction(action)
Example #9
0
	def updateRecentFiles(self):
		self.menuRecentFiles.clear()
		self.recentFilesActions = []
		filesOld = readListFromSettings("recentFileList")
		files = []
		for f in filesOld:
			if QFile.exists(f):
				files.append(f)
				self.recentFilesActions.append(self.act(f, trig=self.openFunction(f)))
		writeListToSettings("recentFileList", files)
		for action in self.recentFilesActions:
			self.menuRecentFiles.addAction(action)
Example #10
0
	def test_storingLists(self):
		data = (
			['1', '2', '3', 'test'],
			[],
			['1'],
			['true'],
			['foo, bar', 'foo, bar']
		)
		for l in data:
			writeListToSettings('testList', l, self.settings)
			lnew = readListFromSettings('testList', self.settings)
			self.assertListEqual(lnew, l)
Example #11
0
    def insertFromMimeData(self, mimeData):
        if mimeData.hasImage():
            if self.parent.dirTree.isVisible():
                fileName = os.path.dirname(
                    os.path.dirname(__file__)) + "/icons/middle.png"
                image = QImage(mimeData.imageData())
                image.save(fileName)
                gitCloneUrl = readListFromSettings("gitCloneUrlList")[0]
                warehouse = gitCloneUrl.split(':')[1]
                warehouse = warehouse[:-4]
                url = 'http://softpic.wingtech.com:9999/upload_file'
                files = {'file': open(fileName, 'rb')}
                res = requests.request("POST",
                                       url,
                                       data={"warehouse": warehouse},
                                       files=files)
                if res.text == "error" or res.text == '0':
                    QMessageBox.about(
                        self, "error!",
                        "please make sure that you can connect http://softpic.wingtech.com:9999 successfully"
                    )
                    return
                elif res.status_code != 200:
                    QMessageBox.about(self, "error!",
                                      "也许是图片服务上不存在对应仓库的路径,请联系SCM处理")
                    return
                link = res.text
                link = link.split(':')[3].split('<')
                link = 'http://softpic.wingtech.com:' + link[0]
                status, output = subprocess.getstatusoutput("rm -rf " +
                                                            fileName)
                if status != 0:
                    QMessageBox.about(self, "error!", output)
            else:
                fileName, link = self.getImageFilenameAndLink()
                image = QImage(mimeData.imageData())
                image.save(fileName)
            if fileName:

                markupClass = self.tab.getActiveMarkupClass()
                if markupClass == MarkdownMarkup:
                    # imageText = '![%s](%s)' % (QFileInfo(link).baseName(), link)
                    imageText = '![](%s)' % (link)
                elif markupClass == ReStructuredTextMarkup:
                    imageText = '.. image:: %s' % link
                elif markupClass == TextileMarkup:
                    imageText = '!%s!' % link

                self.textCursor().insertText(imageText)

        else:
            QTextEdit.insertFromMimeData(self, mimeData)
Example #12
0
	def setCurrentFile(self):
		self.setWindowTitle("")
		self.tabWidget.setTabText(self.ind, self.currentTab.getDocumentTitle(baseName=True))
		self.setWindowFilePath(self.currentTab.fileName)
		files = readListFromSettings("recentFileList")
		while self.currentTab.fileName in files:
			files.remove(self.currentTab.fileName)
		files.insert(0, self.currentTab.fileName)
		if len(files) > 10:
			del files[10:]
		writeListToSettings("recentFileList", files)
		QDir.setCurrent(QFileInfo(self.currentTab.fileName).dir().path())
		self.docTypeChanged()
Example #13
0
	def setCurrentFile(self):
		self.setWindowTitle("")
		self.tabWidget.setTabText(self.ind, self.getDocumentTitle(baseName=True))
		self.setWindowFilePath(self.fileNames[self.ind])
		files = readListFromSettings("recentFileList")
		while self.fileNames[self.ind] in files:
			files.remove(self.fileNames[self.ind])
		files.insert(0, self.fileNames[self.ind])
		if len(files) > 10:
			del files[10:]
		writeListToSettings("recentFileList", files)
		QDir.setCurrent(QFileInfo(self.fileNames[self.ind]).dir().path())
		self.docTypeChanged()
Example #14
0
    def send_picture(self, fileName):
        # fileName = os.path.dirname(os.path.dirname(__file__)) + "/icons/middle.png"
        # image = QImage(mimeData.imageData())
        # image.save(fileName)

        if os.path.exists(fileName):
            gitCloneUrl = readListFromSettings("gitCloneUrlList")[0]
            warehouse = gitCloneUrl.split(':')[1]
            warehouse = warehouse[:-4]
            url = 'http://softpic.wingtech.com:9999/upload_file'
            files = {'file': open(fileName, 'rb')}
            res = requests.request("POST",
                                   url,
                                   data={"warehouse": warehouse},
                                   files=files)
            if res.text == "error" or res.text == '0':
                QMessageBox.about(
                    self, "error!",
                    "please make sure that you can connect http://softpic.wingtech.com:9999 successfully"
                )
                return
            link = res.text
            link = link.split(':')[3].split('<')
            link = 'http://softpic.wingtech.com:' + link[0]
            # status, output = subprocess.getstatusoutput("rm -rf " + fileName)
            # if status != 0:
            # 	QMessageBox.about(self, "error!", output)

            if fileName:

                markupClass = self.tab.getActiveMarkupClass()
                if markupClass == MarkdownMarkup:
                    # imageText = '![%s](%s)' % (QFileInfo(link).baseName(), link)
                    imageText = '![](%s)' % (link)
                elif markupClass == ReStructuredTextMarkup:
                    imageText = '.. image:: %s' % link
                elif markupClass == TextileMarkup:
                    imageText = '!%s!' % link

                self.textCursor().insertText(imageText)
Example #15
0
 def test_storingLists(self):
     data = (["1", "2", "3", "test"], [], ["1"], ["true"], ["foo, bar", "foo, bar"])
     for l in data:
         writeListToSettings("testList", l, self.settings)
         lnew = readListFromSettings("testList", self.settings)
         self.assertListEqual(lnew, l)