summaryrefslogtreecommitdiff
path: root/noncore/graphics/drawpad/importdialog.cpp
Unidiff
Diffstat (limited to 'noncore/graphics/drawpad/importdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/importdialog.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/noncore/graphics/drawpad/importdialog.cpp b/noncore/graphics/drawpad/importdialog.cpp
index 1c447cb..9a59a20 100644
--- a/noncore/graphics/drawpad/importdialog.cpp
+++ b/noncore/graphics/drawpad/importdialog.cpp
@@ -1,95 +1,99 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "importdialog.h" 14#include "importdialog.h"
15 15
16#include <qpe/applnk.h> 16#include <qpe/applnk.h>
17#include <qpe/fileselector.h> 17#include <opie/ofileselector.h>
18 18
19#include <qcheckbox.h> 19#include <qcheckbox.h>
20#include <qimage.h> 20#include <qimage.h>
21#include <qlabel.h> 21#include <qlabel.h>
22#include <qlayout.h> 22#include <qlayout.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24 24
25ImportDialog::ImportDialog(QWidget* parent, const char* name) 25ImportDialog::ImportDialog(QWidget* parent, const char* name)
26 : QDialog(parent, name, true) 26 : QDialog(parent, name, true)
27{ 27{
28 setCaption(tr("DrawPad - Import")); 28 setCaption(tr("DrawPad - Import"));
29 29
30 m_pFileSelector = new FileSelector("image/*", this, "fileselector"); 30 MimeTypes types; types.insert( tr("All images"),"image/*" );
31 m_pFileSelector = new OFileSelector(this,
32 OFileSelector::FileSelector,
33 OFileSelector::Normal,
34 QString::null,
35 QString::null, types );
36 m_pFileSelector->setNameVisible( false );
31 connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged())); 37 connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged()));
32 m_pFileSelector->setNewVisible(false);
33 m_pFileSelector->setCloseVisible(false);
34 38
35 m_pPreviewLabel = new QLabel(this); 39 m_pPreviewLabel = new QLabel(this);
36 m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); 40 m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
37 m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 41 m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
38 m_pPreviewLabel->setFixedSize(114, 114); 42 m_pPreviewLabel->setFixedSize(114, 114);
39 m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid); 43 m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid);
40 44
41 m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this); 45 m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this);
42 m_pAutomaticPreviewCheckBox->setChecked(true); 46 m_pAutomaticPreviewCheckBox->setChecked(true);
43 47
44 QPushButton* previewPushButton = new QPushButton(tr("Preview"), this); 48 QPushButton* previewPushButton = new QPushButton(tr("Preview"), this);
45 connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview())); 49 connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview()));
46 50
47 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 51 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
48 QHBoxLayout* previewLayout = new QHBoxLayout(4); 52 QHBoxLayout* previewLayout = new QHBoxLayout(4);
49 QVBoxLayout* previewSecondLayout = new QVBoxLayout(4); 53 QVBoxLayout* previewSecondLayout = new QVBoxLayout(4);
50 54
51 previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox); 55 previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox);
52 previewSecondLayout->addWidget(previewPushButton); 56 previewSecondLayout->addWidget(previewPushButton);
53 previewSecondLayout->addStretch(); 57 previewSecondLayout->addStretch();
54 58
55 previewLayout->addWidget(m_pPreviewLabel); 59 previewLayout->addWidget(m_pPreviewLabel);
56 previewLayout->addLayout(previewSecondLayout); 60 previewLayout->addLayout(previewSecondLayout);
57 61
58 mainLayout->addWidget(m_pFileSelector); 62 mainLayout->addWidget(m_pFileSelector);
59 mainLayout->addLayout(previewLayout); 63 mainLayout->addLayout(previewLayout);
60 64
61 preview(); 65 preview();
62} 66}
63 67
64ImportDialog::~ImportDialog() 68ImportDialog::~ImportDialog()
65{ 69{
66} 70}
67 71
68const DocLnk* ImportDialog::selected() 72const DocLnk* ImportDialog::selected()
69{ 73{
70 // FIXME change from pointer to reference -zecke 74 // FIXME change from pointer to reference -zecke
71 DocLnk *lnk = new DocLnk( m_pFileSelector->selectedDocument() ); 75 DocLnk *lnk = new DocLnk( m_pFileSelector->selectedDocument() );
72 return lnk; 76 return lnk;
73} 77}
74 78
75void ImportDialog::fileChanged() 79void ImportDialog::fileChanged()
76{ 80{
77 if (m_pAutomaticPreviewCheckBox->isChecked()) { 81 if (m_pAutomaticPreviewCheckBox->isChecked()) {
78 preview(); 82 preview();
79 } 83 }
80} 84}
81 85
82void ImportDialog::preview() 86void ImportDialog::preview()
83{ 87{
84 const DocLnk* docLnk = selected(); 88 const DocLnk* docLnk = selected();
85 89
86 if (docLnk) { 90 if (docLnk) {
87 QImage image(docLnk->file()); 91 QImage image(docLnk->file());
88 92
89 int previewWidth = m_pPreviewLabel->contentsRect().width(); 93 int previewWidth = m_pPreviewLabel->contentsRect().width();
90 int previewHeight = m_pPreviewLabel->contentsRect().height(); 94 int previewHeight = m_pPreviewLabel->contentsRect().height();
91 95
92 float widthScale = 1.0; 96 float widthScale = 1.0;
93 float heightScale = 1.0; 97 float heightScale = 1.0;
94 98
95 if (previewWidth < image.width()) { 99 if (previewWidth < image.width()) {