📄 bclabelaction.cpp
字号:
/*************************************************************************** bclabelaction.cpp ------------------- begin : Sat Nov 9 2002 copyright : (C) 2002 by Robby Stephenson email : robby@periapsis.org ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of version 2 of the GNU General Public License as * * published by the Free Software Foundation; * * * ***************************************************************************/#include "bclabelaction.h"#include <ktoolbar.h>#include <qtoolbutton.h>#include <qstyle.h>// largely copied from KonqLabelAction// Use a toolbutton instead of a label so it is styled correctlyclass BCLabelAction::ToolBarLabel : public QToolButton {public: ToolBarLabel(const QString& text_, QWidget* parent_ = 0, const char* name_ = 0) : QToolButton(parent_, name_) { setText(text_); }protected: void drawButton(QPainter* p_) { // Draw the background style().drawComplexControl(QStyle::CC_ToolButton, p_, this, rect(), colorGroup(), QStyle::Style_Enabled, QStyle::SC_ToolButton); // Draw the label style().drawControl(QStyle::CE_ToolButtonLabel, p_, this, rect(), colorGroup(), QStyle::Style_Enabled); }};BCLabelAction::BCLabelAction(const QString& text_, int accel_, QObject* parent_/*=0*/, const char *name_/*=0*/) : KAction(text_, accel_, parent_, name_), m_label(0) {}int BCLabelAction::plug(QWidget* widget_, int index_) { //do not call the previous implementation here if(widget_->inherits("KToolBar")) { KToolBar* tb = static_cast<KToolBar *>(widget_); int id = KAction::getToolButtonID(); m_label = new ToolBarLabel(text(), tb); tb->insertWidget(id, m_label->width(), m_label, index_); addContainer(tb, id); connect(tb, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); return containerCount() - 1; } return -1;}void BCLabelAction::unplug(QWidget* widget_) { if(widget_->inherits("KToolBar")) { KToolBar* tb = static_cast<KToolBar *>(widget_); int idx = findContainer(tb); if(idx != -1) { tb->removeItem(itemId(idx)); removeContainer(idx); } m_label = 0; return; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -