Browse Source

Use external lib craftlab::ui

isundil 9 months ago
parent
commit
7110765326

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "QtWidgets"]
+	path = QtWidgets
+	url = git:isundil/QtWidgets

+ 1 - 0
QtWidgets

@@ -0,0 +1 @@
+Subproject commit b006c571db70870a6f632ed429db0d4d54680c12

+ 6 - 0
fakeRaid.sln

@@ -9,6 +9,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Engine", "Engine.vcxproj",
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Crypto", "Crypto.vcxproj", "{4814536A-05B1-47B7-8843-4C654A601717}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QtWidgets", "QtWidgets\QtWidgets.vcxproj", "{8CE225AE-E9A9-435B-9EF1-B63684842259}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|x64 = Debug|x64
@@ -27,6 +29,10 @@ Global
 		{4814536A-05B1-47B7-8843-4C654A601717}.Debug|x64.Build.0 = Debug|x64
 		{4814536A-05B1-47B7-8843-4C654A601717}.Release|x64.ActiveCfg = Release|x64
 		{4814536A-05B1-47B7-8843-4C654A601717}.Release|x64.Build.0 = Release|x64
+		{8CE225AE-E9A9-435B-9EF1-B63684842259}.Debug|x64.ActiveCfg = Debug|x64
+		{8CE225AE-E9A9-435B-9EF1-B63684842259}.Debug|x64.Build.0 = Debug|x64
+		{8CE225AE-E9A9-435B-9EF1-B63684842259}.Release|x64.ActiveCfg = Release|x64
+		{8CE225AE-E9A9-435B-9EF1-B63684842259}.Release|x64.Build.0 = Release|x64
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 5 - 4
fakeRaid.vcxproj

@@ -12,7 +12,6 @@
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="fakeRaid\browseModal.cpp" />
-    <ClCompile Include="fakeRaid\checkableComboBox.cpp" />
     <ClCompile Include="fakeRaid\conflictItemWidget.cpp" />
     <ClCompile Include="fakeRaid\conflictModal.cpp" />
     <ClCompile Include="fakeRaid\fileItem.cpp" />
@@ -33,7 +32,6 @@
     <ClInclude Include="fakeRaid\browseModal.h" />
     <QtMoc Include="fakeRaid\conflictItemWidget.h" />
     <QtMoc Include="fakeRaid\conflictModal.h" />
-    <QtMoc Include="fakeRaid\checkableComboBox.h" />
     <ClInclude Include="fakeRaid\exports.h" />
     <ClInclude Include="fakeRaid\fileItem.h" />
     <ClInclude Include="fakeRaid\htmlFont.hh" />
@@ -43,6 +41,9 @@
     <ProjectReference Include="Engine.vcxproj">
       <Project>{f62d1642-3be3-44a3-a03a-116930004deb}</Project>
     </ProjectReference>
+    <ProjectReference Include="QtWidgets\QtWidgets.vcxproj">
+      <Project>{8ce225ae-e9a9-435b-9ef1-b63684842259}</Project>
+    </ProjectReference>
   </ItemGroup>
   <PropertyGroup Label="Globals">
     <ProjectGuid>{8964FB88-5696-4D58-B832-124F25BEA5E8}</ProjectGuid>
@@ -94,11 +95,11 @@
   </ImportGroup>
   <PropertyGroup Label="UserMacros" />
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
-    <IncludePath>$(SolutionDir)\Engine;$(SolutionDir)\fakeRaid;$(SolutionDir)\Crypto;$(IncludePath)</IncludePath>
+    <IncludePath>$(SolutionDir)\Engine;$(SolutionDir)\QtWidgets\includes;$(SolutionDir)\fakeRaid;$(SolutionDir)\Crypto;$(IncludePath)</IncludePath>
     <IntDir>$(SolutionDir)\$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
-    <IncludePath>$(SolutionDir)\Engine;$(SolutionDir)\fakeRaid;$(SolutionDir)\Crypto;$(IncludePath)</IncludePath>
+    <IncludePath>$(SolutionDir)\Engine;$(SolutionDir)\QtWidgets\includes;$(SolutionDir)\fakeRaid;$(SolutionDir)\Crypto;$(IncludePath)</IncludePath>
     <IntDir>$(SolutionDir)\$(Platform)\$(Configuration)\$(MSBuildProjectName)\</IntDir>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">

