summaryrefslogtreecommitdiff
path: root/qt-recordmydesktop/src/rmdPrefsWidget.py
blob: 4c9f5b76c54fbfcea28cf2873d0fbfdcced6fa79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
#/******************************************************************************
#*                       qt-recordMyDesktop                                    *
#*******************************************************************************
#*                                                                             *
#*           Copyright (C) 2007  John Varouhakis                               *
#*                                                                             *
#*                                                                             *
#*  This program is free software; you can redistribute it and/or modify       *
#*  it under the terms of the GNU General Public License as published by       *
#*  the Free Software Foundation; either version 2 of the License, or          *
#*  (at your option) any later version.                                        *
#*                                                                             *
#*  This program is distributed in the hope that it will be useful,            *
#*  but WITHOUT ANY WARRANTY; without even the implied warranty of             *
#*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
#*  GNU General Public License for more details.                               *
#*                                                                             *
#*  You should have received a copy of the GNU General Public License          *
#*  along with this program; if not, write to the Free Software                *
#*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  *
#*                                                                             *
#*                                                                             *
#*                                                                             *
#*  For further information contact me at johnvarouhakis@gmail.com             *
#******************************************************************************/


from PyQt4 import QtGui,QtCore
import locale, gettext
import rmdConfig
def _(s):
    return QtCore.QString.fromUtf8(gettext.gettext(s))
def htmlize(s):
    return "<html><body>"+s.replace("\n","<br>")+"</html></body>"
gettext.textdomain('qt-recordMyDesktop')
gettext.bindtextdomain('qt-recordMyDesktop',rmdConfig.locale_install_dir)
import os




class prefsWidget(object):
    labelStrings=[_('Overwite Existing Files'),_('Working Directory'),
                    _('Frames Per Second'),_('Encode On the Fly'),_('Zero Compression'),
                    _('Quick Subsampling'),_('Full shots at every frame'),
                    _('Channels'),_('Frequency'),_('Device'),_('Display'),_('Mouse Cursor'),
                    _('MIT-Shm extension'),_('Include Window Decorations'),_('Tooltips'),
                    _('Outline Capture Area On Screen'),
                    _('Video Quality'),_('Sound Quality'),
                    _('Drop Frames(encoder)'),_('Startup Delay(secs)'),]
    mouseStrings=[_('Normal'),_('White'),_('Black'),_('None')]
    stateStrings=[_('Enabled'),_('Disabled')]#0,1
    tabStrings=[_('Files'),_('Performance'),_('Sound'),_('Misc')]
    tooltipLabels=[_('By default, if you try to save under a filename that already\nexists, the new file will be renamed\n(for example if you try to save as out.ogg and that file exists, your file will be named out.ogg.1).\nBy checking this box, this behavior is disabled and the old file is overwritten.\n'),
                    _('Directory where temporary files will be saved.'),
                    _('Frames Per Second'),
                    _('Encode simultaneously with the recording.\nThis will require a lot more processing power.\n'),
                    _('Do not apply compression on the temporary files.\nIf enabled, the program will need less processing power,\nin the expense of hard disk space.\nThis option is valid only when encoding on the fly is disabled.'),
                    _('This option, if enabled, will cause the program to require less\nprocessing power, but it might make the colors look a bit more blurry.'),
                    _('This option should be enabled when recording 3d windows.\nIt is also auto-enabled when recording a\nknown 3d compositing window manager.\n '),
                    _('Number of audio channels.'),
                    _('Sound frequency.'),
                    _('ALSA sound device, that is used for sound recording.'),
                    _('Connection to the Xserver.'),
                    _('The mouse cursor that will be drawn.\nNormal is for the real cursor that you see while recording,\nwhile black and white are fake cursors, drawn by the program.\nYou can also disable cursor drawing.'),
                    _('Use the MIT-Shared memory extension, whenever appropriate,\n depending on the rest of the program settings.\nDisabling this option is not recommended,\nas it may severely slow down the program.'),
                    _('When selecting a window via the "Select Window" button,\ninclude that window\'s decorations in the recording area.'),
                    _('Enable or disable tooltips, like this one.\n(Requires restart)'),
                    _('Draw a frame on the screen, around the area\nthat will get captured.\n(This frame will remain throughout the recording.)')]
    jacktip=_("Enable this option to record audio through\nJACK. The Jack server must be running in order to\nobtain the ports that will be recorded.\nThe audio recorded from each one\nwill be written on a channel of its own.\nrecordMyDesktop must be compiled with JACK\nsupport for this option to work.")
    def __tooltips__(self):
        for i in range(16):
            self.labels[i].setToolTip(htmlize(self.tooltipLabels[i]))
        self.jack_button.setToolTip(htmlize(self.jacktip))
        self.jack_lsp_label.setToolTip(htmlize(self.jacktip))
        self.jack_lss_label.setToolTip(htmlize(self.jacktip))
        self.jack_lsp_liststore.setToolTip(htmlize(self.jacktip))
        self.jack_lsp_listSave.setToolTip(htmlize(self.jacktip))

    def destroy(self,Event=None):
        self.values[0]=self.fpsSpinButton.value()
        self.values[1]=self.mouseComboBox.currentIndex()
        self.values[3]=self.fullComboBox.currentIndex()
        self.values[7]=self.channelsSpinButton.value()
        self.values[8]=self.freqSpinButton.value()
        self.values[9]=self.deviceEntry.text().replace(' ','')
        self.values[12]=self.displayEntry.text().replace(' ','')
        self.values[13]=self.sharedComboBox.currentIndex()
        self.values[16]=self.quickComboBox.currentIndex()
        self.values[17]=self.workdirEntry.text()
        self.values[18]=self.onTheFlyComboBox.currentIndex()
        self.values[19]=self.zeroCmpComboBox.currentIndex()
        if self.overwriteFilesButton.checkState()==QtCore.Qt.Checked:
            self.values[20]=True
        else:
            self.values[20]=False
        self.values[21]=self.winDecoComboBox.currentIndex()
        if self.jack_button.checkState()==QtCore.Qt.Checked:
            self.values[22]=True
        else:
            self.values[22]=False
        self.__getSelectedPorts__()
        self.values[24]=self.tooltipsComboBox.currentIndex()
        self.values[25]=self.rFrameComboBox.currentIndex()
        self.optionsOpen[0]=0

    def __getSelectedPorts__(self):
        iters_t=[]
        self.values[23]=[]
        sel_rows=self.jack_lsp_listSave.count()
        for i in range(sel_rows):
            self.values[23].append(self.jack_lsp_listSave.item(i).text())
        if sel_rows==0:
            self.values[22]=False

    def __subWidgets__(self):
        self.labels={}
        self.boxes={}
        self.labelbox={}
        self.tabWidgets={}
        self.notebook = QtGui.QTabWidget(self.window)
        for i in range(4):
            self.labelbox[i]=QtGui.QVBoxLayout()
            self.tabWidgets[i]=QtGui.QWidget()
