Changeset View
Changeset View
Standalone View
Standalone View
src/appearancegtk2.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 77 | // qDebug() << "\tgtkrc file found at : " << it.filePath(); | |||
---|---|---|---|---|---|
82 | 82 | | |||
83 | return QString(); | 83 | return QString(); | ||
84 | } | 84 | } | ||
85 | 85 | | |||
86 | bool AppearanceGTK2::saveSettingsPrivate(const QString& gtkrcFile) const | 86 | bool AppearanceGTK2::saveSettingsPrivate(const QString& gtkrcFile) const | ||
87 | { | 87 | { | ||
88 | QFile gtkrc{gtkrcFile}; | 88 | QFile gtkrc{gtkrcFile}; | ||
89 | 89 | | |||
90 | if (gtkrc.open(QIODevice::ReadOnly | QIODevice::Text)) { | 90 | if (gtkrc.open(QIODevice::ReadWrite | QIODevice::Text)) { | ||
gikari: I think file creation could be simplified. Just replace WriteOnly flag with ReadWrite here. | |||||
91 | QString fileContents{gtkrc.readAll()}; | 91 | QString fileContents{gtkrc.readAll()}; | ||
92 | 92 | | |||
93 | modifyGtkrcContents(fileContents); | 93 | modifyGtkrcContents(fileContents); | ||
94 | 94 | | |||
95 | gtkrc.remove(); | 95 | gtkrc.remove(); | ||
96 | gtkrc.open(QIODevice::WriteOnly | QIODevice::Text); | 96 | gtkrc.open(QIODevice::WriteOnly | QIODevice::Text); | ||
97 | gtkrc.write(fileContents.toUtf8()); | 97 | gtkrc.write(fileContents.toUtf8()); | ||
98 | 98 | | |||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |
I think file creation could be simplified. Just replace WriteOnly flag with ReadWrite here. This would mean, that file will be created automatically if it doesn't exist. If you think intention to open file also for write is unclear, write a comment alongside.