-rw-r--r-- | microkde/kdeui/ktoolbar.cpp | 185 |
1 files changed, 98 insertions, 87 deletions
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp index 027e5e9..02db316 100644 --- a/microkde/kdeui/ktoolbar.cpp +++ b/microkde/kdeui/ktoolbar.cpp | |||
@@ -12,241 +12,252 @@ | |||
12 | modify it under the terms of the GNU Library General Public | 12 | modify it under the terms of the GNU Library General Public |
13 | License version 2 as published by the Free Software Foundation. | 13 | License version 2 as published by the Free Software Foundation. |
14 | 14 | ||
15 | This library is distributed in the hope that it will be useful, | 15 | This library is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | Library General Public License for more details. | 18 | Library General Public License for more details. |
19 | 19 | ||
20 | You should have received a copy of the GNU Library General Public License | 20 | You should have received a copy of the GNU Library General Public License |
21 | along with this library; see the file COPYING.LIB. If not, write to | 21 | along with this library; see the file COPYING.LIB. If not, write to |
22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
23 | Boston, MA 02111-1307, USA. | 23 | Boston, MA 02111-1307, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #ifdef KDE_USE_FINAL | 26 | #ifdef KDE_USE_FINAL |
27 | #undef Always | 27 | #undef Always |
28 | #include <qdockwindow.h> | 28 | #include <q3dockwindow.h> |
29 | #endif | 29 | #endif |
30 | 30 | //Added by qt3to4: | |
31 | #include <Q3ValueList> | ||
32 | #include <Q3PtrList> | ||
33 | #include <QPixmap> | ||
34 | #include <Q3Frame> | ||
35 | #include <QResizeEvent> | ||
36 | #include <QMouseEvent> | ||
37 | #include <QChildEvent> | ||
38 | #include <QEvent> | ||
39 | #include <QShowEvent> | ||
40 | #include <QDesktopWidget> | ||
41 | #include <QBoxLayout> | ||
31 | 42 | ||
32 | 43 | ||
33 | #include "ktoolbar.h" | 44 | #include "ktoolbar.h" |
34 | #include "kmainwindow.h" | 45 | #include "kmainwindow.h" |
35 | 46 | ||
36 | #include <string.h> | 47 | #include <string.h> |
37 | 48 | ||
38 | #include <qpainter.h> | 49 | #include <qpainter.h> |
39 | #include <qtooltip.h> | 50 | #include <qtooltip.h> |
40 | #include <qdrawutil.h> | 51 | #include <qdrawutil.h> |
41 | #include <qstring.h> | 52 | #include <qstring.h> |
42 | #include <qrect.h> | 53 | #include <qrect.h> |
43 | #include <qobjectlist.h> | 54 | #include <qobject.h> |
44 | #include <qtimer.h> | 55 | #include <qtimer.h> |
45 | #include <qstyle.h> | 56 | #include <qstyle.h> |
46 | #include <qapplication.h> | 57 | #include <qapplication.h> |
47 | 58 | ||
48 | //US #include <config.h> | 59 | //US #include <config.h> |
49 | 60 | ||
50 | #include "klineedit.h" | 61 | #include "klineedit.h" |
51 | #include "kseparator.h" | 62 | #include "kseparator.h" |
52 | #include <klocale.h> | 63 | #include <klocale.h> |
53 | #include <kapplication.h> | 64 | #include <kapplication.h> |
54 | #include <kaction.h> | 65 | #include <kaction.h> |
55 | #include <kstdaction.h> | 66 | #include <kstdaction.h> |
56 | #include <kglobal.h> | 67 | #include <kglobal.h> |
57 | #include <kconfig.h> | 68 | #include <kconfig.h> |
58 | #include <kiconloader.h> | 69 | #include <kiconloader.h> |
59 | #include <kcombobox.h> | 70 | #include <kcombobox.h> |
60 | //US #include <kpopupmenu.h> | 71 | //US #include <kpopupmenu.h> |
61 | //US #include <kanimwidget.h> | 72 | //US #include <kanimwidget.h> |
62 | //US #include <kipc.h> | 73 | //US #include <kipc.h> |
63 | //US #include <kwin.h> | 74 | //US #include <kwin.h> |
64 | #include <kdebug.h> | 75 | #include <kdebug.h> |
65 | #include <qlayout.h> | 76 | #include <qlayout.h> |
66 | 77 | ||
67 | #include "ktoolbarbutton.h" | 78 | #include "ktoolbarbutton.h" |
68 | 79 | ||
69 | //US | 80 | //US |
70 | #include "kconfigbase.h" | 81 | #include "kconfigbase.h" |
71 | 82 | ||
72 | #include <qpopupmenu.h> | 83 | #include <q3popupmenu.h> |
73 | #include <qmainwindow.h> | 84 | #include <q3mainwindow.h> |
74 | 85 | ||
75 | enum { | 86 | enum { |
76 | CONTEXT_TOP = 0, | 87 | CONTEXT_TOP = 0, |
77 | CONTEXT_LEFT = 1, | 88 | CONTEXT_LEFT = 1, |
78 | CONTEXT_RIGHT = 2, | 89 | CONTEXT_RIGHT = 2, |
79 | CONTEXT_BOTTOM = 3, | 90 | CONTEXT_BOTTOM = 3, |
80 | CONTEXT_FLOAT = 4, | 91 | CONTEXT_FLOAT = 4, |
81 | CONTEXT_FLAT = 5, | 92 | CONTEXT_FLAT = 5, |
82 | CONTEXT_ICONS = 6, | 93 | CONTEXT_ICONS = 6, |
83 | CONTEXT_TEXT = 7, | 94 | CONTEXT_TEXT = 7, |
84 | CONTEXT_TEXTRIGHT = 8, | 95 | CONTEXT_TEXTRIGHT = 8, |
85 | CONTEXT_TEXTUNDER = 9, | 96 | CONTEXT_TEXTUNDER = 9, |
86 | CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before | 97 | CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before |
87 | }; | 98 | }; |
88 | 99 | ||
89 | class KToolBarPrivate | 100 | class KToolBarPrivate |
90 | { | 101 | { |
91 | public: | 102 | public: |
92 | KToolBarPrivate() { | 103 | KToolBarPrivate() { |
93 | m_iconSize = 0; | 104 | m_iconSize = 0; |
94 | m_iconText = KToolBar::IconOnly; | 105 | m_iconText = KToolBar::IconOnly; |
95 | m_highlight = true; | 106 | m_highlight = true; |
96 | m_transparent = true; | 107 | m_transparent = true; |
97 | m_honorStyle = false; | 108 | m_honorStyle = false; |
98 | 109 | ||
99 | m_enableContext = true; | 110 | m_enableContext = true; |
100 | 111 | ||
101 | m_xmlguiClient = 0; | 112 | m_xmlguiClient = 0; |
102 | m_configurePlugged = false; | 113 | m_configurePlugged = false; |
103 | 114 | ||
104 | //US oldPos = Qt::DockUnmanaged; | 115 | //US oldPos = Qt::DockUnmanaged; |
105 | oldPos = QMainWindow::Unmanaged; | 116 | oldPos = Qt::Unmanaged; |
106 | 117 | ||
107 | modified = m_isHorizontal = positioned = FALSE; | 118 | modified = m_isHorizontal = positioned = FALSE; |
108 | 119 | ||
109 | HiddenDefault = false; | 120 | HiddenDefault = false; |
110 | IconSizeDefault = 0; | 121 | IconSizeDefault = 0; |
111 | IconTextDefault = "IconOnly"; | 122 | IconTextDefault = "IconOnly"; |
112 | IndexDefault = -1; | 123 | IndexDefault = -1; |
113 | NewLineDefault = false; | 124 | NewLineDefault = false; |
114 | OffsetDefault = -1; | 125 | OffsetDefault = -1; |
115 | PositionDefault = "Top"; | 126 | PositionDefault = "Top"; |
116 | idleButtons.setAutoDelete(true); | 127 | idleButtons.setAutoDelete(true); |
117 | } | 128 | } |
118 | 129 | ||
119 | int m_iconSize; | 130 | int m_iconSize; |
120 | KToolBar::IconText m_iconText; | 131 | KToolBar::IconText m_iconText; |
121 | bool m_highlight : 1; | 132 | bool m_highlight : 1; |
122 | bool m_transparent : 1; | 133 | bool m_transparent : 1; |
123 | bool m_honorStyle : 1; | 134 | bool m_honorStyle : 1; |
124 | bool m_isHorizontal : 1; | 135 | bool m_isHorizontal : 1; |
125 | bool m_enableContext : 1; | 136 | bool m_enableContext : 1; |
126 | bool m_configurePlugged : 1; | 137 | bool m_configurePlugged : 1; |
127 | bool modified : 1; | 138 | bool modified : 1; |
128 | bool positioned : 1; | 139 | bool positioned : 1; |
129 | 140 | ||
130 | QWidget *m_parent; | 141 | QWidget *m_parent; |
131 | 142 | ||
132 | QMainWindow::ToolBarDock oldPos; | 143 | Qt::ToolBarDock oldPos; |
133 | 144 | ||
134 | KXMLGUIClient *m_xmlguiClient; | 145 | KXMLGUIClient *m_xmlguiClient; |
135 | 146 | ||
136 | struct ToolBarInfo | 147 | struct ToolBarInfo |
137 | { | 148 | { |
138 | //US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} | 149 | //US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} |
139 | ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {} | 150 | ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} |
140 | //US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} | 151 | //US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} |
141 | ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} | 152 | ToolBarInfo( Qt::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} |
142 | int index, offset; | 153 | int index, offset; |
143 | bool newline; | 154 | bool newline; |
144 | //US Qt::Dock dock; | 155 | //US Qt::Dock dock; |
145 | QMainWindow::ToolBarDock dock; | 156 | Qt::ToolBarDock dock; |
146 | }; | 157 | }; |
147 | 158 | ||
148 | ToolBarInfo toolBarInfo; | 159 | ToolBarInfo toolBarInfo; |
149 | QValueList<int> iconSizes; | 160 | Q3ValueList<int> iconSizes; |
150 | QTimer repaintTimer; | 161 | QTimer repaintTimer; |
151 | 162 | ||
152 | // Default Values. | 163 | // Default Values. |
153 | bool HiddenDefault; | 164 | bool HiddenDefault; |
154 | int IconSizeDefault; | 165 | int IconSizeDefault; |
155 | QString IconTextDefault; | 166 | QString IconTextDefault; |
156 | int IndexDefault; | 167 | int IndexDefault; |
157 | bool NewLineDefault; | 168 | bool NewLineDefault; |
158 | int OffsetDefault; | 169 | int OffsetDefault; |
159 | QString PositionDefault; | 170 | QString PositionDefault; |
160 | 171 | ||
161 | QPtrList<QWidget> idleButtons; | 172 | Q3PtrList<QWidget> idleButtons; |
162 | }; | 173 | }; |
163 | 174 | ||
164 | KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, | 175 | KToolBarSeparator::KToolBarSeparator(Qt::Orientation o , bool l, Q3ToolBar *parent, |
165 | const char* name ) | 176 | const char* name ) |
166 | :QFrame( parent, name ), line( l ) | 177 | :Q3Frame( parent, name ), line( l ) |
167 | { | 178 | { |
168 | connect( parent, SIGNAL(orientationChanged(Orientation)), | 179 | connect( parent, SIGNAL(orientationChanged(Qt::Orientation)), |
169 | this, SLOT(setOrientation(Orientation)) ); | 180 | this, SLOT(setOrientation(Qt::Orientation)) ); |
170 | setOrientation( o ); | 181 | setOrientation( o ); |
171 | setBackgroundMode( parent->backgroundMode() ); | 182 | setBackgroundMode( parent->backgroundMode() ); |
172 | setBackgroundOrigin( ParentOrigin ); | 183 | setBackgroundOrigin( ParentOrigin ); |
173 | } | 184 | } |
174 | 185 | ||
175 | void KToolBarSeparator::setOrientation( Orientation o ) | 186 | void KToolBarSeparator::setOrientation( Qt::Orientation o ) |
176 | { | 187 | { |
177 | orient = o; | 188 | orient = o; |
178 | if ( line ) { | 189 | if ( line ) { |
179 | if ( orientation() == Vertical ) | 190 | if ( orientation() == Qt::Vertical ) |
180 | setFrameStyle( HLine + Sunken ); | 191 | setFrameStyle( HLine + Sunken ); |
181 | else | 192 | else |
182 | setFrameStyle( VLine + Sunken ); | 193 | setFrameStyle( VLine + Sunken ); |
183 | } else { | 194 | } else { |
184 | setFrameStyle( NoFrame ); | 195 | setFrameStyle( NoFrame ); |
185 | } | 196 | } |
186 | } | 197 | } |
187 | 198 | ||
188 | void KToolBarSeparator::styleChange( QStyle& ) | 199 | void KToolBarSeparator::styleChange( QStyle& ) |
189 | { | 200 | { |
190 | setOrientation( orient ); | 201 | setOrientation( orient ); |
191 | } | 202 | } |
192 | 203 | ||
193 | QSize KToolBarSeparator::sizeHint() const | 204 | QSize KToolBarSeparator::sizeHint() const |
194 | { | 205 | { |
195 | return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); | 206 | return orientation() == Qt::Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); |
196 | } | 207 | } |
197 | 208 | ||
198 | QSizePolicy KToolBarSeparator::sizePolicy() const | 209 | QSizePolicy KToolBarSeparator::sizePolicy() const |
199 | { | 210 | { |
200 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); | 211 | return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); |
201 | } | 212 | } |
202 | 213 | ||
203 | KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) | 214 | KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) |
204 | #ifdef DESKTOP_VERSION | 215 | #ifdef DESKTOP_VERSION |
205 | : QToolBar( QString::fromLatin1( name ), | 216 | : Q3ToolBar( QString::fromLatin1( name ), |
206 | parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, | 217 | parent && parent->inherits( "Q3MainWindow" ) ? static_cast<Q3MainWindow*>(parent) : 0, |
207 | parent, FALSE, | 218 | parent, FALSE, |
208 | name ? name : "mainToolBar") | 219 | name ? name : "mainToolBar") |
209 | #else | 220 | #else |
210 | : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, | 221 | : QPEToolBar( parent && parent->inherits( "Q3MainWindow" ) ? static_cast<Q3MainWindow*>(parent) : 0, |
211 | QString::fromLatin1( name )) | 222 | QString::fromLatin1( name )) |
212 | 223 | ||
213 | 224 | ||
214 | #endif | 225 | #endif |
215 | { | 226 | { |
216 | init( readConfig, honorStyle ); | 227 | init( readConfig, honorStyle ); |
217 | } | 228 | } |
218 | 229 | ||
219 | KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) | 230 | KToolBar::KToolBar( Q3MainWindow *parentWindow, Qt::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) |
220 | #ifdef DESKTOP_VERSION | 231 | #ifdef DESKTOP_VERSION |
221 | : QToolBar( QString::fromLatin1( name ), | 232 | : Q3ToolBar( QString::fromLatin1( name ), |
222 | parentWindow, dock, newLine, | 233 | parentWindow, dock, newLine, |
223 | name ? name : "mainToolBar") | 234 | name ? name : "mainToolBar") |
224 | #else | 235 | #else |
225 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) | 236 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) |
226 | 237 | ||
227 | 238 | ||
228 | #endif | 239 | #endif |
229 | 240 | ||
230 | { | 241 | { |
231 | init( readConfig, honorStyle ); | 242 | init( readConfig, honorStyle ); |
232 | } | 243 | } |
233 | 244 | ||
234 | KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) | 245 | KToolBar::KToolBar( Q3MainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) |
235 | #ifdef DESKTOP_VERSION | 246 | #ifdef DESKTOP_VERSION |
236 | : QToolBar( QString::fromLatin1( name ), | 247 | : Q3ToolBar( QString::fromLatin1( name ), |
237 | parentWindow, dock, newLine, | 248 | parentWindow, dock, newLine, |
238 | name ? name : "mainToolBar") | 249 | name ? name : "mainToolBar") |
239 | #else | 250 | #else |
240 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) | 251 | : QPEToolBar( parentWindow,QString::fromLatin1( name )) |
241 | 252 | ||
242 | 253 | ||
243 | #endif | 254 | #endif |
244 | 255 | ||
245 | { | 256 | { |
246 | init( readConfig, honorStyle ); | 257 | init( readConfig, honorStyle ); |
247 | } | 258 | } |
248 | 259 | ||
249 | KToolBar::~KToolBar() | 260 | KToolBar::~KToolBar() |
250 | { | 261 | { |
251 | inshutdownprocess = true; | 262 | inshutdownprocess = true; |
252 | emit toolbarDestroyed(); | 263 | emit toolbarDestroyed(); |
@@ -267,34 +278,34 @@ void KToolBar::init( bool readConfig, bool honorStyle ) | |||
267 | this, SLOT( rebuildLayout() ) ); | 278 | this, SLOT( rebuildLayout() ) ); |
268 | connect( &(d->repaintTimer), SIGNAL( timeout() ), | 279 | connect( &(d->repaintTimer), SIGNAL( timeout() ), |
269 | this, SLOT( slotRepaint() ) ); | 280 | this, SLOT( slotRepaint() ) ); |
270 | /*US | 281 | /*US |
271 | if ( kapp ) { // may be null when started inside designer | 282 | if ( kapp ) { // may be null when started inside designer |
272 | connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); | 283 | connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); |
273 | // request notification of changes in icon style | 284 | // request notification of changes in icon style |
274 | kapp->addKipcEventMask(KIPC::IconChanged); | 285 | kapp->addKipcEventMask(KIPC::IconChanged); |
275 | connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); | 286 | connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); |
276 | } | 287 | } |
277 | */ | 288 | */ |
278 | // finally, read in our configurable settings | 289 | // finally, read in our configurable settings |
279 | if ( readConfig ) | 290 | if ( readConfig ) |
280 | slotReadConfig(); | 291 | slotReadConfig(); |
281 | 292 | ||
282 | if ( mainWindow() ) | 293 | if ( mainWindow() ) |
283 | connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), | 294 | connect( mainWindow(), SIGNAL( toolBarPositionChanged( Q3ToolBar * ) ), |
284 | this, SLOT( toolBarPosChanged( QToolBar * ) ) ); | 295 | this, SLOT( toolBarPosChanged( Q3ToolBar * ) ) ); |
285 | 296 | ||
286 | // Hack to make sure we recalculate our size when we dock. | 297 | // Hack to make sure we recalculate our size when we dock. |
287 | //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); | 298 | //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); |
288 | } | 299 | } |
289 | 300 | ||
290 | int KToolBar::insertButton(const QString& icon, int id, bool enabled, | 301 | int KToolBar::insertButton(const QString& icon, int id, bool enabled, |
291 | const QString& text, int index/*US, KInstance *_instance*/ ) | 302 | const QString& text, int index/*US, KInstance *_instance*/ ) |
292 | { | 303 | { |
293 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); | 304 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); |
294 | 305 | ||
295 | insertWidgetInternal( button, index, id ); | 306 | insertWidgetInternal( button, index, id ); |
296 | button->setEnabled( enabled ); | 307 | button->setEnabled( enabled ); |
297 | doConnections( button ); | 308 | doConnections( button ); |
298 | return index; | 309 | return index; |
299 | } | 310 | } |
300 | 311 | ||
@@ -328,45 +339,45 @@ int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, | |||
328 | #endif | 339 | #endif |
329 | 340 | ||
330 | int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, | 341 | int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, |
331 | const QObject *receiver, const char *slot, | 342 | const QObject *receiver, const char *slot, |
332 | bool enabled, const QString& text, | 343 | bool enabled, const QString& text, |
333 | int index ) | 344 | int index ) |
334 | { | 345 | { |
335 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); | 346 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); |
336 | insertWidgetInternal( button, index, id ); | 347 | insertWidgetInternal( button, index, id ); |
337 | button->setEnabled( enabled ); | 348 | button->setEnabled( enabled ); |
338 | connect( button, signal, receiver, slot ); | 349 | connect( button, signal, receiver, slot ); |
339 | doConnections( button ); | 350 | doConnections( button ); |
340 | return index; | 351 | return index; |
341 | } | 352 | } |
342 | 353 | ||
343 | 354 | ||
344 | int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, | 355 | int KToolBar::insertButton(const QString& icon, int id, Q3PopupMenu *popup, |
345 | bool enabled, const QString &text, int index ) | 356 | bool enabled, const QString &text, int index ) |
346 | { | 357 | { |
347 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); | 358 | KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); |
348 | insertWidgetInternal( button, index, id ); | 359 | insertWidgetInternal( button, index, id ); |
349 | button->setEnabled( enabled ); | 360 | button->setEnabled( enabled ); |
350 | button->setPopup( popup ); | 361 | button->setPopup( popup ); |
351 | doConnections( button ); | 362 | doConnections( button ); |
352 | return index; | 363 | return index; |
353 | } | 364 | } |
354 | 365 | ||
355 | 366 | ||
356 | int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, | 367 | int KToolBar::insertButton(const QPixmap& pixmap, int id, Q3PopupMenu *popup, |
357 | bool enabled, const QString &text, int index ) | 368 | bool enabled, const QString &text, int index ) |
358 | { | 369 | { |
359 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); | 370 | KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); |
360 | insertWidgetInternal( button, index, id ); | 371 | insertWidgetInternal( button, index, id ); |
361 | button->setEnabled( enabled ); | 372 | button->setEnabled( enabled ); |
362 | button->setPopup( popup ); | 373 | button->setPopup( popup ); |
363 | doConnections( button ); | 374 | doConnections( button ); |
364 | return index; | 375 | return index; |
365 | } | 376 | } |
366 | 377 | ||
367 | 378 | ||
368 | int KToolBar::insertLined (const QString& text, int id, | 379 | int KToolBar::insertLined (const QString& text, int id, |
369 | const char *signal, | 380 | const char *signal, |
370 | const QObject *receiver, const char *slot, | 381 | const QObject *receiver, const char *slot, |
371 | bool enabled , | 382 | bool enabled , |
372 | const QString& toolTipText, | 383 | const QString& toolTipText, |
@@ -527,45 +538,45 @@ void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) | |||
527 | if ( button ) | 538 | if ( button ) |
528 | button->setPixmap( _pixmap ); | 539 | button->setPixmap( _pixmap ); |
529 | } | 540 | } |
530 | 541 | ||
531 | 542 | ||
532 | void KToolBar::setButtonIcon( int id, const QString& _icon ) | 543 | void KToolBar::setButtonIcon( int id, const QString& _icon ) |
533 | { | 544 | { |
534 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 545 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
535 | if ( it == id2widget.end() ) | 546 | if ( it == id2widget.end() ) |
536 | return; | 547 | return; |
537 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 548 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
538 | KToolBarButton * button = (KToolBarButton *)( *it ); | 549 | KToolBarButton * button = (KToolBarButton *)( *it ); |
539 | if ( button ) | 550 | if ( button ) |
540 | button->setIcon( _icon ); | 551 | button->setIcon( _icon ); |
541 | } | 552 | } |
542 | 553 | ||
543 | void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) | 554 | void KToolBar::setButtonIconSet( int id, const QIcon& iconset ) |
544 | { | 555 | { |
545 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 556 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
546 | if ( it == id2widget.end() ) | 557 | if ( it == id2widget.end() ) |
547 | return; | 558 | return; |
548 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 559 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
549 | KToolBarButton * button = (KToolBarButton *)( *it ); | 560 | KToolBarButton * button = (KToolBarButton *)( *it ); |
550 | if ( button ) | 561 | if ( button ) |
551 | button->setIconSet( iconset ); | 562 | button->setIconSet( iconset ); |
552 | } | 563 | } |
553 | 564 | ||
554 | 565 | ||
555 | void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) | 566 | void KToolBar::setDelayedPopup (int id , Q3PopupMenu *_popup, bool toggle ) |
556 | { | 567 | { |
557 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 568 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
558 | if ( it == id2widget.end() ) | 569 | if ( it == id2widget.end() ) |
559 | return; | 570 | return; |
560 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 571 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
561 | KToolBarButton * button = (KToolBarButton *)( *it ); | 572 | KToolBarButton * button = (KToolBarButton *)( *it ); |
562 | if ( button ) | 573 | if ( button ) |
563 | button->setDelayedPopup( _popup, toggle ); | 574 | button->setDelayedPopup( _popup, toggle ); |
564 | } | 575 | } |
565 | 576 | ||
566 | 577 | ||
567 | void KToolBar::setAutoRepeat (int id, bool flag) | 578 | void KToolBar::setAutoRepeat (int id, bool flag) |
568 | { | 579 | { |
569 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 580 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
570 | if ( it == id2widget.end() ) | 581 | if ( it == id2widget.end() ) |
571 | return; | 582 | return; |
@@ -774,33 +785,33 @@ QWidget *KToolBar::getWidget (int id) | |||
774 | { | 785 | { |
775 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 786 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
776 | return ( it == id2widget.end() ) ? 0 : (*it); | 787 | return ( it == id2widget.end() ) ? 0 : (*it); |
777 | } | 788 | } |
778 | 789 | ||
779 | 790 | ||
780 | void KToolBar::setItemAutoSized (int id, bool yes ) | 791 | void KToolBar::setItemAutoSized (int id, bool yes ) |
781 | { | 792 | { |
782 | QWidget *w = getWidget(id); | 793 | QWidget *w = getWidget(id); |
783 | if ( w && yes ) | 794 | if ( w && yes ) |
784 | setStretchableWidget( w ); | 795 | setStretchableWidget( w ); |
785 | } | 796 | } |
786 | 797 | ||
787 | 798 | ||
788 | void KToolBar::clear () | 799 | void KToolBar::clear () |
789 | { | 800 | { |
790 | QToolBar::clear(); | 801 | Q3ToolBar::clear(); |
791 | widget2id.clear(); | 802 | widget2id.clear(); |
792 | id2widget.clear(); | 803 | id2widget.clear(); |
793 | } | 804 | } |
794 | 805 | ||
795 | 806 | ||
796 | void KToolBar::removeItem(int id) | 807 | void KToolBar::removeItem(int id) |
797 | { | 808 | { |
798 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 809 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
799 | if ( it == id2widget.end() ) | 810 | if ( it == id2widget.end() ) |
800 | { | 811 | { |
801 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; | 812 | kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; |
802 | return; | 813 | return; |
803 | } | 814 | } |
804 | QWidget * w = (*it); | 815 | QWidget * w = (*it); |
805 | id2widget.remove( id ); | 816 | id2widget.remove( id ); |
806 | widget2id.remove( w ); | 817 | widget2id.remove( w ); |
@@ -863,47 +874,47 @@ bool KToolBar::fullSize() const | |||
863 | return isHorizontalStretchable() || isVerticalStretchable(); | 874 | return isHorizontalStretchable() || isVerticalStretchable(); |
864 | } | 875 | } |
865 | 876 | ||
866 | 877 | ||
867 | void KToolBar::enableMoving(bool flag ) | 878 | void KToolBar::enableMoving(bool flag ) |
868 | { | 879 | { |
869 | //US setMovingEnabled(flag); | 880 | //US setMovingEnabled(flag); |
870 | this->mainWindow()->setToolBarsMovable(flag); | 881 | this->mainWindow()->setToolBarsMovable(flag); |
871 | } | 882 | } |
872 | 883 | ||
873 | 884 | ||
874 | void KToolBar::setBarPos (BarPosition bpos) | 885 | void KToolBar::setBarPos (BarPosition bpos) |
875 | { | 886 | { |
876 | if ( !mainWindow() ) | 887 | if ( !mainWindow() ) |
877 | return; | 888 | return; |
878 | //US mainWindow()->moveDockWindow( this, (Dock)bpos ); | 889 | //US mainWindow()->moveDockWindow( this, (Dock)bpos ); |
879 | mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); | 890 | mainWindow()->moveToolBar( this, (Qt::ToolBarDock)bpos ); |
880 | } | 891 | } |
881 | 892 | ||
882 | 893 | ||
883 | const KToolBar::BarPosition KToolBar::barPos() | 894 | const KToolBar::BarPosition KToolBar::barPos() |
884 | { | 895 | { |
885 | if ( !(QMainWindow*)mainWindow() ) | 896 | if ( !(Q3MainWindow*)mainWindow() ) |
886 | return KToolBar::Top; | 897 | return KToolBar::Top; |
887 | //US Dock dock; | 898 | //US Dock dock; |
888 | QMainWindow::ToolBarDock dock; | 899 | Qt::ToolBarDock dock; |
889 | int dm1, dm2; | 900 | int dm1, dm2; |
890 | bool dm3; | 901 | bool dm3; |
891 | ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); | 902 | ((Q3MainWindow*)mainWindow())->getLocation( (Q3ToolBar*)this, dock, dm1, dm3, dm2 ); |
892 | //US if ( dock == DockUnmanaged ) { | 903 | //US if ( dock == DockUnmanaged ) { |
893 | if ( dock == QMainWindow::Unmanaged ) { | 904 | if ( dock == Qt::Unmanaged ) { |
894 | return (KToolBar::BarPosition)Top; | 905 | return (KToolBar::BarPosition)Top; |
895 | } | 906 | } |
896 | return (BarPosition)dock; | 907 | return (BarPosition)dock; |
897 | } | 908 | } |
898 | 909 | ||
899 | 910 | ||
900 | bool KToolBar::enable(BarStatus stat) | 911 | bool KToolBar::enable(BarStatus stat) |
901 | { | 912 | { |
902 | bool mystat = isVisible(); | 913 | bool mystat = isVisible(); |
903 | 914 | ||
904 | if ( (stat == Toggle && mystat) || stat == Hide ) | 915 | if ( (stat == Toggle && mystat) || stat == Hide ) |
905 | hide(); | 916 | hide(); |
906 | else | 917 | else |
907 | show(); | 918 | show(); |
908 | 919 | ||
909 | return isVisible() == mystat; | 920 | return isVisible() == mystat; |
@@ -954,33 +965,33 @@ void KToolBar::setIconText(IconText icontext, bool update) | |||
954 | { | 965 | { |
955 | bool doUpdate=false; | 966 | bool doUpdate=false; |
956 | 967 | ||
957 | if (icontext != d->m_iconText) { | 968 | if (icontext != d->m_iconText) { |
958 | d->m_iconText = icontext; | 969 | d->m_iconText = icontext; |
959 | doUpdate=true; | 970 | doUpdate=true; |
960 | } | 971 | } |
961 | 972 | ||
962 | if (update == false) | 973 | if (update == false) |
963 | return; | 974 | return; |
964 | 975 | ||
965 | if (doUpdate) | 976 | if (doUpdate) |
966 | emit modechange(); // tell buttons what happened | 977 | emit modechange(); // tell buttons what happened |
967 | 978 | ||
968 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) | 979 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) |
969 | if ( mainWindow() ) { | 980 | if ( mainWindow() ) { |
970 | QMainWindow *mw = mainWindow(); | 981 | Q3MainWindow *mw = mainWindow(); |
971 | mw->setUpdatesEnabled( FALSE ); | 982 | mw->setUpdatesEnabled( FALSE ); |
972 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 983 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
973 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 984 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
974 | mw->setUpdatesEnabled( TRUE ); | 985 | mw->setUpdatesEnabled( TRUE ); |
975 | } | 986 | } |
976 | } | 987 | } |
977 | 988 | ||
978 | 989 | ||
979 | KToolBar::IconText KToolBar::iconText() const | 990 | KToolBar::IconText KToolBar::iconText() const |
980 | { | 991 | { |
981 | return d->m_iconText; | 992 | return d->m_iconText; |
982 | } | 993 | } |
983 | 994 | ||
984 | 995 | ||
985 | void KToolBar::setIconSize(int size) | 996 | void KToolBar::setIconSize(int size) |
986 | { | 997 | { |
@@ -991,33 +1002,33 @@ void KToolBar::setIconSize(int size, bool update) | |||
991 | { | 1002 | { |
992 | bool doUpdate=false; | 1003 | bool doUpdate=false; |
993 | 1004 | ||
994 | if ( size != d->m_iconSize ) { | 1005 | if ( size != d->m_iconSize ) { |
995 | d->m_iconSize = size; | 1006 | d->m_iconSize = size; |
996 | doUpdate=true; | 1007 | doUpdate=true; |
997 | } | 1008 | } |
998 | 1009 | ||
999 | if (update == false) | 1010 | if (update == false) |
1000 | return; | 1011 | return; |
1001 | 1012 | ||
1002 | if (doUpdate) | 1013 | if (doUpdate) |
1003 | emit modechange(); // tell buttons what happened | 1014 | emit modechange(); // tell buttons what happened |
1004 | 1015 | ||
1005 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) | 1016 | // ugly hack to force a QMainWindow::triggerLayout( TRUE ) |
1006 | if ( mainWindow() ) { | 1017 | if ( mainWindow() ) { |
1007 | QMainWindow *mw = mainWindow(); | 1018 | Q3MainWindow *mw = mainWindow(); |
1008 | mw->setUpdatesEnabled( FALSE ); | 1019 | mw->setUpdatesEnabled( FALSE ); |
1009 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 1020 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
1010 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); | 1021 | mw->setToolBarsMovable( !mw->toolBarsMovable() ); |
1011 | mw->setUpdatesEnabled( TRUE ); | 1022 | mw->setUpdatesEnabled( TRUE ); |
1012 | } | 1023 | } |
1013 | } | 1024 | } |
1014 | 1025 | ||
1015 | 1026 | ||
1016 | int KToolBar::iconSize() const | 1027 | int KToolBar::iconSize() const |
1017 | { | 1028 | { |
1018 | /*US | 1029 | /*US |
1019 | if ( !d->m_iconSize ) // default value? | 1030 | if ( !d->m_iconSize ) // default value? |
1020 | { | 1031 | { |
1021 | if (!::qstrcmp(QObject::name(), "mainToolBar")) | 1032 | if (!::qstrcmp(QObject::name(), "mainToolBar")) |
1022 | return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); | 1033 | return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); |
1023 | else | 1034 | else |
@@ -1049,36 +1060,36 @@ void KToolBar::setItemNoStyle(int id, bool no_style ) | |||
1049 | Id2WidgetMap::Iterator it = id2widget.find( id ); | 1060 | Id2WidgetMap::Iterator it = id2widget.find( id ); |
1050 | if ( it == id2widget.end() ) | 1061 | if ( it == id2widget.end() ) |
1051 | return; | 1062 | return; |
1052 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); | 1063 | //US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); |
1053 | KToolBarButton * button = (KToolBarButton *)( *it ); | 1064 | KToolBarButton * button = (KToolBarButton *)( *it ); |
1054 | if (button) | 1065 | if (button) |
1055 | button->setNoStyle( no_style ); | 1066 | button->setNoStyle( no_style ); |
1056 | } | 1067 | } |
1057 | 1068 | ||
1058 | 1069 | ||
1059 | void KToolBar::setFlat (bool flag) | 1070 | void KToolBar::setFlat (bool flag) |
1060 | { | 1071 | { |
1061 | if ( !mainWindow() ) | 1072 | if ( !mainWindow() ) |
1062 | return; | 1073 | return; |
1063 | if ( flag ) | 1074 | if ( flag ) |
1064 | //US mainWindow()->moveDockWindow( this, DockMinimized ); | 1075 | //US mainWindow()->moveDockWindow( this, DockMinimized ); |
1065 | mainWindow()->moveToolBar( this, QMainWindow::Minimized ); | 1076 | mainWindow()->moveToolBar( this, Qt::Minimized ); |
1066 | else | 1077 | else |
1067 | //US mainWindow()->moveDockWindow( this, DockTop ); | 1078 | //US mainWindow()->moveDockWindow( this, DockTop ); |
1068 | mainWindow()->moveToolBar( this, QMainWindow::Top ); | 1079 | mainWindow()->moveToolBar( this, Qt::Top ); |
1069 | // And remember to save the new look later | 1080 | // And remember to save the new look later |
1070 | /*US | 1081 | /*US |
1071 | if ( mainWindow()->inherits( "KMainWindow" ) ) | 1082 | if ( mainWindow()->inherits( "KMainWindow" ) ) |
1072 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1083 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1073 | */ | 1084 | */ |
1074 | } | 1085 | } |
1075 | 1086 | ||
1076 | 1087 | ||
1077 | int KToolBar::count() const | 1088 | int KToolBar::count() const |
1078 | { | 1089 | { |
1079 | return id2widget.count(); | 1090 | return id2widget.count(); |
1080 | } | 1091 | } |
1081 | 1092 | ||
1082 | 1093 | ||
1083 | void KToolBar::saveState() | 1094 | void KToolBar::saveState() |
1084 | { | 1095 | { |
@@ -1236,60 +1247,60 @@ QString KToolBar::text() const | |||
1236 | 1247 | ||
1237 | 1248 | ||
1238 | void KToolBar::doConnections( KToolBarButton *button ) | 1249 | void KToolBar::doConnections( KToolBarButton *button ) |
1239 | { | 1250 | { |
1240 | connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); | 1251 | connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); |
1241 | connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); | 1252 | connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); |
1242 | connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); | 1253 | connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); |
1243 | connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); | 1254 | connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); |
1244 | connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); | 1255 | connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); |
1245 | connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); | 1256 | connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); |
1246 | } | 1257 | } |
1247 | 1258 | ||
1248 | void KToolBar::mousePressEvent ( QMouseEvent *m ) | 1259 | void KToolBar::mousePressEvent ( QMouseEvent *m ) |
1249 | { | 1260 | { |
1250 | if ( !mainWindow() ) | 1261 | if ( !mainWindow() ) |
1251 | return; | 1262 | return; |
1252 | QMainWindow *mw = mainWindow(); | 1263 | Q3MainWindow *mw = mainWindow(); |
1253 | if ( mw->toolBarsMovable() && d->m_enableContext ) { | 1264 | if ( mw->toolBarsMovable() && d->m_enableContext ) { |
1254 | if ( m->button() == RightButton ) { | 1265 | if ( m->button() == Qt::RightButton ) { |
1255 | int i = contextMenu()->exec( m->globalPos(), 0 ); | 1266 | int i = contextMenu()->exec( m->globalPos(), 0 ); |
1256 | switch ( i ) { | 1267 | switch ( i ) { |
1257 | case -1: | 1268 | case -1: |
1258 | return; // popup cancelled | 1269 | return; // popup cancelled |
1259 | case CONTEXT_LEFT: | 1270 | case CONTEXT_LEFT: |
1260 | //US mw->moveDockWindow( this, DockLeft ); | 1271 | //US mw->moveDockWindow( this, DockLeft ); |
1261 | mw->moveToolBar( this, QMainWindow::Left ); | 1272 | mw->moveToolBar( this, Qt::Left ); |
1262 | break; | 1273 | break; |
1263 | case CONTEXT_RIGHT: | 1274 | case CONTEXT_RIGHT: |
1264 | //US mw->moveDockWindow( this, DockRight ); | 1275 | //US mw->moveDockWindow( this, DockRight ); |
1265 | mw->moveToolBar( this, QMainWindow::Right ); | 1276 | mw->moveToolBar( this, Qt::Right ); |
1266 | break; | 1277 | break; |
1267 | case CONTEXT_TOP: | 1278 | case CONTEXT_TOP: |
1268 | //US mw->moveDockWindow( this, DockTop ); | 1279 | //US mw->moveDockWindow( this, DockTop ); |
1269 | mw->moveToolBar( this, QMainWindow::Top ); | 1280 | mw->moveToolBar( this, Qt::Top ); |
1270 | break; | 1281 | break; |
1271 | case CONTEXT_BOTTOM: | 1282 | case CONTEXT_BOTTOM: |
1272 | //US mw->moveDockWindow( this, DockBottom ); | 1283 | //US mw->moveDockWindow( this, DockBottom ); |
1273 | mw->moveToolBar( this, QMainWindow::Bottom ); | 1284 | mw->moveToolBar( this, Qt::Bottom ); |
1274 | break; | 1285 | break; |
1275 | case CONTEXT_FLOAT: | 1286 | case CONTEXT_FLOAT: |
1276 | break; | 1287 | break; |
1277 | case CONTEXT_FLAT: | 1288 | case CONTEXT_FLAT: |
1278 | //US mw->moveDockWindow( this, DockMinimized ); | 1289 | //US mw->moveDockWindow( this, DockMinimized ); |
1279 | mw->moveToolBar( this, QMainWindow::Minimized ); | 1290 | mw->moveToolBar( this, Qt::Minimized ); |
1280 | break; | 1291 | break; |
1281 | case CONTEXT_ICONS: | 1292 | case CONTEXT_ICONS: |
1282 | setIconText( IconOnly ); | 1293 | setIconText( IconOnly ); |
1283 | break; | 1294 | break; |
1284 | case CONTEXT_TEXTRIGHT: | 1295 | case CONTEXT_TEXTRIGHT: |
1285 | setIconText( IconTextRight ); | 1296 | setIconText( IconTextRight ); |
1286 | break; | 1297 | break; |
1287 | case CONTEXT_TEXT: | 1298 | case CONTEXT_TEXT: |
1288 | setIconText( TextOnly ); | 1299 | setIconText( TextOnly ); |
1289 | break; | 1300 | break; |
1290 | case CONTEXT_TEXTUNDER: | 1301 | case CONTEXT_TEXTUNDER: |
1291 | setIconText( IconTextBottom ); | 1302 | setIconText( IconTextBottom ); |
1292 | break; | 1303 | break; |
1293 | default: | 1304 | default: |
1294 | if ( i >= CONTEXT_ICONSIZES ) | 1305 | if ( i >= CONTEXT_ICONSIZES ) |
1295 | setIconSize( i - CONTEXT_ICONSIZES ); | 1306 | setIconSize( i - CONTEXT_ICONSIZES ); |
@@ -1319,143 +1330,143 @@ void KToolBar::rebuildLayout() | |||
1319 | // clear the old layout | 1330 | // clear the old layout |
1320 | QLayoutIterator it = l->iterator(); | 1331 | QLayoutIterator it = l->iterator(); |
1321 | 1332 | ||
1322 | while ( it.current() ) { | 1333 | while ( it.current() ) { |
1323 | it.deleteCurrent(); | 1334 | it.deleteCurrent(); |
1324 | } | 1335 | } |
1325 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { | 1336 | for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { |
1326 | if ( w == rightAligned ) { | 1337 | if ( w == rightAligned ) { |
1327 | continue; | 1338 | continue; |
1328 | } | 1339 | } |
1329 | if ( w->inherits( "KToolBarSeparator" ) && | 1340 | if ( w->inherits( "KToolBarSeparator" ) && |
1330 | !( (KToolBarSeparator*)w )->showLine() ) { | 1341 | !( (KToolBarSeparator*)w )->showLine() ) { |
1331 | l->addSpacing( 6 ); | 1342 | l->addSpacing( 6 ); |
1332 | w->hide(); | 1343 | w->hide(); |
1333 | continue; | 1344 | continue; |
1334 | } | 1345 | } |
1335 | if ( w->inherits( "QPopupMenu" ) ) | 1346 | if ( w->inherits( "Q3PopupMenu" ) ) |
1336 | continue; | 1347 | continue; |
1337 | l->addWidget( w ); | 1348 | l->addWidget( w ); |
1338 | w->show(); | 1349 | w->show(); |
1339 | } | 1350 | } |
1340 | if ( rightAligned ) { | 1351 | if ( rightAligned ) { |
1341 | l->addStretch(); | 1352 | l->addStretch(); |
1342 | l->addWidget( rightAligned ); | 1353 | l->addWidget( rightAligned ); |
1343 | rightAligned->show(); | 1354 | rightAligned->show(); |
1344 | } | 1355 | } |
1345 | 1356 | ||
1346 | if ( fullSize() ) { | 1357 | if ( fullSize() ) { |
1347 | // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). | 1358 | // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). |
1348 | //if ( !stretchableWidget && widgets.last() && | 1359 | //if ( !stretchableWidget && widgets.last() && |
1349 | // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) | 1360 | // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) |
1350 | // setStretchableWidget( widgets.last() ); | 1361 | // setStretchableWidget( widgets.last() ); |
1351 | if ( !rightAligned ) | 1362 | if ( !rightAligned ) |
1352 | l->addStretch(); | 1363 | l->addStretch(); |
1353 | if ( stretchableWidget ) | 1364 | if ( stretchableWidget ) |
1354 | l->setStretchFactor( stretchableWidget, 10 ); | 1365 | l->setStretchFactor( stretchableWidget, 10 ); |
1355 | } | 1366 | } |
1356 | l->invalidate(); | 1367 | l->invalidate(); |
1357 | QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); | 1368 | QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); |
1358 | //#endif //DESKTOP_VERSION | 1369 | //#endif //DESKTOP_VERSION |
1359 | } | 1370 | } |
1360 | 1371 | ||
1361 | void KToolBar::childEvent( QChildEvent *e ) | 1372 | void KToolBar::childEvent( QChildEvent *e ) |
1362 | { | 1373 | { |
1363 | 1374 | ||
1364 | if ( e->child()->isWidgetType() ) { | 1375 | if ( e->child()->isWidgetType() ) { |
1365 | QWidget * w = (QWidget*)e->child(); | 1376 | QWidget * w = (QWidget*)e->child(); |
1366 | if ( e->type() == QEvent::ChildInserted ) { | 1377 | if ( e->type() == QEvent::ChildInserted ) { |
1367 | if ( !e->child()->inherits( "QPopupMenu" ) && | 1378 | if ( !e->child()->inherits( "Q3PopupMenu" ) && |
1368 | ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { | 1379 | ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { |
1369 | 1380 | ||
1370 | // prevent items that have been explicitly inserted by insert*() from | 1381 | // prevent items that have been explicitly inserted by insert*() from |
1371 | // being inserted again | 1382 | // being inserted again |
1372 | if ( !widget2id.contains( w ) ) | 1383 | if ( !widget2id.contains( w ) ) |
1373 | { | 1384 | { |
1374 | int dummy = -1; | 1385 | int dummy = -1; |
1375 | insertWidgetInternal( w, dummy, -1 ); | 1386 | insertWidgetInternal( w, dummy, -1 ); |
1376 | } | 1387 | } |
1377 | } | 1388 | } |
1378 | } else { | 1389 | } else if( e->type() == QEvent::ChildRemoved ) { |
1379 | removeWidgetInternal( w ); | 1390 | removeWidgetInternal( w ); |
1380 | } | 1391 | } |
1381 | if ( isVisibleTo( 0 ) ) | 1392 | /* TODO:hacker: if ( isVisibleTo( 0 ) ) |
1382 | { | 1393 | { |
1383 | QBoxLayout *l = boxLayout(); | 1394 | QBoxLayout *l = boxLayout(); |
1384 | // QLayout *l = layout(); | 1395 | // QLayout *l = layout(); |
1385 | 1396 | ||
1386 | // clear the old layout so that we don't get unnecassery layout | 1397 | // clear the old layout so that we don't get unnecassery layout |
1387 | // changes till we have rebuild the thing | 1398 | // changes till we have rebuild the thing |
1388 | QLayoutIterator it = l->iterator(); | 1399 | QLayoutIterator it = l->iterator(); |
1389 | while ( it.current() ) { | 1400 | while ( it.current() ) { |
1390 | it.deleteCurrent(); | 1401 | it.deleteCurrent(); |
1391 | } | 1402 | } |
1392 | layoutTimer->start( 50, TRUE ); | 1403 | layoutTimer->start( 50, TRUE ); |
1393 | } | 1404 | } */ |
1394 | } | 1405 | } |
1395 | QToolBar::childEvent( e ); | 1406 | Q3ToolBar::childEvent( e ); |
1396 | } | 1407 | } |
1397 | 1408 | ||
1398 | void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) | 1409 | void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) |
1399 | { | 1410 | { |
1400 | // we can't have it in widgets, or something is really wrong | 1411 | // we can't have it in widgets, or something is really wrong |
1401 | //widgets.removeRef( w ); | 1412 | //widgets.removeRef( w ); |
1402 | 1413 | ||
1403 | connect( w, SIGNAL( destroyed() ), | 1414 | connect( w, SIGNAL( destroyed() ), |
1404 | this, SLOT( widgetDestroyed() ) ); | 1415 | this, SLOT( widgetDestroyed() ) ); |
1405 | if ( index == -1 || index > (int)widgets.count() ) { | 1416 | if ( index == -1 || index > (int)widgets.count() ) { |
1406 | widgets.append( w ); | 1417 | widgets.append( w ); |
1407 | index = (int)widgets.count(); | 1418 | index = (int)widgets.count(); |
1408 | } | 1419 | } |
1409 | else | 1420 | else |
1410 | widgets.insert( index, w ); | 1421 | widgets.insert( index, w ); |
1411 | if ( id == -1 ) | 1422 | if ( id == -1 ) |
1412 | id = id2widget.count(); | 1423 | id = id2widget.count(); |
1413 | id2widget.insert( id, w ); | 1424 | id2widget.insert( id, w ); |
1414 | widget2id.insert( w, id ); | 1425 | widget2id.insert( w, id ); |
1415 | } | 1426 | } |
1416 | void KToolBar::repaintMe() | 1427 | void KToolBar::repaintMe() |
1417 | { | 1428 | { |
1418 | setUpdatesEnabled( true ); | 1429 | setUpdatesEnabled( true ); |
1419 | QToolBar::repaint( true ); | 1430 | Q3ToolBar::repaint( true ); |
1420 | qDebug(" KToolBar::repaintMe() "); | 1431 | qDebug(" KToolBar::repaintMe() "); |
1421 | } | 1432 | } |
1422 | 1433 | ||
1423 | void KToolBar::showEvent( QShowEvent *e ) | 1434 | void KToolBar::showEvent( QShowEvent *e ) |
1424 | { | 1435 | { |
1425 | rebuildLayout(); | 1436 | rebuildLayout(); |
1426 | QToolBar::showEvent( e ); | 1437 | Q3ToolBar::showEvent( e ); |
1427 | } | 1438 | } |
1428 | 1439 | ||
1429 | void KToolBar::setStretchableWidget( QWidget *w ) | 1440 | void KToolBar::setStretchableWidget( QWidget *w ) |
1430 | { | 1441 | { |
1431 | QToolBar::setStretchableWidget( w ); | 1442 | Q3ToolBar::setStretchableWidget( w ); |
1432 | stretchableWidget = w; | 1443 | stretchableWidget = w; |
1433 | } | 1444 | } |
1434 | 1445 | ||
1435 | QSizePolicy KToolBar::sizePolicy() const | 1446 | QSizePolicy KToolBar::sizePolicy() const |
1436 | { | 1447 | { |
1437 | if ( orientation() == Horizontal ) | 1448 | if ( orientation() == Qt::Horizontal ) |
1438 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); | 1449 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); |
1439 | else | 1450 | else |
1440 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); | 1451 | return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); |
1441 | } | 1452 | } |
1442 | 1453 | ||
1443 | QSize KToolBar::sizeHint() const | 1454 | QSize KToolBar::sizeHint() const |
1444 | { | 1455 | { |
1445 | QSize sh = QToolBar::sizeHint(); | 1456 | QSize sh = Q3ToolBar::sizeHint(); |
1446 | //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() ); | 1457 | //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() ); |
1447 | if ( sh.height() <= 20 || sh.width() < 60 ) | 1458 | if ( sh.height() <= 20 || sh.width() < 60 ) |
1448 | return QSize( sizeHintW, sizeHintH ); | 1459 | return QSize( sizeHintW, sizeHintH ); |
1449 | KToolBar* ttt = (KToolBar*) this; | 1460 | KToolBar* ttt = (KToolBar*) this; |
1450 | ttt->sizeHintW = sh.width(); | 1461 | ttt->sizeHintW = sh.width(); |
1451 | ttt->sizeHintH = sh.height(); | 1462 | ttt->sizeHintH = sh.height(); |
1452 | return sh; | 1463 | return sh; |
1453 | //return QToolBar::sizeHint(); | 1464 | //return QToolBar::sizeHint(); |
1454 | #if 0 | 1465 | #if 0 |
1455 | QWidget::polish(); | 1466 | QWidget::polish(); |
1456 | static int iii = 0; | 1467 | static int iii = 0; |
1457 | ++iii; | 1468 | ++iii; |
1458 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); | 1469 | qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); |
1459 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); | 1470 | int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); |
1460 | switch( barPos() ) | 1471 | switch( barPos() ) |
1461 | { | 1472 | { |
@@ -1495,69 +1506,69 @@ QSize KToolBar::sizeHint() const | |||
1495 | else | 1506 | else |
1496 | { | 1507 | { |
1497 | QSize sh = w->sizeHint(); | 1508 | QSize sh = w->sizeHint(); |
1498 | if (!sh.isValid()) | 1509 | if (!sh.isValid()) |
1499 | sh = w->minimumSize(); | 1510 | sh = w->minimumSize(); |
1500 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); | 1511 | minSize = minSize.expandedTo(QSize(sh.width(), 0)); |
1501 | minSize += QSize(0, sh.height()+1); | 1512 | minSize += QSize(0, sh.height()+1); |
1502 | } | 1513 | } |
1503 | } | 1514 | } |
1504 | /*US | 1515 | /*US |
1505 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); | 1516 | minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); |
1506 | */ | 1517 | */ |
1507 | minSize += QSize(margin*2, margin*2); | 1518 | minSize += QSize(margin*2, margin*2); |
1508 | break; | 1519 | break; |
1509 | 1520 | ||
1510 | default: | 1521 | default: |
1511 | minSize = QToolBar::sizeHint(); | 1522 | minSize = Q3ToolBar::sizeHint(); |
1512 | break; | 1523 | break; |
1513 | } | 1524 | } |
1514 | return minSize; | 1525 | return minSize; |
1515 | #endif | 1526 | #endif |
1516 | } | 1527 | } |
1517 | 1528 | ||
1518 | QSize KToolBar::minimumSize() const | 1529 | QSize KToolBar::minimumSize() const |
1519 | { | 1530 | { |
1520 | return minimumSizeHint(); | 1531 | return minimumSizeHint(); |
1521 | } | 1532 | } |
1522 | 1533 | ||
1523 | QSize KToolBar::minimumSizeHint() const | 1534 | QSize KToolBar::minimumSizeHint() const |
1524 | { | 1535 | { |
1525 | return sizeHint(); | 1536 | return sizeHint(); |
1526 | } | 1537 | } |
1527 | 1538 | ||
1528 | bool KToolBar::highlight() const | 1539 | bool KToolBar::highlight() const |
1529 | { | 1540 | { |
1530 | return d->m_highlight; | 1541 | return d->m_highlight; |
1531 | } | 1542 | } |
1532 | 1543 | ||
1533 | void KToolBar::hide() | 1544 | void KToolBar::hide() |
1534 | { | 1545 | { |
1535 | QToolBar::hide(); | 1546 | Q3ToolBar::hide(); |
1536 | } | 1547 | } |
1537 | 1548 | ||
1538 | void KToolBar::show() | 1549 | void KToolBar::show() |
1539 | { | 1550 | { |
1540 | QToolBar::show(); | 1551 | Q3ToolBar::show(); |
1541 | } | 1552 | } |
1542 | 1553 | ||
1543 | void KToolBar::resizeEvent( QResizeEvent *e ) | 1554 | void KToolBar::resizeEvent( QResizeEvent *e ) |
1544 | { | 1555 | { |
1545 | bool b = isUpdatesEnabled(); | 1556 | bool b = isUpdatesEnabled(); |
1546 | setUpdatesEnabled( FALSE ); | 1557 | setUpdatesEnabled( FALSE ); |
1547 | QToolBar::resizeEvent( e ); | 1558 | Q3ToolBar::resizeEvent( e ); |
1548 | if (b) | 1559 | if (b) |
1549 | d->repaintTimer.start( 100, true ); | 1560 | d->repaintTimer.start( 100, true ); |
1550 | } | 1561 | } |
1551 | 1562 | ||
1552 | void KToolBar::slotIconChanged(int group) | 1563 | void KToolBar::slotIconChanged(int group) |
1553 | { | 1564 | { |
1554 | if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) | 1565 | if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) |
1555 | return; | 1566 | return; |
1556 | if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) | 1567 | if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) |
1557 | return; | 1568 | return; |
1558 | 1569 | ||
1559 | emit modechange(); | 1570 | emit modechange(); |
1560 | if (isVisible()) | 1571 | if (isVisible()) |
1561 | updateGeometry(); | 1572 | updateGeometry(); |
1562 | } | 1573 | } |
1563 | 1574 | ||
@@ -1713,33 +1724,33 @@ void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGr | |||
1713 | else | 1724 | else |
1714 | icon_text = IconOnly; | 1725 | icon_text = IconOnly; |
1715 | 1726 | ||
1716 | // check if the icon/text has changed | 1727 | // check if the icon/text has changed |
1717 | if (icon_text != d->m_iconText) { | 1728 | if (icon_text != d->m_iconText) { |
1718 | //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; | 1729 | //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; |
1719 | setIconText(icon_text, false); | 1730 | setIconText(icon_text, false); |
1720 | doUpdate = true; | 1731 | doUpdate = true; |
1721 | } | 1732 | } |
1722 | 1733 | ||
1723 | // ...and check if the icon size has changed | 1734 | // ...and check if the icon size has changed |
1724 | if (iconsize != d->m_iconSize) { | 1735 | if (iconsize != d->m_iconSize) { |
1725 | setIconSize(iconsize, false); | 1736 | setIconSize(iconsize, false); |
1726 | doUpdate = true; | 1737 | doUpdate = true; |
1727 | } | 1738 | } |
1728 | 1739 | ||
1729 | QMainWindow *mw = mainWindow(); | 1740 | Q3MainWindow *mw = mainWindow(); |
1730 | 1741 | ||
1731 | // ...and if we should highlight | 1742 | // ...and if we should highlight |
1732 | if ( highlight != d->m_highlight ) { | 1743 | if ( highlight != d->m_highlight ) { |
1733 | d->m_highlight = highlight; | 1744 | d->m_highlight = highlight; |
1734 | doUpdate = true; | 1745 | doUpdate = true; |
1735 | } | 1746 | } |
1736 | 1747 | ||
1737 | // ...and if we should move transparently | 1748 | // ...and if we should move transparently |
1738 | if ( mw && transparent != (!mw->opaqueMoving()) ) { | 1749 | if ( mw && transparent != (!mw->opaqueMoving()) ) { |
1739 | mw->setOpaqueMoving( !transparent ); | 1750 | mw->setOpaqueMoving( !transparent ); |
1740 | } | 1751 | } |
1741 | 1752 | ||
1742 | if (doUpdate) | 1753 | if (doUpdate) |
1743 | emit modechange(); // tell buttons what happened | 1754 | emit modechange(); // tell buttons what happened |
1744 | if (isVisible ()) | 1755 | if (isVisible ()) |
1745 | updateGeometry(); | 1756 | updateGeometry(); |
@@ -1792,55 +1803,55 @@ void KToolBar::applySettings(KConfig *config, const QString &_configGroup) | |||
1792 | bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); | 1803 | bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); |
1793 | 1804 | ||
1794 | /*US Dock pos(DockTop); | 1805 | /*US Dock pos(DockTop); |
1795 | if ( position == "Top" ) | 1806 | if ( position == "Top" ) |
1796 | pos = DockTop; | 1807 | pos = DockTop; |
1797 | else if ( position == "Bottom" ) | 1808 | else if ( position == "Bottom" ) |
1798 | pos = DockBottom; | 1809 | pos = DockBottom; |
1799 | else if ( position == "Left" ) | 1810 | else if ( position == "Left" ) |
1800 | pos = DockLeft; | 1811 | pos = DockLeft; |
1801 | else if ( position == "Right" ) | 1812 | else if ( position == "Right" ) |
1802 | pos = DockRight; | 1813 | pos = DockRight; |
1803 | else if ( position == "Floating" ) | 1814 | else if ( position == "Floating" ) |
1804 | pos = DockTornOff; | 1815 | pos = DockTornOff; |
1805 | else if ( position == "Flat" ) | 1816 | else if ( position == "Flat" ) |
1806 | pos = DockMinimized; | 1817 | pos = DockMinimized; |
1807 | */ | 1818 | */ |
1808 | QMainWindow::ToolBarDock pos(QMainWindow::Top); | 1819 | Qt::ToolBarDock pos(Qt::DockTop); |
1809 | if ( position == "Top" ) | 1820 | if ( position == "Top" ) |
1810 | pos = QMainWindow::Top; | 1821 | pos = Qt::Top; |
1811 | else if ( position == "Bottom" ) | 1822 | else if ( position == "Bottom" ) |
1812 | pos = QMainWindow::Bottom; | 1823 | pos = Qt::Bottom; |
1813 | else if ( position == "Left" ) | 1824 | else if ( position == "Left" ) |
1814 | pos = QMainWindow::Left; | 1825 | pos = Qt::Left; |
1815 | else if ( position == "Right" ) | 1826 | else if ( position == "Right" ) |
1816 | pos = QMainWindow::Right; | 1827 | pos = Qt::Right; |
1817 | else if ( position == "Floating" ) | 1828 | else if ( position == "Floating" ) |
1818 | pos = QMainWindow::TornOff; | 1829 | pos = Qt::TornOff; |
1819 | else if ( position == "Flat" ) | 1830 | else if ( position == "Flat" ) |
1820 | pos = QMainWindow::Minimized; | 1831 | pos = Qt::Minimized; |
1821 | 1832 | ||
1822 | //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; | 1833 | //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; |
1823 | if (hidden) | 1834 | if (hidden) |
1824 | hide(); | 1835 | hide(); |
1825 | else | 1836 | else |
1826 | show(); | 1837 | show(); |
1827 | 1838 | ||
1828 | if ( mainWindow() ) | 1839 | if ( mainWindow() ) |
1829 | { | 1840 | { |
1830 | QMainWindow *mw = mainWindow(); | 1841 | Q3MainWindow *mw = mainWindow(); |
1831 | 1842 | ||
1832 | //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; | 1843 | //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; |
1833 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); | 1844 | d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); |
1834 | 1845 | ||
1835 | // moveDockWindow calls QDockArea which does a reparent() on us with | 1846 | // moveDockWindow calls QDockArea which does a reparent() on us with |
1836 | // showIt = true, so we loose our visibility status | 1847 | // showIt = true, so we loose our visibility status |
1837 | bool doHide = isHidden(); | 1848 | bool doHide = isHidden(); |
1838 | 1849 | ||
1839 | //US mw->moveDockWindow( this, pos, newLine, index, offset ); | 1850 | //US mw->moveDockWindow( this, pos, newLine, index, offset ); |
1840 | mw->moveToolBar( this, pos, newLine, index, offset ); | 1851 | mw->moveToolBar( this, pos, newLine, index, offset ); |
1841 | 1852 | ||
1842 | //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; | 1853 | //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; |
1843 | if ( doHide ) | 1854 | if ( doHide ) |
1844 | hide(); | 1855 | hide(); |
1845 | } | 1856 | } |
1846 | if (isVisible ()) | 1857 | if (isVisible ()) |
@@ -1849,58 +1860,58 @@ void KToolBar::applySettings(KConfig *config, const QString &_configGroup) | |||
1849 | } | 1860 | } |
1850 | 1861 | ||
1851 | bool KToolBar::event( QEvent *e ) | 1862 | bool KToolBar::event( QEvent *e ) |
1852 | { | 1863 | { |
1853 | if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) | 1864 | if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) |
1854 | d->repaintTimer.start( 100, true ); | 1865 | d->repaintTimer.start( 100, true ); |
1855 | 1866 | ||
1856 | if (e->type() == QEvent::ChildInserted ) | 1867 | if (e->type() == QEvent::ChildInserted ) |
1857 | { | 1868 | { |
1858 | // By pass QToolBar::event, | 1869 | // By pass QToolBar::event, |
1859 | // it will show() the inserted child and we don't want to | 1870 | // it will show() the inserted child and we don't want to |
1860 | // do that until we have rebuild the layout. | 1871 | // do that until we have rebuild the layout. |
1861 | childEvent((QChildEvent *)e); | 1872 | childEvent((QChildEvent *)e); |
1862 | return true; | 1873 | return true; |
1863 | } | 1874 | } |
1864 | 1875 | ||
1865 | return QToolBar::event( e ); | 1876 | return Q3ToolBar::event( e ); |
1866 | } | 1877 | } |
1867 | 1878 | ||
1868 | void KToolBar::slotRepaint() | 1879 | void KToolBar::slotRepaint() |
1869 | { | 1880 | { |
1870 | setUpdatesEnabled( FALSE ); | 1881 | setUpdatesEnabled( FALSE ); |
1871 | // Send a resizeEvent to update the "toolbar extension arrow" | 1882 | // Send a resizeEvent to update the "toolbar extension arrow" |
1872 | // (The button you get when your toolbar-items don't fit in | 1883 | // (The button you get when your toolbar-items don't fit in |
1873 | // the available space) | 1884 | // the available space) |
1874 | QResizeEvent ev(size(), size()); | 1885 | QResizeEvent ev(size(), size()); |
1875 | resizeEvent(&ev); | 1886 | resizeEvent(&ev); |
1876 | //#ifdef DESKTOP_VERSION | 1887 | //#ifdef DESKTOP_VERSION |
1877 | QApplication::sendPostedEvents( this, QEvent::LayoutHint ); | 1888 | QApplication::sendPostedEvents( this, QEvent::LayoutHint ); |
1878 | //#endif //DESKTOP_VERSION | 1889 | //#endif //DESKTOP_VERSION |
1879 | setUpdatesEnabled( TRUE ); | 1890 | setUpdatesEnabled( TRUE ); |
1880 | repaint( TRUE ); | 1891 | repaint( TRUE ); |
1881 | } | 1892 | } |
1882 | 1893 | ||
1883 | void KToolBar::toolBarPosChanged( QToolBar *tb ) | 1894 | void KToolBar::toolBarPosChanged( Q3ToolBar *tb ) |
1884 | { | 1895 | { |
1885 | if ( tb != this ) | 1896 | if ( tb != this ) |
1886 | return; | 1897 | return; |
1887 | //US if ( d->oldPos == DockMinimized ) | 1898 | //US if ( d->oldPos == DockMinimized ) |
1888 | if ( d->oldPos == QMainWindow::Minimized ) | 1899 | if ( d->oldPos == Qt::Minimized ) |
1889 | rebuildLayout(); | 1900 | rebuildLayout(); |
1890 | d->oldPos = (QMainWindow::ToolBarDock)barPos(); | 1901 | d->oldPos = (Qt::ToolBarDock)barPos(); |
1891 | /*US | 1902 | /*US |
1892 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) | 1903 | if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) |
1893 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); | 1904 | static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); |
1894 | */ | 1905 | */ |
1895 | } | 1906 | } |
1896 | 1907 | ||
1897 | /*US | 1908 | /*US |
1898 | void KToolBar::loadState( const QDomElement &element ) | 1909 | void KToolBar::loadState( const QDomElement &element ) |
1899 | { | 1910 | { |
1900 | //kdDebug(220) << "KToolBar::loadState " << this << endl; | 1911 | //kdDebug(220) << "KToolBar::loadState " << this << endl; |
1901 | if ( !mainWindow() ) | 1912 | if ( !mainWindow() ) |
1902 | return; | 1913 | return; |
1903 | 1914 | ||
1904 | { | 1915 | { |
1905 | QCString text = element.namedItem( "text" ).toElement().text().utf8(); | 1916 | QCString text = element.namedItem( "text" ).toElement().text().utf8(); |
1906 | if ( text.isEmpty() ) | 1917 | if ( text.isEmpty() ) |
@@ -2018,33 +2029,33 @@ void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) | |||
2018 | case KToolBar::Left: | 2029 | case KToolBar::Left: |
2019 | position = "Left"; | 2030 | position = "Left"; |
2020 | break; | 2031 | break; |
2021 | case KToolBar::Right: | 2032 | case KToolBar::Right: |
2022 | position = "Right"; | 2033 | position = "Right"; |
2023 | break; | 2034 | break; |
2024 | case KToolBar::Floating: | 2035 | case KToolBar::Floating: |
2025 | position = "Floating"; | 2036 | position = "Floating"; |
2026 | break; | 2037 | break; |
2027 | case KToolBar::Top: | 2038 | case KToolBar::Top: |
2028 | default: | 2039 | default: |
2029 | position = "Top"; | 2040 | position = "Top"; |
2030 | break; | 2041 | break; |
2031 | } | 2042 | } |
2032 | 2043 | ||
2033 | if ( mainWindow() ) { | 2044 | if ( mainWindow() ) { |
2034 | QMainWindow::ToolBarDock dock; | 2045 | Qt::ToolBarDock dock; |
2035 | bool newLine; | 2046 | bool newLine; |
2036 | int offset; | 2047 | int offset; |
2037 | mainWindow()->getLocation( this, dock, index, newLine, offset ); | 2048 | mainWindow()->getLocation( this, dock, index, newLine, offset ); |
2038 | } | 2049 | } |
2039 | 2050 | ||
2040 | switch (d->m_iconText) { | 2051 | switch (d->m_iconText) { |
2041 | case KToolBar::IconTextRight: | 2052 | case KToolBar::IconTextRight: |
2042 | icontext = "IconTextRight"; | 2053 | icontext = "IconTextRight"; |
2043 | break; | 2054 | break; |
2044 | case KToolBar::IconTextBottom: | 2055 | case KToolBar::IconTextBottom: |
2045 | icontext = "IconTextBottom"; | 2056 | icontext = "IconTextBottom"; |
2046 | break; | 2057 | break; |
2047 | case KToolBar::TextOnly: | 2058 | case KToolBar::TextOnly: |
2048 | icontext = "TextOnly"; | 2059 | icontext = "TextOnly"; |
2049 | break; | 2060 | break; |
2050 | case KToolBar::IconOnly: | 2061 | case KToolBar::IconOnly: |
@@ -2087,78 +2098,78 @@ void KToolBar::positionYourself( bool force ) | |||
2087 | bool doHide = isHidden(); | 2098 | bool doHide = isHidden(); |
2088 | //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; | 2099 | //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; |
2089 | /*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, | 2100 | /*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, |
2090 | d->toolBarInfo.newline, | 2101 | d->toolBarInfo.newline, |
2091 | d->toolBarInfo.index, | 2102 | d->toolBarInfo.index, |
2092 | d->toolBarInfo.offset ); | 2103 | d->toolBarInfo.offset ); |
2093 | */ | 2104 | */ |
2094 | mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); | 2105 | mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); |
2095 | 2106 | ||
2096 | if ( doHide ) | 2107 | if ( doHide ) |
2097 | hide(); | 2108 | hide(); |
2098 | // This method can only have an effect once - unless force is set | 2109 | // This method can only have an effect once - unless force is set |
2099 | d->positioned = TRUE; | 2110 | d->positioned = TRUE; |
2100 | } | 2111 | } |
2101 | 2112 | ||
2102 | //US KPopupMenu *KToolBar::contextMenu() | 2113 | //US KPopupMenu *KToolBar::contextMenu() |
2103 | QPopupMenu *KToolBar::contextMenu() | 2114 | Q3PopupMenu *KToolBar::contextMenu() |
2104 | { | 2115 | { |
2105 | if ( context ) | 2116 | if ( context ) |
2106 | return context; | 2117 | return context; |
2107 | 2118 | ||
2108 | // Construct our context popup menu. Name it qt_dockwidget_internal so it | 2119 | // Construct our context popup menu. Name it qt_dockwidget_internal so it |
2109 | // won't be deleted by QToolBar::clear(). | 2120 | // won't be deleted by QToolBar::clear(). |
2110 | //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); | 2121 | //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); |
2111 | context = new QPopupMenu( this, "qt_dockwidget_internal" ); | 2122 | context = new Q3PopupMenu( this, "qt_dockwidget_internal" ); |
2112 | //US context->insertTitle(i18n("Toolbar Menu")); | 2123 | //US context->insertTitle(i18n("Toolbar Menu")); |
2113 | 2124 | ||
2114 | //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); | 2125 | //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); |
2115 | QPopupMenu *orient = new QPopupMenu( context, "orient" ); | 2126 | Q3PopupMenu *orient = new Q3PopupMenu( context, "orient" ); |
2116 | orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); | 2127 | orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); |
2117 | orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); | 2128 | orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); |
2118 | orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); | 2129 | orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); |
2119 | orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); | 2130 | orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); |
2120 | orient->insertSeparator(-1); | 2131 | orient->insertSeparator(-1); |
2121 | //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); | 2132 | //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); |
2122 | orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); | 2133 | orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); |
2123 | 2134 | ||
2124 | //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); | 2135 | //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); |
2125 | QPopupMenu *mode = new QPopupMenu( context, "mode" ); | 2136 | Q3PopupMenu *mode = new Q3PopupMenu( context, "mode" ); |
2126 | mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); | 2137 | mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); |
2127 | mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); | 2138 | mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); |
2128 | mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); | 2139 | mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); |
2129 | mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); | 2140 | mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); |
2130 | 2141 | ||
2131 | //US KPopupMenu *size = new KPopupMenu( context, "size" ); | 2142 | //US KPopupMenu *size = new KPopupMenu( context, "size" ); |
2132 | QPopupMenu *size = new QPopupMenu( context, "size" ); | 2143 | Q3PopupMenu *size = new Q3PopupMenu( context, "size" ); |
2133 | size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); | 2144 | size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); |
2134 | // Query the current theme for available sizes | 2145 | // Query the current theme for available sizes |
2135 | QValueList<int> avSizes; | 2146 | Q3ValueList<int> avSizes; |
2136 | /*US | 2147 | /*US |
2137 | KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); | 2148 | KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); |
2138 | if (!::qstrcmp(QObject::name(), "mainToolBar")) | 2149 | if (!::qstrcmp(QObject::name(), "mainToolBar")) |
2139 | avSizes = theme->querySizes( KIcon::MainToolbar); | 2150 | avSizes = theme->querySizes( KIcon::MainToolbar); |
2140 | else | 2151 | else |
2141 | avSizes = theme->querySizes( KIcon::Toolbar); | 2152 | avSizes = theme->querySizes( KIcon::Toolbar); |
2142 | */ | 2153 | */ |
2143 | avSizes << 16; | 2154 | avSizes << 16; |
2144 | avSizes << 32; | 2155 | avSizes << 32; |
2145 | 2156 | ||
2146 | d->iconSizes = avSizes; | 2157 | d->iconSizes = avSizes; |
2147 | 2158 | ||
2148 | QValueList<int>::Iterator it; | 2159 | Q3ValueList<int>::Iterator it; |
2149 | for (it=avSizes.begin(); it!=avSizes.end(); it++) { | 2160 | for (it=avSizes.begin(); it!=avSizes.end(); it++) { |
2150 | QString text; | 2161 | QString text; |
2151 | if ( *it < 19 ) | 2162 | if ( *it < 19 ) |
2152 | text = i18n("Small (%1x%2)").arg(*it).arg(*it); | 2163 | text = i18n("Small (%1x%2)").arg(*it).arg(*it); |
2153 | else if (*it < 25) | 2164 | else if (*it < 25) |
2154 | text = i18n("Medium (%1x%2)").arg(*it).arg(*it); | 2165 | text = i18n("Medium (%1x%2)").arg(*it).arg(*it); |
2155 | else | 2166 | else |
2156 | text = i18n("Large (%1x%2)").arg(*it).arg(*it); | 2167 | text = i18n("Large (%1x%2)").arg(*it).arg(*it); |
2157 | //we use the size as an id, with an offset | 2168 | //we use the size as an id, with an offset |
2158 | size->insertItem( text, CONTEXT_ICONSIZES + *it ); | 2169 | size->insertItem( text, CONTEXT_ICONSIZES + *it ); |
2159 | } | 2170 | } |
2160 | 2171 | ||
2161 | context->insertItem( i18n("Orientation"), orient ); | 2172 | context->insertItem( i18n("Orientation"), orient ); |
2162 | orient->setItemChecked(CONTEXT_TOP, true); | 2173 | orient->setItemChecked(CONTEXT_TOP, true); |
2163 | context->insertItem( i18n("Text Position"), mode ); | 2174 | context->insertItem( i18n("Text Position"), mode ); |
2164 | context->setItemChecked(CONTEXT_ICONS, true); | 2175 | context->setItemChecked(CONTEXT_ICONS, true); |
@@ -2205,34 +2216,34 @@ void KToolBar::slotContextAboutToShow() | |||
2205 | { | 2216 | { |
2206 | case IconOnly: | 2217 | case IconOnly: |
2207 | default: | 2218 | default: |
2208 | context->setItemChecked(CONTEXT_ICONS, true); | 2219 | context->setItemChecked(CONTEXT_ICONS, true); |
2209 | break; | 2220 | break; |
2210 | case IconTextRight: | 2221 | case IconTextRight: |
2211 | context->setItemChecked(CONTEXT_TEXTRIGHT, true); | 2222 | context->setItemChecked(CONTEXT_TEXTRIGHT, true); |
2212 | break; | 2223 | break; |
2213 | case TextOnly: | 2224 | case TextOnly: |
2214 | context->setItemChecked(CONTEXT_TEXT, true); | 2225 | context->setItemChecked(CONTEXT_TEXT, true); |
2215 | break; | 2226 | break; |
2216 | case IconTextBottom: | 2227 | case IconTextBottom: |
2217 | context->setItemChecked(CONTEXT_TEXTUNDER, true); | 2228 | context->setItemChecked(CONTEXT_TEXTUNDER, true); |
2218 | break; | 2229 | break; |
2219 | } | 2230 | } |
2220 | 2231 | ||
2221 | QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); | 2232 | Q3ValueList<int>::ConstIterator iIt = d->iconSizes.begin(); |
2222 | QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); | 2233 | Q3ValueList<int>::ConstIterator iEnd = d->iconSizes.end(); |
2223 | for (; iIt != iEnd; ++iIt ) | 2234 | for (; iIt != iEnd; ++iIt ) |
2224 | context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); | 2235 | context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); |
2225 | 2236 | ||
2226 | context->setItemChecked( CONTEXT_ICONSIZES, false ); | 2237 | context->setItemChecked( CONTEXT_ICONSIZES, false ); |
2227 | 2238 | ||
2228 | context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); | 2239 | context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); |
2229 | 2240 | ||
2230 | for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) | 2241 | for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) |
2231 | context->setItemChecked( i, false ); | 2242 | context->setItemChecked( i, false ); |
2232 | 2243 | ||
2233 | switch ( barPos() ) | 2244 | switch ( barPos() ) |
2234 | { | 2245 | { |
2235 | case KToolBar::Flat: | 2246 | case KToolBar::Flat: |
2236 | context->setItemChecked( CONTEXT_FLAT, true ); | 2247 | context->setItemChecked( CONTEXT_FLAT, true ); |
2237 | break; | 2248 | break; |
2238 | case KToolBar::Bottom: | 2249 | case KToolBar::Bottom: |