#Files page
        for i in range(2):
            self.labels[i]=QtGui.QLabel(self.labelStrings[i],self.tabWidgets[0])
            self.labels[i].setAlignment(QtCore.Qt.AlignLeft)
            self.boxes[i]=QtGui.QHBoxLayout()
            self.boxes[i].insertWidget(-1,self.labels[i])
            self.labelbox[0].insertLayout(-1,self.boxes[i])
            self.labelbox[0].insertSpacing(-1,20)
        self.labelbox[0].setSizeConstraint(QtGui.QLayout.SetMaximumSize)

        self.overwriteFilesButton=QtGui.QCheckBox(self.tabWidgets[0])
        if self.values[20]:
            self.overwriteFilesButton.setCheckState(QtCore.Qt.Checked)
        else:
            self.overwriteFilesButton.setCheckState(QtCore.Qt.Unchecked)
        self.boxes[0].insertWidget(-1,self.overwriteFilesButton)

        self.workdirEntry= QtGui.QLineEdit(self.values[17],self.tabWidgets[0])
        self.boxes[1].insertWidget(-1,self.workdirEntry)

#Performance page
        for i in xrange(2,7):
            self.labels[i]=QtGui.QLabel(self.labelStrings[i],self.tabWidgets[1])
            self.labels[i].setAlignment(QtCore.Qt.AlignLeft)
            self.boxes[i]=QtGui.QHBoxLayout()
            self.boxes[i].insertWidget(-1,self.labels[i])
            self.labelbox[1].insertLayout(-1,self.boxes[i])
            self.labelbox[1].insertSpacing(-1,20)
        self.labelbox[1].setSizeConstraint(QtGui.QLayout.SetMaximumSize)

        self.fpsSpinButton= QtGui.QSpinBox(self.tabWidgets[1])
        self.fpsSpinButton.setRange(1,50)
        self.fpsSpinButton.setValue(self.values[0])
        self.boxes[2].insertWidget(-1,self.fpsSpinButton)

        self.onTheFlyComboBox = QtGui.QComboBox(self.tabWidgets[1])
        for i in range(2):
            self.onTheFlyComboBox.addItem(self.stateStrings[i])
        self.onTheFlyComboBox.setCurrentIndex(self.values[18])
        self.boxes[3].insertWidget(-1,self.onTheFlyComboBox)

        self.zeroCmpComboBox = QtGui.QComboBox(self.tabWidgets[1])
        for i in range(2):
            self.zeroCmpComboBox.addItem(self.stateStrings[i])
        self.zeroCmpComboBox.setCurrentIndex(self.values[19])
        self.boxes[4].insertWidget(-1,self.zeroCmpComboBox)

        self.quickComboBox = QtGui.QComboBox(self.tabWidgets[1])
        for i in range(2):
            self.quickComboBox.addItem(self.stateStrings[i])
        self.quickComboBox.setCurrentIndex(self.values[16])
        self.boxes[5].insertWidget(-1,self.quickComboBox)

        self.fullComboBox = QtGui.QComboBox(self.tabWidgets[1])
        for i in range(2):
            self.fullComboBox.addItem(self.stateStrings[i])
        self.fullComboBox.setCurrentIndex(self.values[3])
        self.boxes[6].insertWidget(-1,self.fullComboBox)

