summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/exportdialog.cpp2
-rw-r--r--noncore/graphics/drawpad/importdialog.cpp2
-rw-r--r--noncore/graphics/drawpad/thumbnailview.cpp2
3 files changed, 3 insertions, 3 deletions
diff --git a/noncore/graphics/drawpad/exportdialog.cpp b/noncore/graphics/drawpad/exportdialog.cpp
index 0a980fc..5b11c0e 100644
--- a/noncore/graphics/drawpad/exportdialog.cpp
+++ b/noncore/graphics/drawpad/exportdialog.cpp
@@ -1,129 +1,129 @@
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 "exportdialog.h" 14#include "exportdialog.h"
15 15
16#include <qpe/fileselector.h> 16#include <qpe/fileselector.h>
17 17
18#include <qbuttongroup.h> 18#include <qbuttongroup.h>
19#include <qcombobox.h> 19#include <qcombobox.h>
20#include <qgroupbox.h> 20#include <qgroupbox.h>
21#include <qimage.h> 21#include <qimage.h>
22#include <qlabel.h> 22#include <qlabel.h>
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qlineedit.h> 24#include <qlineedit.h>
25#include <qradiobutton.h> 25#include <qradiobutton.h>
26#include <qspinbox.h> 26#include <qspinbox.h>
27 27
28#include <stdlib.h> 28#include <stdlib.h>
29 29
30ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name) 30ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name)
31 : QDialog(parent, name, true) 31 : QDialog(parent, name, true)
32{ 32{
33 setCaption(tr("Export")); 33 setCaption(tr("DrawPad - Export"));
34 34
35 m_pageAt = pageAt; 35 m_pageAt = pageAt;
36 m_pageCount = pageCount; 36 m_pageCount = pageCount;
37 37
38 QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this); 38 QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this);
39 connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int))); 39 connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int)));
40 40
41 QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup); 41 QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup);
42 QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup); 42 QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup);
43 QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup); 43 QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup);
44 44
45 QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup); 45 QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup);
46 46
47 m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); 47 m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
48 connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int))); 48 connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int)));
49 49
50 m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup); 50 m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
51 connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int))); 51 connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int)));
52 52
53 selectionButtonGroup->setButton(1); 53 selectionButtonGroup->setButton(1);
54 selectionChanged(1); 54 selectionChanged(1);
55 55
56 m_pFromPageSpinBox->setValue(pageAt); 56 m_pFromPageSpinBox->setValue(pageAt);
57 m_pToPageSpinBox->setValue(pageAt); 57 m_pToPageSpinBox->setValue(pageAt);
58 58
59 QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this); 59 QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this);
60 60
61 QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox); 61 QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox);
62 QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox); 62 QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox);
63 63
64 m_pNameLineEdit = new QLineEdit(exportGroupBox); 64 m_pNameLineEdit = new QLineEdit(exportGroupBox);
65 65
66 m_pFormatComboBox = new QComboBox(exportGroupBox); 66 m_pFormatComboBox = new QComboBox(exportGroupBox);
67 m_pFormatComboBox->insertStrList(QImageIO::outputFormats()); 67 m_pFormatComboBox->insertStrList(QImageIO::outputFormats());
68 68
69 FileSelector* fileSelector = new FileSelector("image/*", this, "fileselector"); 69 FileSelector* fileSelector = new FileSelector("image/*", this, "fileselector");
70 fileSelector->setNewVisible(false); 70 fileSelector->setNewVisible(false);
71 fileSelector->setCloseVisible(false); 71 fileSelector->setCloseVisible(false);
72 72
73 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 73 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
74 selectionButtonGroup->layout()->setSpacing(4); 74 selectionButtonGroup->layout()->setSpacing(4);
75 exportGroupBox->layout()->setSpacing(4); 75 exportGroupBox->layout()->setSpacing(4);
76 QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2); 76 QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2);
77 QHBoxLayout* rangeLayout = new QHBoxLayout(); 77 QHBoxLayout* rangeLayout = new QHBoxLayout();
78 QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2); 78 QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2);
79 79
80 selectionLayout->addWidget(selectAllRadioButton, 0, 0); 80 selectionLayout->addWidget(selectAllRadioButton, 0, 0);
81 selectionLayout->addWidget(selectCurrentRadioButton, 1, 0); 81 selectionLayout->addWidget(selectCurrentRadioButton, 1, 0);
82 selectionLayout->addWidget(selectRangeRadioButton, 0, 1); 82 selectionLayout->addWidget(selectRangeRadioButton, 0, 1);
83 selectionLayout->addLayout(rangeLayout, 1, 1); 83 selectionLayout->addLayout(rangeLayout, 1, 1);
84 84
85 rangeLayout->addWidget(m_pFromPageSpinBox); 85 rangeLayout->addWidget(m_pFromPageSpinBox);
86 rangeLayout->addWidget(toLabel); 86 rangeLayout->addWidget(toLabel);
87 rangeLayout->addWidget(m_pToPageSpinBox); 87 rangeLayout->addWidget(m_pToPageSpinBox);
88 88
89 exportLayout->addWidget(nameLabel, 0, 0); 89 exportLayout->addWidget(nameLabel, 0, 0);
90 exportLayout->addWidget(formatLabel, 1, 0); 90 exportLayout->addWidget(formatLabel, 1, 0);
91 91
92 exportLayout->addWidget(m_pNameLineEdit, 0, 1); 92 exportLayout->addWidget(m_pNameLineEdit, 0, 1);
93 exportLayout->addWidget(m_pFormatComboBox, 1, 1); 93 exportLayout->addWidget(m_pFormatComboBox, 1, 1);
94 94
95 exportLayout->setColStretch(1, 1); 95 exportLayout->setColStretch(1, 1);
96 96
97 mainLayout->addWidget(selectionButtonGroup); 97 mainLayout->addWidget(selectionButtonGroup);
98 mainLayout->addWidget(exportGroupBox); 98 mainLayout->addWidget(exportGroupBox);
99 mainLayout->addWidget(fileSelector); 99 mainLayout->addWidget(fileSelector);
100 100
101 m_pNameLineEdit->setFocus(); 101 m_pNameLineEdit->setFocus();
102} 102}
103 103
104ExportDialog::~ExportDialog() 104ExportDialog::~ExportDialog()
105{ 105{
106} 106}
107 107
108uint ExportDialog::selectedFromPage() 108uint ExportDialog::selectedFromPage()
109{ 109{
110 return (m_pFromPageSpinBox->value()); 110 return (m_pFromPageSpinBox->value());
111} 111}
112 112
113uint ExportDialog::selectedToPage() 113uint ExportDialog::selectedToPage()
114{ 114{
115 return (m_pToPageSpinBox->value()); 115 return (m_pToPageSpinBox->value());
116} 116}
117 117
118QString ExportDialog::selectedName() 118QString ExportDialog::selectedName()
119{ 119{
120 return (m_pNameLineEdit->text()); 120 return (m_pNameLineEdit->text());
121} 121}
122 122
123QString ExportDialog::selectedFormat() 123QString ExportDialog::selectedFormat()
124{ 124{
125 return (m_pFormatComboBox->currentText()); 125 return (m_pFormatComboBox->currentText());
126} 126}
127 127
128void ExportDialog::accept() 128void ExportDialog::accept()
129{ 129{
diff --git a/noncore/graphics/drawpad/importdialog.cpp b/noncore/graphics/drawpad/importdialog.cpp
index 645111e..0783ed8 100644
--- a/noncore/graphics/drawpad/importdialog.cpp
+++ b/noncore/graphics/drawpad/importdialog.cpp
@@ -1,111 +1,111 @@
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 <qpe/fileselector.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("Import")); 28 setCaption(tr("DrawPad - Import"));
29 29
30 m_pFileSelector = new FileSelector("image/*", this, "fileselector"); 30 m_pFileSelector = new FileSelector("image/*", this, "fileselector");
31 connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged())); 31 connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged()));
32 m_pFileSelector->setNewVisible(false); 32 m_pFileSelector->setNewVisible(false);
33 m_pFileSelector->setCloseVisible(false); 33 m_pFileSelector->setCloseVisible(false);
34 34
35 m_pPreviewLabel = new QLabel(this); 35 m_pPreviewLabel = new QLabel(this);
36 m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); 36 m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
37 m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); 37 m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
38 m_pPreviewLabel->setFixedSize(114, 114); 38 m_pPreviewLabel->setFixedSize(114, 114);
39 m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid); 39 m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid);
40 40
41 m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this); 41 m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this);
42 m_pAutomaticPreviewCheckBox->setChecked(true); 42 m_pAutomaticPreviewCheckBox->setChecked(true);
43 43
44 QPushButton* previewPushButton = new QPushButton(tr("Preview"), this); 44 QPushButton* previewPushButton = new QPushButton(tr("Preview"), this);
45 connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview())); 45 connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview()));
46 46
47 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 47 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
48 QHBoxLayout* previewLayout = new QHBoxLayout(4); 48 QHBoxLayout* previewLayout = new QHBoxLayout(4);
49 QVBoxLayout* previewSecondLayout = new QVBoxLayout(4); 49 QVBoxLayout* previewSecondLayout = new QVBoxLayout(4);
50 50
51 previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox); 51 previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox);
52 previewSecondLayout->addWidget(previewPushButton); 52 previewSecondLayout->addWidget(previewPushButton);
53 previewSecondLayout->addStretch(); 53 previewSecondLayout->addStretch();
54 54
55 previewLayout->addWidget(m_pPreviewLabel); 55 previewLayout->addWidget(m_pPreviewLabel);
56 previewLayout->addLayout(previewSecondLayout); 56 previewLayout->addLayout(previewSecondLayout);
57 57
58 mainLayout->addWidget(m_pFileSelector); 58 mainLayout->addWidget(m_pFileSelector);
59 mainLayout->addLayout(previewLayout); 59 mainLayout->addLayout(previewLayout);
60 60
61 preview(); 61 preview();
62} 62}
63 63
64ImportDialog::~ImportDialog() 64ImportDialog::~ImportDialog()
65{ 65{
66} 66}
67 67
68const DocLnk* ImportDialog::selected() 68const DocLnk* ImportDialog::selected()
69{ 69{
70 return m_pFileSelector->selected(); 70 return m_pFileSelector->selected();
71} 71}
72 72
73void ImportDialog::fileChanged() 73void ImportDialog::fileChanged()
74{ 74{
75 if (m_pAutomaticPreviewCheckBox->isChecked()) { 75 if (m_pAutomaticPreviewCheckBox->isChecked()) {
76 preview(); 76 preview();
77 } 77 }
78} 78}
79 79
80void ImportDialog::preview() 80void ImportDialog::preview()
81{ 81{
82 const DocLnk* docLnk = m_pFileSelector->selected(); 82 const DocLnk* docLnk = m_pFileSelector->selected();
83 83
84 if (docLnk) { 84 if (docLnk) {
85 QImage image(docLnk->file()); 85 QImage image(docLnk->file());
86 86
87 int previewWidth = m_pPreviewLabel->contentsRect().width(); 87 int previewWidth = m_pPreviewLabel->contentsRect().width();
88 int previewHeight = m_pPreviewLabel->contentsRect().height(); 88 int previewHeight = m_pPreviewLabel->contentsRect().height();
89 89
90 float widthScale = 1.0; 90 float widthScale = 1.0;
91 float heightScale = 1.0; 91 float heightScale = 1.0;
92 92
93 if (previewWidth < image.width()) { 93 if (previewWidth < image.width()) {
94 widthScale = (float)previewWidth / float(image.width()); 94 widthScale = (float)previewWidth / float(image.width());
95 } 95 }
96 96
97 if (previewHeight < image.height()) { 97 if (previewHeight < image.height()) {
98 heightScale = (float)previewHeight / float(image.height()); 98 heightScale = (float)previewHeight / float(image.height());
99 } 99 }
100 100
101 float scale = (widthScale < heightScale ? widthScale : heightScale); 101 float scale = (widthScale < heightScale ? widthScale : heightScale);
102 QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); 102 QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale));
103 103
104 QPixmap previewPixmap; 104 QPixmap previewPixmap;
105 previewPixmap.convertFromImage(previewImage); 105 previewPixmap.convertFromImage(previewImage);
106 106
107 m_pPreviewLabel->setPixmap(previewPixmap); 107 m_pPreviewLabel->setPixmap(previewPixmap);
108 108
109 delete docLnk; 109 delete docLnk;
110 } 110 }
111} 111}
diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp
index 08e106d..0c7934e 100644
--- a/noncore/graphics/drawpad/thumbnailview.cpp
+++ b/noncore/graphics/drawpad/thumbnailview.cpp
@@ -60,193 +60,193 @@ PageListViewItem::PageListViewItem(Page* page, QListView* parent)
60 bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2, 60 bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2,
61 (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap); 61 (pixmap.height() - previewPixmap.height()) / 2, &previewPixmap);
62 62
63 setPixmap(0, pixmap); 63 setPixmap(0, pixmap);
64} 64}
65 65
66PageListViewItem::~PageListViewItem() 66PageListViewItem::~PageListViewItem()
67{ 67{
68} 68}
69 69
70Page* PageListViewItem::page() const 70Page* PageListViewItem::page() const
71{ 71{
72 return m_pPage; 72 return m_pPage;
73} 73}
74 74
75PageListView::PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) 75PageListView::PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
76 : QListView(parent, name) 76 : QListView(parent, name)
77{ 77{
78 m_pDrawPadCanvas = drawPadCanvas; 78 m_pDrawPadCanvas = drawPadCanvas;
79 79
80 header()->hide(); 80 header()->hide();
81 setVScrollBarMode(QScrollView::AlwaysOn); 81 setVScrollBarMode(QScrollView::AlwaysOn);
82 setAllColumnsShowFocus(true); 82 setAllColumnsShowFocus(true);
83 83
84 addColumn(tr("Thumbnail")); 84 addColumn(tr("Thumbnail"));
85 addColumn(tr("Information")); 85 addColumn(tr("Information"));
86 86
87 updateView(); 87 updateView();
88} 88}
89 89
90PageListView::~PageListView() 90PageListView::~PageListView()
91{ 91{
92} 92}
93 93
94void PageListView::updateView() 94void PageListView::updateView()
95{ 95{
96 clear(); 96 clear();
97 97
98 if (m_pDrawPadCanvas) { 98 if (m_pDrawPadCanvas) {
99 QList<Page> pageList = m_pDrawPadCanvas->pages(); 99 QList<Page> pageList = m_pDrawPadCanvas->pages();
100 QListIterator<Page> it(pageList); 100 QListIterator<Page> it(pageList);
101 101
102 for (; it.current(); ++it) { 102 for (; it.current(); ++it) {
103 new PageListViewItem(it.current(), this); 103 new PageListViewItem(it.current(), this);
104 } 104 }
105 105
106 setSorting(0, false); 106 setSorting(0, false);
107 select(m_pDrawPadCanvas->currentPage()); 107 select(m_pDrawPadCanvas->currentPage());
108 } 108 }
109} 109}
110 110
111void PageListView::resizeEvent(QResizeEvent* e) 111void PageListView::resizeEvent(QResizeEvent* e)
112{ 112{
113 Q_UNUSED(e); 113 Q_UNUSED(e);
114 114
115 setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width()); 115 setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width());
116} 116}
117 117
118void PageListView::select(Page* page) 118void PageListView::select(Page* page)
119{ 119{
120 PageListViewItem* item = (PageListViewItem*)firstChild(); 120 PageListViewItem* item = (PageListViewItem*)firstChild();
121 121
122 while (item) { 122 while (item) {
123 if (item->page() == page) { 123 if (item->page() == page) {
124 setSelected(item, true); 124 setSelected(item, true);
125 ensureItemVisible(item); 125 ensureItemVisible(item);
126 break; 126 break;
127 } 127 }
128 128
129 item = (PageListViewItem*)(item->nextSibling()); 129 item = (PageListViewItem*)(item->nextSibling());
130 } 130 }
131} 131}
132 132
133Page* PageListView::selected() const 133Page* PageListView::selected() const
134{ 134{
135 Page* page; 135 Page* page;
136 136
137 PageListViewItem* item = (PageListViewItem*)selectedItem(); 137 PageListViewItem* item = (PageListViewItem*)selectedItem();
138 138
139 if (item) { 139 if (item) {
140 page = item->page(); 140 page = item->page();
141 } else { 141 } else {
142 page = NULL; 142 page = NULL;
143 } 143 }
144 144
145 return page; 145 return page;
146} 146}
147 147
148ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) 148ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
149 : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) 149 : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel)
150{ 150{
151 inLoop = false; 151 inLoop = false;
152 152
153 m_pDrawPad = drawPad; 153 m_pDrawPad = drawPad;
154 m_pDrawPadCanvas = drawPadCanvas; 154 m_pDrawPadCanvas = drawPadCanvas;
155 155
156 setCaption(tr("Thumbnail")); 156 setCaption(tr("DrawPad - Thumbnail View"));
157 157
158 QToolButton* newPageButton = new QToolButton(this); 158 QToolButton* newPageButton = new QToolButton(this);
159 newPageButton->setIconSet(Resource::loadIconSet("new")); 159 newPageButton->setIconSet(Resource::loadIconSet("new"));
160 newPageButton->setAutoRaise(true); 160 newPageButton->setAutoRaise(true);
161 connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); 161 connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage()));
162 162
163 QToolButton* clearPageButton = new QToolButton(this); 163 QToolButton* clearPageButton = new QToolButton(this);
164 clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); 164 clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear"));
165 clearPageButton->setAutoRaise(true); 165 clearPageButton->setAutoRaise(true);
166 connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); 166 connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage()));
167 167
168 QToolButton* deletePageButton = new QToolButton(this); 168 QToolButton* deletePageButton = new QToolButton(this);
169 deletePageButton->setIconSet(Resource::loadIconSet("trash")); 169 deletePageButton->setIconSet(Resource::loadIconSet("trash"));
170 deletePageButton->setAutoRaise(true); 170 deletePageButton->setAutoRaise(true);
171 connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); 171 connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage()));
172 172
173 QToolButton* movePageUpButton = new QToolButton(this); 173 QToolButton* movePageUpButton = new QToolButton(this);
174 movePageUpButton->setIconSet(Resource::loadIconSet("up")); 174 movePageUpButton->setIconSet(Resource::loadIconSet("up"));
175 movePageUpButton->setAutoRaise(true); 175 movePageUpButton->setAutoRaise(true);
176 176
177 QToolButton* movePageDownButton = new QToolButton(this); 177 QToolButton* movePageDownButton = new QToolButton(this);
178 movePageDownButton->setIconSet(Resource::loadIconSet("down")); 178 movePageDownButton->setIconSet(Resource::loadIconSet("down"));
179 movePageDownButton->setAutoRaise(true); 179 movePageDownButton->setAutoRaise(true);
180 180
181 m_pPageListView = new PageListView(m_pDrawPadCanvas, this); 181 m_pPageListView = new PageListView(m_pDrawPadCanvas, this);
182 connect(m_pPageListView, SIGNAL(selectionChanged()), this, SLOT(changePage())); 182 connect(m_pPageListView, SIGNAL(selectionChanged()), this, SLOT(changePage()));
183 183
184 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); 184 QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
185 QHBoxLayout* buttonLayout = new QHBoxLayout(0); 185 QHBoxLayout* buttonLayout = new QHBoxLayout(0);
186 186
187 buttonLayout->addWidget(newPageButton); 187 buttonLayout->addWidget(newPageButton);
188 buttonLayout->addWidget(clearPageButton); 188 buttonLayout->addWidget(clearPageButton);
189 buttonLayout->addWidget(deletePageButton); 189 buttonLayout->addWidget(deletePageButton);
190 buttonLayout->addStretch(); 190 buttonLayout->addStretch();
191 buttonLayout->addWidget(movePageUpButton); 191 buttonLayout->addWidget(movePageUpButton);
192 buttonLayout->addWidget(movePageDownButton); 192 buttonLayout->addWidget(movePageDownButton);
193 193
194 mainLayout->addLayout(buttonLayout); 194 mainLayout->addLayout(buttonLayout);
195 mainLayout->addWidget(m_pPageListView); 195 mainLayout->addWidget(m_pPageListView);
196} 196}
197 197
198ThumbnailView::~ThumbnailView() 198ThumbnailView::~ThumbnailView()
199{ 199{
200 hide(); 200 hide();
201} 201}
202 202
203void ThumbnailView::hide() 203void ThumbnailView::hide()
204{ 204{
205 QWidget::hide(); 205 QWidget::hide();
206 206
207 if (inLoop) { 207 if (inLoop) {
208 inLoop = false; 208 inLoop = false;
209 qApp->exit_loop(); 209 qApp->exit_loop();
210 } 210 }
211} 211}
212 212
213void ThumbnailView::exec() 213void ThumbnailView::exec()
214{ 214{
215 show(); 215 show();
216 216
217 if (!inLoop) { 217 if (!inLoop) {
218 inLoop = true; 218 inLoop = true;
219 qApp->enter_loop(); 219 qApp->enter_loop();
220 } 220 }
221} 221}
222 222
223void ThumbnailView::newPage() 223void ThumbnailView::newPage()
224{ 224{
225 QRect rect = m_pDrawPadCanvas->contentsRect(); 225 QRect rect = m_pDrawPadCanvas->contentsRect();
226 226
227 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(), 227 NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(),
228 m_pDrawPad->brush().color(), this); 228 m_pDrawPad->brush().color(), this);
229 229
230 if (newPageDialog.exec() == QDialog::Accepted) { 230 if (newPageDialog.exec() == QDialog::Accepted) {
231 m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(), 231 m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(),
232 newPageDialog.selectedColor()); 232 newPageDialog.selectedColor());
233 m_pPageListView->updateView(); 233 m_pPageListView->updateView();
234 } 234 }
235} 235}
236 236
237void ThumbnailView::clearPage() 237void ThumbnailView::clearPage()
238{ 238{
239 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"), 239 QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected page?"),
240 QMessageBox::Information, QMessageBox::Yes, 240 QMessageBox::Information, QMessageBox::Yes,
241 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default, 241 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
242 QMessageBox::NoButton, this); 242 QMessageBox::NoButton, this);
243 243
244 messageBox.setButtonText(QMessageBox::Yes, tr("Yes")); 244 messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
245 messageBox.setButtonText(QMessageBox::No, tr("No")); 245 messageBox.setButtonText(QMessageBox::No, tr("No"));
246 246
247 if (messageBox.exec() == QMessageBox::Yes) { 247 if (messageBox.exec() == QMessageBox::Yes) {
248 m_pDrawPadCanvas->clearPage(); 248 m_pDrawPadCanvas->clearPage();
249 m_pPageListView->updateView(); 249 m_pPageListView->updateView();
250 } 250 }
251} 251}
252 252