Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9.2, 1.9.3, and 2.0

qscilib: use QFile for fileEditor, fix ESC exit, cleanup code

Changeset 61dae24f81de

Parent 3b2bb8300a25

by Steve Borho

Changes to one file · Browse files at 61dae24f81de Showing diff from parent 3b2bb8300a25 Diff from another changeset...

 
410
411
412
413
414
 
 
415
416
 
417
418
 
419
420
421
 
422
423
424
 
428
429
430
431
 
432
433
434
435
436
437
438
439
 
 
440
 
 
 
441
442
443
444
445
446
 
 
 
447
448
449
450
451
452
453
454
455
456
457
 
 
 
458
459
460
 
410
411
412
 
 
413
414
415
416
417
418
419
420
421
422
 
423
424
425
426
 
430
431
432
 
433
434
435
436
437
438
 
 
 
439
440
441
442
443
444
445
446
 
 
 
 
447
448
449
450
 
 
 
 
 
451
452
 
 
 
453
454
455
456
457
458
@@ -410,15 +410,17 @@
  'Open a simple modal file editing dialog'   dialog = QDialog()   dialog.setWindowFlags(dialog.windowFlags() & ~Qt.WindowContextHelpButtonHint) - vbox = QVBoxLayout() - dialog.setLayout(vbox) + dialog.setWindowTitle(filename) + dialog.setLayout(QVBoxLayout())   editor = Scintilla()   editor.setBraceMatching(QsciScintilla.SloppyBraceMatch) + editor.installEventFilter(KeyPressInterceptor(dialog))   editor.setMarginLineNumbers(1, True)   editor.setMarginWidth(1, '000') + editor.setLexer(QsciLexerProperties())   if opts.get('foldable'):   editor.setFolding(QsciScintilla.BoxedTreeFoldStyle) - vbox.addWidget(editor) + dialog.layout().addWidget(editor)     searchbar = SearchToolBar(dialog, hidable=True)   searchbar.searchRequested.connect(editor.find) @@ -428,33 +430,29 @@
  searchbar.show()   searchbar.setFocus(Qt.OtherFocusReason)   QShortcut(QKeySequence.Find, dialog, showsearchbar) - vbox.addWidget(searchbar) + dialog.layout().addWidget(searchbar)     BB = QDialogButtonBox   bb = QDialogButtonBox(BB.Save|BB.Cancel)   bb.accepted.connect(dialog.accept)   bb.rejected.connect(dialog.reject) - vbox.addWidget(bb) - lexer = QsciLexerProperties() - editor.setLexer(lexer) + dialog.layout().addWidget(bb) +   s = QSettings() + geomname = 'editor-geom' + dialog.restoreGeometry(s.value(geomname).toByteArray()) +   ret = QDialog.Rejected   try: - contents = hglib.tounicode(open(filename, 'rb').read()) - dialog.setWindowTitle(filename) - geomname = 'editor-geom' - editor.setText(contents) + f = QFile(filename) + f.open(QIODevice.ReadOnly) + editor.read(f)   editor.setModified(False) - if '\r\n' in contents: - editor.setEolMode(QsciScintilla.EolWindows) - else: - editor.setEolMode(QsciScintilla.EolUnix) - dialog.restoreGeometry(s.value(geomname).toByteArray())   ret = dialog.exec_()   if ret == QDialog.Accepted: - f = util.atomictempfile(filename, 'wb', createmode=None) - f.write(hglib.fromunicode(editor.text())) - f.rename() + f = QFile(filename) + f.open(QIODevice.WriteOnly) + editor.write(f)   s.setValue(geomname, dialog.saveGeometry())   except EnvironmentError, e:   qtlib.WarningMsgBox(_('Unable to read/write config file'),