~adamreichold/qpdfview/trunk

« back to all changes in this revision

Viewing changes to sources/mainwindow.cpp

  • Committer: Adam Reichold
  • Date: 2012-11-12 10:22:05 UTC
  • mto: This revision was merged to the branch mainline in revision 743.
  • Revision ID: adamreichold@myopera.com-20121112102205-7avptk8nyf2ohj80
separate 'save copy' (without changes) and 'save as' (with changes) actions

Show diffs side-by-side

added added

removed removed

Lines of Context:
216
216
    {
217
217
        m_refreshAction->setEnabled(true);
218
218
        m_saveCopyAction->setEnabled(true);
 
219
        m_saveAsAction->setEnabled(true);
219
220
        m_printAction->setEnabled(true);
220
221
 
221
222
        m_previousPageAction->setEnabled(true);
296
297
    {
297
298
        m_refreshAction->setEnabled(false);
298
299
        m_saveCopyAction->setEnabled(false);
 
300
        m_saveAsAction->setEnabled(false);
299
301
        m_printAction->setEnabled(false);
300
302
 
301
303
        m_previousPageAction->setEnabled(false);
677
679
 
678
680
    if(!filePath.isEmpty())
679
681
    {
680
 
        if(!currentTab()->saveCopy(filePath))
 
682
        if(!currentTab()->save(filePath, false))
681
683
        {
682
684
            QMessageBox::warning(this, tr("Warning"), tr("Could not save copy at '%1'.").arg(filePath));
683
685
        }
684
686
    }
685
687
}
686
688
 
 
689
void MainWindow::on_saveAs_triggered()
 
690
{
 
691
    QString filePath = QFileDialog::getSaveFileName(this, tr("Save as"), currentTab()->filePath(), "Portable document format (*.pdf)");
 
692
 
 
693
    if(!filePath.isEmpty())
 
694
    {
 
695
        if(currentTab()->save(filePath, true))
 
696
        {
 
697
            open(filePath, currentTab()->currentPage());
 
698
        }
 
699
        else
 
700
        {
 
701
            QMessageBox::warning(this, tr("Warning"), tr("Could not save as '%1'.").arg(filePath));
 
702
        }
 
703
    }
 
704
}
 
705
 
687
706
void MainWindow::on_print_triggered()
688
707
{
689
708
    QPrinter* printer = new QPrinter();
1456
1475
    m_saveCopyAction->setIconVisibleInMenu(true);
1457
1476
    connect(m_saveCopyAction, SIGNAL(triggered()), SLOT(on_saveCopy_triggered()));
1458
1477
 
 
1478
    // save as
 
1479
 
 
1480
    m_saveAsAction = new QAction(tr("Save &as..."), this);
 
1481
    m_saveAsAction->setShortcut(QKeySequence::SaveAs);
 
1482
    m_saveAsAction->setIcon(QIcon::fromTheme("document-save-as", QIcon(":icons/document-save-as.svg")));
 
1483
    m_saveAsAction->setIconVisibleInMenu(true);
 
1484
    connect(m_saveAsAction, SIGNAL(triggered()), SLOT(on_saveAs_triggered()));
 
1485
 
1459
1486
    // print
1460
1487
 
1461
1488
    m_printAction = new QAction(tr("&Print..."), this);
1765
1792
        else if(action == "openInNewTab") { m_fileToolBar->addAction(m_openInNewTabAction); }
1766
1793
        else if(action == "refresh") { m_fileToolBar->addAction(m_refreshAction); }
1767
1794
        else if(action == "saveCopy") { m_fileToolBar->addAction(m_saveCopyAction); }
 
1795
        else if(action == "saveAs") { m_fileToolBar->addAction(m_saveAsAction); }
1768
1796
        else if(action == "print") { m_fileToolBar->addAction(m_printAction); }
1769
1797
    }
1770
1798
 
1928
1956
 
1929
1957
    m_fileMenu->addAction(m_refreshAction);
1930
1958
    m_fileMenu->addAction(m_saveCopyAction);
 
1959
    m_fileMenu->addAction(m_saveAsAction);
1931
1960
    m_fileMenu->addAction(m_printAction);
1932
1961
    m_fileMenu->addSeparator();
1933
1962
    m_fileMenu->addAction(m_exitAction);