Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef DIALOG_H
00029 #define DIALOG_H
00030
00031 #include "QGpGuiToolsDLLExport.h"
00032 #include "Settings.h"
00033
00034 namespace QGpGuiTools {
00035
00036 class QGPGUITOOLS_EXPORT FrameGrabber
00037 {
00038 public:
00039 FrameGrabber() {_valid=false;_lock=5;}
00040
00041 void setRect(QWidget * w, QString name);
00042 protected:
00043 inline void setFrame(QWidget * w);
00044 private:
00045 int _x, _y, _width, _height;
00046 int _lock;
00047 bool _valid;
00048 };
00049
00050 inline void FrameGrabber::setFrame(QWidget * w)
00051 {
00052 TRACE;
00053 if(w->isVisible()) {
00054 if(_lock==0) {
00055 _x=w->x();
00056 _y=w->y();
00057 _width=w->width();
00058 _height=w->height();
00059 _valid=true;
00060 } else {
00061 _lock--;
00062 }
00063 }
00064 }
00065
00066 class QGPGUITOOLS_EXPORT Dialog : public QDialog, public FrameGrabber
00067 {
00068 Q_OBJECT
00069 public:
00070 Dialog(QWidget * parent=0, Qt::WFlags f=0);
00071
00072 void setRect(QString name) {FrameGrabber::setRect(this, name);}
00073 void getRect(QString name) {Settings::getRect(this, name);}
00074
00075 enum Buttons {None, OkCancel, Close, TitleClose};
00076
00077 void addWidget(QWidget * w);
00078 void addButtons(Buttons b=OkCancel);
00079 void setMainWidget(QWidget * w, Buttons b=OkCancel);
00080 protected:
00081 virtual void resizeEvent(QResizeEvent * e);
00082 virtual void moveEvent(QMoveEvent * e);
00083 virtual void closeEvent(QCloseEvent * e);
00084 private:
00085 QVBoxLayout * _vboxLayout;
00086 Buttons _buttons;
00087 };
00088
00089 class QGPGUITOOLS_EXPORT FileDialog: public QFileDialog, public FrameGrabber
00090 {
00091 Q_OBJECT
00092 public:
00093 FileDialog(QWidget * parent, Qt::WFlags flags) : QFileDialog(parent, flags) {}
00094 FileDialog(QWidget * parent=0, const QString & caption=QString::null, const QString & directory=QString::null, const QString & filter=QString::null)
00095 : QFileDialog(parent, caption, directory, filter) {}
00096
00097 void setRect(QString name) {FrameGrabber::setRect(this, name);}
00098 void getRect(QString name) {Settings::getRect(this, name);}
00099 protected:
00100 virtual void resizeEvent(QResizeEvent * e);
00101 virtual void moveEvent(QMoveEvent * e);
00102 };
00103
00104 }
00105
00106 #endif // DIALOG_H