mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Log message if qss file can not be opened for write
This commit is contained in:
committed by
Mat Sutcliffe
parent
26ddf3a353
commit
b71fb71fdc
@@ -93,6 +93,7 @@ namespace BlackGui
|
||||
|
||||
void CSettingsFontComponent::changeFont()
|
||||
{
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
const QString fontSize = ui->cb_SettingsGuiFontSize->currentText().append("pt");
|
||||
const QString fontFamily = ui->cb_SettingsGuiFont->currentFont().family();
|
||||
const QString fontStyleCombined = ui->cb_SettingsGuiFontStyle->currentText();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackgui/stylesheetutility.h"
|
||||
#include "blackmisc/fileutils.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/restricted.h"
|
||||
|
||||
@@ -41,6 +42,12 @@ namespace BlackGui
|
||||
connect(&m_fileWatcher, &QFileSystemWatcher::fileChanged, this, &CStyleSheetUtility::qssDirectoryChanged);
|
||||
}
|
||||
|
||||
const CLogCategoryList &CStyleSheetUtility::getLogCategories()
|
||||
{
|
||||
static const CLogCategoryList cats { CLogCategory::guiComponent() };
|
||||
return cats;
|
||||
}
|
||||
|
||||
const QString &CStyleSheetUtility::fontStyleAsString(const QFont &font)
|
||||
{
|
||||
static const QString n("normal");
|
||||
@@ -247,11 +254,9 @@ namespace BlackGui
|
||||
|
||||
bool CStyleSheetUtility::updateFont(const QString &qss)
|
||||
{
|
||||
QString qssWidget("QWidget {\n");
|
||||
qssWidget.append(qss);
|
||||
qssWidget.append("}\n");
|
||||
|
||||
QFile fontFile(CDirectoryUtils::stylesheetsDirectory() + "/" + fileNameFontsModified());
|
||||
const QString qssWidget(u"QWidget {\n" % qss % u"}\n");
|
||||
const QString fn = CFileUtils::appendFilePaths(CDirectoryUtils::stylesheetsDirectory(), fileNameFontsModified());
|
||||
QFile fontFile(fn);
|
||||
bool ok = fontFile.open(QFile::Text | QFile::WriteOnly);
|
||||
if (ok)
|
||||
{
|
||||
@@ -260,6 +265,10 @@ namespace BlackGui
|
||||
fontFile.close();
|
||||
ok = this->read();
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(getLogCategories()).warning(u"Cannot open file '%1' for writing") << fn;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#define BLACKGUI_STYLESHEETUTILITY_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/logcategorylist.h"
|
||||
#include "blackmisc/restricted.h"
|
||||
#include "blackmisc/digestsignal.h"
|
||||
|
||||
@@ -40,6 +41,9 @@ namespace BlackGui
|
||||
//! Constructor
|
||||
explicit CStyleSheetUtility(BlackMisc::Restricted<CGuiApplication>, QObject *parent = nullptr);
|
||||
|
||||
//! Log cats.
|
||||
static const BlackMisc::CLogCategoryList &getLogCategories();
|
||||
|
||||
//! Style for given file name
|
||||
QString style(const QString &fileName) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user