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 5, 2023
1 parent eb5e0f0 commit f39a340
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 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.
19 changes: 15 additions & 4 deletions docs/widgets/dcombobox.zh_CN.dox
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@
@~chinese
@file dcombobox.h
@ingroup button
@class
@brief
@details

TODO: 添加类简介、示例代码、示例截图和函数使用说明等
@class Dtk::Widget::DComboBox
@brief DComboBox 重写QComboBox, 提供一个下拉列表供用户选择

@note 代码示例

@code
DComboBox *btn1 = new DComboBox("btn1");
btn1->addItem("ComboBox");
@endcode

## demo示例
@image html ../images/DComboBox_1.png"
@image html ../images/DComboBox_2.png"

@fn void DComboBox::showPopup()
@brief 重写QComboBox::showPopup, 按照maxVisibleItems()来限制最大显示高度,其值默认为16,可通过setMaxVisibleItems()来改变最大显示高度,这个功能使得setMaximumHeight()接口无效。
*/

26 changes: 14 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,14 @@ 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 Code example.
* @~english @code
* DComboBox *btn1 = new DComboBox("btn1");
* btn1->addItem("ComboBox");
* @endcode
*/
DComboBox::DComboBox(QWidget *parent)
: QComboBox(parent)
Expand All @@ -116,8 +118,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 +147,7 @@ void DComboBox::showPopup()
}
return count;
};
// 小于 16 的时候使用 qt 默认的,直接返回,避免显示多余的空白
// When the value of maxVisibleItems() is less than 16, use the default value of qt and return it directly to avoid displaying excess whitespace
QComboBoxPrivateContainer *container = this->findChild<QComboBoxPrivateContainer *>();
if (getRowCount() <= maxVisibleItems() || !container)
return QComboBox::showPopup();
Expand Down

0 comments on commit f39a340

Please sign in to comment.