kdeui
kpixmapregionselectordialog.cpp
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 #include "kpixmapregionselectordialog.h"
00021 #include <kdialogbase.h>
00022 #include <qdialog.h>
00023 #include <qdesktopwidget.h>
00024 #include <klocale.h>
00025 #include <kdialog.h>
00026
00027 KPixmapRegionSelectorDialog::KPixmapRegionSelectorDialog(QWidget *parent,
00028 const char *name, bool modal ) : KDialogBase(parent, name, modal, i18n("Select Region of Image"), Help|Ok|Cancel, Ok, true )
00029 {
00030 QVBox *vbox=new QVBox(this);
00031 new QLabel(i18n("Please click and drag on the image to select the region of interest:"), vbox);
00032 m_pixmapSelectorWidget= new KPixmapRegionSelectorWidget(vbox);
00033
00034 vbox->setSpacing( KDialog::spacingHint() );
00035
00036 setMainWidget(vbox);
00037 }
00038
00039 KPixmapRegionSelectorDialog::~KPixmapRegionSelectorDialog()
00040 {
00041 }
00042
00043 QRect KPixmapRegionSelectorDialog::getSelectedRegion(const QPixmap &pixmap, QWidget *parent )
00044 {
00045 KPixmapRegionSelectorDialog dialog(parent);
00046
00047 dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
00048
00049 QDesktopWidget desktopWidget;
00050 QRect screen=desktopWidget.availableGeometry();
00051 dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
00052 (int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
00053
00054 int result = dialog.exec();
00055
00056 QRect rect;
00057
00058 if ( result == QDialog::Accepted )
00059 rect = dialog.pixmapRegionSelectorWidget()->unzoomedSelectedRegion();
00060
00061 return rect;
00062 }
00063
00064 QRect KPixmapRegionSelectorDialog::getSelectedRegion(const QPixmap &pixmap, int aspectRatioWidth, int aspectRatioHeight, QWidget *parent )
00065 {
00066 KPixmapRegionSelectorDialog dialog(parent);
00067
00068 dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
00069 dialog.pixmapRegionSelectorWidget()->setSelectionAspectRatio(aspectRatioWidth,aspectRatioHeight);
00070
00071 QDesktopWidget desktopWidget;
00072 QRect screen=desktopWidget.availableGeometry();
00073 dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
00074 (int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
00075
00076 int result = dialog.exec();
00077
00078 QRect rect;
00079
00080 if ( result == QDialog::Accepted )
00081 rect = dialog.pixmapRegionSelectorWidget()->unzoomedSelectedRegion();
00082
00083 return rect;
00084 }
00085
00086 QImage KPixmapRegionSelectorDialog::getSelectedImage(const QPixmap &pixmap, QWidget *parent )
00087 {
00088 KPixmapRegionSelectorDialog dialog(parent);
00089
00090 dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
00091
00092 QDesktopWidget desktopWidget;
00093 QRect screen=desktopWidget.availableGeometry();
00094 dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
00095 (int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
00096 int result = dialog.exec();
00097
00098 QImage image;
00099
00100 if ( result == QDialog::Accepted )
00101 image = dialog.pixmapRegionSelectorWidget()->selectedImage();
00102
00103 return image;
00104 }
00105
00106 QImage KPixmapRegionSelectorDialog::getSelectedImage(const QPixmap &pixmap, int aspectRatioWidth, int aspectRatioHeight, QWidget *parent )
00107 {
00108 KPixmapRegionSelectorDialog dialog(parent);
00109
00110 dialog.pixmapRegionSelectorWidget()->setPixmap(pixmap);
00111 dialog.pixmapRegionSelectorWidget()->setSelectionAspectRatio(aspectRatioWidth,aspectRatioHeight);
00112
00113 QDesktopWidget desktopWidget;
00114 QRect screen=desktopWidget.availableGeometry();
00115 dialog.pixmapRegionSelectorWidget()->setMaximumWidgetSize(
00116 (int)(screen.width()*4.0/5), (int)(screen.height()*4.0/5));
00117
00118 int result = dialog.exec();
00119
00120 QImage image;
00121
00122 if ( result == QDialog::Accepted )
00123 image = dialog.pixmapRegionSelectorWidget()->selectedImage();
00124
00125 return image;
00126 }
00127