manualviewerdlg.cpp 1.6 KB
#include <QImageReader>
#include <QDebug>
#include "manualviewerdlg.h"
#include "ui_manualviewerdlg.h"

ManualViewerDlg::ManualViewerDlg(QWidget *parent, uint32_t start) :
    QDialog(parent),
    ui(new Ui::ManualViewerDlg)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose);
    this->setFocus();

    m_nCurPage = start;
    if(m_nCurPage<1 || m_nCurPage > MAX_MANUAL_PAGE) m_nCurPage = 1;

    //ui->ctrLbManual->setScaledContents(true);
    QPixmap image(QString("/prime/manual/manual-%1.png").arg(m_nCurPage,2,10,QLatin1Char('0')));
    ui->ctrLbManual->setPixmap(image);
}

ManualViewerDlg::~ManualViewerDlg()
{
    delete ui;
}

void ManualViewerDlg::on_backButton_clicked()
{
    deleteLater();
}

void ManualViewerDlg::on_leftButton_clicked()
{
    m_nCurPage--;
    if(m_nCurPage<1) m_nCurPage=MAX_MANUAL_PAGE;
    QPixmap image(QString("/prime/manual/manual-%1.png").arg(m_nCurPage,2,10,QLatin1Char('0')));
    ui->ctrLbManual->setPixmap(image);
    //ui->ctrLbManual->setPixmap(image.scaled(ui->ctrLbManual->size(),Qt::KeepAspectRatio, Qt::SmoothTransformation));
}



void ManualViewerDlg::on_rightButton_clicked()
{
    m_nCurPage++;
    if(m_nCurPage > MAX_MANUAL_PAGE) m_nCurPage = 1;
    QPixmap image(QString("/prime/manual/manual-%1.png").arg(m_nCurPage,2,10,QLatin1Char('0')));
//    QPixmap scale = image.scaled(ui->ctrLbManual->size(),Qt::KeepAspectRatio, Qt::SmoothTransformation);
//    qDebug() << image.size();
//    qDebug() << scale.size();
//    ui->ctrLbManual->setPixmap(image.scaled(ui->ctrLbManual->size(),Qt::KeepAspectRatio, Qt::SmoothTransformation));
    ui->ctrLbManual->setPixmap(image);
}