Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: update docs for dtoolbutton #486

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/images/DToolButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 24 additions & 3 deletions docs/widgets/dtoolbutton.zh_CN.dox
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,32 @@
@~chinese
@file dtoolbutton.h
@ingroup button
@class
@brief
@class Dtk::Widget::DToolButton
@brief 继承自QToolButton类,用于自定义工具按钮。
@details

TODO: 添加类简介、示例代码、示例截图和函数使用说明等
### demo示例图片
@image html ../images/DToolButton.png

@fn void DToolButton::paintEvent(QPaintEvent *event)
@brief 重写QToolButton的paintEvent方法,用于绘制自定义的工具按钮外观。
@param event 绘制事件,未使用。

@fn void DToolButton::initStyleOption(QStyleOptionToolButton *option) const
@brief 初始化工具按钮的样式选项。
@param option QStyleOptionToolButton类型指针,用于指定样式选项。

@fn QSize DToolButton::sizeHint() const
@brief 推荐合适的工具按钮大小。
@return 工具按钮的大小提示,类型为QSize。

@fn void DToolButton::setAlignment(Qt::Alignment flag)
@brief DToolButton::setAlignment 设置DToolButton的对齐方式
@a flag 对齐方式

@fn Qt::Alignment DToolButton::alignment() const
@brief DToolButton::alignment 返回DToolButton当前的对齐方式
@return 如果setAlignment设置成功则返回当前对齐方式,否则返回Qt::AlignLeft

*/

38 changes: 34 additions & 4 deletions src/widgets/dtoolbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@

DWIDGET_BEGIN_NAMESPACE

/*!
@~english
@class Dtk::Widget::DToolButton
@brief Inherited from the QToolButton class, used to customize tool buttons.
*/

DToolButton::DToolButton(QWidget *parent)
: QToolButton(parent)
{

}

/*!
@~english
@fn void DToolButton::paintEvent(QPaintEvent *event)
@brief This method overrides the paintEvent method of QToolButton to draw a custom appearance for the tool button.
@param event The paint event, which is not used.
*/

void DToolButton::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
Expand All @@ -24,28 +37,45 @@ void DToolButton::paintEvent(QPaintEvent *event)
p.drawComplexControl(QStyle::CC_ToolButton, opt);
}

/*!
@~english
@fn void DToolButton::initStyleOption(QStyleOptionToolButton *option) const
@brief Initializes the style options for the tool button.
@param option A pointer to a QStyleOptionToolButton object, used to specify style options.
*/
void DToolButton::initStyleOption(QStyleOptionToolButton *option) const
{
QToolButton::initStyleOption(option);
}

/*!
@~english
@fn QSize DToolButton::sizeHint() const
@brief Gets the size hint for the tool button.
@return The size hint for the tool button, of type QSize.
*/

QSize DToolButton::sizeHint() const
{
return QToolButton::sizeHint();
}

/*!
\brief DToolButton::setAlignment 设置DToolButton的对齐方式
\a flag Qt::AlignCenter居中对齐 Qt::AlignLeft左对齐 Qt::AlignRight右对齐
@~english
@fn void DToolButton::setAlignment(Qt::Alignment flag)
@brief DToolButton:: setAlignment set the alignment of DToolButton
@a flag alignment mode
*/
void DToolButton::setAlignment(Qt::Alignment flag)
{
this->setProperty("_d_dtk_toolButtonAlign", QVariant(flag));
}

/*!
\brief DToolButton::alignment 返回DToolButton当前的对齐方式
\return 如果setAlignment设置成功则返回当前对齐方式,否则返回Qt::AlignLeft
@~english
@fn Qt::Alignment DToolButton::alignment() const
@brief DToolButton:: alignment returns the current alignment of DToolButton
@return If setAlignment is successfully set, the current alignment is returned; otherwise, Qt:: AlignLeft is returned
*/
Qt::Alignment DToolButton::alignment() const
{
Expand Down