Skip to content

Commit

Permalink
Use open() instead of QFile and QTextStream
Browse files Browse the repository at this point in the history
  • Loading branch information
mitya57 committed Jan 4, 2025
1 parent bfe5269 commit 4aff25a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
9 changes: 2 additions & 7 deletions ReText/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@
from PyQt6.QtCore import (
QCommandLineOption,
QCommandLineParser,
QFile,
QFileInfo,
QIODevice,
QLibraryInfo,
Qt,
QTextStream,
QTranslator,
)
from PyQt6.QtDBus import QDBusConnection, QDBusInterface
Expand Down Expand Up @@ -100,10 +97,8 @@ def main():
print('Using configuration file:', settings.fileName())
print('Using cache file:', cache.fileName())
if globalSettings.appStyleSheet:
sheetfile = QFile(globalSettings.appStyleSheet)
sheetfile.open(QIODevice.OpenModeFlag.ReadOnly)
app.setStyleSheet(QTextStream(sheetfile).readAll())
sheetfile.close()
with open(globalSettings.appStyleSheet) as sheetfile:
app.setStyleSheet(sheetfile.read())
window = ReTextWindow()

# ReText can change directory when loading files, so we
Expand Down
8 changes: 2 additions & 6 deletions ReText/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@
QFile,
QFileInfo,
QFileSystemWatcher,
QIODevice,
QLocale,
QMarginsF,
QStandardPaths,
Qt,
QTextStream,
QTimer,
QUrl,
pyqtSlot,
Expand Down Expand Up @@ -488,10 +486,8 @@ def iterateTabs(self):
def updateStyleSheet(self):
self.ss = None
if globalSettings.styleSheet:
sheetfile = QFile(globalSettings.styleSheet)
sheetfile.open(QIODevice.OpenModeFlag.ReadOnly)
self.ss = QTextStream(sheetfile).readAll()
sheetfile.close()
with open(globalSettings.styleSheet) as sheetfile:
self.ss = sheetfile.read()

def initTabWidget(self):
def dragEnterEvent(e):
Expand Down

0 comments on commit 4aff25a

Please sign in to comment.