ATOM-15451 always bring material editor and foreground when launching
Bus, command line option, and handler to activate material editor window Made sure that material editor action in Ly tools menu is not checked/checkable Ly editor pushes command line option to use the same RHI https://jira.agscollab.com/browse/LYN-2610 https://jira.agscollab.com/browse/ATOM-15451 https://jira.agscollab.com/browse/ATOM-13742
This commit is contained in:
+3
@@ -28,6 +28,9 @@ namespace MaterialEditor
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
|
||||
//! Bring main window to foreground
|
||||
virtual void ActivateWindow() = 0;
|
||||
|
||||
//! Add dockable widget in main window
|
||||
//! @param name title of the dockable window
|
||||
//! @param widget docked window content
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
|
||||
#include <Atom/Window/MaterialEditorWindowModule.h>
|
||||
#include <Atom/Window/MaterialEditorWindowFactoryRequestBus.h>
|
||||
#include <Atom/Window/MaterialEditorWindowRequestBus.h>
|
||||
#include <AzCore/Utils/Utils.h>
|
||||
|
||||
AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT
|
||||
@@ -309,6 +310,13 @@ namespace MaterialEditor
|
||||
|
||||
void MaterialEditorApplication::ProcessCommandLine(const AZ::CommandLine& commandLine)
|
||||
{
|
||||
const AZStd::string activateWindowSwitchName = "activatewindow";
|
||||
if (commandLine.HasSwitch(activateWindowSwitchName))
|
||||
{
|
||||
MaterialEditor::MaterialEditorWindowRequestBus::Broadcast(
|
||||
&MaterialEditor::MaterialEditorWindowRequestBus::Handler::ActivateWindow);
|
||||
}
|
||||
|
||||
const AZStd::string timeoputSwitchName = "timeout";
|
||||
if (commandLine.HasSwitch(timeoputSwitchName))
|
||||
{
|
||||
@@ -438,6 +446,10 @@ namespace MaterialEditor
|
||||
// Handle commmand line params from connected socket
|
||||
if (buffer.startsWith("ProcessCommandLine:"))
|
||||
{
|
||||
// Bring the material editor to the foreground
|
||||
MaterialEditor::MaterialEditorWindowRequestBus::Broadcast(
|
||||
&MaterialEditor::MaterialEditorWindowRequestBus::Handler::ActivateWindow);
|
||||
|
||||
// Remove header and parse commands
|
||||
AZStd::string params(buffer.data(), buffer.size());
|
||||
params = params.substr(strlen("ProcessCommandLine:"));
|
||||
|
||||
@@ -129,6 +129,12 @@ namespace MaterialEditor
|
||||
MaterialEditorWindowRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void MaterialEditorWindow::ActivateWindow()
|
||||
{
|
||||
activateWindow();
|
||||
raise();
|
||||
}
|
||||
|
||||
bool MaterialEditorWindow::AddDockWidget(const AZStd::string& name, QWidget* widget, uint32_t area, uint32_t orientation)
|
||||
{
|
||||
auto dockWidgetItr = m_dockWidgets.find(name);
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace MaterialEditor
|
||||
|
||||
private:
|
||||
// MaterialEditorWindowRequestBus::Handler overrides...
|
||||
void ActivateWindow() override;
|
||||
bool AddDockWidget(const AZStd::string& name, QWidget* widget, uint32_t area, uint32_t orientation) override;
|
||||
void RemoveDockWidget(const AZStd::string& name) override;
|
||||
void SetDockWidgetVisible(const AZStd::string& name, bool visible) override;
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace MaterialEditor
|
||||
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
|
||||
->Attribute(AZ::Script::Attributes::Category, "Editor")
|
||||
->Attribute(AZ::Script::Attributes::Module, "materialeditor")
|
||||
->Event("ActivateWindow", &MaterialEditorWindowRequestBus::Events::ActivateWindow)
|
||||
->Event("SetDockWidgetVisible", &MaterialEditorWindowRequestBus::Events::SetDockWidgetVisible)
|
||||
->Event("IsDockWidgetVisible", &MaterialEditorWindowRequestBus::Events::IsDockWidgetVisible)
|
||||
->Event("GetDockWidgetNames", &MaterialEditorWindowRequestBus::Events::GetDockWidgetNames)
|
||||
|
||||
+17
-1
@@ -23,6 +23,8 @@
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
#include <AzToolsFramework/Thumbnails/ThumbnailContext.h>
|
||||
|
||||
#include <Atom/RHI/Factory.h>
|
||||
|
||||
#include <AtomToolsFramework/Util/Util.h>
|
||||
|
||||
#include <Material/MaterialThumbnail.h>
|
||||
@@ -125,6 +127,17 @@ namespace AZ
|
||||
|
||||
QStringList arguments;
|
||||
arguments.append(sourcePath.c_str());
|
||||
|
||||
// Bring the material editor to the foreground if running
|
||||
arguments.append("--activatewindow");
|
||||
|
||||
// Use the same RHI as the main editor
|
||||
AZ::Name apiName = AZ::RHI::Factory::Get().GetName();
|
||||
if (!apiName.IsEmpty())
|
||||
{
|
||||
arguments.append(QString("--rhi=%1").arg(apiName.GetCStr()));
|
||||
}
|
||||
|
||||
AtomToolsFramework::LaunchTool("MaterialEditor", ".exe", arguments);
|
||||
}
|
||||
|
||||
@@ -139,7 +152,10 @@ namespace AZ
|
||||
{
|
||||
m_openMaterialEditorAction = new QAction("Material Editor");
|
||||
m_openMaterialEditorAction->setShortcut(QKeySequence(Qt::Key_M));
|
||||
QObject::connect(m_openMaterialEditorAction, &QAction::triggered, m_openMaterialEditorAction, [this]()
|
||||
m_openMaterialEditorAction->setCheckable(false);
|
||||
m_openMaterialEditorAction->setChecked(false);
|
||||
QObject::connect(
|
||||
m_openMaterialEditorAction, &QAction::triggered, m_openMaterialEditorAction, [this]()
|
||||
{
|
||||
OpenInMaterialEditor("");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user