summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp2
-rw-r--r--noncore/graphics/drawpad/drawpadcanvas.cpp12
-rw-r--r--noncore/graphics/drawpad/newpagedialog.cpp22
-rw-r--r--noncore/graphics/drawpad/newpagedialog.h4
4 files changed, 24 insertions, 16 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index aae9ab0..1375792 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -144,39 +144,41 @@ DrawPad::DrawPad(QWidget* parent, const char* name)
QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton);
m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this);
connect(m_pRectangleToolAction, SIGNAL(activated()), this, SLOT(setRectangleTool()));
m_pRectangleToolAction->addTo(rectanglePopupMenu);
m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadIconSet("drawpad/filledrectangle.png"), "", 0, this);
connect(m_pFilledRectangleToolAction, SIGNAL(activated()), this, SLOT(setFilledRectangleTool()));
m_pFilledRectangleToolAction->addTo(rectanglePopupMenu);
m_pRectangleToolButton->setPopup(rectanglePopupMenu);
+ m_pRectangleToolButton->setPopupDelay(0);
m_pEllipseToolButton = new QToolButton(drawModeToolBar);
m_pEllipseToolButton->setToggleButton(true);
QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton);
m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this);
connect(m_pEllipseToolAction, SIGNAL(activated()), this, SLOT(setEllipseTool()));
m_pEllipseToolAction->addTo(ellipsePopupMenu);
m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadIconSet("drawpad/filledellipse.png"), "", 0, this);
connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool()));
m_pFilledEllipseToolAction->addTo(ellipsePopupMenu);
m_pEllipseToolButton->setPopup(ellipsePopupMenu);
+ m_pEllipseToolButton->setPopupDelay(0);
m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this);
m_pFillToolAction->setToggleAction(true);
connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool()));
m_pFillToolAction->addTo(drawModeToolBar);
m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this);
m_pEraseToolAction->setToggleAction(true);
connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool()));
m_pEraseToolAction->addTo(drawModeToolBar);
m_pTool = 0;
diff --git a/noncore/graphics/drawpad/drawpadcanvas.cpp b/noncore/graphics/drawpad/drawpadcanvas.cpp
index 8818c03..b8a1c2e 100644
--- a/noncore/graphics/drawpad/drawpadcanvas.cpp
+++ b/noncore/graphics/drawpad/drawpadcanvas.cpp
@@ -45,24 +45,25 @@ public:
bool endElement(const QString& namespaceURI, const QString& localName,
const QString& qName);
bool characters(const QString& ch);
private:
enum State {
Unknown,
InData
};
State m_state;
ulong m_dataLenght;
+ QString m_dataFormat;
QList<QPixmap> m_pixmaps;
};
DrawPadCanvasXmlHandler::DrawPadCanvasXmlHandler()
{
m_state = Unknown;
}
DrawPadCanvasXmlHandler::~DrawPadCanvasXmlHandler()
{
}
@@ -71,24 +72,29 @@ QList<QPixmap> DrawPadCanvasXmlHandler::pixmaps()
return m_pixmaps;
}
bool DrawPadCanvasXmlHandler::startElement(const QString& namespaceURI, const QString& localName,
const QString& qName, const QXmlAttributes& atts)
{
Q_CONST_UNUSED(namespaceURI)
Q_CONST_UNUSED(localName)
if (qName.compare("data") == 0) {
m_state = InData;
m_dataLenght = atts.value("length").toULong();
+ m_dataFormat = atts.value("format");
+
+ if (m_dataFormat.isEmpty()) {
+ m_dataFormat = "XPM";
+ }
}
return true;
}
bool DrawPadCanvasXmlHandler::endElement(const QString& namespaceURI, const QString& localName,
const QString& qName)
{
Q_CONST_UNUSED(namespaceURI)
Q_CONST_UNUSED(localName)
if (qName.compare("data") == 0) {
@@ -124,25 +130,25 @@ bool DrawPadCanvasXmlHandler::characters(const QString& ch)
byteArray[i] = r;
}
if (m_dataLenght < ch.length() * 5) {
m_dataLenght = ch.length() * 5;
}
QByteArray byteArrayUnzipped(m_dataLenght);
::uncompress((uchar*)byteArrayUnzipped.data(), &m_dataLenght, (uchar*)byteArray.data(), byteArray.size());
QImage image;
- image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, "XPM");
+ image.loadFromData((const uchar*)byteArrayUnzipped.data(), m_dataLenght, m_dataFormat);
QPixmap* pixmap = new QPixmap(image.width(), image.height());
pixmap->convertFromImage(image);
m_pixmaps.append(pixmap);
}
return true;
}
DrawPadCanvas::DrawPadCanvas(DrawPad* drawPad, QWidget* parent, const char* name)
: QScrollView(parent, name)
{
@@ -206,36 +212,36 @@ void DrawPadCanvas::save(QIODevice* ioDevice)
textStream << "<drawpad>" << endl;
textStream << " <images>" << endl;
QListIterator<QPixmap> bufferIterator(m_pages);
for (bufferIterator.toFirst(); bufferIterator.current() != 0; ++bufferIterator) {
textStream << " <image>" << endl;
QImage image = bufferIterator.current()->convertToImage();
QByteArray byteArray;
QBuffer buffer(byteArray);
- QImageIO imageIO(&buffer, "XPM");
+ QImageIO imageIO(&buffer, "PNG");
buffer.open(IO_WriteOnly);
imageIO.setImage(image);
imageIO.write();
buffer.close();
ulong size = byteArray.size() * 2;
QByteArray byteArrayZipped(size);
::compress((uchar*)byteArrayZipped.data(), &size, (uchar*)byteArray.data(), byteArray.size());
- textStream << " <data length=\"" << byteArray.size() << "\">";
+ textStream << " <data length=\"" << byteArray.size() << "\" format=\"PNG\">";
static const char hexchars[] = "0123456789abcdef";
for (int i = 0; i < (int)size; i++ ) {
uchar s = (uchar)byteArrayZipped[i];
textStream << hexchars[s >> 4];
textStream << hexchars[s & 0x0f];
}
textStream << "</data>" << endl;
textStream << " </image>" << endl;
}
diff --git a/noncore/graphics/drawpad/newpagedialog.cpp b/noncore/graphics/drawpad/newpagedialog.cpp
index b1b26ef..5c31978 100644
--- a/noncore/graphics/drawpad/newpagedialog.cpp
+++ b/noncore/graphics/drawpad/newpagedialog.cpp
@@ -11,68 +11,68 @@
* *
***************************************************************************/
#include "newpagedialog.h"
#include <qbuttongroup.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <qspinbox.h>
-NewPageDialog::NewPageDialog(uint width, uint height, const QColor& foregroundColor,
- const QColor& backgroundColor, QWidget* parent, const char* name)
+NewPageDialog::NewPageDialog(uint width, uint height, const QColor& penColor,
+ const QColor& brushColor, QWidget* parent, const char* name)
: QDialog(parent, name, true)
{
setCaption(tr("New Page"));
- m_foregroundColor = foregroundColor;
- m_backgroundColor = backgroundColor;
+ m_penColor = penColor;
+ m_brushColor = brushColor;
QGroupBox* sizeGroupBox = new QGroupBox(0, Qt::Vertical, tr("Page Size"), this);
QLabel* widthLabel = new QLabel(tr("Width :"), sizeGroupBox);
QLabel* heightLabel = new QLabel(tr("Height :"), sizeGroupBox);
m_pWidthSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox);
m_pHeightSpinBox = new QSpinBox(1, 1024, 1, sizeGroupBox);
m_pWidthSpinBox->setValue(width);
m_pHeightSpinBox->setValue(height);
- m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Contents"), this);
+ m_pContentButtonGroup = new QButtonGroup(0, Qt::Vertical, tr("Background"), this);
QRadioButton* whiteColorRadioButton = new QRadioButton(tr("White"), m_pContentButtonGroup);
- QRadioButton* foregroundColorRadioButton = new QRadioButton(tr("Foreground Color"), m_pContentButtonGroup);
- QRadioButton* backgroundColorRadioButton = new QRadioButton(tr("Background Color"), m_pContentButtonGroup);
+ QRadioButton* penColorRadioButton = new QRadioButton(tr("Pen Color"), m_pContentButtonGroup);
+ QRadioButton* brushColorRadioButton = new QRadioButton(tr("Brush Color"), m_pContentButtonGroup);
m_pContentButtonGroup->setButton(0);
QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4);
sizeGroupBox->layout()->setSpacing(4);
m_pContentButtonGroup->layout()->setSpacing(4);
QGridLayout* sizeLayout = new QGridLayout(sizeGroupBox->layout(), 2, 2);
QVBoxLayout* contentLayout = new QVBoxLayout(m_pContentButtonGroup->layout());
sizeLayout->addWidget(widthLabel, 0, 0);
sizeLayout->addWidget(heightLabel, 1, 0);
sizeLayout->addWidget(m_pWidthSpinBox, 0, 1);
sizeLayout->addWidget(m_pHeightSpinBox, 1, 1);
sizeLayout->setColStretch(1, 1);
contentLayout->addWidget(whiteColorRadioButton);
- contentLayout->addWidget(foregroundColorRadioButton);
- contentLayout->addWidget(backgroundColorRadioButton);
+ contentLayout->addWidget(penColorRadioButton);
+ contentLayout->addWidget(brushColorRadioButton);
mainLayout->addWidget(sizeGroupBox);
mainLayout->addWidget(m_pContentButtonGroup);
}
NewPageDialog::~NewPageDialog()
{
}
uint NewPageDialog::selectedWidth()
{
return (m_pWidthSpinBox->value());
@@ -81,22 +81,22 @@ uint NewPageDialog::selectedWidth()
uint NewPageDialog::selectedHeight()
{
return (m_pHeightSpinBox->value());
}
const QColor& NewPageDialog::selectedColor()
{
switch (m_pContentButtonGroup->id(m_pContentButtonGroup->selected())) {
case 0:
return (Qt::white);
break;
case 1:
- return (m_foregroundColor);
+ return (m_penColor);
break;
case 2:
- return (m_backgroundColor);
+ return (m_brushColor);
break;
default:
return (Qt::white);
break;
}
}
diff --git a/noncore/graphics/drawpad/newpagedialog.h b/noncore/graphics/drawpad/newpagedialog.h
index f418340..d680394 100644
--- a/noncore/graphics/drawpad/newpagedialog.h
+++ b/noncore/graphics/drawpad/newpagedialog.h
@@ -27,19 +27,19 @@ public:
NewPageDialog(uint width, uint height, const QColor& foregroundColor,
const QColor& backgroundColor, QWidget* parent = 0, const char* name = 0);
~NewPageDialog();
uint selectedWidth();
uint selectedHeight();
const QColor& selectedColor();
private:
QSpinBox* m_pWidthSpinBox;
QSpinBox* m_pHeightSpinBox;
- QColor m_foregroundColor;
- QColor m_backgroundColor;
+ QColor m_penColor;
+ QColor m_brushColor;
QButtonGroup* m_pContentButtonGroup;
};
#endif // NEWPAGEDIALOG_H