1
0
Эх сурвалжийг харах

shared/icon-label: Split into header and source file

Splits the IconLabel widget header into a header and source file. The
source uses the moc_icon-label include to prevent the moc from being
included in the global mocs_compilation (as described in 5eb04cd).
gxalpha 9 сар өмнө
parent
commit
9dcef85e69

+ 1 - 1
shared/qt/icon-label/CMakeLists.txt

@@ -5,7 +5,7 @@ find_package(Qt6 REQUIRED Core Widgets)
 add_library(qt-icon-label INTERFACE)
 add_library(OBS::qt-icon-label ALIAS qt-icon-label)
 
-target_sources(qt-icon-label INTERFACE IconLabel.hpp)
+target_sources(qt-icon-label INTERFACE IconLabel.cpp IconLabel.hpp)
 target_include_directories(qt-icon-label INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}")
 
 target_link_libraries(qt-icon-label INTERFACE Qt::Core Qt::Widgets)

+ 31 - 0
shared/qt/icon-label/IconLabel.cpp

@@ -0,0 +1,31 @@
+/******************************************************************************
+    Copyright (C) 2024 by Sebastian Beckmann
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+******************************************************************************/
+
+#include "IconLabel.hpp"
+
+void IconLabel::setIcon(const QIcon &icon)
+{
+	m_icon = icon;
+	QLabel::setPixmap(icon.pixmap(m_iconSize));
+}
+
+void IconLabel::setIconSize(int newSize)
+{
+	m_iconSize = newSize;
+}
+
+#include "moc_IconLabel.cpp"

+ 2 - 6
shared/qt/icon-label/IconLabel.hpp

@@ -35,14 +35,10 @@ public:
 	inline IconLabel(QWidget *parent = nullptr) : QLabel(parent), m_icon(), m_iconSize(16) {}
 
 	inline QIcon icon() const { return m_icon; }
-	void setIcon(const QIcon &icon)
-	{
-		m_icon = icon;
-		QLabel::setPixmap(icon.pixmap(m_iconSize));
-	}
+	void setIcon(const QIcon &icon);
 
 	inline int iconSize() const { return m_iconSize; }
-	void setIconSize(int newSize) { m_iconSize = newSize; }
+	void setIconSize(int newSize);
 
 private:
 	QIcon m_icon;