kedittoolbar.h
00001 // -*- mode: c++; c-basic-offset: 2 -*- 00002 /* This file is part of the KDE libraries 00003 Copyright (C) 2000 Kurt Granroth <granroth@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 #ifndef _KEDITTOOLBAR_H 00020 #define _KEDITTOOLBAR_H 00021 00022 #include <tqwidget.h> 00023 #include <kxmlguiclient.h> 00024 #include <kdialogbase.h> 00025 00026 class TDEProcess; 00027 class TDEActionCollection; 00028 class TQComboBox; 00029 class TQToolButton; 00030 class TDEListView; 00031 class TQListViewItem; 00032 00033 class KEditToolbarWidget; 00034 class KEditToolbarPrivate; 00035 class KEditToolbarWidgetPrivate; 00036 namespace KEditToolbarInternal 00037 { 00038 class ToolbarItem; 00039 class ToolbarListView; 00040 } 00110 class TDEUI_EXPORT KEditToolbar : public KDialogBase 00111 { 00112 Q_OBJECT 00113 public: 00144 KEditToolbar(TDEActionCollection *collection, 00145 const TQString& xmlfile = TQString::null, bool global = true, 00146 TQWidget* parent = 0, const char* name = 0); 00147 00148 //KDE 4.0: merge the two constructors 00149 /* Constructor for apps that do not use components, which has an extra argument 00150 * specifying the toolbar to be shown. 00151 * @param defaultToolbar The toolbar with this name will appear for editing. 00152 * @param collection The collection of actions to work on. 00153 * @param xmlfile The application's local resource file. 00154 * @param global If @p true, then the global resource file will also 00155 * be parsed. 00156 * @param parent The parent of the dialog. 00157 * @param name An internal name. 00158 * @since 3.2 00159 */ 00160 KEditToolbar(const TQString& defaultToolbar, TDEActionCollection *collection, 00161 const TQString& xmlfile = TQString::null, bool global = true, 00162 TQWidget* parent = 0, const char* name = 0); 00186 KEditToolbar(KXMLGUIFactory* factory, TQWidget* parent = 0, const char* name = 0); 00187 00188 //KDE 4.0: merge the two constructors 00198 KEditToolbar(const TQString& defaultToolbar, KXMLGUIFactory* factory, 00199 TQWidget* parent = 0, const char* name = 0); 00200 00202 ~KEditToolbar(); 00203 00209 static void setDefaultToolbar(const char *toolbarName); 00210 00211 protected slots: 00215 virtual void slotOk(); 00219 virtual void slotApply(); 00220 00224 void acceptOK(bool b); 00225 00229 void slotDefault(); 00230 00231 signals: 00237 void newToolbarConfig(); 00238 00239 private: 00240 void init(); 00241 KEditToolbarWidget *m_widget; 00242 protected: 00243 virtual void virtual_hook( int id, void* data ); 00244 private: 00245 KEditToolbarPrivate *d; 00246 00247 static const char *s_defaultToolbar; 00248 }; 00249 00250 00270 class TDEUI_EXPORT KEditToolbarWidget : public TQWidget, virtual public KXMLGUIClient 00271 { 00272 Q_OBJECT 00273 public: 00303 KEditToolbarWidget(TDEActionCollection *collection, 00304 const TQString& xmlfile = TQString::null, 00305 bool global = true, TQWidget *parent = 0L); 00306 00307 //KDE 4.0: merge the two constructors 00308 /* Same as above, with an extra agrument specifying the toolbar to be shown. 00309 * 00310 * @param defaultToolbar The toolbar with this name will appear for editing. 00311 * @param collection The collection of actions to work on 00312 * @param xmlfile The application's local resource file 00313 * @param global If true, then the global resource file will also 00314 * be parsed 00315 * @param parent This widget's parent 00316 * @since 3.2 00317 */ 00318 KEditToolbarWidget(const TQString& defaultToolbar, 00319 TDEActionCollection *collection, 00320 const TQString& file = TQString::null, 00321 bool global = true, 00322 TQWidget *parent = 0L); 00323 00344 KEditToolbarWidget(KXMLGUIFactory* factory, TQWidget *parent = 0L); 00345 00346 //KDE 4.0: merge the two constructors 00347 /* Same as above, with an extra agrument specifying the toolbar to be shown. 00348 * 00349 * 00350 * @param defaultToolbar The toolbar with this name will appear for editing. 00351 * @param factory Your application's factory object 00352 * @param parent This widget's parent 00353 * @since 3.2 00354 */ 00355 KEditToolbarWidget(const TQString& defaultToolbar, 00356 KXMLGUIFactory* factory, 00357 TQWidget *parent = 0L); 00358 00364 virtual ~KEditToolbarWidget(); 00365 00369 virtual TDEActionCollection *actionCollection() const; 00370 00379 bool save(); 00380 00385 void rebuildKXMLGUIClients(); 00386 00387 signals: 00391 void enableOk(bool); 00392 00393 protected slots: 00394 void slotToolbarSelected(const TQString& text); 00395 00396 void slotInactiveSelected(TQListViewItem *item); 00397 void slotActiveSelected(TQListViewItem *item); 00398 00399 void slotDropped(TDEListView *list, TQDropEvent *e, TQListViewItem *after); 00400 00401 void slotInsertButton(); 00402 void slotRemoveButton(); 00403 void slotUpButton(); 00404 void slotDownButton(); 00405 00406 void slotChangeIcon(); 00407 00408 private slots: 00409 void slotProcessExited( TDEProcess* ); 00410 00411 protected: // KDE4: make private 00412 void setupLayout(); 00413 00414 void insertActive(KEditToolbarInternal::ToolbarItem *item, TQListViewItem *before, bool prepend = false); 00415 void removeActive(KEditToolbarInternal::ToolbarItem *item); 00416 void moveActive(KEditToolbarInternal::ToolbarItem *item, TQListViewItem *before); 00417 void initNonKPart(TDEActionCollection *collection, const TQString& file, bool global); 00418 void initKPart(KXMLGUIFactory* factory); 00419 void loadToolbarCombo(const TQString& defaultToolbar = TQString::null); 00420 void loadActionList(TQDomElement& elem); 00421 void updateLocal(TQDomElement& elem); 00422 00423 private: 00424 KEditToolbarInternal::ToolbarListView *m_inactiveList; 00425 KEditToolbarInternal::ToolbarListView *m_activeList; 00426 TQComboBox *m_toolbarCombo; 00427 00428 TQToolButton *m_upAction; 00429 TQToolButton *m_removeAction; 00430 TQToolButton *m_insertAction; 00431 TQToolButton *m_downAction; 00432 00433 protected: 00434 virtual void virtual_hook( int id, void* data ); 00435 private: 00436 KEditToolbarWidgetPrivate *d; 00437 }; 00438 00439 #endif // _KEDITTOOLBAR_H