summaryrefslogtreecommitdiff
path: root/noncore/graphics/drawpad
authorkergoth <kergoth>2003-08-09 16:24:58 (UTC)
committer kergoth <kergoth>2003-08-09 16:24:58 (UTC)
commite16d333ec2e8509fc665921ca106c25325bae9e0 (patch) (side-by-side diff)
tree9e9068190a15bc9b2a52ab33b40881128f732c0e /noncore/graphics/drawpad
parent1c58d1407f9584fedcdae390a04e2b37e5853361 (diff)
downloadopie-e16d333ec2e8509fc665921ca106c25325bae9e0.zip
opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.gz
opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.bz2
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/graphics/drawpad') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp6
-rw-r--r--noncore/graphics/drawpad/drawpad.h1
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp20
-rw-r--r--noncore/graphics/drawpad/exportdialog.cpp11
-rw-r--r--noncore/graphics/drawpad/importdialog.cpp14
-rw-r--r--noncore/graphics/drawpad/importdialog.h4
-rw-r--r--noncore/graphics/drawpad/main.cpp2
-rw-r--r--noncore/graphics/drawpad/opie-drawpad.control2
-rw-r--r--noncore/graphics/drawpad/texttool.h1
9 files changed, 44 insertions, 17 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 4db6208..aac6bc1 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -233,108 +233,114 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
m_pTool = 0;
setRectangleTool();
setEllipseTool();
setPointTool();
emptyToolBar = new QPEToolBar(this);
emptyToolBar->setHorizontalStretchable(true);
emptyToolBar->addSeparator();
// init draw parameters toolbar
QPEToolBar* drawParametersToolBar = new QPEToolBar(this);
m_pPenWidthSpinBox = new QSpinBox(1, 9, 1, drawParametersToolBar);
connect(m_pPenWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
QToolTip::add(m_pPenWidthSpinBox, tr("Pen Width"));
m_pPenWidthSpinBox->setValue(1);
m_pPenWidthSpinBox->setFocusPolicy(QWidget::NoFocus);
QWhatsThis::add( m_pPenWidthSpinBox, tr( "Click here to select the width of the drawing pen." ) );
m_pPenColorToolButton = new QToolButton(drawParametersToolBar);
m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor"));
QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) );
OColorPopupMenu* penColorPopupMenu = new OColorPopupMenu(Qt::black, m_pPenColorToolButton);
connect(penColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changePenColor(const QColor&)));
QToolTip::add(m_pPenColorToolButton, tr("Pen Color"));
m_pPenColorToolButton->setPopup(penColorPopupMenu);
m_pPenColorToolButton->setPopupDelay(0);
changePenColor(Qt::black);
m_pBrushColorToolButton = new QToolButton(drawParametersToolBar);
m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor"));
QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) );
OColorPopupMenu* brushColorPopupMenu = new OColorPopupMenu(Qt::white, m_pBrushColorToolButton);
connect(brushColorPopupMenu, SIGNAL(colorSelected(const QColor&)), this, SLOT(changeBrushColor(const QColor&)));
QToolTip::add(m_pBrushColorToolButton, tr("Fill Color"));
m_pBrushColorToolButton->setPopup(brushColorPopupMenu);
m_pBrushColorToolButton->setPopupDelay(0);
changeBrushColor(Qt::white);
+}
+
+
+void DrawPad::finishStartup()
+{
// init pages
QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
if (file.open(IO_ReadOnly)) {
m_pDrawPadCanvas->load(&file);
file.close();
} else {
m_pDrawPadCanvas->initialPage();
}
loadConfig();
+
}
DrawPad::~DrawPad()
{
saveConfig();
QFile file(Global::applicationFileName("drawpad", "drawpad.xml"));
if (file.open(IO_WriteOnly)) {
m_pDrawPadCanvas->save(&file);
file.close();
}
}
bool DrawPad::antiAliasing()
{
return (m_pAntiAliasingAction->isOn());
}
void DrawPad::newPage()
{
QRect rect = m_pDrawPadCanvas->contentsRect();
NewPageDialog newPageDialog(rect.width(), rect.height(), m_pen.color(), m_brush.color(), this);
if (newPageDialog.exec() == QDialog::Accepted) {
m_pDrawPadCanvas->newPage(newPageDialog.selectedTitle(), newPageDialog.selectedWidth(),
newPageDialog.selectedHeight(), newPageDialog.selectedColor());
}
}
void DrawPad::clearPage()
{
QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe current page?"),
QMessageBox::Information, QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default,
QMessageBox::NoButton, this);
messageBox.setButtonText(QMessageBox::Yes, tr("Yes"));
messageBox.setButtonText(QMessageBox::No, tr("No"));
if (messageBox.exec() == QMessageBox::Yes) {
m_pDrawPadCanvas->clearPage();
}
}
void DrawPad::deletePage()
{
diff --git a/noncore/graphics/drawpad/drawpad.h b/noncore/graphics/drawpad/drawpad.h
index 7306228..2cae700 100644
--- a/noncore/graphics/drawpad/drawpad.h
+++ b/noncore/graphics/drawpad/drawpad.h
@@ -1,90 +1,91 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef DRAWPAD_H
#define DRAWPAD_H
#include <qmainwindow.h>
#include <qpen.h>
class DrawPadCanvas;
class Tool;
class QAction;
class QColor;
class QSpinBox;
class QToolButton;
class QWidgetStack;
class DrawPad : public QMainWindow
{
Q_OBJECT
public:
DrawPad(QWidget* parent = 0, const char* name = 0);
~DrawPad();
Tool* tool() { return m_pTool; }
QPen pen() { return m_pen; }
QBrush brush() { return m_brush; }
bool antiAliasing();
+ void finishStartup();
private slots:
void newPage();
void clearPage();
void deletePage();
void setPointTool();
void setLineTool();
void setRectangleTool();
void setFilledRectangleTool();
void setEllipseTool();
void setFilledEllipseTool();
void setTextTool();
void setFillTool();
void setEraseTool();
void changePenWidth(int value);
void changePenColor(const QColor& color);
void changeBrushColor(const QColor& color);
void updateView();
void deleteAll();
void importPage();
void exportPage();
void thumbnailView();
void pageInformation();
private:
void loadConfig();
void saveConfig();
DrawPadCanvas* m_pDrawPadCanvas;
Tool* m_pTool;
QPen m_pen;
QBrush m_brush;
QAction* m_pAntiAliasingAction;
QAction* m_pUndoAction;
QAction* m_pRedoAction;
QAction* m_pFirstPageAction;
QAction* m_pPreviousPageAction;
QAction* m_pNextPageAction;
QAction* m_pLastPageAction;
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 025bebb..dec498b 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -137,109 +137,115 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch)
r += l - '0';
} else {
r += l - 'a' + 10;
}
byteArray[i] = r;
}
QImage image;
image.loadFromData((const uchar*)byteArray.data(), m_dataLenght, m_dataFormat);
Page* page = new Page(m_title, image.width(), image.height());
page->setLastModified(m_date);
page->pixmap()->convertFromImage(image);
m_pages.append(page);
}
return true;
}
DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name)
: QScrollView(parent, name)
{
m_pDrawPad = drawPad;
m_pages.setAutoDelete(true);
viewport()->setBackgroundMode(QWidget::NoBackground);
}
DrawPadCanvas::~DrawPadCanvas()
{
}
void DrawPadCanvas::load(QIODevice* ioDevice)
{
QTextStream textStream(ioDevice);
textStream.setCodec(QTextCodec::codecForName("UTF-8"));
QXmlInputSource xmlInputSource(textStream);
QXmlSimpleReader xmlSimpleReader;
DrawPadCanvasXmlHandler drawPadCanvasXmlHandler;
xmlSimpleReader.setContentHandler(&drawPadCanvasXmlHandler);
xmlSimpleReader.parse(xmlInputSource);
m_pages = drawPadCanvasXmlHandler.pages();
if (m_pages.isEmpty()) {
- m_pages.append(new Page("", contentsRect().size()));
+ m_pages.append(new Page("",
+ clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
+ clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
m_pages.current()->pixmap()->fill(Qt::white);
}
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::initialPage()
{
- m_pages.append(new Page("", 236, 232));
+ m_pages.append(new Page("",
+ clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
+ clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
+ //236, 232)); no more fixed sizes
+
m_pages.current()->pixmap()->fill(Qt::white);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::save(QIODevice* ioDevice)
{
QTextStream textStream(ioDevice);
textStream.setCodec(QTextCodec::codecForName("UTF-8"));
textStream << "<drawpad>" << endl;
textStream << " <images>" << endl;
QListIterator<Page> bufferIterator(m_pages);
for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) {
textStream << " <image>" << endl;
textStream << " <title>" << bufferIterator.current()->title() << "</title>" << endl;
int intDate = QDateTime(QDate(1970, 1, 1)).secsTo(bufferIterator.current()->lastModified());
textStream << " <date>" << intDate << "</date>" << endl;
QImage image = bufferIterator.current()->pixmap()->convertToImage();
QByteArray byteArray;
QBuffer buffer(byteArray);
QImageIO imageIO(&buffer, "PNG");
buffer.open(IO_WriteOnly);
imageIO.setImage(image);
imageIO.write();
buffer.close();
textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">";
static const char hexchars[] = "0123456789abcdef";
for (int i = 0; i < (int)byteArray.size(); i++ ) {
uchar s = (uchar)byteArray[i];
textStream << hexchars[s >> 4];
textStream << hexchars[s & 0x0f];
}
textStream << "</data>" << endl;
textStream << " </image>" << endl;
}
@@ -304,130 +310,136 @@ Page* DrawPadCanvas::currentPage()
}
QList<Page> DrawPadCanvas::pages()
{
return m_pages;
}
uint DrawPadCanvas::pagePosition()
{
return (m_pages.at() + 1);
}
uint DrawPadCanvas::pageCount()
{
return m_pages.count();
}
void DrawPadCanvas::selectPage(Page* page)
{
m_pages.findRef(page);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::backupPage()
{
m_pages.current()->backup();
emit pagesChanged();
}
void DrawPadCanvas::selectPage(uint pagePosition)
{
m_pages.at(pagePosition - 1);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::deleteAll()
{
m_pages.clear();
- m_pages.append(new Page("", contentsRect().size()));
+ m_pages.append(new Page("",
+ clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
+ clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
+
m_pages.current()->pixmap()->fill(Qt::white);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::newPage(QString title, uint width, uint height, const QColor& color)
{
m_pages.insert(m_pages.at() + 1, new Page(title, width, height));
m_pages.current()->pixmap()->fill(color);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::clearPage()
{
m_pages.current()->pixmap()->fill(Qt::white);
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
}
void DrawPadCanvas::deletePage()
{
m_pages.remove(m_pages.current());
if (m_pages.isEmpty()) {
- m_pages.append(new Page("", contentsRect().size()));
+ m_pages.append(new Page("",
+ clipper()->width()+(verticalScrollBar()->isVisible()?verticalScrollBar()->width():0),
+ clipper()->height()+(horizontalScrollBar()->isVisible()?horizontalScrollBar()->height():0)));
+
m_pages.current()->pixmap()->fill(Qt::white);
}
resizeContents(m_pages.current()->pixmap()->width(), m_pages.current()->pixmap()->height());
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::movePageUp()
{
int index = m_pages.at();
Page* page = m_pages.take();
m_pages.insert(index - 1, page);
emit pagesChanged();
}
void DrawPadCanvas::movePageDown()
{
int index = m_pages.at();
Page* page = m_pages.take();
m_pages.insert(index + 1, page);
emit pagesChanged();
}
bool DrawPadCanvas::goPreviousPageEnabled()
{
return (m_pages.current() != m_pages.getFirst());
}
bool DrawPadCanvas::goNextPageEnabled()
{
return (m_pages.current() != m_pages.getLast());
}
void DrawPadCanvas::undo()
{
m_pages.current()->undo();
viewport()->update();
emit pagesChanged();
}
void DrawPadCanvas::redo()
{
diff --git a/noncore/graphics/drawpad/exportdialog.cpp b/noncore/graphics/drawpad/exportdialog.cpp
index 5b11c0e..adbd612 100644
--- a/noncore/graphics/drawpad/exportdialog.cpp
+++ b/noncore/graphics/drawpad/exportdialog.cpp
@@ -1,119 +1,122 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "exportdialog.h"
-#include <qpe/fileselector.h>
+#include <opie/ofileselector.h>
#include <qbuttongroup.h>
#include <qcombobox.h>
#include <qgroupbox.h>
#include <qimage.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlineedit.h>
#include <qradiobutton.h>
#include <qspinbox.h>
#include <stdlib.h>
ExportDialog::ExportDialog(uint pageAt, uint pageCount, QWidget* parent, const char* name)
: QDialog(parent, name, true)
{
setCaption(tr("DrawPad - Export"));
m_pageAt = pageAt;
m_pageCount = pageCount;
QButtonGroup* selectionButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Page Selection"), this);
connect(selectionButtonGroup, SIGNAL(pressed(int)), this, SLOT(selectionChanged(int)));
QRadioButton* selectAllRadioButton = new QRadioButton(tr("All"), selectionButtonGroup);
QRadioButton* selectCurrentRadioButton = new QRadioButton(tr("Current"), selectionButtonGroup);
QRadioButton* selectRangeRadioButton = new QRadioButton(tr("Range"), selectionButtonGroup);
QLabel* toLabel = new QLabel(tr("To:"), selectionButtonGroup);
m_pFromPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
connect(m_pFromPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fromPageChanged(int)));
m_pToPageSpinBox = new QSpinBox(1, m_pageCount, 1, selectionButtonGroup);
connect(m_pToPageSpinBox, SIGNAL(valueChanged(int)), this, SLOT(toPageChanged(int)));
selectionButtonGroup->setButton(1);
selectionChanged(1);
m_pFromPageSpinBox->setValue(pageAt);
m_pToPageSpinBox->setValue(pageAt);
QGroupBox* exportGroupBox = new QGroupBox(0, Qt::Vertical, tr("Export As"), this);
QLabel* nameLabel = new QLabel(tr("Name:"), exportGroupBox);
QLabel* formatLabel = new QLabel(tr("Format:"), exportGroupBox);
m_pNameLineEdit = new QLineEdit(exportGroupBox);
m_pFormatComboBox = new QComboBox(exportGroupBox);
m_pFormatComboBox->insertStrList(QImageIO::outputFormats());
- FileSelector* fileSelector = new FileSelector("image/*", this, "fileselector");
- fileSelector->setNewVisible(false);
- fileSelector->setCloseVisible(false);
+ MimeTypes types; types.insert( tr("All Images"), "image/*" );
+ OFileSelector* fileSelector = new OFileSelector(this, OFileSelector::FileSelector,
+ OFileSelector::Normal,
+ QString::null, QString::null,
+ types );
+ fileSelector->setNameVisible( false );
QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
selectionButtonGroup->layout()->setSpacing(4);
exportGroupBox->layout()->setSpacing(4);
QGridLayout* selectionLayout = new QGridLayout(selectionButtonGroup->layout(), 2, 2);
QHBoxLayout* rangeLayout = new QHBoxLayout();
QGridLayout* exportLayout = new QGridLayout(exportGroupBox->layout(), 2, 2);
selectionLayout->addWidget(selectAllRadioButton, 0, 0);
selectionLayout->addWidget(selectCurrentRadioButton, 1, 0);
selectionLayout->addWidget(selectRangeRadioButton, 0, 1);
selectionLayout->addLayout(rangeLayout, 1, 1);
rangeLayout->addWidget(m_pFromPageSpinBox);
rangeLayout->addWidget(toLabel);
rangeLayout->addWidget(m_pToPageSpinBox);
exportLayout->addWidget(nameLabel, 0, 0);
exportLayout->addWidget(formatLabel, 1, 0);
exportLayout->addWidget(m_pNameLineEdit, 0, 1);
exportLayout->addWidget(m_pFormatComboBox, 1, 1);
exportLayout->setColStretch(1, 1);
mainLayout->addWidget(selectionButtonGroup);
mainLayout->addWidget(exportGroupBox);
mainLayout->addWidget(fileSelector);
m_pNameLineEdit->setFocus();
}
ExportDialog::~ExportDialog()
{
}
uint ExportDialog::selectedFromPage()
{
return (m_pFromPageSpinBox->value());
}
uint ExportDialog::selectedToPage()
{
return (m_pToPageSpinBox->value());
}
QString ExportDialog::selectedName()
{
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,113 +1,117 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "importdialog.h"
#include <qpe/applnk.h>
-#include <qpe/fileselector.h>
+#include <opie/ofileselector.h>
#include <qcheckbox.h>
#include <qimage.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
ImportDialog::ImportDialog(QWidget* parent, const char* name)
: QDialog(parent, name, true)
{
setCaption(tr("DrawPad - Import"));
- m_pFileSelector = new FileSelector("image/*", this, "fileselector");
+ MimeTypes types; types.insert( tr("All images"),"image/*" );
+ m_pFileSelector = new OFileSelector(this,
+ OFileSelector::FileSelector,
+ OFileSelector::Normal,
+ QString::null,
+ QString::null, types );
+ m_pFileSelector->setNameVisible( false );
connect(m_pFileSelector, SIGNAL(fileSelected(const DocLnk&)), this, SLOT(fileChanged()));
- m_pFileSelector->setNewVisible(false);
- m_pFileSelector->setCloseVisible(false);
m_pPreviewLabel = new QLabel(this);
m_pPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
m_pPreviewLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
m_pPreviewLabel->setFixedSize(114, 114);
m_pPreviewLabel->setBackgroundMode(QWidget::PaletteMid);
m_pAutomaticPreviewCheckBox = new QCheckBox(tr("Automatic preview"), this);
m_pAutomaticPreviewCheckBox->setChecked(true);
QPushButton* previewPushButton = new QPushButton(tr("Preview"), this);
connect(previewPushButton, SIGNAL(clicked()), this, SLOT(preview()));
QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
QHBoxLayout* previewLayout = new QHBoxLayout(4);
QVBoxLayout* previewSecondLayout = new QVBoxLayout(4);
previewSecondLayout->addWidget(m_pAutomaticPreviewCheckBox);
previewSecondLayout->addWidget(previewPushButton);
previewSecondLayout->addStretch();
previewLayout->addWidget(m_pPreviewLabel);
previewLayout->addLayout(previewSecondLayout);
mainLayout->addWidget(m_pFileSelector);
mainLayout->addLayout(previewLayout);
preview();
}
ImportDialog::~ImportDialog()
{
}
const DocLnk* ImportDialog::selected()
{
// FIXME change from pointer to reference -zecke
- DocLnk *lnk = new DocLnk( m_pFileSelector->selectedDocument() );
+ DocLnk *lnk = new DocLnk( m_pFileSelector->selectedDocument() );
return lnk;
}
void ImportDialog::fileChanged()
{
if (m_pAutomaticPreviewCheckBox->isChecked()) {
preview();
}
}
void ImportDialog::preview()
{
const DocLnk* docLnk = selected();
if (docLnk) {
QImage image(docLnk->file());
int previewWidth = m_pPreviewLabel->contentsRect().width();
int previewHeight = m_pPreviewLabel->contentsRect().height();
float widthScale = 1.0;
float heightScale = 1.0;
if (previewWidth < image.width()) {
widthScale = (float)previewWidth / float(image.width());
}
if (previewHeight < image.height()) {
heightScale = (float)previewHeight / float(image.height());
}
float scale = (widthScale < heightScale ? widthScale : heightScale);
QImage previewImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale));
QPixmap previewPixmap;
previewPixmap.convertFromImage(previewImage);
m_pPreviewLabel->setPixmap(previewPixmap);
delete docLnk;
}
}
diff --git a/noncore/graphics/drawpad/importdialog.h b/noncore/graphics/drawpad/importdialog.h
index ef51d7c..ed655a5 100644
--- a/noncore/graphics/drawpad/importdialog.h
+++ b/noncore/graphics/drawpad/importdialog.h
@@ -1,45 +1,45 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef IMPORTDIALOG_H
#define IMPORTDIALOG_H
#include <qdialog.h>
class DocLnk;
-class FileSelector;
+class OFileSelector;
class QCheckBox;
class QLabel;
class ImportDialog : public QDialog
{
Q_OBJECT
public:
ImportDialog(QWidget* parent = 0, const char* name = 0);
~ImportDialog();
const DocLnk* selected();
private slots:
void fileChanged();
void preview();
private:
- FileSelector* m_pFileSelector;
+ OFileSelector* m_pFileSelector;
QLabel* m_pPreviewLabel;
QCheckBox* m_pAutomaticPreviewCheckBox;
};
#endif // IMPORTDIALOG_H
diff --git a/noncore/graphics/drawpad/main.cpp b/noncore/graphics/drawpad/main.cpp
index ec628cc..12f8084 100644
--- a/noncore/graphics/drawpad/main.cpp
+++ b/noncore/graphics/drawpad/main.cpp
@@ -1,27 +1,27 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "drawpad.h"
#include <qpe/qpeapplication.h>
int main(int argc, char **argv)
{
QPEApplication a(argc, argv);
DrawPad mw; // = new DrawPad();;
a.showMainWidget(&mw );
-
+ mw.finishStartup();
return a.exec();
}
diff --git a/noncore/graphics/drawpad/opie-drawpad.control b/noncore/graphics/drawpad/opie-drawpad.control
index 1c22186..5095b52 100644
--- a/noncore/graphics/drawpad/opie-drawpad.control
+++ b/noncore/graphics/drawpad/opie-drawpad.control
@@ -1,12 +1,12 @@
Package: opie-drawpad
Files: bin/drawpad apps/1Pim/drawpad.desktop pics/drawpad
Priority: optional
Section: opie/applications
Maintainer: Sébastien Prud'homme <prudhomme@laposte.net>
Architecture: arm
-Version: $QPE_VERSION-$SUB_VERSION
Depends: task-opie-minimal, libopie1
Description: A note taking program with basic draw tools
DrawPad is an easy note taking program for Zaurus. It can also
be used to draw simple images. DrawPad was developed for the Opie
project, an alternative to the standard Zaurus environment.
+Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/graphics/drawpad/texttool.h b/noncore/graphics/drawpad/texttool.h
index 3187675..17556a1 100644
--- a/noncore/graphics/drawpad/texttool.h
+++ b/noncore/graphics/drawpad/texttool.h
@@ -1,46 +1,47 @@
/***************************************************************************
* *
* DrawPad - a drawing program for Opie Environment *
* *
* (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef TEXTTOOL_H
#define TEXTTOOL_H
#include "tool.h"
#include <qdialog.h>
class QLineEdit;
class TextToolDialog : public QDialog
{
+ Q_OBJECT
public:
TextToolDialog(QWidget* parent = 0, const char* name = 0);
~TextToolDialog();
QString text();
private:
QLineEdit* m_pLineEdit;
};
class TextTool : public Tool
{
public:
TextTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas);
~TextTool();
void mousePressEvent(QMouseEvent* e);
void mouseReleaseEvent(QMouseEvent* e);
void mouseMoveEvent(QMouseEvent* e);
};
#endif // TEXTTOOL_H