2 from PyQt4
.QtGui
import QDialog
3 from PyQt4
.QtGui
import QMainWindow
4 from maingui
import Ui_maingui
5 from outputgui
import Ui_outputgui
6 from optionsgui
import Ui_optionsgui
7 from branchgui
import Ui_branchgui
8 from commitgui
import Ui_commitgui
9 from createbranchgui
import Ui_createbranchgui
10 from pushgui
import Ui_pushgui
11 from syntax
import DiffSyntaxHighlighter
14 class View(Ui_maingui
, QMainWindow
):
15 '''The main ugit interface.'''
16 def __init__(self
, parent
=None):
17 QMainWindow
.__init
__(self
, parent
)
18 Ui_maingui
.__init
__(self
)
20 DiffSyntaxHighlighter(self
.displayText
.document())
21 self
.set_display
= self
.displayText
.setText
22 self
.set_info
= self
.displayLabel
.setText
23 self
.action_undo
= self
.commitText
.undo
24 self
.action_redo
= self
.commitText
.redo
25 self
.action_paste
= self
.commitText
.paste
26 self
.action_select_all
= self
.commitText
.selectAll
27 # Qt does not support noun/verbs
28 self
.commitButton
.setText(qtutils
.tr('Commit@@verb'))
29 self
.menuCommit
.setTitle(qtutils
.tr('Commit@@verb'))
33 def action_copy(self
):
34 cursor
= self
.commitText
.textCursor()
35 selection
= cursor
.selection().toPlainText()
36 qtutils
.set_clipboard(selection
)
37 def action_delete(self
):
38 self
.commitText
.textCursor().removeSelectedText()
39 def reset_display(self
):
42 def copy_display(self
):
43 cursor
= self
.displayText
.textCursor()
44 selection
= cursor
.selection().toPlainText()
45 qtutils
.set_clipboard(selection
)
46 def diff_selection(self
):
47 cursor
= self
.displayText
.textCursor()
48 offset
= cursor
.position()
49 selection
= cursor
.selection().toPlainText()
50 num_selected_lines
= selection
.count(os
.linesep
)
51 return offset
, selection
53 class OutputGUI(Ui_outputgui
, QDialog
):
54 '''A simple dialog to display command output.'''
55 def __init__(self
, parent
=None, output
=None):
56 QDialog
.__init
__(self
, parent
)
57 Ui_outputgui
.__init
__(self
)
59 if output
: self
.set_output(output
)
60 def set_output(self
, output
):
61 self
.outputText
.setText(output
)
63 class BranchGUI(Ui_branchgui
, QDialog
):
64 '''A dialog for choosing branches.'''
65 def __init__(self
, parent
=None, branches
=None):
66 QDialog
.__init
__(self
, parent
)
67 Ui_branchgui
.__init
__(self
)
70 if branches
: self
.add(branches
)
74 def add(self
, branches
):
75 for branch
in branches
:
76 self
.branches
.append(branch
)
77 self
.comboBox
.addItem(branch
)
78 def get_selected(self
):
80 if self
.exec_() == QDialog
.Accepted
:
81 return self
.branches
[ self
.comboBox
.currentIndex() ]
85 class CommitGUI(Ui_commitgui
, QDialog
):
86 def __init__(self
, parent
=None):
87 QDialog
.__init
__(self
, parent
)
88 Ui_commitgui
.__init
__(self
)
90 # Make the list widget slighty larger
91 self
.splitter
.setSizes([ 50, 200 ])
92 DiffSyntaxHighlighter(self
.commitText
.document())
94 class CreateBranchGUI(Ui_createbranchgui
, QDialog
):
95 def __init__(self
, parent
=None):
96 QDialog
.__init
__(self
, parent
)
97 Ui_createbranchgui
.__init
__(self
)
100 class PushGUI(Ui_pushgui
, QDialog
):
101 def __init__(self
, parent
=None):
102 QDialog
.__init
__(self
, parent
)
103 Ui_pushgui
.__init
__(self
)
106 class OptionsGUI(Ui_optionsgui
, QDialog
):
107 def __init__(self
, parent
=None):
108 QDialog
.__init
__(self
, parent
)
109 Ui_optionsgui
.__init
__(self
)