Renamed SideTabIconLabel - added C prefix CSideTabIconLabel

This commit is contained in:
Uwe Kindler 2022-10-18 15:29:31 +02:00
parent 60e0201060
commit 0cbc810a5a
3 changed files with 29 additions and 13 deletions

View File

@ -57,7 +57,7 @@ struct DockWidgetSideTabPrivate
CSideTabBar* SideTabBar; CSideTabBar* SideTabBar;
QSize IconSize; QSize IconSize;
Qt::Orientation Orientation{Qt::Vertical}; Qt::Orientation Orientation{Qt::Vertical};
SideTabIconLabel* IconLabel = nullptr; CSideTabIconLabel* IconLabel = nullptr;
QIcon Icon; QIcon Icon;
/** /**
@ -129,7 +129,7 @@ void DockWidgetSideTabPrivate::createLayout()
TitleLabel = new tTabLabel(); TitleLabel = new tTabLabel();
TitleLabel->setElideMode(Qt::ElideRight); TitleLabel->setElideMode(Qt::ElideRight);
TitleLabel->setText(DockWidget->windowTitle()); TitleLabel->setText(DockWidget->windowTitle());
TitleLabel->setObjectName("dockWidgetTabLabel"); TitleLabel->setObjectName("sideTabLabel");
_this->connect(TitleLabel, SIGNAL(elidedChanged(bool)), SIGNAL(elidedChanged(bool))); _this->connect(TitleLabel, SIGNAL(elidedChanged(bool)), SIGNAL(elidedChanged(bool)));
// Fill the layout // Fill the layout
@ -231,7 +231,7 @@ void CDockWidgetSideTab::setIcon(const QIcon& Icon)
if (!d->IconLabel) if (!d->IconLabel)
{ {
d->IconLabel = new SideTabIconLabel(); d->IconLabel = new CSideTabIconLabel();
internal::setToolTip(d->IconLabel, d->TitleLabel->toolTip()); internal::setToolTip(d->IconLabel, d->TitleLabel->toolTip());
Layout->insertWidget(0, d->IconLabel, Qt::AlignHCenter); Layout->insertWidget(0, d->IconLabel, Qt::AlignHCenter);
} }
@ -345,27 +345,28 @@ CDockWidget* CDockWidgetSideTab::dockWidget() const
*/ */
struct SideTabIconLabelPrivate struct SideTabIconLabelPrivate
{ {
SideTabIconLabel* _this; CSideTabIconLabel* _this;
QLabel* IconLabel; QLabel* IconLabel;
QBoxLayout* Layout; QBoxLayout* Layout;
SideTabIconLabelPrivate(SideTabIconLabel* _public); SideTabIconLabelPrivate(CSideTabIconLabel* _public);
}; // struct SideTabIconLabelPrivate }; // struct SideTabIconLabelPrivate
//============================================================================ //============================================================================
SideTabIconLabelPrivate::SideTabIconLabelPrivate(SideTabIconLabel* _public) : SideTabIconLabelPrivate::SideTabIconLabelPrivate(CSideTabIconLabel* _public) :
_this(_public) _this(_public)
{ {
} }
//============================================================================ //============================================================================
SideTabIconLabel::SideTabIconLabel(QWidget* parent) : QWidget(parent), CSideTabIconLabel::CSideTabIconLabel(QWidget* parent) : QFrame(parent),
d(new SideTabIconLabelPrivate(this)) d(new SideTabIconLabelPrivate(this))
{ {
d->Layout = new QBoxLayout(QBoxLayout::TopToBottom); d->Layout = new QBoxLayout(QBoxLayout::TopToBottom);
d->Layout->addWidget(d->IconLabel = new QLabel()); d->Layout->addWidget(d->IconLabel = new QLabel());
d->IconLabel->setObjectName("sideTabIconLabel");
d->Layout->setAlignment(Qt::AlignCenter); d->Layout->setAlignment(Qt::AlignCenter);
d->IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); d->IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
setLayout(d->Layout); setLayout(d->Layout);
@ -373,21 +374,21 @@ SideTabIconLabel::SideTabIconLabel(QWidget* parent) : QWidget(parent),
//============================================================================ //============================================================================
SideTabIconLabel::~SideTabIconLabel() CSideTabIconLabel::~CSideTabIconLabel()
{ {
delete d; delete d;
} }
//============================================================================ //============================================================================
void SideTabIconLabel::setPixmap(const QPixmap& pixmap) void CSideTabIconLabel::setPixmap(const QPixmap& pixmap)
{ {
d->IconLabel->setPixmap(pixmap); d->IconLabel->setPixmap(pixmap);
} }
//============================================================================ //============================================================================
void SideTabIconLabel::setContentsMargins(int left, int top, int right, int bottom) void CSideTabIconLabel::setContentsMargins(int left, int top, int right, int bottom)
{ {
d->Layout->setContentsMargins(left, top, right, bottom); d->Layout->setContentsMargins(left, top, right, bottom);
} }

View File

@ -152,14 +152,15 @@ Q_SIGNALS:
void clicked(); void clicked();
}; // class DockWidgetSideTab }; // class DockWidgetSideTab
class SideTabIconLabel : public QWidget class CSideTabIconLabel : public QFrame
{ {
Q_OBJECT
private: private:
SideTabIconLabelPrivate *d; ///< private data (pimpl) SideTabIconLabelPrivate *d; ///< private data (pimpl)
public: public:
SideTabIconLabel(QWidget* parent = nullptr); CSideTabIconLabel(QWidget* parent = nullptr);
virtual ~SideTabIconLabel(); virtual ~CSideTabIconLabel();
void setPixmap(const QPixmap &pixmap); void setPixmap(const QPixmap &pixmap);
void setContentsMargins(int left, int top, int right, int bottom); void setContentsMargins(int left, int top, int right, int bottom);

View File

@ -116,10 +116,24 @@ ads--CDockWidgetSideTab {
ads--CDockWidgetSideTab[sideTabBarArea="0"] { ads--CDockWidgetSideTab[sideTabBarArea="0"] {
border-right: 1px solid white; border-right: 1px solid white;
background: red;
}
#sideTabLabel {
background: green;
}
#sideTabIconLabel {
background: blue;
}
ads--CSideTabIconLabel {
border: 1px solid yellow
} }
ads--CDockWidgetSideTab[sideTabBarArea="1"] { ads--CDockWidgetSideTab[sideTabBarArea="1"] {
border-bottom: 1px solid white; border-bottom: 1px solid white;
background: red;
} }
ads--CDockWidgetSideTab[sideTabBarArea="2"] { ads--CDockWidgetSideTab[sideTabBarArea="2"] {