• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

ktoolbarlabelaction.cpp

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00016     Boston, MA 02110-1301, 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 }

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal