kdeui
ktoolbarlabelaction.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "ktoolbarlabelaction.h"
00020
00021 #include <qlabel.h>
00022 #include <qapplication.h>
00023
00024 class KToolBarLabelAction::KToolBarLabelActionPrivate
00025 {
00026 public:
00027 KToolBarLabelActionPrivate()
00028 : m_label(0)
00029 {
00030 }
00031 QLabel* m_label;
00032 };
00033
00034
00035 KToolBarLabelAction::KToolBarLabelAction(const QString &text,
00036 const KShortcut &cut,
00037 const QObject *receiver,
00038 const char *slot,
00039 KActionCollection *parent,
00040 const char *name)
00041 : KWidgetAction(new QLabel(text, 0, "kde toolbar widget"), text, cut,
00042 receiver, slot, parent, name),
00043 d(new KToolBarLabelActionPrivate)
00044 {
00045 init();
00046 }
00047
00048 KToolBarLabelAction::KToolBarLabelAction(QWidget* buddy,
00049 const QString &text,
00050 const KShortcut &cut,
00051 const QObject *receiver,
00052 const char *slot,
00053 KActionCollection *parent,
00054 const char *name)
00055 : KWidgetAction(new QLabel(buddy, text, 0, "kde toolbar widget"), text,
00056 cut, receiver, slot, parent, name),
00057 d(new KToolBarLabelActionPrivate)
00058 {
00059 init();
00060 }
00061
00062 KToolBarLabelAction::KToolBarLabelAction(QLabel* label,
00063 const KShortcut &cut,
00064 const QObject *receiver,
00065 const char *slot,
00066 KActionCollection* parent,
00067 const char *name)
00068 : KWidgetAction(label, label->text(), cut, receiver, slot, parent, name),
00069 d(new KToolBarLabelActionPrivate)
00070 {
00071 Q_ASSERT(QString::fromLatin1("kde toolbar widget") == label->name());
00072 init();
00073 }
00074
00075 KToolBarLabelAction::~KToolBarLabelAction()
00076 {
00077 delete d;
00078 d = 0;
00079 }
00080
00081 void KToolBarLabelAction::init()
00082 {
00083 d->m_label = static_cast<QLabel*>(widget());
00084
00085
00086 d->m_label->setBackgroundMode(Qt::PaletteButton);
00087 d->m_label->setAlignment((QApplication::reverseLayout()
00088 ? Qt::AlignRight : Qt::AlignLeft) |
00089 Qt::AlignVCenter | Qt::ShowPrefix );
00090 d->m_label->adjustSize();
00091 }
00092
00093 void KToolBarLabelAction::setText(const QString& text)
00094 {
00095 KWidgetAction::setText(text);
00096 d->m_label->setText(text);
00097 }
00098
00099 void KToolBarLabelAction::setBuddy(QWidget* buddy)
00100 {
00101 d->m_label->setBuddy(buddy);
00102 }
00103
00104 QWidget* KToolBarLabelAction::buddy() const
00105 {
00106 return d->m_label->buddy();
00107 }
00108
00109 QLabel* KToolBarLabelAction::label() const
00110 {
00111 return d->m_label;
00112 }
00113
00114 void KToolBarLabelAction::virtual_hook(int, void*)
00115 {
00116
00117 }