#sound page
        for i in xrange(7,10):
            self.labels[i]=QtGui.QLabel(self.labelStrings[i],self.tabWidgets[2])
            self.labels[i].setAlignment(QtCore.Qt.AlignLeft)
            self.boxes[i]=QtGui.QHBoxLayout()
            self.boxes[i].insertWidget(-1,self.labels[i])
            self.labelbox[2].insertLayout(-1,self.boxes[i])
            self.labelbox[2].insertSpacing(-1,20)
        self.labelbox[2].setSizeConstraint(QtGui.QLayout.SetMaximumSize)

        self.labelbox[2].insertSpacing(-1,15)
        self.jack_button= QtGui.QCheckBox(_("Use Jack for audio capture."),self.tabWidgets[2])
        self.jack_lsp_label=QtGui.QLabel(_("Available ports (double click to add):"),self.tabWidgets[2])
        self.jack_lss_label=QtGui.QLabel(_("Selected ports (double click to remove):"),self.tabWidgets[2])
        self.jack_lsp_liststore=QtGui.QListWidget(self.tabWidgets[2])
        self.jack_lsp_liststore.setFixedHeight(100)
        self.jack_lsp_listSave=QtGui.QListWidget(self.tabWidgets[2])
        self.jack_lsp_listSave.setFixedHeight(100)


        self.jack_lsp_refresh=QtGui.QPushButton(_("Refresh"),self.tabWidgets[2])
        self.jack_box=QtGui.QVBoxLayout()
        self.jack_box.insertWidget(-1,self.jack_button)
        self.jack_box.insertWidget(-1,self.jack_lsp_label)
        self.jack_box.insertWidget(-1,self.jack_lsp_liststore)
        self.jack_box.insertWidget(-1,self.jack_lss_label)
        self.jack_box.insertWidget(-1,self.jack_lsp_listSave)
        self.jack_box.insertWidget(-1,self.jack_lsp_refresh)
        self.labelbox[2].insertLayout(-1,self.jack_box)


        if self.values[22]==True:
            self.jack_button.setCheckState(QtCore.Qt.Checked)
        else:
            self.jack_button.setCheckState(QtCore.Qt.Unchecked)

        self.channelsSpinButton= QtGui.QSpinBox(self.tabWidgets[2])
        self.channelsSpinButton.setRange(1,2)
        self.channelsSpinButton.setValue(self.values[7])
        self.boxes[7].insertWidget(-1,self.channelsSpinButton)


        self.freqSpinButton= QtGui.QSpinBox(self.tabWidgets[2])
        self.freqSpinButton.setRange(0,44100)
        self.freqSpinButton.setSingleStep(100)
        self.freqSpinButton.setValue(self.values[8])
        self.boxes[8].insertWidget(-1,self.freqSpinButton)

        self.deviceEntry= QtGui.QLineEdit(self.values[9],self.tabWidgets[2])
        self.boxes[9].insertWidget(-1,self.deviceEntry)

