Browse Source

updated FormOptionWidget UX

Signed-off-by: T.J. Kotha <[email protected]>
T.J. Kotha 2 năm trước cách đây
mục cha
commit
6843924858

+ 18 - 0
Code/Tools/ProjectManager/Resources/ProjectManager.qss

@@ -66,6 +66,10 @@ QStackedWidget#createAGemRHS{
     margin-left: 0px;
 }
 
+#createAGemRHS #formOptionsFrame{
+    margin-left:2px;
+}
+
 #createAGemRHS #formTagField{
     margin-left: 0px;
 }
@@ -129,6 +133,11 @@ QTabBar::tab:focus {
     height: 40px;
 }
 
+#formOptionsWidget QCheckBox{
+    font-size: 16px;
+    height: 40px;
+}
+
 #ToastNotification {
     background-color: black;
     border-radius: 20px;
@@ -151,6 +160,7 @@ QTabBar::tab:focus {
 
 #formLineEditWidget,
 #formBrowseEditWidget, 
+#formOptionsWidget,
 #formComboBoxWidget {
     max-width: 890px;
 }
@@ -165,6 +175,13 @@ QTabBar::tab:focus {
     margin-left:50px;
 }
 
+#formOptionsFrame {
+    max-width: 840px;
+    padding: 0px 10px 2px 6px;
+    margin-top:10px;
+    margin-left:50px;
+}
+
 #formTagField {
     max-width: 840px;
     background-color: #333333;
@@ -205,6 +222,7 @@ QTabBar::tab:focus {
     border:1px solid #959595;
 }
 
+#formOptionsFrame QLabel,
 #formFrame QLabel {
     font-size: 13px;
     color: #cccccc;

+ 18 - 1
Code/Tools/ProjectManager/Source/CreateAGemScreen.cpp

@@ -269,9 +269,26 @@ namespace O3DE::ProjectManager
         m_requirements = new FormLineEditWidget(tr("Requirements"), "", tr("Notice of any requirements your Gem. i.e. This requires X other gem"), "");
         gemDetailsLayout->addWidget(m_requirements);
 
-        m_platformOptions = new FormOptionsWidget((QStringList() << tr("Windows") << tr("Linux") << tr("iOS") << tr("Android")), tr("All Platforms"));
+
+
+        QStringList platformOptions;
+        
+        //input the platform list in reverse alphabetical order
+        for(int i = GemInfo::NumPlatforms-1; i >= 0; i--)
+        {
+            const GemInfo::Platform platform = static_cast<GemInfo::Platform>(1 << i);
+            if(platform & m_platformSupportMask)
+            {
+                platformOptions << GemInfo::GetPlatformString(platform);
+            }
+        }
+
+        m_platformOptions = new FormOptionsWidget(tr("Target Platform(s)"), platformOptions, tr("All Platforms"), s_platformOptionItemSpacing);
         gemDetailsLayout->addWidget(m_platformOptions);
 
+        //handle workflow specific logic for platforms
+        LoadSupportedPlatforms();
+
         m_license = new FormLineEditWidget(
             tr("License*"), "", tr("License uses goes here: i.e. Apache-2.0 or MIT"), tr("License details are required."));
         gemDetailsLayout->addWidget(m_license);

+ 9 - 0
Code/Tools/ProjectManager/Source/CreateAGemScreen.h

@@ -64,6 +64,10 @@ namespace O3DE::ProjectManager
 
         virtual bool ValidateGemLocation(const QDir& chosenGemLocation) const;
 
+        virtual void LoadSupportedPlatforms()
+        {
+        }
+
         //Gem Setup
         QVector<TemplateInfo> m_gemTemplates;
         QButtonGroup* m_radioButtonGroup = nullptr;
@@ -107,10 +111,15 @@ namespace O3DE::ProjectManager
         static constexpr int GemDetailsScreen = 1;
         static constexpr int GemCreatorDetailsScreen = 2;
 
+        static inline constexpr int s_platformOptionItemSpacing = 24;
+
         int m_indexBackLimit = 0;
 
         QString m_gemActionString;
 
+        GemInfo::Platforms m_platformSupportMask = GemInfo::Platform::Windows | GemInfo::Platform::Linux |
+                                                 GemInfo::Platform::iOS | GemInfo::Platform::Android;
+
     private:
         void LoadButtonsFromGemTemplatePaths(QVBoxLayout* gemSetupLayout);
         QScrollArea* CreateGemSetupScrollArea();

+ 12 - 0
Code/Tools/ProjectManager/Source/EditAGemScreen.cpp

@@ -137,4 +137,16 @@ namespace O3DE::ProjectManager
         }
     }
 
+    void EditGem::LoadSupportedPlatforms()
+    {
+        for(int i = GemInfo::NumPlatforms-1; i >= 0; i--)
+        {
+            const GemInfo::Platform platform = static_cast<GemInfo::Platform>(1 << i);
+            if(platform & m_gemInfo.m_platforms)
+            {
+                m_platformOptions->enable(GemInfo::GetPlatformString(platform));
+            }
+        }
+    }
+
 } // namespace O3DE::ProjectManager

+ 2 - 0
Code/Tools/ProjectManager/Source/EditAGemScreen.h

@@ -40,6 +40,8 @@ namespace O3DE::ProjectManager
 
         bool ValidateGemLocation(const QDir& chosenGemLocation) const override;
 
+        void LoadSupportedPlatforms() override;
+
         QString m_oldGemName;
 
     };

+ 37 - 18
Code/Tools/ProjectManager/Source/FormOptionsWidget.cpp

