kdeui Library API Documentation

ktoolbarlabelaction.cpp

00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2004 Felix Berger <felixberger@beldesign.de> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00016 Boston, MA 02111-1307, USA. 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 /* these lines were copied from Konqueror's KonqDraggableLabel class in 00085 konq_misc.cc */ 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 }
KDE Logo
This file is part of the documentation for kdeui Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Apr 12 22:56:33 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003