Merge pull request #1250 from aws-lumberyard-dev/lawalfua/commonToolsApplication
Addition of a base AzQtToolsApplication class
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <AzQtComponents/Application/AzQtApplication.h>
|
||||
|
||||
#include <AzCore/PlatformIncl.h> // This should be the first include to make sure Windows.h is defined with NOMINMAX
|
||||
#include <AzQtComponents/Utilities/QtPluginPaths.h>
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
|
||||
AzQtApplication::AzQtApplication(int& argc, char** argv)
|
||||
: QApplication(argc, argv)
|
||||
{
|
||||
// Use a common Qt settings path for applications that don't register their own application name
|
||||
QApplication::setOrganizationName("O3DE");
|
||||
QApplication::setOrganizationDomain("o3de.org");
|
||||
QApplication::setApplicationName("O3DE Tools Application");
|
||||
|
||||
AzQtComponents::PrepareQtPaths();
|
||||
|
||||
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
|
||||
}
|
||||
|
||||
void AzQtApplication::InitializeDpiScaling()
|
||||
{
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
|
||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::SystemDpiAware);
|
||||
}
|
||||
} // namespace AzQtComponents
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <AzQtComponents/Utilities/HandleDpiAwareness.h>
|
||||
|
||||
namespace AzQtComponents
|
||||
{
|
||||
//! Base class for O3DE Tools Applications
|
||||
class AZ_QT_COMPONENTS_API AzQtApplication
|
||||
: public QApplication
|
||||
{
|
||||
public:
|
||||
AzQtApplication(int& argc, char** argv);
|
||||
|
||||
//! Initializes Qt DPI scaling to handle displays with high display densities, such as Retina displays.
|
||||
//! Currently, this uses Qt's system DPI awareness, in which a common device scaling factor will be
|
||||
//! calculated across all attached screens.
|
||||
//! \warning This must be called before this AzQtApplication instance is initialized.
|
||||
static void InitializeDpiScaling();
|
||||
};
|
||||
|
||||
} // namespace AzQtComponents
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
set(FILES
|
||||
AzQtComponentsAPI.h
|
||||
Application/AzQtApplication.cpp
|
||||
Application/AzQtApplication.h
|
||||
Buses/DragAndDrop.h
|
||||
Buses/ShortcutDispatch.h
|
||||
DragAndDrop/MainWindowDragAndDrop.h
|
||||
|
||||
Reference in New Issue
Block a user