+ 0 - 6
fakeRaid.vcxproj.filters

@@ -44,9 +44,6 @@
     <ClCompile Include="fakeRaid\fileItem.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="fakeRaid\checkableComboBox.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <QtUic Include="fakeRaid\MainWindow.ui">
@@ -72,9 +69,6 @@
     <QtMoc Include="fakeRaid\conflictModal.h">
       <Filter>Header Files</Filter>
     </QtMoc>
-    <QtMoc Include="fakeRaid\checkableComboBox.h">
-      <Filter>Header Files</Filter>
-    </QtMoc>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="fakeRaid\exports.h">

+ 2 - 2
fakeRaid/ConflictItemWidget.ui

@@ -107,7 +107,7 @@
         </spacer>
        </item>
        <item>
-        <widget class="CheckableComboBox" name="ddUseVersion"/>
+        <widget class="craftlab::ui::CheckableComboBox" name="ddUseVersion"/>
        </item>
        <item>
         <widget class="QPushButton" name="buttonCopy">
@@ -147,7 +147,7 @@
  </widget>
  <customwidgets>
   <customwidget>
-   <class>CheckableComboBox</class>
+   <class>craftlab::ui::CheckableComboBox</class>
    <extends>QComboBox</extends>
    <header>checkablecombobox.h</header>
   </customwidget>

+ 0 - 61
fakeRaid/checkableComboBox.cpp

@@ -1,61 +0,0 @@
-#include <QStylePainter>
-#include "checkableComboBox.h"
-
-CheckableComboBox::CheckableComboBox(QWidget* parent): QComboBox(parent)
-{
-}
-
-void CheckableComboBox::setChecked(bool val)
-{
-    if (checked != val)
-    {
-        checked = val;
-        this->update();
-    }
-}
-
-bool CheckableComboBox::isChecked() const
-{
-	return checked;
-}
-
-void CheckableComboBox::paintEvent(QPaintEvent* e)
-{
-    QStylePainter painter(this);
-    painter.setPen(palette().color(QPalette::Text));
-    QStyleOptionComboBox opt;
-    initStyleOption(&opt);
-
-    if (checked)
-    {
-        QStyleOptionButton option;
-        QRectF downButtonRect = style()->proxy()->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow, this);
-        option.initFrom(this);
-        option.features = QStyleOptionButton::HasMenu;
-        option.state |= QStyle::State_On;
-        option.text = currentText();
-        option.icon = qvariant_cast<QIcon>(currentData(Qt::DecorationRole));
-        option.iconSize = iconSize();
-
-        // Draw button
-        option.rect.adjust(0, 0, downButtonRect.width() +4, 0);
-        painter.drawControl(QStyle::CE_PushButtonBevel, option);
-
-        // Draw button text
-        option.rect.adjust(0, 0, -downButtonRect.width() -4, 0);
-        painter.drawControl(QStyle::CE_PushButtonLabel, option);
-
-        // Draw dropdown button
-        painter.setPen(palette().text().color());
-        painter.drawText(downButtonRect, "\uE019", Qt::AlignVCenter | Qt::AlignHCenter);
-    }
-    else
-    {
-        if (currentIndex() < 0 && !placeholderText().isEmpty()) {
-            opt.palette.setBrush(QPalette::ButtonText, opt.palette.placeholderText());
-            opt.currentText = placeholderText();
-        }
-        painter.drawComplexControl(QStyle::CC_ComboBox, opt);
-        painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
-    }
-}

+ 0 - 18
fakeRaid/checkableComboBox.h

@@ -1,18 +0,0 @@
-#pragma once
-
-#include <QComboBox>
-
-class CheckableComboBox : public QComboBox
-{
-	Q_OBJECT
-	public:
-		CheckableComboBox(QWidget* parent =nullptr);
-
-		void paintEvent(QPaintEvent* e) override;
-
-		void setChecked(bool value);
-		bool isChecked() const;
-
-	private:
-		bool checked =false;
-};

+ 1 - 0
fakeRaid/conflictItemWidget.cpp

@@ -4,6 +4,7 @@
 #include "htmlFont.hh"
 
 using namespace craftlab::fakeraid;
+using namespace craftlab::ui;
 
 ConflictItemWidget::ConflictItemWidget(QListWidget* parent, const QFile& file, const std::string& _fileName): QWidget(parent), filename(_fileName)
 {