@@ -21,21 +21,34 @@
 namespace O3DE::ProjectManager
 {
 
-    FormOptionsWidget::FormOptionsWidget(const QStringList& options, const QString& allOptionsText, QWidget* parent) : QWidget(parent)
+    FormOptionsWidget::FormOptionsWidget(const QString& labelText,
+                                         const QStringList& options,
+                                         const QString& allOptionsText,
+                                         const int optionItemSpacing,
+                                         QWidget* parent)
+                                         : QWidget(parent)
     {
         setObjectName("formOptionsWidget");
 
         QVBoxLayout* mainLayout = new QVBoxLayout();
         mainLayout->setAlignment(Qt::AlignTop);
         {
-            m_optionFrame = QFrame(this);
+            m_optionFrame = new QFrame(this);
+            m_optionFrame->setObjectName("formOptionsFrame");
             QHBoxLayout* optionFrameLayout = new QHBoxLayout();
             {
+                QVBoxLayout* fieldLayout = new QVBoxLayout();
+
+                QLabel* label = new QLabel(labelText, this);
+                fieldLayout->addWidget(label);
+
+
+                QHBoxLayout* optionLayout = new QHBoxLayout();
                 //Add the options
                 for(const QString& option : options)
                 {
                     QCheckBox* optionCheckBox = new QCheckBox(option);
-                    optionFrameLayout->addWidget(optionCheckBox);
+                    optionLayout->addWidget(optionCheckBox);
                     connect(optionCheckBox, &QCheckBox::clicked, this, [=](bool checked){
                         if(checked)
                         {
@@ -47,6 +60,7 @@ namespace O3DE::ProjectManager
                         }
                     });
                     m_options.insert(option, optionCheckBox);
+                    optionLayout->addSpacing(optionItemSpacing);
                 }
 
                 //Add the platform option toggle
@@ -63,7 +77,12 @@ namespace O3DE::ProjectManager
                 });
                 AzQtComponents::CheckBox::applyToggleSwitchStyle(m_allOptionsToggle);
 
-                optionFrameLayout->addWidget(m_allOptionsToggle);
+                optionLayout->addWidget(m_allOptionsToggle);
+
+                optionLayout->addStretch();
+
+                fieldLayout->addLayout(optionLayout);
+                optionFrameLayout->addLayout(fieldLayout);
             }
 
             m_optionFrame->setLayout(optionFrameLayout);
@@ -77,15 +96,11 @@ namespace O3DE::ProjectManager
         if(m_options.contains(option))
         {
             auto checkbox = m_options.value(option);
-            if(!checkbox->isChecked())
+            checkbox->setChecked(true);
+            if(getCheckedCount() == m_options.values().count())
             {
-                m_currentlyActive++;
-                if(m_currentlyActive == m_options.keys().count())
-                {
-                    m_allOptionsToggle->setChecked(true);
-                }
+                m_allOptionsToggle->setChecked(true);
             }
-            checkbox->setChecked(true);
         }
     }
 
@@ -102,11 +117,7 @@ namespace O3DE::ProjectManager
         if(m_options.contains(option))
         {
             auto checkbox = m_options.value(option);
-            if(checkbox->isChecked())
-            {
-                m_currentlyActive--;
-                m_allOptionsToggle->setChecked(false);
-            }
+            m_allOptionsToggle->setChecked(false);
             checkbox->setChecked(false);
         }
     }
@@ -126,7 +137,6 @@ namespace O3DE::ProjectManager
             checkbox->setChecked(true);
         }
         m_allOptionsToggle->setChecked(true);
-        m_currentlyActive = m_options.keys().count();
     }
     
     void FormOptionsWidget::clear()
@@ -136,7 +146,6 @@ namespace O3DE::ProjectManager
             checkbox->setChecked(false);
         }
         m_allOptionsToggle->setChecked(false);
-        m_currentlyActive = 0;
     }
 
     QStringList FormOptionsWidget::getOptions() const
@@ -159,4 +168,14 @@ namespace O3DE::ProjectManager
         return options;
     }
 
+    int FormOptionsWidget::getCheckedCount() const
+    {
+        int count = 0;
+        for(const auto& checkbox : m_options.values())
+        {
+            count += static_cast<int>(checkbox->isChecked());
+        }
+        return count;
+    }
+
 } // namespace O3DE::ProjectManager

+ 8 - 7
Code/Tools/ProjectManager/Source/FormOptionsWidget.h

@@ -22,13 +22,16 @@ namespace AzQtComponents
 
 namespace O3DE::ProjectManager
 {
-    class FormOptionsWidget
-        : public QWidget
+    class FormOptionsWidget : public QWidget
     {
         Q_OBJECT
 
     public:
-        FormOptionsWidget(const QStringList& options, const QString& allOptionsText, QWidget* parent = nullptr);
+        FormOptionsWidget(const QString& labelText,
+                          const QStringList& options,
+                          const QString& allOptionsText,
+                          const int optionItemSpacing = 24,
+                          QWidget* parent = nullptr);
 
         void clear();
 
@@ -45,13 +48,11 @@ namespace O3DE::ProjectManager
         QStringList getOptions() const;
 
     private:
+        int getCheckedCount() const;
         QFrame* m_optionFrame = nullptr;
         QHash<QString, QCheckBox*> m_options;
         QCheckBox* m_allOptionsToggle = nullptr;
-
-        //! Represents active options in m_options. Should never exceed the count of keys in m_options
-        int m_currentlyActive = 0;
-    }
+    };
 
 } // namespace O3DE::ProjectManager