~ubuntu-branches/ubuntu/saucy/merkaartor/saucy

« back to all changes in this revision

Viewing changes to Utils/PictureViewerDialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz
  • Date: 2009-09-13 00:52:12 UTC
  • mto: (1.2.7 upstream) (0.1.3 upstream) (3.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090913005212-pjecal8zxm07x0fj
ImportĀ upstreamĀ versionĀ 0.14+svnfixes~20090912

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// C++ Implementation: PictureViewerDialog
3
 
//
4
 
// Description:
5
 
//
6
 
//
7
 
// Author: Chris Browet <cbro@semperpax.com>, (C) 2008
8
 
//
9
 
// Copyright: See COPYING file that comes with this distribution
10
 
//
11
 
//
12
 
#include "PictureViewerDialog.h"
13
 
 
14
 
#include <QFileDialog>
15
 
#include <QFile>
16
 
 
17
 
PictureViewerDialog::PictureViewerDialog(const QString& title, const QString &filename, QWidget *parent)
18
 
    :QDialog(parent), m_filename(filename)
19
 
{
20
 
        setupUi(this);
21
 
 
22
 
        pixWidget->loadFile(filename);
23
 
        setWindowTitle(title);
24
 
}
25
 
 
26
 
PictureViewerDialog::PictureViewerDialog(const QString& title, const QPixmap& thePixmap, QWidget *parent)
27
 
    :QDialog(parent)
28
 
{
29
 
        setupUi(this);
30
 
 
31
 
        pixWidget->setPixmap(thePixmap);
32
 
        setWindowTitle(title);
33
 
}
34
 
 
35
 
void PictureViewerDialog::on_buttonBox_clicked(QAbstractButton * button)
36
 
{
37
 
        if (buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
38
 
                if (m_filename.endsWith("svg", Qt::CaseInsensitive)) {
39
 
                        QString s = QFileDialog::getSaveFileName(this,tr("Output filename"),"",tr("SVG files (*.svg)"));
40
 
                        if (!s.isNull()) {
41
 
                                QFile(m_filename).copy(s);
42
 
                        }
43
 
                } else {
44
 
                        QString s = QFileDialog::getSaveFileName(this,tr("Output filename"),"",tr("Image files (*.png *.jpg)"));
45
 
                        if (!s.isNull()) {
46
 
                                pixWidget->pixmap()->save(s);
47
 
                        }
48
 
                }
49
 
        }
50
 
}