~vcs-imports/qtpfsgui/trunk

« back to all changes in this revision

Viewing changes to src/Common/ImageQualityDialog.cpp

  • Committer: fcomida
  • Date: 2009-07-08 15:30:39 UTC
  • Revision ID: vcs-imports@canonical.com-20090708153039-66puaj50rnppo2yk
I made some changes to filenames to easy navigation of the source code,
it was quite a mess (ui dialog names different from cpp filenames
implementing the dialog and so on).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * This file is a part of Qtpfsgui package.
 
3
 * ----------------------------------------------------------------------
 
4
 * Copyright (C) 2009 Franco Comida
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 * ----------------------------------------------------------------------
 
20
 *
 
21
 * @author Franco Comida <fcomida@users.sourceforge.net>
 
22
 */
 
23
 
 
24
#include <QImage>
 
25
#include <QString>
 
26
#include <QByteArray>
 
27
#include <QBuffer>
 
28
 
 
29
#include "ImageQualityDialog.h"
 
30
 
 
31
ImageQualityDialog::~ImageQualityDialog() {}
 
32
 
 
33
ImageQualityDialog::ImageQualityDialog(const QImage &img, QString fmt, QWidget *parent) : QDialog(parent), image(img)  {
 
34
        setupUi(this);
 
35
        format = fmt;
 
36
        connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(reset(int)));
 
37
        connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(reset(int)));
 
38
}
 
39
 
 
40
int ImageQualityDialog::getQuality(void) {
 
41
        return spinBox->value();
 
42
}
 
43
 
 
44
void ImageQualityDialog::on_getSizeButton_clicked() {
 
45
        setCursor(QCursor(Qt::WaitCursor));
 
46
        int quality = spinBox->value();
 
47
        QByteArray ba;
 
48
        QBuffer buffer(&ba);
 
49
        buffer.open(QIODevice::WriteOnly);
 
50
        image.save(&buffer, (const char *) format.toLatin1(), quality);
 
51
        label_filesize->setText(QString::number( ba.size() )); //the JPG on disk differs by 374 more bytes
 
52
        setCursor(QCursor(Qt::ArrowCursor));
 
53
}
 
54
 
 
55
void ImageQualityDialog::reset(int) {
 
56
        label_filesize->setText(tr("Unknown"));
 
57
}