Skip to content

Commit

Permalink
shared/icon-label: Split into header and source file
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
gxalpha committed Jan 16, 2025
1 parent 22f2226 commit 786dd76
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion shared/qt/icon-label/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 icon-label.hpp)
target_sources(qt-icon-label INTERFACE icon-label.cpp icon-label.hpp)
target_include_directories(qt-icon-label INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}")

target_link_libraries(qt-icon-label INTERFACE Qt::Core Qt::Widgets)
29 changes: 29 additions & 0 deletions shared/qt/icon-label/icon-label.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/******************************************************************************
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 "moc_icon-label.cpp"

void IconLabel::setIcon(const QIcon &icon)
{
m_icon = icon;
QLabel::setPixmap(icon.pixmap(m_iconSize));
}

void IconLabel::setIconSize(int newSize)
{
m_iconSize = newSize;
}
8 changes: 2 additions & 6 deletions shared/qt/icon-label/icon-label.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@ class IconLabel : public QLabel {
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;
Expand Down

0 comments on commit 786dd76

Please sign in to comment.