Skip to content

Commit

Permalink
doc: update docs for dcombobox
Browse files Browse the repository at this point in the history
更新dcombobox文档

Log: update docs
Issue: linuxdeepin/dtk#94 (comment)
  • Loading branch information
Skye-rs committed Jul 4, 2023
1 parent aa18184 commit c286c75
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
Binary file added docs/images/DComboBox_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/DComboBox_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions docs/widgets/dcombobox.zh_CN.dox
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
@~chinese
@file dcombobox.h
@ingroup button
@class
@brief
@details

TODO: 添加类简介、示例代码、示例截图和函数使用说明等
@class Dtk::Widget::DComboBox
@brief DComboBox 重写QComboBox, 提供一个下拉列表供用户选择
@note@row 代码示例
@note@row DComboBox *btn1 = new DComboBox("btn1");
@note@row btn1->addItem("ComboBox");
@details

## demo示例
<img src="../images/DComboBox_1.png" alt="Example 1" width="700" height="370">
<img src="../images/DComboBox_2.png" alt="Example 2" width="700" height="370">

*/
@fn void DComboBox::showPopup()
@brief 重写QComboBox::showPopup, 按照maxVisibleItems()来限制最大显示高度,其值默认为16,可通过setMaxVisibleItems()来改变最大显示高度,这个功能使得setMaximumHeight()接口无效。
*/
24 changes: 12 additions & 12 deletions src/widgets/dcombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void DComboBoxPrivate::init()
}

/*!
* \~chinese \brief 获得控件屏幕矩形位置,QDesktopWidgetPrivate改为QApplication::desktop()访问应用位置。
* @~english
@brief Obtain the screen rectangle position of the control, replace QDesktopWidgetPrivate with QApplication::desktop() to access the application position.
*/
QRect DComboBoxPrivate::popupGeometry()
{
Expand All @@ -58,9 +59,8 @@ QRect DComboBoxPrivate::popupGeometry()
}

/*!
* \~chinese \brief
* Computes a size hint based on the maximum width
* for the items in the combobox.
* @~english
@brief Computes a size hint based on the maximum width for the items in the combobox.
*/
int DComboBoxPrivate::computeWidthHint() const
{
Expand Down Expand Up @@ -92,12 +92,12 @@ int DComboBoxPrivate::computeWidthHint() const


/*!
* \~chinese \class DComboBox
* \~chinese \brief DComboBox 重写QComboBox, 提供一个下拉列表供用户选择
* @~english @class DComboBox
* @~english @brief Override QComboBox to create a ComboBox and provide a dropdown list for the user to select from.
*
* \~chinese \note\row 代码示例
* \~chinese \note\row DComboBox *btn1 = new DComboBox("btn1");
* \~chinese \note\row btn1->addItem("ComboBox");
* @~english @note@row Code example.
* @~english @note@row DComboBox *btn1 = new DComboBox("btn1");
* @~english @note@row btn1->addItem("ComboBox");
*/
DComboBox::DComboBox(QWidget *parent)
: QComboBox(parent)
Expand All @@ -116,8 +116,8 @@ DComboBox::DComboBox(DComboBoxPrivate &dd, QWidget *parent)
}

/*!
* \~chinese \brief 重写QComboBox::showPopup, 按照maxVisibleItems()来限制最大显示高度,其值默认为16,
* 可通过setMaxVisibleItems()来改变最大显示高度,这个功能使得setMaximumHeight()接口无效。
* @~english
@brief Override QComboBox::showPopup to limit the maximum display height according to maxVisibleItems(), which has a default value of 16. The maximum display height can be changed using setMaxVisibleItems(), which makes the setMaximumHeight() interface ineffective.
*/
void DComboBox::showPopup()
{
Expand Down Expand Up @@ -145,7 +145,7 @@ void DComboBox::showPopup()
}
return count;
};
// 小于 16 的时候使用 qt 默认的,直接返回,避免显示多余的空白
// When the value of maxVisibleItems() is less than 16, use the default value provided by Qt and return directly to avoid displaying extra blank space.
QComboBoxPrivateContainer *container = this->findChild<QComboBoxPrivateContainer *>();
if (getRowCount() <= maxVisibleItems() || !container)
return QComboBox::showPopup();
Expand Down

0 comments on commit c286c75

Please sign in to comment.