• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

kpixmapregionselectordialog.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 2004 Antonio Larrosa <larrosa@kde.org
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
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 
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 

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal