by
Changes to 9 files · Browse files at 2f06fb2116a1 Showing diff from parent acf33fe36841 4172a81623d1 Diff from another changeset...
@@ -191,16 +191,14 @@ FD = QFileDialog
if select['type'] == 'files':
caption = _('Select Destination Folder')
- path = FD.getExistingDirectory(parent=self, caption=caption,
+ response = FD.getExistingDirectory(parent=self, caption=caption,
directory=dest, options=FD.ShowDirsOnly | FD.ReadOnly)
- response = str(path)
else:
caption = _('Open File')
ext = '*' + select['ext']
filter = '%s (%s)\nAll Files (*.*)' % (select['label'], ext)
- filename = FD.getOpenFileName(parent=self, caption=caption,
- directory=dest, filter=filter, options=FD.ReadOnly );
- response = str(filename)
+ response = FD.getOpenFileName(parent=self, caption=caption,
+ directory=dest, filter=filter, options=FD.ReadOnly)
if response:
self.dest_edit.setText(response)
self.update_path()
|
@@ -10,7 +10,7 @@ from tortoisehg.util import hglib
from tortoisehg.hgqt.i18n import _
from tortoisehg.hgqt import qtlib, csinfo, i18n, cmdui, status, resolve
-from tortoisehg.hgqt import commit, qscilib, thgrepo
+from tortoisehg.hgqt import qscilib, thgrepo, messageentry
from PyQt4.QtCore import *
from PyQt4.QtGui import *
@@ -232,6 +232,7 @@ cmd = hglib.fromunicode(cmd)
repo = self.repo
if cmd == 'commit':
+ from tortoisehg.hgqt import commit
dlg = commit.CommitDialog(repo, [], {}, self.wizard())
dlg.finished.connect(dlg.deleteLater)
dlg.exec_()
@@ -419,7 +420,7 @@ # commit message area
msg_sep = qtlib.LabeledSeparator(_('Commit message'))
self.layout().addWidget(msg_sep)
- msgEntry = commit.MessageEntry(self)
+ msgEntry = messageentry.MessageEntry(self)
msgEntry.installEventFilter(qscilib.KeyPressInterceptor(self))
msgEntry.refresh(repo)
msgEntry.loadSettings(QSettings(), 'backout/message')
|
|
@@ -9,14 +9,17 @@
from mercurial import ui, util, error
+from tortoisehg.util import hglib, shlib, wconfig, bugtraq
+
+from tortoisehg.hgqt.i18n import _
+from tortoisehg.hgqt.messageentry import MessageEntry
+from tortoisehg.hgqt import qtlib, qscilib, status, cmdui, branchop, revpanel
+from tortoisehg.hgqt import hgrcutil, mq
+
from PyQt4.QtCore import *
from PyQt4.QtGui import *
-from PyQt4.Qsci import QsciScintilla, QsciAPIs, QsciLexerMakefile
+from PyQt4.Qsci import QsciAPIs
-from tortoisehg.hgqt.i18n import _
-from tortoisehg.util import hglib, shlib, wconfig, bugtraq
-from tortoisehg.hgqt import qtlib, qscilib, status, cmdui, branchop, revpanel
-from tortoisehg.hgqt import hgrcutil, mq
# Technical Debt for CommitWidget
# disable commit button while no message is entered or no files are selected
@@ -24,136 +27,6 @@# spell check / tab completion
# in-memory patching / committing chunk selected files
-class MessageEntry(qscilib.Scintilla):
-
- def __init__(self, parent, getCheckedFunc=None):
- super(MessageEntry, self).__init__(parent)
- self.setEdgeColor(QColor('LightSalmon'))
- self.setEdgeMode(QsciScintilla.EdgeLine)
- self.setReadOnly(False)
- self.setMarginWidth(1, 0)
- self.setFont(qtlib.getfont('fontcomment').font())
- self.setCaretWidth(10)
- self.setCaretLineBackgroundColor(QColor("#e6fff0"))
- self.setCaretLineVisible(True)
- self.setAutoIndent(True)
- self.setAutoCompletionThreshold(2)
- self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
- self.setAutoCompletionFillupsEnabled(True)
- self.setLexer(QsciLexerMakefile(self))
- self.lexer().setFont(qtlib.getfont('fontcomment').font())
- self.lexer().setColor(QColor(Qt.red), QsciLexerMakefile.Error)
- self.setMatchedBraceBackgroundColor(Qt.yellow)
- self.setIndentationsUseTabs(False)
- self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
- #self.setIndentationGuidesBackgroundColor(QColor("#e6e6de"))
- #self.setFolding(QsciScintilla.BoxedFoldStyle)
- # http://www.riverbankcomputing.com/pipermail/qscintilla/2009-February/000461.html
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
- self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
- # default message entry widgets to word wrap, user may override
- self.setWrapMode(QsciScintilla.WrapWord)
-
- self.getChecked = getCheckedFunc
- self.setContextMenuPolicy(Qt.CustomContextMenu)
- self.customContextMenuRequested.connect(self.menuRequested)
-
- def menuRequested(self, point):
- line = self.lineAt(point)
- point = self.viewport().mapToGlobal(point)
-
- def apply():
- line = 0
- while True:
- line = self.reflowBlock(line)
- if line is None:
- break;
- def paste():
- files = self.getChecked()
- self.insert(', '.join(files))
- def settings():
- from tortoisehg.hgqt.settings import SettingsDialog
- dlg = SettingsDialog(True, focus='tortoisehg.summarylen')
- dlg.exec_()
-
- menu = self.createStandardContextMenu()
- menu.addSeparator()
- if self.getChecked:
- action = menu.addAction(_('Paste &Filenames'))
- action.triggered.connect(paste)
- for name, func in [(_('App&ly Format'), apply),
- (_('C&onfigure Format'), settings)]:
- def add(name, func):
- action = menu.addAction(name)
- action.triggered.connect(func)
- add(name, func)
- return menu.exec_(point)
-
- def refresh(self, repo):
- self.setEdgeColumn(repo.summarylen)
- self.setIndentationWidth(repo.tabwidth)
- self.setTabWidth(repo.tabwidth)
- self.summarylen = repo.summarylen
-
- def reflowBlock(self, line):
- lines = self.text().split('\n', QString.KeepEmptyParts)
- if line >= len(lines):
- return None
- if not len(lines[line]) > 1:
- return line+1
-
- # find boundaries (empty lines or bounds)
- b = line
- while b and len(lines[b-1]) > 1:
- b = b - 1
- e = line
- while e+1 < len(lines) and len(lines[e+1]) > 1:
- e = e + 1
- group = QStringList([lines[l].simplified() for l in xrange(b, e+1)])
- sentence = group.join(' ')
- parts = sentence.split(' ', QString.SkipEmptyParts)
-
- outlines = QStringList()
- line = QStringList()
- partslen = 0
- for part in parts:
- if partslen + len(line) + len(part) + 1 > self.summarylen:
- if line:
- outlines.append(line.join(' '))
- line, partslen = QStringList(), 0
- line.append(part)
- partslen += len(part)
- if line:
- outlines.append(line.join(' '))
-
- self.beginUndoAction()
- self.setSelection(b, 0, e+1, 0)
- self.removeSelectedText()
- self.insertAt(outlines.join('\n')+'\n', b, 0)
- self.endUndoAction()
- self.setCursorPosition(b, 0)
- return b + len(outlines) + 1
-
- def moveCursorToEnd(self):
- lines = self.lines()
- if lines:
- lines -= 1
- pos = self.lineLength(lines)
- self.setCursorPosition(lines, pos)
- self.ensureLineVisible(lines)
- self.horizontalScrollBar().setSliderPosition(0)
-
- def keyPressEvent(self, event):
- if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_E:
- line, col = self.getCursorPosition()
- self.reflowBlock(line)
- elif event.key() == Qt.Key_Backtab:
- event.accept()
- newev = QKeyEvent(event.type(), Qt.Key_Tab, Qt.ShiftModifier)
- super(MessageEntry, self).keyPressEvent(newev)
- else:
- super(MessageEntry, self).keyPressEvent(event)
-
class CommitWidget(QWidget, qtlib.TaskWidget):
'A widget that encompasses a StatusWidget and commit extras'
commitButtonEnable = pyqtSignal(bool)
|
@@ -10,8 +10,8 @@
from tortoisehg.util import hglib
from tortoisehg.hgqt.i18n import _
-from tortoisehg.hgqt import qtlib, csinfo, i18n, cmdui, status, commit, resolve
-from tortoisehg.hgqt import qscilib, thgrepo
+from tortoisehg.hgqt import qtlib, csinfo, i18n, cmdui, status, resolve
+from tortoisehg.hgqt import qscilib, thgrepo, messageentry
from PyQt4.QtCore import *
from PyQt4.QtGui import *
@@ -295,6 +295,7 @@ cmd = hglib.fromunicode(cmd)
repo = self.repo
if cmd == 'commit':
+ from tortoisehg.hgqt import commit
dlg = commit.CommitDialog(repo, [], {}, self)
dlg.finished.connect(dlg.deleteLater)
dlg.exec_()
@@ -496,7 +497,7 @@ # commit message area
msg_sep = qtlib.LabeledSeparator(_('Commit message'))
self.layout().addWidget(msg_sep)
- msgEntry = commit.MessageEntry(self)
+ msgEntry = messageentry.MessageEntry(self)
msgEntry.installEventFilter(qscilib.KeyPressInterceptor(self))
msgEntry.refresh(repo)
msgEntry.loadSettings(QSettings(), 'merge/message')
|
|
|
@@ -0,0 +1,145 @@ + # messageentry.py - TortoiseHg's commit message editng widget
+#
+# Copyright 2011 Steve Borho <steve@borho.org>
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2, incorporated herein by reference.
+
+import os
+
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+from PyQt4.Qsci import QsciScintilla, QsciLexerMakefile
+
+from tortoisehg.hgqt.i18n import _
+from tortoisehg.hgqt import qtlib, qscilib
+
+class MessageEntry(qscilib.Scintilla):
+
+ def __init__(self, parent, getCheckedFunc=None):
+ super(MessageEntry, self).__init__(parent)
+ self.setEdgeColor(QColor('LightSalmon'))
+ self.setEdgeMode(QsciScintilla.EdgeLine)
+ self.setReadOnly(False)
+ self.setMarginWidth(1, 0)
+ self.setFont(qtlib.getfont('fontcomment').font())
+ self.setCaretWidth(10)
+ self.setCaretLineBackgroundColor(QColor("#e6fff0"))
+ self.setCaretLineVisible(True)
+ self.setAutoIndent(True)
+ self.setAutoCompletionThreshold(2)
+ self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
+ self.setAutoCompletionFillupsEnabled(True)
+ self.setLexer(QsciLexerMakefile(self))
+ self.lexer().setFont(qtlib.getfont('fontcomment').font())
+ self.lexer().setColor(QColor(Qt.red), QsciLexerMakefile.Error)
+ self.setMatchedBraceBackgroundColor(Qt.yellow)
+ self.setIndentationsUseTabs(False)
+ self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
+ #self.setIndentationGuidesBackgroundColor(QColor("#e6e6de"))
+ #self.setFolding(QsciScintilla.BoxedFoldStyle)
+ # http://www.riverbankcomputing.com/pipermail/qscintilla/2009-February/000461.html
+ self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
+ self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
+ # default message entry widgets to word wrap, user may override
+ self.setWrapMode(QsciScintilla.WrapWord)
+
+ self.getChecked = getCheckedFunc
+ self.setContextMenuPolicy(Qt.CustomContextMenu)
+ self.customContextMenuRequested.connect(self.menuRequested)
+
+ def menuRequested(self, point):
+ line = self.lineAt(point)
+ point = self.viewport().mapToGlobal(point)
+
+ def apply():
+ line = 0
+ while True:
+ line = self.reflowBlock(line)
+ if line is None:
+ break;
+ def paste():
+ files = self.getChecked()
+ self.insert(', '.join(files))
+ def settings():
+ from tortoisehg.hgqt.settings import SettingsDialog
+ dlg = SettingsDialog(True, focus='tortoisehg.summarylen')
+ dlg.exec_()
+
+ menu = self.createStandardContextMenu()
+ menu.addSeparator()
+ if self.getChecked:
+ action = menu.addAction(_('Paste &Filenames'))
+ action.triggered.connect(paste)
+ for name, func in [(_('App&ly Format'), apply),
+ (_('C&onfigure Format'), settings)]:
+ def add(name, func):
+ action = menu.addAction(name)
+ action.triggered.connect(func)
+ add(name, func)
+ return menu.exec_(point)
+
+ def refresh(self, repo):
+ self.setEdgeColumn(repo.summarylen)
+ self.setIndentationWidth(repo.tabwidth)
+ self.setTabWidth(repo.tabwidth)
+ self.summarylen = repo.summarylen
+
+ def reflowBlock(self, line):
+ lines = self.text().split('\n', QString.KeepEmptyParts)
+ if line >= len(lines):
+ return None
+ if not len(lines[line]) > 1:
+ return line+1
+
+ # find boundaries (empty lines or bounds)
+ b = line
+ while b and len(lines[b-1]) > 1:
+ b = b - 1
+ e = line
+ while e+1 < len(lines) and len(lines[e+1]) > 1:
+ e = e + 1
+ group = QStringList([lines[l].simplified() for l in xrange(b, e+1)])
+ sentence = group.join(' ')
+ parts = sentence.split(' ', QString.SkipEmptyParts)
+
+ outlines = QStringList()
+ line = QStringList()
+ partslen = 0
+ for part in parts:
+ if partslen + len(line) + len(part) + 1 > self.summarylen:
+ if line:
+ outlines.append(line.join(' '))
+ line, partslen = QStringList(), 0
+ line.append(part)
+ partslen += len(part)
+ if line:
+ outlines.append(line.join(' '))
+
+ self.beginUndoAction()
+ self.setSelection(b, 0, e+1, 0)
+ self.removeSelectedText()
+ self.insertAt(outlines.join('\n')+'\n', b, 0)
+ self.endUndoAction()
+ self.setCursorPosition(b, 0)
+ return b + len(outlines) + 1
+
+ def moveCursorToEnd(self):
+ lines = self.lines()
+ if lines:
+ lines -= 1
+ pos = self.lineLength(lines)
+ self.setCursorPosition(lines, pos)
+ self.ensureLineVisible(lines)
+ self.horizontalScrollBar().setSliderPosition(0)
+
+ def keyPressEvent(self, event):
+ if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_E:
+ line, col = self.getCursorPosition()
+ self.reflowBlock(line)
+ elif event.key() == Qt.Key_Backtab:
+ event.accept()
+ newev = QKeyEvent(event.type(), Qt.Key_Tab, Qt.ShiftModifier)
+ super(MessageEntry, self).keyPressEvent(newev)
+ else:
+ super(MessageEntry, self).keyPressEvent(event)
|
@@ -18,8 +18,8 @@
from tortoisehg.util import hglib, patchctx
from tortoisehg.hgqt.i18n import _
-from tortoisehg.hgqt import qtlib, cmdui, rejects, commit, qscilib, thgrepo
-from tortoisehg.hgqt import qqueue, qreorder, fileview, thgimport, status
+from tortoisehg.hgqt import qtlib, cmdui, rejects, qscilib, thgrepo, status
+from tortoisehg.hgqt import qqueue, qreorder, fileview, thgimport, messageentry
from tortoisehg.hgqt.qtlib import geticon
# TODO
@@ -654,7 +654,7 @@ mtbarhbox.addWidget(self.newCheckBox)
mtbarhbox.addWidget(self.patchNameLE, 1)
- self.messageEditor = commit.MessageEntry(self)
+ self.messageEditor = messageentry.MessageEntry(self)
self.messageEditor.installEventFilter(qscilib.KeyPressInterceptor(self))
self.messageEditor.refresh(repo)
@@ -856,6 +856,7 @@ @pyqtSlot()
def qinitOrCommit(self):
if os.path.isdir(self.repo.mq.join('.hg')):
+ from tortoisehg.hgqt import commit
mqrepo = thgrepo.repository(None, self.repo.mq.path)
dlg = commit.CommitDialog(mqrepo, [], {}, self)
dlg.finished.connect(dlg.deleteLater)
|
@@ -16,8 +16,7 @@
from tortoisehg.util import hglib
from tortoisehg.hgqt.i18n import _
-from tortoisehg.hgqt import cmdui, qscilib, qtlib
-from tortoisehg.hgqt.commit import MessageEntry
+from tortoisehg.hgqt import cmdui, qscilib, qtlib, messageentry
class QFoldDialog(QDialog):
@@ -36,7 +35,7 @@
mlbl = QLabel(_('New patch message:'))
self.layout().addWidget(mlbl)
- self.msgte = MessageEntry(self)
+ self.msgte = messageentry.MessageEntry(self)
self.msgte.installEventFilter(qscilib.KeyPressInterceptor(self))
self.layout().addWidget(self.msgte)
|
@@ -309,6 +309,7 @@ _('An error occurred while updating the repository hgrc '
'file (%s)' % abshgrcpath))
return False
+ self.setShortName(shortname)
return True
return False
@@ -407,9 +408,11 @@ self.name = value.toString()
return True
return False
+
def menulist(self):
return ['openAll', 'add', None, 'newGroup', None, 'rename', 'remove',
None, 'reloadRegistry']
+
def flags(self):
return (Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDropEnabled
| Qt.ItemIsDragEnabled | Qt.ItemIsEditable)
@@ -483,9 +486,11 @@class AllRepoGroupItem(RepoGroupItem):
def __init__(self, parent=None):
RepoGroupItem.__init__(self, name=_('default'), parent=parent)
+
def menulist(self):
return ['openAll', 'add', None, 'newGroup', None, 'rename',
None, 'reloadRegistry']
+
def undump(self, xr):
a = xr.attributes()
name = a.value('', 'name').toString()
|
@@ -1413,11 +1413,12 @@ def exportRevisions(self, revisions):
if not revisions:
revisions = [self.rev]
- dir = QFileDialog.getExistingDirectory(self, _('Export patch'),
+ udir = QFileDialog.getExistingDirectory(self, _('Export patch'),
hglib.tounicode(self.repo.root))
- if not dir:
+ if not udir:
return
- epath = os.path.join(hglib.fromunicode(dir),
+ strdir = hglib.fromunicode(udir)
+ epath = os.path.join(strdir,
hglib.fromunicode(self.repo.shortname)+'_%r.patch')
cmdline = ['export', '--repository', self.repo.root, '--verbose',
@@ -1446,7 +1447,7 @@ 'in the selected location (%s).\n\n') \
% (len(existingRevisions),
" ,".join([str(rev) for rev in existingRevisions]),
- dir)
+ udir)
warningMessage += \
_('What do you want to do?\n') + u'\n' + \
@@ -1468,6 +1469,29 @@
self.runCommand(cmdline)
+ if len(revisions) == 1:
+ # Show a message box with a link to the export folder and to the
+ # exported file
+ rev = revisions[0]
+ patchfilename = os.path.normpath(epath % rev)
+ patchdirname = os.path.normpath(strdir)
+ patchshortname = os.path.basename(patchfilename)
+ qtlib.InfoMsgBox(_('Patch exported'),
+ _('Revision #%d (%s) was exported to:<p>'
+ '<a href="file:///%s">%s</a>%s'
+ '<a href="file:///%s">%s</a>') \
+ % (rev, str(self.repo[rev]),
+ patchdirname, patchdirname, os.path.sep,
+ patchfilename, patchshortname))
+ else:
+ # Show a message box with a link to the export folder
+ qtlib.InfoMsgBox(_('Patches exported'),
+ _('%d patches were exported to:<p>'
+ '<a href="file:///%s">%s</a>') \
+ % (len(revisions),
+ strdir,
+ strdir))
+
def visualDiffRevision(self):
opts = dict(change=self.rev)
dlg = visdiff.visualdiff(self.repo.ui, self.repo, [], opts)
|
Loading...