kicondialog.h
00001 /* vi: ts=8 sts=4 sw=4 00002 * 00003 * This file is part of the KDE project, module tdefile. 00004 * Copyright (C) 2000 Geert Jansen <jansen@kde.org> 00005 * (C) 2000 Kurt Granroth <granroth@kde.org> 00006 * (C) 1997 Christoph Neerfeld <chris@kde.org> 00007 * (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org> 00008 * 00009 * This is free software; it comes under the GNU Library General 00010 * Public License, version 2. See the file "COPYING.LIB" for the 00011 * exact licensing terms. 00012 */ 00013 00014 #ifndef __TDEIconDialog_h__ 00015 #define __TDEIconDialog_h__ 00016 00017 #include <tqstring.h> 00018 #include <tqstringlist.h> 00019 #include <tqpushbutton.h> 00020 00021 #include <kicontheme.h> 00022 #include <kdialogbase.h> 00023 #include <kiconview.h> 00024 00025 class TQComboBox; 00026 class TQTimer; 00027 class TQKeyEvent; 00028 class TQRadioButton; 00029 class KProgress; 00030 class TDEIconLoader; 00031 00035 class TDEIO_EXPORT TDEIconCanvas: public TDEIconView 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 TDEIconCanvas(TQWidget *parent=0L, const char *name=0L); 00041 ~TDEIconCanvas(); 00042 00046 void loadFiles(const TQStringList& files); 00047 00051 TQString getCurrent() const; 00052 00053 public slots: 00054 void stopLoading(); 00055 00056 signals: 00060 void nameChanged(TQString); 00061 /* KDE 4: Make it const TQString & */ 00062 00063 void startLoading(int); 00064 void progress(int); 00065 void finished(); 00066 00067 private slots: 00068 void slotLoadFiles(); 00069 void slotCurrentChanged(TQIconViewItem *item); 00070 00071 private: 00072 TQStringList mFiles; 00073 TQTimer *mpTimer; 00074 TDEIconLoader *mpLoader; // unused 00075 00076 protected: 00077 virtual void virtual_hook( int id, void* data ); 00078 00079 private: 00080 class TDEIconCanvasPrivate; 00081 TDEIconCanvasPrivate *d; 00082 }; 00083 00084 00091 class TDEIO_EXPORT TDEIconDialog: public KDialogBase 00092 { 00093 Q_OBJECT 00094 00095 public: 00099 TDEIconDialog(TQWidget *parent=0L, const char *name=0L); 00103 TDEIconDialog(TDEIconLoader *loader, TQWidget *parent=0, 00104 const char *name=0); 00108 ~TDEIconDialog(); 00109 00116 void setStrictIconSize(bool b); 00120 bool strictIconSize() const; 00125 void setCustomLocation( const TQString& location ); 00126 00132 void setIconSize(int size); 00133 00138 int iconSize() const; 00139 00140 #ifndef KDE_NO_COMPAT 00141 00144 TQString selectIcon(TDEIcon::Group group=TDEIcon::Desktop, TDEIcon::Context 00145 context=TDEIcon::Application, bool user=false); 00146 #endif 00147 00152 void setup( TDEIcon::Group group, 00153 TDEIcon::Context context = TDEIcon::Application, 00154 bool strictIconSize = false, int iconSize = 0, 00155 bool user = false ); 00156 00166 void setup( TDEIcon::Group group, TDEIcon::Context context, 00167 bool strictIconSize, int iconSize, bool user, bool lockUser, 00168 bool lockCustomDir ); 00169 00176 TQString openDialog(); 00177 00182 void showDialog(); 00183 00203 static TQString getIcon(TDEIcon::Group group=TDEIcon::Desktop, 00204 TDEIcon::Context context=TDEIcon::Application, 00205 bool strictIconSize=false, int iconSize = 0, 00206 bool user=false, TQWidget *parent=0, 00207 const TQString &caption=TQString::null); 00208 00209 signals: 00210 void newIconName(const TQString&); 00211 00212 protected slots: 00213 void slotOk(); 00214 00215 private slots: 00216 void slotButtonClicked(int); 00217 void slotContext(int); 00218 void slotStartLoading(int); 00219 void slotProgress(int); 00220 void slotFinished(); 00221 void slotAcceptIcons(); 00222 private: 00223 void init(); 00224 void showIcons(); 00225 void setContext( TDEIcon::Context context ); 00226 00227 int mGroupOrSize; 00228 TDEIcon::Context mContext; 00229 int mType; 00230 00231 TQStringList mFileList; 00232 TQComboBox *mpCombo; 00233 TQPushButton *mpBrowseBut; 00234 TQRadioButton *mpRb1, *mpRb2; 00235 KProgress *mpProgress; 00236 TDEIconLoader *mpLoader; 00237 TDEIconCanvas *mpCanvas; 00238 int mNumContext; 00239 TDEIcon::Context mContextMap[ 12 ]; // must match TDEIcon::Context size, code has assert 00240 00241 protected: 00242 virtual void virtual_hook( int id, void* data ); 00243 private: 00244 class TDEIconDialogPrivate; 00245 TDEIconDialogPrivate *d; 00246 }; 00247 00248 00257 class TDEIO_EXPORT TDEIconButton: public TQPushButton 00258 { 00259 Q_OBJECT 00260 TQ_PROPERTY( TQString icon READ icon WRITE setIcon RESET resetIcon ) 00261 TQ_PROPERTY( int iconSize READ iconSize WRITE setIconSize) 00262 TQ_PROPERTY( bool strictIconSize READ strictIconSize WRITE setStrictIconSize ) 00263 00264 public: 00268 TDEIconButton(TQWidget *parent=0L, const char *name=0L); 00269 00273 TDEIconButton(TDEIconLoader *loader, TQWidget *parent, const char *name=0L); 00277 ~TDEIconButton(); 00278 00284 void setStrictIconSize(bool b); 00288 bool strictIconSize() const; 00289 00294 void setIconType(TDEIcon::Group group, TDEIcon::Context context, bool user=false); 00295 00299 void setIcon(const TQString& icon); 00300 00304 void resetIcon(); 00305 00309 TQString icon() const { return mIcon; } 00310 00316 void setIconSize( int size ); 00317 00322 int iconSize() const; 00323 00324 signals: 00328 void iconChanged(TQString icon); 00329 /* KDE 4: Make it const TQString & */ 00330 00331 private slots: 00332 void slotChangeIcon(); 00333 void newIconName(const TQString& name); 00334 00335 private: 00336 void init( TDEIconLoader *loader ); 00337 00338 bool mbUser; 00339 TDEIcon::Group mGroup; 00340 TDEIcon::Context mContext; 00341 00342 TQString mIcon; 00343 TDEIconDialog *mpDialog; 00344 TDEIconLoader *mpLoader; 00345 class TDEIconButtonPrivate; 00346 TDEIconButtonPrivate *d; 00347 }; 00348 00349 00350 #endif // __TDEIconDialog_h__