mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 01:35:45 +08:00
Move sounds and stylesheet directory configuration to buildconfig.h.in
refs #615
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackgui/stylesheetutility.h"
|
#include "blackgui/stylesheetutility.h"
|
||||||
|
#include "blackmisc/buildconfig.h"
|
||||||
#include "blackmisc/fileutils.h"
|
#include "blackmisc/fileutils.h"
|
||||||
#include "blackmisc/restricted.h"
|
#include "blackmisc/restricted.h"
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ namespace BlackGui
|
|||||||
CStyleSheetUtility::CStyleSheetUtility(BlackMisc::Restricted<CGuiApplication>, QObject *parent) : QObject(parent)
|
CStyleSheetUtility::CStyleSheetUtility(BlackMisc::Restricted<CGuiApplication>, QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
this->read();
|
this->read();
|
||||||
this->m_fileWatcher.addPath(qssDirectory());
|
this->m_fileWatcher.addPath(CBuildConfig::getStylesheetsDir());
|
||||||
connect(&this->m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &CStyleSheetUtility::ps_qssDirectoryChanged);
|
connect(&this->m_fileWatcher, &QFileSystemWatcher::directoryChanged, this, &CStyleSheetUtility::ps_qssDirectoryChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +108,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
bool CStyleSheetUtility::read()
|
bool CStyleSheetUtility::read()
|
||||||
{
|
{
|
||||||
QDir directory(qssDirectory());
|
QDir directory(CBuildConfig::getStylesheetsDir());
|
||||||
if (!directory.exists()) { return false; }
|
if (!directory.exists()) { return false; }
|
||||||
|
|
||||||
// ini file
|
// ini file
|
||||||
@@ -210,7 +211,7 @@ namespace BlackGui
|
|||||||
qss.append(fontStyleSheet);
|
qss.append(fontStyleSheet);
|
||||||
qss.append("}\n");
|
qss.append("}\n");
|
||||||
|
|
||||||
QFile fontFile(qssDirectory().append("/").append(fileNameFontsModified()));
|
QFile fontFile(CBuildConfig::getStylesheetsDir() + "/" + fileNameFontsModified());
|
||||||
bool ok = fontFile.open(QFile::Text | QFile::WriteOnly);
|
bool ok = fontFile.open(QFile::Text | QFile::WriteOnly);
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
@@ -264,7 +265,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
bool CStyleSheetUtility::deleteModifiedFontFile()
|
bool CStyleSheetUtility::deleteModifiedFontFile()
|
||||||
{
|
{
|
||||||
const QString fn = CFileUtils::appendFilePaths(qssDirectory(), fileNameFontsModified());
|
const QString fn = CFileUtils::appendFilePaths(CBuildConfig::getStylesheetsDir(), fileNameFontsModified());
|
||||||
QFile file(fn);
|
QFile file(fn);
|
||||||
if (!file.exists()) { return false; }
|
if (!file.exists()) { return false; }
|
||||||
bool r = file.remove();
|
bool r = file.remove();
|
||||||
@@ -357,19 +358,6 @@ namespace BlackGui
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CStyleSheetUtility::qssDirectory()
|
|
||||||
{
|
|
||||||
static QString dirPath;
|
|
||||||
if (!dirPath.isEmpty()) { return dirPath; }
|
|
||||||
QDir dir(QCoreApplication::applicationDirPath());
|
|
||||||
bool ok = dir.cdUp();
|
|
||||||
Q_ASSERT_X(ok, Q_FUNC_INFO, "Wrong directory structure");
|
|
||||||
if (!ok) { return ""; }
|
|
||||||
dirPath = CFileUtils::appendFilePaths(dir.absolutePath(), "qss");
|
|
||||||
Q_ASSERT_X(QDir(dirPath).exists(), Q_FUNC_INFO, "Wrong directory structure");
|
|
||||||
return dirPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CStyleSheetUtility::useStyleSheetInDerivedWidget(QWidget *usedWidget, QStyle::PrimitiveElement element)
|
bool CStyleSheetUtility::useStyleSheetInDerivedWidget(QWidget *usedWidget, QStyle::PrimitiveElement element)
|
||||||
{
|
{
|
||||||
Q_ASSERT(usedWidget);
|
Q_ASSERT(usedWidget);
|
||||||
|
|||||||
@@ -121,9 +121,6 @@ namespace BlackGui
|
|||||||
//! Transparent background color
|
//! Transparent background color
|
||||||
static const QString &transparentBackgroundColor();
|
static const QString &transparentBackgroundColor();
|
||||||
|
|
||||||
//! qss directory
|
|
||||||
static QString qssDirectory();
|
|
||||||
|
|
||||||
//! Font style as string
|
//! Font style as string
|
||||||
static const QString &fontStyleAsString(const QFont &font);
|
static const QString &fontStyleAsString(const QFont &font);
|
||||||
|
|
||||||
|
|||||||
@@ -167,10 +167,40 @@ namespace BlackMisc
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString getSoundFilesDirImpl()
|
||||||
|
{
|
||||||
|
const QString d(CBuildConfig::getSwiftResourceDir());
|
||||||
|
if (d.isEmpty()) { return ""; }
|
||||||
|
QDir dir(CFileUtils::appendFilePaths(d, "sounds"));
|
||||||
|
Q_ASSERT_X(dir.exists(), Q_FUNC_INFO, "missing dir");
|
||||||
|
return dir.absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &CBuildConfig::getSoundFilesDir()
|
||||||
|
{
|
||||||
|
static QString s(getSoundFilesDirImpl());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getStylesheetsDirImpl()
|
||||||
|
{
|
||||||
|
const QString d(CBuildConfig::getSwiftResourceDir());
|
||||||
|
if (d.isEmpty()) { return ""; }
|
||||||
|
QDir dir(CFileUtils::appendFilePaths(d, "qss"));
|
||||||
|
Q_ASSERT_X(dir.exists(), Q_FUNC_INFO, "missing dir");
|
||||||
|
return dir.absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &CBuildConfig::getStylesheetsDir()
|
||||||
|
{
|
||||||
|
static QString s(getStylesheetsDirImpl());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
QString getImagesDirImpl()
|
QString getImagesDirImpl()
|
||||||
{
|
{
|
||||||
const QString d(CBuildConfig::getSwiftResourceDir());
|
const QString d(CBuildConfig::getSwiftResourceDir());
|
||||||
QDir dir(CFileUtils::appendFilePaths(d, "data/images"));
|
QDir dir(CFileUtils::appendFilePaths(d, "images"));
|
||||||
Q_ASSERT_X(dir.exists(), Q_FUNC_INFO, "missing dir");
|
Q_ASSERT_X(dir.exists(), Q_FUNC_INFO, "missing dir");
|
||||||
return dir.absolutePath();
|
return dir.absolutePath();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,12 @@ namespace BlackMisc
|
|||||||
//! Where static DB files are located
|
//! Where static DB files are located
|
||||||
static const QString &getSwiftStaticDbFilesDir();
|
static const QString &getSwiftStaticDbFilesDir();
|
||||||
|
|
||||||
|
//! Where sound files are located
|
||||||
|
static const QString &getSoundFilesDir();
|
||||||
|
|
||||||
|
//! Where qss files are located
|
||||||
|
static const QString &getStylesheetsDir();
|
||||||
|
|
||||||
//! Where images are located
|
//! Where images are located
|
||||||
static const QString &getImagesDir();
|
static const QString &getImagesDir();
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "blacksound/soundgenerator.h"
|
#include "blacksound/soundgenerator.h"
|
||||||
#include "blackmisc/filedeleter.h"
|
#include "blackmisc/filedeleter.h"
|
||||||
|
#include "blackmisc/buildconfig.h"
|
||||||
#include <QtCore/qendian.h>
|
#include <QtCore/qendian.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
@@ -492,12 +493,12 @@ namespace BlackSound
|
|||||||
// order here is crucial, needs to be the same as in CSoundGenerator::Notification
|
// order here is crucial, needs to be the same as in CSoundGenerator::Notification
|
||||||
if (!playlist) playlist = new QMediaPlaylist(mediaPlayer);
|
if (!playlist) playlist = new QMediaPlaylist(mediaPlayer);
|
||||||
bool success = true;
|
bool success = true;
|
||||||
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/error.wav"))) && success;
|
success = playlist->addMedia(QUrl::fromLocalFile(CBuildConfig::getSoundFilesDir() + "/error.wav")) && success;
|
||||||
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/login.wav"))) && success;
|
success = playlist->addMedia(QUrl::fromLocalFile(CBuildConfig::getSoundFilesDir() + "/login.wav")) && success;
|
||||||
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/logoff.wav"))) && success;
|
success = playlist->addMedia(QUrl::fromLocalFile(CBuildConfig::getSoundFilesDir() + "/logoff.wav")) && success;
|
||||||
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/privatemessage.wav"))) && success;
|
success = playlist->addMedia(QUrl::fromLocalFile(CBuildConfig::getSoundFilesDir() + "/privatemessage.wav")) && success;
|
||||||
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/voiceroomjoined.wav"))) && success;
|
success = playlist->addMedia(QUrl::fromLocalFile(CBuildConfig::getSoundFilesDir() + "/voiceroomjoined.wav")) && success;
|
||||||
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/../sounds/voiceroomleft.wav"))) && success;
|
success = playlist->addMedia(QUrl::fromLocalFile(CBuildConfig::getSoundFilesDir() + "/voiceroomleft.wav")) && success;
|
||||||
|
|
||||||
Q_ASSERT(success);
|
Q_ASSERT(success);
|
||||||
playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
|
playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
|
||||||
|
|||||||
Reference in New Issue
Block a user