summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/drawpad.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp
index 5c7e541..aae9ab0 100644
--- a/noncore/graphics/drawpad/drawpad.cpp
+++ b/noncore/graphics/drawpad/drawpad.cpp
@@ -297,207 +297,212 @@ void DrawPad::setLineTool()
void DrawPad::setRectangleTool()
{
if (m_pTool) {
delete m_pTool;
}
m_pTool = new RectangleTool(this, m_pDrawPadCanvas);
m_pRectangleToolButton->setIconSet(m_pRectangleToolAction->iconSet());
QToolTip::add(m_pRectangleToolButton, m_pRectangleToolAction->text());
disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pRectangleToolAction, SIGNAL(activated()));
m_pPointToolAction->setOn(false);
m_pLineToolAction->setOn(false);
m_pRectangleToolButton->setOn(true);
m_pEllipseToolButton->setOn(false);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
}
void DrawPad::setFilledRectangleTool()
{
if (m_pTool) {
delete m_pTool;
}
m_pTool = new FilledRectangleTool(this, m_pDrawPadCanvas);
m_pRectangleToolButton->setIconSet(m_pFilledRectangleToolAction->iconSet());
QToolTip::add(m_pRectangleToolButton, m_pFilledRectangleToolAction->text());
disconnect(m_pRectangleToolButton, SIGNAL(clicked()), 0, 0);
connect(m_pRectangleToolButton, SIGNAL(clicked()), m_pFilledRectangleToolAction, SIGNAL(activated()));
m_pPointToolAction->setOn(false);
m_pLineToolAction->setOn(false);
m_pRectangleToolButton->setOn(true);
m_pEllipseToolButton->setOn(false);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
}
void DrawPad::setEllipseTool()
{
if (m_pTool) {
delete m_pTool;
}
m_pTool = new EllipseTool(this, m_pDrawPadCanvas);
m_pEllipseToolButton->setIconSet(m_pEllipseToolAction->iconSet());
QToolTip::add(m_pEllipseToolButton, m_pEllipseToolAction->text());
disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pEllipseToolAction, SIGNAL(activated()));
m_pPointToolAction->setOn(false);
m_pLineToolAction->setOn(false);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(true);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
}
void DrawPad::setFilledEllipseTool()
{
if (m_pTool) {
delete m_pTool;
}
m_pTool = new FilledEllipseTool(this, m_pDrawPadCanvas);
m_pEllipseToolButton->setIconSet(m_pFilledEllipseToolAction->iconSet());
QToolTip::add(m_pEllipseToolButton, m_pFilledEllipseToolAction->text());
disconnect(m_pEllipseToolButton, SIGNAL(clicked()), 0, 0);
connect(m_pEllipseToolButton, SIGNAL(clicked()), m_pFilledEllipseToolAction, SIGNAL(activated()));
m_pPointToolAction->setOn(false);
m_pLineToolAction->setOn(false);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(true);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(false);
}
void DrawPad::setFillTool()
{
if (m_pTool) {
delete m_pTool;
}
m_pTool = new FillTool(this, m_pDrawPadCanvas);
m_pPointToolAction->setOn(false);
m_pLineToolAction->setOn(false);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(false);
m_pFillToolAction->setOn(true);
m_pEraseToolAction->setOn(false);
}
void DrawPad::setEraseTool()
{
if (m_pTool) {
delete m_pTool;
}
m_pTool = new EraseTool(this, m_pDrawPadCanvas);
m_pPointToolAction->setOn(false);
m_pLineToolAction->setOn(false);
m_pRectangleToolButton->setOn(false);
m_pEllipseToolButton->setOn(false);
m_pFillToolAction->setOn(false);
m_pEraseToolAction->setOn(true);
}
void DrawPad::changePenWidth(int value)
{
m_pen.setWidth(value);
}
void DrawPad::changePenColor(const QColor& color)
{
m_pen.setColor(color);
QPainter painter;
painter.begin(m_pPenColorToolButton->pixmap());
painter.fillRect(QRect(0, 12, 14, 2), m_pen.color());
painter.end();
m_pPenColorToolButton->popup()->hide();
}
void DrawPad::changeBrushColor(const QColor& color)
{
m_brush = QBrush(color);
QPainter painter;
painter.begin(m_pBrushColorToolButton->pixmap());
painter.fillRect(QRect(0, 12, 14, 2), m_brush.color());
painter.end();
m_pBrushColorToolButton->popup()->hide();
}
void DrawPad::choosePenColor()
{
QColor newPenColor = QColorDialog::getColor(m_pen.color());
changePenColor(newPenColor);
}
void DrawPad::chooseBrushColor()
{
QColor newBrushColor = QColorDialog::getColor(m_brush.color());
changeBrushColor(newBrushColor);
}
void DrawPad::updateUndoRedoToolButtons()
{
m_pUndoAction->setEnabled(m_pDrawPadCanvas->undoEnabled());
m_pRedoAction->setEnabled(m_pDrawPadCanvas->redoEnabled());
}
void DrawPad::updateNavigationToolButtons()
{
m_pFirstPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
m_pPreviousPageAction->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled());
m_pNextPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
m_pLastPageAction->setEnabled(m_pDrawPadCanvas->goNextPageEnabled());
}
void DrawPad::updateCaption()
{
uint pagePosition = m_pDrawPadCanvas->pagePosition();
uint pageCount = m_pDrawPadCanvas->pageCount();
setCaption(tr("DrawPad") + " - " + tr("Page") + " "
+ QString::number(pagePosition) + "/" + QString::number(pageCount));
}
void DrawPad::importPage()
{
ImportDialog importDialog(this);
importDialog.showMaximized();
if (importDialog.exec() == QDialog::Accepted) {
- m_pDrawPadCanvas->importPage(importDialog.selected()->file());
+ const DocLnk* docLnk = importDialog.selected();
+
+ if (docLnk) {
+ m_pDrawPadCanvas->importPage(docLnk->file());
+ delete docLnk;
+ }
}
}
void DrawPad::exportPage()
{
ExportDialog exportDialog(m_pDrawPadCanvas->pagePosition(), m_pDrawPadCanvas->pageCount(), this);
exportDialog.showMaximized();
if (exportDialog.exec() == QDialog::Accepted) {
m_pDrawPadCanvas->exportPage(exportDialog.selectedFromPage(), exportDialog.selectedToPage(),
exportDialog.selectedName(), exportDialog.selectedFormat());
}
}