-rw-r--r-- | noncore/graphics/drawpad/drawpad.cpp | 53 | ||||
-rw-r--r-- | noncore/graphics/drawpad/pageinformationdialog.cpp | 10 | ||||
-rw-r--r-- | noncore/graphics/drawpad/thumbnailview.cpp | 29 |
3 files changed, 59 insertions, 33 deletions
diff --git a/noncore/graphics/drawpad/drawpad.cpp b/noncore/graphics/drawpad/drawpad.cpp index b0a414e..53db993 100644 --- a/noncore/graphics/drawpad/drawpad.cpp +++ b/noncore/graphics/drawpad/drawpad.cpp @@ -18,265 +18,285 @@ #include "erasetool.h" #include "exportdialog.h" #include "filledellipsetool.h" #include "filledrectangletool.h" #include "filltool.h" #include "importdialog.h" #include "linetool.h" #include "newpagedialog.h" #include "page.h" #include "pageinformationdialog.h" #include "pointtool.h" #include "rectangletool.h" #include "texttool.h" #include "thumbnailview.h" #include <opie/colordialog.h> #include <opie/colorpopupmenu.h> #include <qpe/applnk.h> #include <qpe/config.h> #include <qpe/global.h> #include <qpe/qpemenubar.h> #include <qpe/qpetoolbar.h> #include <qpe/resource.h> #include <qaction.h> #include <qfile.h> #include <qmessagebox.h> #include <qpainter.h> #include <qspinbox.h> #include <qtoolbutton.h> #include <qtooltip.h> +#include <qwhatsthis.h> DrawPad::DrawPad(QWidget* parent, const char* name) - : QMainWindow(parent, name) + : QMainWindow(parent, name, WStyle_ContextHelp) { // init members m_pDrawPadCanvas = new DrawPadCanvas(this, this); connect(m_pDrawPadCanvas, SIGNAL(pagesChanged()), this, SLOT(updateView())); setCentralWidget(m_pDrawPadCanvas); // init menu setToolBarsMovable(false); QPEToolBar* menuToolBar = new QPEToolBar(this); QPEMenuBar* menuBar = new QPEMenuBar(menuToolBar); QPopupMenu* toolsPopupMenu = new QPopupMenu(menuBar); QAction* deleteAllAction = new QAction(tr("Delete All"), QString::null, 0, this); connect(deleteAllAction, SIGNAL(activated()), this, SLOT(deleteAll())); deleteAllAction->addTo(toolsPopupMenu); toolsPopupMenu->insertSeparator(); QAction* importPageAction = new QAction(tr("Import"), tr("Import..."), 0, this); connect(importPageAction, SIGNAL(activated()), this, SLOT(importPage())); importPageAction->addTo(toolsPopupMenu); QAction* exportPageAction = new QAction(tr("Export"), tr("Export..."), 0, this); connect(exportPageAction, SIGNAL(activated()), this, SLOT(exportPage())); exportPageAction->addTo(toolsPopupMenu); toolsPopupMenu->insertSeparator(); QAction* thumbnailViewAction = new QAction(tr("Thumbnail View"), tr("Thumbnail View..."), 0, this); connect(thumbnailViewAction, SIGNAL(activated()), this, SLOT(thumbnailView())); thumbnailViewAction->addTo(toolsPopupMenu); QAction* pageInformationAction = new QAction(tr("Page Information"), tr("Page Information..."), 0, this); connect(pageInformationAction, SIGNAL(activated()), this, SLOT(pageInformation())); pageInformationAction->addTo(toolsPopupMenu); toolsPopupMenu->insertSeparator(); m_pAntiAliasingAction = new QAction(tr("Anti-Aliasing"), QString::null, 0, this); m_pAntiAliasingAction->setToggleAction(true); m_pAntiAliasingAction->addTo(toolsPopupMenu); menuBar->insertItem(tr("Tools"), toolsPopupMenu); // init page toolbar QPEToolBar* pageToolBar = new QPEToolBar(this); - QAction* newPageAction = new QAction(tr("New Page"), Resource::loadIconSet("new"), QString::null, 0, this); + QAction* newPageAction = new QAction(tr("New Page"), Resource::loadPixmap("new"), QString::null, 0, this); connect(newPageAction, SIGNAL(activated()), this, SLOT(newPage())); newPageAction->addTo(pageToolBar); + newPageAction->setWhatsThis( tr( "Click here to add a new sheet." ) ); - QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadIconSet("drawpad/clear"), QString::null, 0, this); + QAction* clearPageAction = new QAction(tr("Clear Page"), Resource::loadPixmap("drawpad/clear"), QString::null, 0, this); connect(clearPageAction, SIGNAL(activated()), this, SLOT(clearPage())); clearPageAction->addTo(pageToolBar); + clearPageAction->setWhatsThis( tr( "Click here to erase the current sheet." ) ); - QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadIconSet("trash"), QString::null, 0, this); + QAction* deletePageAction = new QAction(tr("Delete Page"), Resource::loadPixmap("trash"), QString::null, 0, this); connect(deletePageAction, SIGNAL(activated()), this, SLOT(deletePage())); deletePageAction->addTo(pageToolBar); + deletePageAction->setWhatsThis( tr( "Click here to remove the current sheet." ) ); QPEToolBar* emptyToolBar = new QPEToolBar(this); emptyToolBar->setHorizontalStretchable(true); // init navigation toolbar QPEToolBar* navigationToolBar = new QPEToolBar(this); m_pUndoAction = new QAction(tr("Undo"), Resource::loadIconSet("drawpad/undo"), QString::null, 0, this); connect(m_pUndoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(undo())); m_pUndoAction->addTo(navigationToolBar); + m_pUndoAction->setWhatsThis( tr( "Click here to undo the last action." ) ); m_pRedoAction = new QAction(tr("Redo"), Resource::loadIconSet("drawpad/redo"), QString::null, 0, this); connect(m_pRedoAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(redo())); m_pRedoAction->addTo(navigationToolBar); + m_pRedoAction->setWhatsThis( tr( "Click here to re-perform the last action." ) ); m_pFirstPageAction = new QAction(tr("First Page"), Resource::loadIconSet("fastback"), QString::null, 0, this); connect(m_pFirstPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goFirstPage())); m_pFirstPageAction->addTo(navigationToolBar); + m_pFirstPageAction->setWhatsThis( tr( "Click here to view the first page." ) ); m_pPreviousPageAction = new QAction(tr("Previous Page"), Resource::loadIconSet("back"), QString::null, 0, this); connect(m_pPreviousPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goPreviousPage())); m_pPreviousPageAction->addTo(navigationToolBar); + m_pPreviousPageAction->setWhatsThis( tr( "Click here to view the previous page." ) ); m_pNextPageAction = new QAction(tr("Next Page"), Resource::loadIconSet("forward"), QString::null, 0, this); connect(m_pNextPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goNextPage())); m_pNextPageAction->addTo(navigationToolBar); + m_pNextPageAction->setWhatsThis( tr( "Click here to view the next page." ) ); m_pLastPageAction = new QAction(tr("Last Page"), Resource::loadIconSet("fastforward"), QString::null, 0, this); connect(m_pLastPageAction, SIGNAL(activated()), m_pDrawPadCanvas, SLOT(goLastPage())); m_pLastPageAction->addTo(navigationToolBar); + m_pLastPageAction->setWhatsThis( tr( "Click here to view the last page." ) ); // init draw mode toolbar QPEToolBar* drawModeToolBar = new QPEToolBar(this); m_pLineToolButton = new QToolButton(drawModeToolBar); m_pLineToolButton->setToggleButton(true); + QWhatsThis::add( m_pLineToolButton, tr( "Click here to select one of the available tools to draw lines." ) ); + QPopupMenu* linePopupMenu = new QPopupMenu(m_pLineToolButton); - m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadIconSet("drawpad/point.png"), "", 0, this); + m_pPointToolAction = new QAction(tr("Draw Point"), Resource::loadPixmap("drawpad/point"), "", 0, this); connect(m_pPointToolAction, SIGNAL(activated()), this, SLOT(setPointTool())); m_pPointToolAction->addTo(linePopupMenu); - m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadIconSet("drawpad/line.png"), "", 0, this); + m_pLineToolAction = new QAction(tr("Draw Line"), Resource::loadPixmap("drawpad/line"), "", 0, this); connect(m_pLineToolAction, SIGNAL(activated()), this, SLOT(setLineTool())); m_pLineToolAction->addTo(linePopupMenu); m_pLineToolButton->setPopup(linePopupMenu); m_pLineToolButton->setPopupDelay(0); m_pRectangleToolButton = new QToolButton(drawModeToolBar); m_pRectangleToolButton->setToggleButton(true); + QWhatsThis::add( m_pRectangleToolButton, tr( "Click here to select one of the available tools to draw rectangles." ) ); QPopupMenu* rectanglePopupMenu = new QPopupMenu(m_pRectangleToolButton); - m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadIconSet("drawpad/rectangle.png"), "", 0, this); + m_pRectangleToolAction = new QAction(tr("Draw Rectangle"), Resource::loadPixmap("drawpad/rectangle"), "", 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); + m_pFilledRectangleToolAction = new QAction(tr("Draw Filled Rectangle"), Resource::loadPixmap("drawpad/filledrectangle"), "", 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); + QWhatsThis::add( m_pEllipseToolButton, tr( "Click here to select one of the available tools to draw ellipses." ) ); QPopupMenu* ellipsePopupMenu = new QPopupMenu(m_pEllipseToolButton); - m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadIconSet("drawpad/ellipse.png"), "", 0, this); + m_pEllipseToolAction = new QAction(tr("Draw Ellipse"), Resource::loadPixmap("drawpad/ellipse"), "", 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); + m_pFilledEllipseToolAction = new QAction(tr("Draw Filled Ellipse"), Resource::loadPixmap("drawpad/filledellipse"), "", 0, this); connect(m_pFilledEllipseToolAction, SIGNAL(activated()), this, SLOT(setFilledEllipseTool())); m_pFilledEllipseToolAction->addTo(ellipsePopupMenu); m_pEllipseToolButton->setPopup(ellipsePopupMenu); m_pEllipseToolButton->setPopupDelay(0); - m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadIconSet("drawpad/text.png"), QString::null, 0, this); + m_pTextToolAction = new QAction(tr("Insert Text"), Resource::loadPixmap("drawpad/text"), QString::null, 0, this); m_pTextToolAction->setToggleAction(true); connect(m_pTextToolAction, SIGNAL(activated()), this, SLOT(setTextTool())); m_pTextToolAction->addTo(drawModeToolBar); + m_pTextToolAction->setWhatsThis( tr( "Click here to select the text drawing tool." ) ); - m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadIconSet("drawpad/fill.png"), QString::null, 0, this); + m_pFillToolAction = new QAction(tr("Fill Region"), Resource::loadPixmap("drawpad/fill"), QString::null, 0, this); m_pFillToolAction->setToggleAction(true); connect(m_pFillToolAction, SIGNAL(activated()), this, SLOT(setFillTool())); m_pFillToolAction->addTo(drawModeToolBar); + m_pFillToolAction->setWhatsThis( tr( "Click here to select the fill tool." ) ); - m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadIconSet("drawpad/erase.png"), QString::null, 0, this); + m_pEraseToolAction = new QAction(tr("Erase Point"), Resource::loadPixmap("drawpad/erase"), QString::null, 0, this); m_pEraseToolAction->setToggleAction(true); connect(m_pEraseToolAction, SIGNAL(activated()), this, SLOT(setEraseTool())); m_pEraseToolAction->addTo(drawModeToolBar); + m_pEraseToolAction->setWhatsThis( tr( "Click here to select the eraser tool." ) ); 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.png")); + m_pPenColorToolButton->setPixmap(Resource::loadPixmap("drawpad/pencolor")); + QWhatsThis::add( m_pPenColorToolButton, tr( "Click here to select the color used when drawing." ) ); ColorPopupMenu* penColorPopupMenu = new ColorPopupMenu(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.png")); + m_pBrushColorToolButton->setPixmap(Resource::loadPixmap("drawpad/brushcolor")); + QWhatsThis::add( m_pBrushColorToolButton, tr( "Click here to select the color used when filling in areas." ) ); ColorPopupMenu* brushColorPopupMenu = new ColorPopupMenu(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); // 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); @@ -516,66 +536,65 @@ 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::updateView() { uint pagePosition = m_pDrawPadCanvas->pagePosition(); uint pageCount = m_pDrawPadCanvas->pageCount(); - setCaption(tr("DrawPad") + " - " + tr("Page") + " " - + QString::number(pagePosition) + "/" + QString::number(pageCount)); + setCaption( tr( "DrawPad - Page %1/%2" ).arg( pagePosition ).arg( pageCount ) ); m_pUndoAction->setEnabled(m_pDrawPadCanvas->currentPage()->undoEnabled()); m_pRedoAction->setEnabled(m_pDrawPadCanvas->currentPage()->redoEnabled()); 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::deleteAll() { QMessageBox messageBox(tr("Delete All"), tr("Do you want to delete\nall the pages?"), 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->deleteAll(); } } void DrawPad::importPage() { ImportDialog importDialog(this); importDialog.showMaximized(); if (importDialog.exec() == QDialog::Accepted) { diff --git a/noncore/graphics/drawpad/pageinformationdialog.cpp b/noncore/graphics/drawpad/pageinformationdialog.cpp index cb14d73..d769668 100644 --- a/noncore/graphics/drawpad/pageinformationdialog.cpp +++ b/noncore/graphics/drawpad/pageinformationdialog.cpp @@ -65,53 +65,53 @@ PageInformationDialog::PageInformationDialog(Page* page, QWidget* parent, const sizeLayout->addWidget(widthValueLabel, 0, 1); sizeLayout->addWidget(heightLabel, 1, 0); sizeLayout->addWidget(heightValueLabel, 1, 1); sizeLayout->setColStretch(1, 1); mainLayout->addWidget(generalGroupBox); mainLayout->addWidget(sizeGroupBox); } PageInformationDialog::~PageInformationDialog() { } QString PageInformationDialog::selectedTitle() { return (m_pTitleLineEdit->text()); } QString PageInformationDialog::dateTimeString(QDateTime dateTime) { QString result; Config config("qpe"); config.setGroup("Date"); QChar separator = config.readEntry("Separator", "/")[0]; DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); for (int i = 0; i < 3; i++) { switch((shortOrder >> (i * 3)) & 0x0007) { case 0x0001: - result += QString().sprintf("%02d", dateTime.date().day()); + result.append( QString().sprintf("%02d", dateTime.date().day()) ); break; case 0x0002: - result += QString().sprintf("%02d", dateTime.date().month()); + result.append( QString().sprintf("%02d", dateTime.date().month()) ); break; case 0x0004: - result += QString().sprintf("%04d", dateTime.date().year()); + result.append( QString().sprintf("%04d", dateTime.date().year()) ); break; default: break; } if (i < 2) { - result += separator; + result.append( separator ); } } - result += QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()); + result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) ); return result; } diff --git a/noncore/graphics/drawpad/thumbnailview.cpp b/noncore/graphics/drawpad/thumbnailview.cpp index 9b08ca2..90ba39c 100644 --- a/noncore/graphics/drawpad/thumbnailview.cpp +++ b/noncore/graphics/drawpad/thumbnailview.cpp @@ -1,94 +1,96 @@ /*************************************************************************** * * * 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 "thumbnailview.h" #include "drawpad.h" #include "drawpadcanvas.h" #include "newpagedialog.h" #include "page.h" #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/timestring.h> #include <qapplication.h> #include <qimage.h> #include <qlayout.h> #include <qmessagebox.h> #include <qtoolbutton.h> +#include <qwhatsthis.h> #define THUMBNAIL_SIZE 48 PageListBoxItem::PageListBoxItem(Page* page, QListBox* parent) : QListBoxItem(parent) { m_pPage = page; QImage image = m_pPage->pixmap()->convertToImage(); int previewWidth = THUMBNAIL_SIZE; int previewHeight = THUMBNAIL_SIZE; 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 thumbnailImage = image.smoothScale((int)(image.width() * scale) , (int)(image.height() * scale)); m_thumbnail.convertFromImage(thumbnailImage); - m_titleText = QObject::tr("Title:") + " " + m_pPage->title(); - m_dimensionText = QObject::tr("Dimension:") + " " + QString::number(m_pPage->pixmap()->width()) - + "x" + QString::number(m_pPage->pixmap()->height()); - m_dateText = QObject::tr("Date:") + " " + dateTimeString(m_pPage->lastModified()); + m_titleText = QObject::tr( "Title: %1" ).arg( m_pPage->title() ); + m_dimensionText = QObject::tr( "Dimension: %1x%2" ). + arg( m_pPage->pixmap()->width() ). + arg( m_pPage->pixmap()->height() ); + m_dateText = QObject::tr( "Date: %1" ).arg( dateTimeString(m_pPage->lastModified()) ); QColor baseColor = parent->colorGroup().base(); int h, s, v; baseColor.hsv(&h, &s, &v); if (v > 128) { m_alternateColor = baseColor.dark(115); } else if (baseColor != Qt::black) { m_alternateColor = baseColor.light(115); } else { m_alternateColor = QColor(32, 32, 32); } } PageListBoxItem::~PageListBoxItem() { } int PageListBoxItem::height(const QListBox*) const { return QMAX(THUMBNAIL_SIZE + 4, QApplication::globalStrut().height()); } int PageListBoxItem::width(const QListBox* lb) const { QFontMetrics fontMetrics = lb->fontMetrics(); int maxtextLength = QMAX(fontMetrics.width(m_titleText), QMAX(fontMetrics.width(m_dimensionText), fontMetrics.width(m_dateText))); return QMAX(THUMBNAIL_SIZE + maxtextLength + 8, QApplication::globalStrut().width()); } @@ -115,82 +117,82 @@ void PageListBoxItem::paint(QPainter *painter) itemRect.height() - 4); painter->setFont(boldFont); painter->drawText(textRect, Qt::AlignLeft | Qt::AlignTop, m_titleText); painter->setFont(standardFont); painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_dimensionText); painter->drawText(textRect, Qt::AlignLeft | Qt::AlignBottom, m_dateText); if (!selected() && !(listBox()->hasFocus() && listBox()->item(listBox()->currentItem()) == this)) { painter->drawLine(0, itemRect.height() - 1, itemRect.width() - 1, itemRect.height() - 1); } } Page* PageListBoxItem::page() const { return m_pPage; } QString PageListBoxItem::dateTimeString(QDateTime dateTime) { QString result; Config config("qpe"); config.setGroup("Date"); QChar separator = config.readEntry("Separator", "/")[0]; DateFormat::Order shortOrder = (DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear); for (int i = 0; i < 3; i++) { switch((shortOrder >> (i * 3)) & 0x0007) { case 0x0001: - result += QString().sprintf("%02d", dateTime.date().day()); + result.append( QString().sprintf("%02d", dateTime.date().day()) ); break; case 0x0002: - result += QString().sprintf("%02d", dateTime.date().month()); + result.append( QString().sprintf("%02d", dateTime.date().month()) ); break; case 0x0004: - result += QString().sprintf("%04d", dateTime.date().year()); + result.append( QString().sprintf("%04d", dateTime.date().year()) ); break; default: break; } if (i < 2) { - result += separator; + result.append( separator ); } } - result += QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()); + result.append( QString().sprintf(" %02d:%02d", dateTime.time().hour(), dateTime.time().minute()) ); return result; } PageListBox::PageListBox(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) : QListBox(parent, name) { m_pDrawPadCanvas = drawPadCanvas; setVScrollBarMode(QScrollView::AlwaysOn); updateView(); } PageListBox::~PageListBox() { } void PageListBox::updateView() { clear(); if (m_pDrawPadCanvas) { QList<Page> pageList = m_pDrawPadCanvas->pages(); QListIterator<Page> it(pageList); for (; it.current(); ++it) { new PageListBoxItem(it.current(), this); } select(m_pDrawPadCanvas->currentPage()); } @@ -200,97 +202,102 @@ void PageListBox::select(Page* page) { uint i = 0; uint itemCount = count(); while (i < itemCount) { PageListBoxItem* currentItem = (PageListBoxItem*)item(i); if (currentItem->page() == page) { setCurrentItem(currentItem); break; } i++; } } Page* PageListBox::selected() const { Page* page; PageListBoxItem* selectedItem = (PageListBoxItem*)item(currentItem()); if (selectedItem) { page = selectedItem->page(); } else { page = NULL; } return page; } ThumbnailView::ThumbnailView(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name) - : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel) + : QWidget(parent, name, Qt::WType_Modal | Qt::WType_TopLevel | Qt::WStyle_ContextHelp) { inLoop = false; m_pDrawPad = drawPad; m_pDrawPadCanvas = drawPadCanvas; setCaption(tr("DrawPad - Thumbnail View")); QToolButton* newPageButton = new QToolButton(this); newPageButton->setIconSet(Resource::loadIconSet("new")); newPageButton->setAutoRaise(true); connect(newPageButton, SIGNAL(clicked()), this, SLOT(newPage())); + QWhatsThis::add( newPageButton, tr( "Click here to add a new sheet." ) ); QToolButton* clearPageButton = new QToolButton(this); clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear")); clearPageButton->setAutoRaise(true); connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage())); + QWhatsThis::add( clearPageButton, tr( "Click here to erase the current sheet." ) ); QToolButton* deletePageButton = new QToolButton(this); deletePageButton->setIconSet(Resource::loadIconSet("trash")); deletePageButton->setAutoRaise(true); connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage())); + QWhatsThis::add( deletePageButton, tr( "Click here to remove the current sheet." ) ); m_pMovePageUpButton = new QToolButton(this); m_pMovePageUpButton->setIconSet(Resource::loadIconSet("up")); m_pMovePageUpButton->setAutoRaise(true); connect(m_pMovePageUpButton, SIGNAL(clicked()), this, SLOT(movePageUp())); - + QWhatsThis::add( m_pMovePageUpButton, tr( "Click here to move the current sheet up one position in the list." ) ); + m_pMovePageDownButton = new QToolButton(this); m_pMovePageDownButton->setIconSet(Resource::loadIconSet("down")); m_pMovePageDownButton->setAutoRaise(true); connect(m_pMovePageDownButton, SIGNAL(clicked()), this, SLOT(movePageDown())); + QWhatsThis::add( m_pMovePageDownButton, tr( "Click here to move the current sheet down one position in the list." ) ); m_pPageListBox = new PageListBox(m_pDrawPadCanvas, this); connect(m_pPageListBox, SIGNAL(selectionChanged()), this, SLOT(changePage())); QVBoxLayout* mainLayout = new QVBoxLayout(this, 4, 4); QHBoxLayout* buttonLayout = new QHBoxLayout(0); buttonLayout->addWidget(newPageButton); buttonLayout->addWidget(clearPageButton); buttonLayout->addWidget(deletePageButton); buttonLayout->addStretch(); buttonLayout->addWidget(m_pMovePageUpButton); buttonLayout->addWidget(m_pMovePageDownButton); mainLayout->addLayout(buttonLayout); mainLayout->addWidget(m_pPageListBox); updateView(); } ThumbnailView::~ThumbnailView() { hide(); } void ThumbnailView::updateView() { m_pMovePageUpButton->setEnabled(m_pDrawPadCanvas->goPreviousPageEnabled()); m_pMovePageDownButton->setEnabled(m_pDrawPadCanvas->goNextPageEnabled()); } void ThumbnailView::hide() |