• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • actions
ktoolbarspaceraction.cpp
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 Copyright (C) 2006 Hamish Rodda <rodda@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
7
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
12
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
17*/
18
19#include "ktoolbarspaceraction.h"
20
21#include <QToolBar>
22
23class KToolBarSpacerAction::Private
24{
25 public:
26 Private()
27 : width( 0 ),
28 minimumWidth( -1 ),
29 maximumWidth( -1 )
30 {
31 }
32
33 void _k_spacerDestroyed( QObject* spacer )
34 {
35 spacers.removeAll( static_cast<QWidget*>( spacer ) );
36 }
37
38 int width, minimumWidth, maximumWidth;
39 QList<QWidget*> spacers;
40};
41
42KToolBarSpacerAction::KToolBarSpacerAction(QObject *parent)
43 : KAction(parent),
44 d( new Private )
45{
46}
47
48KToolBarSpacerAction::~KToolBarSpacerAction()
49{
50 delete d;
51}
52
53int KToolBarSpacerAction::width() const
54{
55 return d->width;
56}
57
58void KToolBarSpacerAction::setWidth( int width )
59{
60 if ( d->width == width )
61 return;
62
63 d->width = width;
64
65 foreach ( QWidget* spacer, d->spacers )
66 spacer->resize( width, spacer->height() );
67}
68
69int KToolBarSpacerAction::minimumWidth() const
70{
71 return d->minimumWidth;
72}
73
74void KToolBarSpacerAction::setMinimumWidth( int width )
75{
76 if ( d->minimumWidth == width )
77 return;
78
79 d->minimumWidth = width;
80
81 foreach ( QWidget* spacer, d->spacers )
82 spacer->setMinimumWidth( width );
83}
84
85int KToolBarSpacerAction::maximumWidth( ) const
86{
87 return d->maximumWidth;
88}
89
90void KToolBarSpacerAction::setMaximumWidth( int width )
91{
92 if ( d->maximumWidth == width )
93 return;
94
95 d->maximumWidth = width;
96
97 foreach ( QWidget* spacer, d->spacers )
98 spacer->setMaximumWidth( width );
99}
100
101QWidget * KToolBarSpacerAction::createWidget( QWidget * _parent )
102{
103 QToolBar *parent = qobject_cast<QToolBar *>(_parent);
104 if (!_parent)
105 return KAction::createWidget(_parent);
106 QWidget* spacer = new QWidget( parent );
107 spacer->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
108
109 d->spacers.append( spacer );
110 connect( spacer, SIGNAL(destroyed(QObject*)),
111 SLOT(_k_spacerDestroyed(QObject*)) );
112
113 return spacer;
114}
115
116void KToolBarSpacerAction::deleteWidget(QWidget *widget)
117{
118 d->spacers.removeAll(widget);
119 KAction::deleteWidget(widget);
120}
121
122#include "ktoolbarspaceraction.moc"
KAction
Class to encapsulate user-driven action or event.
Definition: kaction.h:217
KToolBarSpacerAction::maximumWidth
int maximumWidth
Definition: ktoolbarspaceraction.h:37
KToolBarSpacerAction::createWidget
virtual QWidget * createWidget(QWidget *parent)
Reimplemented from.
Definition: ktoolbarspaceraction.cpp:101
KToolBarSpacerAction::setMinimumWidth
void setMinimumWidth(int width)
Sets the minimum.
Definition: ktoolbarspaceraction.cpp:74
KToolBarSpacerAction::deleteWidget
virtual void deleteWidget(QWidget *widget)
Reimplemented from.
Definition: ktoolbarspaceraction.cpp:116
KToolBarSpacerAction::width
int width
Definition: ktoolbarspaceraction.h:35
KToolBarSpacerAction::~KToolBarSpacerAction
~KToolBarSpacerAction()
Definition: ktoolbarspaceraction.cpp:48
KToolBarSpacerAction::minimumWidth
int minimumWidth
Definition: ktoolbarspaceraction.h:36
KToolBarSpacerAction::KToolBarSpacerAction
KToolBarSpacerAction(QObject *parent)
Creates a new toolbar spacer action.
Definition: ktoolbarspaceraction.cpp:42
KToolBarSpacerAction::setWidth
void setWidth(int width)
Sets the.
Definition: ktoolbarspaceraction.cpp:58
KToolBarSpacerAction::setMaximumWidth
void setMaximumWidth(int width)
Sets the maximum.
Definition: ktoolbarspaceraction.cpp:90
QList
QObject
QToolBar
QWidget
ktoolbarspaceraction.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal