Integrating latest from github/staging

Integrating up through commit 5e1bdae
This commit is contained in:
alexpete
2021-03-26 14:31:50 -07:00
parent 9c54341af8
commit 36c4e827bd
764 changed files with 11453 additions and 20251 deletions
@@ -11,6 +11,8 @@
*/
#include <AzCore/Debug/Trace.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzQtComponents/Components/StyleManager.h>
#include <QTextStream>
#include <QApplication>
@@ -52,7 +54,8 @@ namespace AzQtComponents
}
void StyleManager::addSearchPaths(const QString& searchPrefix, const QString& pathOnDisk, const QString& qrcPrefix)
void StyleManager::addSearchPaths(const QString& searchPrefix, const QString& pathOnDisk, const QString& qrcPrefix,
const AZ::IO::PathView& engineRootPath)
{
if (!s_instance)
{
@@ -60,7 +63,7 @@ namespace AzQtComponents
return;
}
s_instance->m_stylesheetCache->addSearchPaths(searchPrefix, pathOnDisk, qrcPrefix);
s_instance->m_stylesheetCache->addSearchPaths(searchPrefix, pathOnDisk, qrcPrefix, engineRootPath);
}
bool StyleManager::setStyleSheet(QWidget* widget, QString styleFileName)
@@ -153,7 +156,7 @@ namespace AzQtComponents
}
}
void StyleManager::initialize(QApplication* application)
void StyleManager::initialize([[maybe_unused]] QApplication* application, const AZ::IO::PathView& engineRootPath)
{
if (s_instance)
{
@@ -167,7 +170,7 @@ namespace AzQtComponents
connect(application, &QCoreApplication::aboutToQuit, this, &StyleManager::cleanupStyles);
initializeSearchPaths(application);
initializeSearchPaths(application, engineRootPath);
initializeFonts();
m_titleBarOverdrawHandler = TitleBarOverdrawHandler::createHandler(application, this);
@@ -228,10 +231,11 @@ namespace AzQtComponents
QFontDatabase::addApplicationFont(openSansPathSpecifier.arg("OpenSans-SemiboldItalic.ttf"));
}
void StyleManager::initializeSearchPaths(QApplication* application)
void StyleManager::initializeSearchPaths([[maybe_unused]] QApplication* application, const AZ::IO::PathView& engineRootPath)
{
// now that QT is initialized, we can use its path manipulation functions to set the rest up:
QString rootDir = FindEngineRootDir(application);
QString rootDir = QString::fromUtf8(engineRootPath.Native().data(), aznumeric_cast<int>(engineRootPath.Native().size()));
if (!rootDir.isEmpty())
{
@@ -14,6 +14,8 @@
#if !defined(Q_MOC_RUN)
#include <AzQtComponents/AzQtComponentsAPI.h>
#include <AzCore/IO/Path/Path_fwd.h>
#include <QObject>
#include <QColor>
#include <QHash>
@@ -62,7 +64,8 @@ namespace AzQtComponents
public:
static bool isInstanced() { return s_instance; }
static void addSearchPaths(const QString& searchPrefix, const QString& pathOnDisk, const QString& qrcPrefix);
static void addSearchPaths(const QString& searchPrefix, const QString& pathOnDisk, const QString& qrcPrefix,
const AZ::IO::PathView& engineRootPath);
static bool setStyleSheet(QWidget* widget, QString styleFileName);
@@ -76,10 +79,10 @@ namespace AzQtComponents
/*!
* Call to initialize the StyleManager, allowing it to hook into the application and apply the global style
* The AzQtComponents does not hook in the AZ::Environment, so the Settings Registry isn't available
* Therefore the engine root path must be supplied via function arguments
*/
void initialize(QApplication* application);
// deprecated; introduced before the new camelCase Qt based method names were adopted.
void Initialize(QApplication* application) { initialize(application); }
void initialize(QApplication* application, const AZ::IO::PathView& engineRootPath);
/*!
* Call this to force a refresh of the global stylesheet and a reload of any settings files.
@@ -108,7 +111,7 @@ namespace AzQtComponents
private:
void initializeFonts();
void initializeSearchPaths(QApplication* application);
void initializeSearchPaths(QApplication* application, const AZ::IO::PathView& engineRootPath);
void resetWidgetSheets();
@@ -13,6 +13,8 @@
#include <AzQtComponents/Components/StyleSheetCache.h>
#include <AzQtComponents/Utilities/QtPluginPaths.h>
#include <AzCore/Debug/Trace.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <QProxyStyle>
#include <QWidget>
#include <QDir>
@@ -89,7 +91,8 @@ void StyleSheetCache::registerPathsFoundOnDisk(const QString& pathOnDisk, const
}
}
void StyleSheetCache::addSearchPaths(const QString& searchPrefix, const QString& pathOnDisk, const QString& qrcPrefix)
void StyleSheetCache::addSearchPaths(const QString& searchPrefix, const QString& pathOnDisk, const QString& qrcPrefix,
const AZ::IO::PathView& engineRootPath)
{
AZ_Warning("StyleSheetCache", m_prefixes.find(searchPrefix) == m_prefixes.end(),
"Style prefix \"%s\" was already registered, ignoring...", searchPrefix.constData());
@@ -98,7 +101,7 @@ void StyleSheetCache::addSearchPaths(const QString& searchPrefix, const QString&
QString diskPathToUse = pathOnDisk;
if (!QFileInfo(pathOnDisk).isAbsolute())
{
QDir rootDir(AzQtComponents::FindEngineRootDir(qApp));
QDir rootDir = QString::fromUtf8(engineRootPath.Native().data(), aznumeric_cast<int>(engineRootPath.Native().size()));
diskPathToUse = rootDir.absoluteFilePath(pathOnDisk);
}
@@ -14,6 +14,8 @@
#if !defined(Q_MOC_RUN)
#include <AzQtComponents/AzQtComponentsAPI.h>
#include <AzCore/IO/Path/Path_fwd.h>
#include <QObject>
#include <QHash>
#include <QString>
@@ -45,7 +47,8 @@ namespace AzQtComponents
public:
static const QString& styleSheetExtension();
void addSearchPaths(const QString& searchPrefix, const QString& pathOnDisk, const QString& qrcPrefix);
void addSearchPaths(const QString& searchPrefix, const QString& pathOnDisk, const QString& qrcPrefix,
const AZ::IO::PathView& engineRootPath);
void setFallbackSearchPaths(const QString& fallbackPrefix, const QString& pathOnDisk, const QString& qrcPrefix);
QString loadStyleSheet(QString styleFileName);
@@ -13,6 +13,9 @@
#include "StyleSheetPage.h"
#include "Gallery/ui_StyleSheetPage.h"
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzQtComponents/Components/StyleHelpers.h>
#include <AzQtComponents/Components/StyleManager.h>
@@ -97,7 +100,12 @@ StyleSheetPage::StyleSheetPage(QWidget* parent)
// developers. The style will be loaded from a Qt Resource file if Editor is installed, but
// developers with the file on disk will be able to modify the style and have it automatically
// reloaded.
AzQtComponents::StyleManager::addSearchPaths("gallery", pathOnDisk, qrcPath);
AZ::IO::FixedMaxPath engineRootPath;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Get(engineRootPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
}
AzQtComponents::StyleManager::addSearchPaths("gallery", pathOnDisk, qrcPath, engineRootPath);
// The following label shows the intended use:
AzQtComponents::StyleManager::setStyleSheet(ui->exampleWidget, "gallery:StyleSheetPage.qss");
@@ -14,6 +14,8 @@
#include <AzCore/Asset/AssetManagerComponent.h>
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/Component/ComponentApplicationBus.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/IO/Streamer/StreamerComponent.h>
#include <AzCore/Jobs/JobManagerComponent.h>
#include <AzCore/Memory/PoolAllocator.h>
@@ -151,7 +153,12 @@ int main(int argc, char **argv)
app.installEventFilter(globalEventFilter);
AzQtComponents::StyleManager styleManager(&app);
styleManager.Initialize(&app);
AZ::IO::FixedMaxPath engineRootPath;
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Get(engineRootPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
}
styleManager.initialize(&app, engineRootPath);
auto wrapper = new AzQtComponents::WindowDecorationWrapper(AzQtComponents::WindowDecorationWrapper::OptionNone);
auto widget = new ComponentDemoWidget(wrapper);
@@ -17,11 +17,14 @@
#include <AzQtComponents/Utilities/QtPluginPaths.h>
#include <AzQtComponents/Utilities/HandleDpiAwareness.h>
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/Component/EntityId.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/containers/map.h>
#include <AzCore/std/containers/set.h>
#include <AzCore/std/containers/unordered_set.h>
#include <AzCore/Component/EntityId.h>
#include <QDialog>
#include <QVBoxLayout>
@@ -168,6 +171,12 @@ public:
int main(int argc, char** argv)
{
AZ::IO::FixedMaxPath engineRootPath;
{
AZ::ComponentApplication componentApplication(argc, argv);
auto settingsRegistry = AZ::SettingsRegistry::Get();
settingsRegistry->Get(engineRootPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
}
AzQtComponents::PrepareQtPaths();
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@@ -176,7 +185,7 @@ int main(int argc, char** argv)
QApplication qtApp(argc, argv);
AzQtComponents::StyleManager styleManager(&qtApp);
styleManager.Initialize(&qtApp);
styleManager.initialize(&qtApp, engineRootPath);
StandaloneRPE::RPEApplication app(&argc, &argv);
app.Start(AzFramework::Application::Descriptor());
@@ -10,6 +10,9 @@
*
*/
#include "mainwidget.h"
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/IO/Path/Path.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzQtComponents/Components/StyledDockWidget.h>
#include <AzQtComponents/Components/ToolButtonComboBox.h>
#include <AzQtComponents/Components/ToolButtonLineEdit.h>
@@ -173,15 +176,21 @@ static void addMenu(QMainWindow *w, const QString &name)
menu->addAction("Longer item 5");
}
int main(int argv, char **argc)
int main(int argc, char **argv)
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
QApplication app(argv, argc);
QApplication app(argc, argv);
AzQtComponents::LumberyardStylesheet stylesheet(&app);
stylesheet.Initialize(&app);
AZ::IO::FixedMaxPath engineRootPath;
{
AZ::ComponentApplication componentApplication(argc, argv);
auto settingsRegistry = AZ::SettingsRegistry::Get();
settingsRegistry->Get(engineRootPath.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
}
stylesheet.initialize(&app, engineRootPath);
auto wrapper = new AzQtComponents::WindowDecorationWrapper();
QMainWindow *w = new MainWindow();
@@ -73,30 +73,5 @@ namespace AzQtComponents
}
#endif
}
QString FindEngineRootDir(QApplication* app)
{
// The QApplication must be initialized before this method is called
// so it must be passed in as a parameter, even if we don't use it.
(void)app;
// Attempt to locate the engine by looking for 'engineroot.txt' and walking up the folder path until it is found (or not)
QDir appPath(QApplication::applicationDirPath());
QString engineRootPath;
while (!appPath.isRoot())
{
if (QFile::exists(appPath.filePath("engine.json")))
{
engineRootPath = appPath.absolutePath();
break;
}
if (!appPath.cdUp())
{
break;
}
}
return engineRootPath;
}
} // namespace AzQtComponents
@@ -19,10 +19,6 @@ class QApplication;
namespace AzQtComponents
{
AZ_QT_COMPONENTS_API void PrepareQtPaths();
AZ_QT_COMPONENTS_API QString FindEngineRootDir(QApplication* app);
} // namespace AzQtComponents