tdetoolbarlabelaction.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., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #include "tdetoolbarlabelaction.h" 00020 00021 #include <tqlabel.h> 00022 #include <tqapplication.h> 00023 00024 class TDEToolBarLabelAction::TDEToolBarLabelActionPrivate 00025 { 00026 public: 00027 TDEToolBarLabelActionPrivate() 00028 : m_label(0) 00029 { 00030 } 00031 TQLabel* m_label; 00032 }; 00033 00034 00035 TDEToolBarLabelAction::TDEToolBarLabelAction(const TQString &text, 00036 const TDEShortcut &cut, 00037 const TQObject *receiver, 00038 const char *slot, 00039 TDEActionCollection *parent, 00040 const char *name) 00041 : KWidgetAction(new TQLabel(text, 0, "tde toolbar widget"), text, cut, 00042 receiver, slot, parent, name), 00043 d(new TDEToolBarLabelActionPrivate) 00044 { 00045 init(); 00046 } 00047 00048 TDEToolBarLabelAction::TDEToolBarLabelAction(TQWidget* buddy, 00049 const TQString &text, 00050 const TDEShortcut &cut, 00051 const TQObject *receiver, 00052 const char *slot, 00053 TDEActionCollection *parent, 00054 const char *name) 00055 : KWidgetAction(new TQLabel(buddy, text, 0, "tde toolbar widget"), text, 00056 cut, receiver, slot, parent, name), 00057 d(new TDEToolBarLabelActionPrivate) 00058 { 00059 init(); 00060 } 00061 00062 TDEToolBarLabelAction::TDEToolBarLabelAction(TQLabel* label, 00063 const TDEShortcut &cut, 00064 const TQObject *receiver, 00065 const char *slot, 00066 TDEActionCollection* parent, 00067 const char *name) 00068 : KWidgetAction(label, label->text(), cut, receiver, slot, parent, name), 00069 d(new TDEToolBarLabelActionPrivate) 00070 { 00071 Q_ASSERT(TQString::fromLatin1("tde toolbar widget") == label->name()); 00072 init(); 00073 } 00074 00075 TDEToolBarLabelAction::~TDEToolBarLabelAction() 00076 { 00077 delete d; 00078 d = 0; 00079 } 00080 00081 void TDEToolBarLabelAction::init() 00082 { 00083 d->m_label = static_cast<TQLabel*>(widget()); 00084 /* these lines were copied from Konqueror's KonqDraggableLabel class in 00085 konq_misc.cc */ 00086 d->m_label->setBackgroundMode(TQt::PaletteButton); 00087 d->m_label->setAlignment((TQApplication::reverseLayout() 00088 ? Qt::AlignRight : Qt::AlignLeft) | 00089 Qt::AlignVCenter | TQt::ShowPrefix ); 00090 d->m_label->adjustSize(); 00091 } 00092 00093 void TDEToolBarLabelAction::setText(const TQString& text) 00094 { 00095 KWidgetAction::setText(text); 00096 d->m_label->setText(text); 00097 } 00098 00099 void TDEToolBarLabelAction::setBuddy(TQWidget* buddy) 00100 { 00101 d->m_label->setBuddy(buddy); 00102 } 00103 00104 TQWidget* TDEToolBarLabelAction::buddy() const 00105 { 00106 return d->m_label->buddy(); 00107 } 00108 00109 TQLabel* TDEToolBarLabelAction::label() const 00110 { 00111 return d->m_label; 00112 } 00113 00114 void TDEToolBarLabelAction::virtual_hook(int, void*) 00115 { 00116 00117 }