Skip to content

Commit

Permalink
pannel的一些接口调整为protected
Browse files Browse the repository at this point in the history
- pannel的一些接口调整为protected
- 设置panneltitle高度时调整label的字体大小
  • Loading branch information
czyt1988 committed Jan 18, 2025
1 parent 8082f15 commit 18499a1
Show file tree
Hide file tree
Showing 2 changed files with 231 additions and 211 deletions.
58 changes: 31 additions & 27 deletions src/SARibbonBar/SARibbonPannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ SARibbonToolButton* SARibbonPannel::PrivateData::lastAddActionButton()
void SARibbonPannel::PrivateData::resetTitleLabelFont()
{
if (SARibbonPannelLayout* lay = pannelLayout()) {
int h = lay->pannelTitleHeight();
QFont f = q_ptr->font();
f.setPixelSize(h * 0.8);
if (m_label) {
m_label->setFont(f);
int h = lay->pannelTitleHeight();
if (h > 1) {
QFont f = q_ptr->font();
f.setPixelSize(h * 0.8);
if (m_label) {
m_label->setFont(f);
}
}
}
}
Expand Down Expand Up @@ -631,14 +633,19 @@ bool SARibbonPannel::isExpanding() const
}

/**
@brief 设置标题栏的高度
@param h
* @brief 设置标题栏的高度
*
* 为了避免用户误操作,这个函数为protect,如果你要设置pannel的标题栏高度,你应该调用@ref SARibbonBar::setPannelTitleHeight
* @sa SARibbonBar::setPannelTitleHeight
*
* @param h 高度
*/
void SARibbonPannel::setTitleHeight(int h)
{
if (SARibbonPannelLayout* lay = pannelLayout()) {
lay->setPannelTitleHeight(h);
}
d_ptr->resetTitleLabelFont();
}

/**
Expand Down Expand Up @@ -667,6 +674,10 @@ bool SARibbonPannel::isEnableShowTitle() const

/**
* @brief 是否显示标题,显示标题后,标题的高度需要设置,默认高度为15
*
* 为了避免用户误操作,这个函数为protected,如果你要设置pannel题栏是否显示,你应该调用@ref SARibbonBar::setEnableShowPannelTitle
*
* @sa SARibbonBar::setEnableShowPannelTitle
* @param on
*/
void SARibbonPannel::setEnableShowTitle(bool on)
Expand Down Expand Up @@ -800,6 +811,10 @@ SARibbonBar* SARibbonPannel::ribbonBar() const

/**
* @brief 设置按钮之间的间隔
*
* 为了避免用户误操作,这个函数为protected,如果你要设置pannel按钮之间的间隔,你应该调用@ref SARibbonBar::setPannelSpacing
* @sa SARibbonBar::setPannelSpacing
*
* @param n
*/
void SARibbonPannel::setSpacing(int n)
Expand Down Expand Up @@ -862,26 +877,6 @@ void SARibbonPannel::resetToolButtonSize()
}
}

bool SARibbonPannel::event(QEvent* e)
{
#if SA_DEBUG_PRINT_EVENT
if (e->type() != QEvent::Paint) {
qDebug() << "SARibbonPannel event(" << e->type() << "),name=" << pannelName();
}
#endif
// if (SARibbonPannelLayout* lay = pannelLayout()) {
// if (lay->isDirty() && e->type() == QEvent::LayoutRequest) {
// if (QWidget* parw = parentWidget()) {
// if (QLayout* pl = parw->layout()) {
// pl->invalidate();
// }
// }
// lay->m_dirty = false;
// }
// }
return QWidget::event(e);
}

/**
* @brief 处理action的事件
*
Expand Down Expand Up @@ -1015,3 +1010,12 @@ SARibbonToolButton* SARibbonPannel::lastAddActionButton()
{
return d_ptr->lastAddActionButton();
}

/**
* @brief 获取title对应的label控件
* @return
*/
SARibbonPannelLabel* SARibbonPannel::titleLabel() const
{
return d_ptr->m_label;
}
Loading

0 comments on commit 18499a1

Please sign in to comment.