summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show 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 @@
/***************************************************************************
* *
* 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 <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("Export"));
+ 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);
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()
{
return (m_pNameLineEdit->text());
}
QString ExportDialog::selectedFormat()
{
return (m_pFormatComboBox->currentText());
}
void ExportDialog::accept()
{
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 @@
/***************************************************************************
* *
* 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 <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("Import"));
+ setCaption(tr("DrawPad - Import"));
m_pFileSelector = new FileSelector("image/*", this, "fileselector");
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()
{
return m_pFileSelector->selected();
}
void ImportDialog::fileChanged()
{
if (m_pAutomaticPreviewCheckBox->isChecked()) {
preview();
}
}
void ImportDialog::preview()
{
const DocLnk* docLnk = m_pFileSelector->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/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)
bitBlt(&pixmap, (pixmap.width() - previewPixmap.width()) / 2,
(pixmap.height() - previewPixmap.height()) / 2, &previewPixmap);
setPixmap(0, pixmap);
}
PageListViewItem::~PageListViewItem()
{
}
Page* PageListViewItem::page() const
{
return m_pPage;
}
PageListView::PageListView(DrawPadCanvas* drawPadCanvas, QWidget* parent, const char* name)
: QListView(parent, name)
{
m_pDrawPadCanvas = drawPadCanvas;
header()->hide();
setVScrollBarMode(QScrollView::AlwaysOn);
setAllColumnsShowFocus(true);
addColumn(tr("Thumbnail"));
addColumn(tr("Information"));
updateView();
}
PageListView::~PageListView()
{
}
void PageListView::updateView()
{
clear();
if (m_pDrawPadCanvas) {
QList<Page> pageList = m_pDrawPadCanvas->pages();
QListIterator<Page> it(pageList);
for (; it.current(); ++it) {
new PageListViewItem(it.current(), this);
}
setSorting(0, false);
select(m_pDrawPadCanvas->currentPage());
}
}
void PageListView::resizeEvent(QResizeEvent* e)
{
Q_UNUSED(e);
setColumnWidth(1, contentsRect().width() - columnWidth(0) - verticalScrollBar()->width());
}
void PageListView::select(Page* page)
{
PageListViewItem* item = (PageListViewItem*)firstChild();
while (item) {
if (item->page() == page) {
setSelected(item, true);
ensureItemVisible(item);
break;
}
item = (PageListViewItem*)(item->nextSibling());
}
}
Page* PageListView::selected() const
{
Page* page;
PageListViewItem* item = (PageListViewItem*)selectedItem();
if (item) {
page = item->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)
{
inLoop = false;
m_pDrawPad = drawPad;
m_pDrawPadCanvas = drawPadCanvas;
- setCaption(tr("Thumbnail"));
+ 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()));
QToolButton* clearPageButton = new QToolButton(this);
clearPageButton->setIconSet(Resource::loadIconSet("drawpad/clear"));
clearPageButton->setAutoRaise(true);
connect(clearPageButton, SIGNAL(clicked()), this, SLOT(clearPage()));
QToolButton* deletePageButton = new QToolButton(this);
deletePageButton->setIconSet(Resource::loadIconSet("trash"));
deletePageButton->setAutoRaise(true);
connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePage()));
QToolButton* movePageUpButton = new QToolButton(this);
movePageUpButton->setIconSet(Resource::loadIconSet("up"));
movePageUpButton->setAutoRaise(true);
QToolButton* movePageDownButton = new QToolButton(this);
movePageDownButton->setIconSet(Resource::loadIconSet("down"));
movePageDownButton->setAutoRaise(true);
m_pPageListView = new PageListView(m_pDrawPadCanvas, this);
connect(m_pPageListView, 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(movePageUpButton);
buttonLayout->addWidget(movePageDownButton);
mainLayout->addLayout(buttonLayout);
mainLayout->addWidget(m_pPageListView);
}
ThumbnailView::~ThumbnailView()
{
hide();
}
void ThumbnailView::hide()
{
QWidget::hide();
if (inLoop) {
inLoop = false;
qApp->exit_loop();
}
}
void ThumbnailView::exec()
{
show();
if (!inLoop) {
inLoop = true;
qApp->enter_loop();
}
}
void ThumbnailView::newPage()
{
QRect rect = m_pDrawPadCanvas->contentsRect();
NewPageDialog newPageDialog(rect.width(), rect.height(), m_pDrawPad->pen().color(),
m_pDrawPad->brush().color(), this);
if (newPageDialog.exec() == QDialog::Accepted) {
m_pDrawPadCanvas->newPage(newPageDialog.selectedWidth(), newPageDialog.selectedHeight(),
newPageDialog.selectedColor());
m_pPageListView->updateView();
}
}
void ThumbnailView::clearPage()
{
QMessageBox messageBox(tr("Clear Page"), tr("Do you want to clear\nthe selected 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();
m_pPageListView->updateView();
}
}