#misc page
        for i in xrange(10,16):
            self.labels[i]=QtGui.QLabel(self.labelStrings[i],self.tabWidgets[3])
            self.labels[i].setAlignment(QtCore.Qt.AlignLeft)
            self.boxes[i]=QtGui.QHBoxLayout()
            self.boxes[i].insertWidget(-1,self.labels[i])
            self.labelbox[3].insertLayout(-1,self.boxes[i])
            self.labelbox[3].insertSpacing(-1,20)
        self.labelbox[3].setSizeConstraint(QtGui.QLayout.SetMaximumSize)

        self.displayEntry= QtGui.QLineEdit(self.values[12])
        self.boxes[10].insertWidget(-1,self.displayEntry)

        self.mouseComboBox = QtGui.QComboBox(self.tabWidgets[3])
        for i in range(4):
            self.mouseComboBox.addItem(self.mouseStrings[i])
        self.mouseComboBox.setCurrentIndex(self.values[1])
        self.boxes[11].insertWidget(-1,self.mouseComboBox)


        self.sharedComboBox = QtGui.QComboBox(self.tabWidgets[3])
        for i in range(2):
            self.sharedComboBox.addItem(self.stateStrings[i])
        self.sharedComboBox.setCurrentIndex(self.values[13])
        self.boxes[12].insertWidget(-1,self.sharedComboBox)

        self.winDecoComboBox = QtGui.QComboBox(self.tabWidgets[3])
        for i in range(2):
            self.winDecoComboBox.addItem(self.stateStrings[i])
        self.winDecoComboBox.setCurrentIndex(self.values[21])
        self.boxes[13].insertWidget(-1,self.winDecoComboBox)

        self.tooltipsComboBox = QtGui.QComboBox(self.tabWidgets[3])
        for i in range(2):
            self.tooltipsComboBox.addItem(self.stateStrings[i])
        self.tooltipsComboBox.setCurrentIndex(self.values[24])
        self.boxes[14].insertWidget(-1,self.tooltipsComboBox)


        self.rFrameComboBox = QtGui.QComboBox(self.tabWidgets[3])
        for i in range(2):
            self.rFrameComboBox.addItem(self.stateStrings[i])
        self.rFrameComboBox.setCurrentIndex(self.values[25])
        self.boxes[15].insertWidget(-1,self.rFrameComboBox)


        for i in range(4):
            self.tabWidgets[i].setLayout(self.labelbox[i])
            self.notebook.insertTab(-1,self.tabWidgets[i],self.tabStrings[i])
        self.notebook.show()
        return

    def addPort(self,lwi):
        pli=lwi.clone()
        self.jack_lsp_listSave.insertItem(-1,pli)
    def remPort(self,lwi):
        self.jack_lsp_listSave.takeItem(self.jack_lsp_listSave.row(lwi))

    def __runJackLSP__(self,button=None):
        self.ports=[]
        failed=0
        (stdin,stdout,stderr)=os.popen3(['jack_lsp'],'t')
        ports=stdout.readlines()
        stdin.close()
        stdout.close()
        stderr.close()
        self.jack_lsp_liststore.clear()
        if ports!=[]:
            for i in ports:
                self.ports.append(i.replace('\n',""))
            self.jack_lsp_liststore.setEnabled(True)
        else:
            failed=1
            self.ports.append(_("jack_lsp returned no ports."))
            self.ports.append(_("Make sure that jackd is running."))
            self.jack_lsp_liststore.setEnabled(False)
            self.jack_lsp_listSave.setEnabled(False)
            self.values[23]=[]
        for i in self.values[23]:
            self.jack_lsp_listSave.insertItem(-1,QtGui.QListWidgetItem(i))
        for i in self.ports:
            self.jack_lsp_liststore.insertItem(-1,QtGui.QListWidgetItem(i))


    def __makeCons__(self):
        self.jack_button.connect(self.jack_button,QtCore.SIGNAL("clicked()"),self.__jack_enabled_check__)
        self.jack_lsp_refresh.connect(self.jack_lsp_refresh,QtCore.SIGNAL("clicked()"),self.__runJackLSP__)
        self.jack_lsp_liststore.connect(self.jack_lsp_liststore,QtCore.SIGNAL("itemDoubleClicked(QListWidgetItem *)"),self.addPort)
        self.jack_lsp_listSave.connect(self.jack_lsp_listSave,QtCore.SIGNAL("itemDoubleClicked(QListWidgetItem *)"),self.remPort)

    def __jack_enabled_check__(self):
        val=False
        if self.jack_button.checkState()==QtCore.Qt.Checked:
            val=True
        else:
            val=False
        self.channelsSpinButton.setEnabled(not val)
        self.freqSpinButton.setEnabled(not val)
        self.deviceEntry.setEnabled(not val)
        self.jack_lsp_liststore.setEnabled(val)
        self.jack_lsp_listSave.setEnabled(val)
        self.jack_lsp_refresh.setEnabled(val)

    def __init__(self,values,optionsOpen):
        self.values=values
        self.ports=[]
        self.optionsOpen=optionsOpen
        self.window = QtGui.QWidget()
        self.window.closeEvent= self.destroy

        self.window.setWindowTitle("recordMyDesktop")
        self.__subWidgets__()
        self.__makeCons__()
        self.__runJackLSP__()
        self.__jack_enabled_check__()
        if self.values[24]==0:
            self.__tooltips__()
        self.window.show()
© All Rights Reserved