Merge pull request #945 from lioncash/exist
qt/main: Better file-existence checking within OnMenuRecentFile() and UpdateUITheme()
This commit is contained in:
commit
bf51bbffcb
@ -654,9 +654,8 @@ void GMainWindow::OnMenuRecentFile() {
|
|||||||
QAction* action = qobject_cast<QAction*>(sender());
|
QAction* action = qobject_cast<QAction*>(sender());
|
||||||
assert(action);
|
assert(action);
|
||||||
|
|
||||||
QString filename = action->data().toString();
|
const QString filename = action->data().toString();
|
||||||
QFileInfo file_info(filename);
|
if (QFileInfo::exists(filename)) {
|
||||||
if (file_info.exists()) {
|
|
||||||
BootGame(filename);
|
BootGame(filename);
|
||||||
} else {
|
} else {
|
||||||
// Display an error message and remove the file from the list.
|
// Display an error message and remove the file from the list.
|
||||||
@ -947,15 +946,14 @@ void GMainWindow::UpdateUITheme() {
|
|||||||
QStringList theme_paths(default_theme_paths);
|
QStringList theme_paths(default_theme_paths);
|
||||||
if (UISettings::values.theme != UISettings::themes[0].second &&
|
if (UISettings::values.theme != UISettings::themes[0].second &&
|
||||||
!UISettings::values.theme.isEmpty()) {
|
!UISettings::values.theme.isEmpty()) {
|
||||||
QString theme_uri(":" + UISettings::values.theme + "/style.qss");
|
const QString theme_uri(":" + UISettings::values.theme + "/style.qss");
|
||||||
QFile f(theme_uri);
|
QFile f(theme_uri);
|
||||||
if (!f.exists()) {
|
if (f.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found");
|
|
||||||
} else {
|
|
||||||
f.open(QFile::ReadOnly | QFile::Text);
|
|
||||||
QTextStream ts(&f);
|
QTextStream ts(&f);
|
||||||
qApp->setStyleSheet(ts.readAll());
|
qApp->setStyleSheet(ts.readAll());
|
||||||
GMainWindow::setStyleSheet(ts.readAll());
|
GMainWindow::setStyleSheet(ts.readAll());
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(Frontend, "Unable to set style, stylesheet file not found");
|
||||||
}
|
}
|
||||||
theme_paths.append(QStringList{":/icons/default", ":/icons/" + UISettings::values.theme});
|
theme_paths.append(QStringList{":/icons/default", ":/icons/" + UISettings::values.theme});
|
||||||
QIcon::setThemeName(":/icons/" + UISettings::values.theme);
|
QIcon::setThemeName(":/icons/" + UISettings::values.theme);
|
||||||
|
Loading…
Reference in New Issue
Block a user