Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

exportdialog.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   DrawPad - a drawing program for Opie Environment                      *
00004  *                                                                         *
00005  *   (C) 2002 by S. Prud'homme <prudhomme@laposte.net>                     *
00006  *                                                                         *
00007  *   This program is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU General Public License as published by  *
00009  *   the Free Software Foundation; either version 2 of the License, or     *
00010  *   (at your option) any later version.                                   *
00011  *                                                                         *
00012  ***************************************************************************/
00013 
00014 #include "exportdialog.h"
00015 
00016 #include <opie2/ofileselector.h>
00017 
00018 #include <qbuttongroup.h>
00019 #include <qcombobox.h>
00020 #include <qimage.h>
00021 #include <qlabel.h>
00022 #include <qlayout.h>
00023 #include <qlineedit.h>
00024 #include <qradiobutton.h>
00025 #include <qspinbox.h>
00026 
00027 #include <stdlib.h>
00028 
00029 using namespace Opie::Ui;
00030 ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name)
00031     : QDialog(parent, name, true)
00032 {
00033     setCaption(tr("DrawPad - Export"));
00034 
00035     m_pageAt = pageAt;
00036     m_pageCount = pageCount;
00037 
00038     QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this);
00039     connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int)));
00040 
00041     QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup);
00042     QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup);
00043     QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup);
00044 
00045     QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup);
00046 
00047     m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
00048     connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int)));
00049 
00050     m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
00051     connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int)));
00052 
00053     selectionButtonGroup->setButton(1);
00054     selectionChanged(1);
00055 
00056     m_pFromPageSpinBox->setValue(pageAt);
00057     m_pToPageSpinBox->setValue(pageAt);
00058 
00059     QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this);
00060 
00061     QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox);
00062     QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox);
00063 
00064     m_pNameLineEdit = new QLineEdit(exportGroupBox);
00065 
00066     m_pFormatComboBox = new QComboBox(exportGroupBox);
00067     m_pFormatComboBox->insertStrList(QImageIO::outputFormats());
00068 
00069     MimeTypes types; types.insert( tr("All Images"), "image/*" );
00070     OFileSelector* fileSelector = new OFileSelector(this, OFileSelector::FileSelector,
00071                                                    OFileSelector::Normal,
00072                                                    QString::null, QString::null,
00073                                                    types );
00074     fileSelector->setNameVisible( false );
00075 
00076     QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
00077     selectionButtonGroup->layout()->setSpacing(4);
00078     exportGroupBox->layout()->setSpacing(4);
00079     QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2);
00080     QHBoxLayout* rangeLayout = new QHBoxLayout();
00081     QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2);
00082 
00083     selectionLayout->addWidget(selectAllRadioButton, 0, 0);
00084     selectionLayout->addWidget(selectCurrentRadioButton, 1, 0);
00085     selectionLayout->addWidget(selectRangeRadioButton, 0, 1);
00086     selectionLayout->addLayout(rangeLayout, 1, 1);
00087 
00088     rangeLayout->addWidget(m_pFromPageSpinBox);
00089     rangeLayout->addWidget(toLabel);
00090     rangeLayout->addWidget(m_pToPageSpinBox);
00091 
00092     exportLayout->addWidget(nameLabel, 0, 0);
00093     exportLayout->addWidget(formatLabel, 1, 0);
00094 
00095     exportLayout->addWidget(m_pNameLineEdit, 0, 1);
00096     exportLayout->addWidget(m_pFormatComboBox, 1, 1);
00097 
00098     exportLayout->setColStretch(1, 1);
00099 
00100     mainLayout->addWidget(selectionButtonGroup);
00101     mainLayout->addWidget(exportGroupBox);
00102     mainLayout->addWidget(fileSelector);
00103 
00104     m_pNameLineEdit->setFocus();
00105 }
00106 
00107 ExportDialog::~ExportDialog()
00108 {
00109 }
00110 
00111 uint ExportDialog::selectedFromPage()
00112 {
00113     return (m_pFromPageSpinBox->value());
00114 }
00115 
00116 uint ExportDialog::selectedToPage()
00117 {
00118     return (m_pToPageSpinBox->value());
00119 }
00120 
00121 QString ExportDialog::selectedName()
00122 {
00123     return (m_pNameLineEdit->text());
00124 }
00125 
00126 QString ExportDialog::selectedFormat()
00127 {
00128     return (m_pFormatComboBox->currentText());
00129 }
00130 
00131 void ExportDialog::accept()
00132 {
00133     if (!(m_pNameLineEdit->text().isEmpty())) {
00134         QDialog::accept();
00135     }
00136 }
00137 
00138 void ExportDialog::selectionChanged(int id)
00139 {
00140     switch (id) {
00141         case 0:
00142             m_pFromPageSpinBox->setValue(1);
00143             m_pToPageSpinBox->setValue(m_pageCount);
00144 
00145             m_pFromPageSpinBox->setEnabled(false);
00146             m_pToPageSpinBox->setEnabled(false);
00147             break;
00148         case 1:
00149             m_pFromPageSpinBox->setValue(m_pageAt);
00150             m_pToPageSpinBox->setValue(m_pageAt);
00151 
00152             m_pFromPageSpinBox->setEnabled(false);
00153             m_pToPageSpinBox->setEnabled(false);
00154             break;
00155         case 2:
00156             m_pFromPageSpinBox->setEnabled(true);
00157             m_pToPageSpinBox->setEnabled(true);
00158             break;
00159         default:
00160             break;
00161     }
00162 }
00163 
00164 void ExportDialog::fromPageChanged(int value)
00165 {
00166     if (m_pToPageSpinBox->value() < value) {
00167         m_pToPageSpinBox->setValue(value);
00168     }
00169 }
00170 
00171 void ExportDialog::toPageChanged(int value)
00172 {
00173     if (m_pFromPageSpinBox->value() > value) {
00174         m_pFromPageSpinBox->setValue(value);
00175     }
00176 }

Generated on Sat Nov 5 16:17:29 2005 for OPIE by  doxygen 1.4.2