Commit 0ea96257 authored by Fabio D'Urso's avatar Fabio D'Urso

Save action implemented

parent d29b8a26
......@@ -654,6 +654,7 @@ void Part::setupViewerActions()
m_findPrev = KStandardAction::findPrev( this, SLOT(slotFindPrev()), ac );
m_findPrev->setEnabled( false );
m_save = 0;
m_saveAs = 0;
QAction * prefs = KStandardAction::preferences( this, SLOT(slotPreferences()), ac);
......@@ -750,6 +751,8 @@ void Part::setupActions()
m_selectAll = KStandardAction::selectAll( m_pageView, SLOT(selectAll()), ac );
m_save = KStandardAction::save( this, SLOT(saveFile()), ac );
m_save->setEnabled( false );
m_saveAs = KStandardAction::saveAs( this, SLOT(slotSaveFileAs()), ac );
m_saveAs->setEnabled( false );
......@@ -1327,6 +1330,7 @@ bool Part::openFile()
m_find->setEnabled( ok && canSearch );
m_findNext->setEnabled( ok && canSearch );
m_findPrev->setEnabled( ok && canSearch );
if( m_save ) m_save->setEnabled( ok && !( isstdin || mime->is( "inode/directory" ) ) );
if( m_saveAs ) m_saveAs->setEnabled( ok && !( isstdin || mime->is( "inode/directory" ) ) );
emit enablePrintAction( ok && m_document->printingSupport() != Okular::Document::NoPrinting );
m_printPreview->setEnabled( ok && m_document->printingSupport() != Okular::Document::NoPrinting );
......@@ -1491,13 +1495,13 @@ bool Part::queryClose()
const int res = KMessageBox::warningYesNoCancel( widget(),
i18n( "Do you want to save your annotation changes or discard them?" ),
i18n( "Close Document" ),
KStandardGuiItem::saveAs(),
KStandardGuiItem::save(),
KStandardGuiItem::discard() );
switch ( res )
{
case KMessageBox::Yes: // Save as
slotSaveFileAs();
saveFile();
return !isModified(); // Only allow closing if file was really saved
case KMessageBox::No: // Discard
return true;
......@@ -1524,6 +1528,7 @@ bool Part::closeUrl(bool promptToSave)
m_find->setEnabled( false );
m_findNext->setEnabled( false );
m_findPrev->setEnabled( false );
if( m_save ) m_save->setEnabled( false );
if( m_saveAs ) m_saveAs->setEnabled( false );
m_printPreview->setEnabled( false );
m_showProperties->setEnabled( false );
......@@ -2117,8 +2122,10 @@ void Part::slotFindPrev()
bool Part::saveFile()
{
kDebug() << "Okular part doesn't support saving the file in the location from which it was opened";
return false;
if ( !isModified() )
return true;
else
return saveAs( url() );
}
bool Part::slotSaveFileAs( bool showOkularArchiveAsDefaultFormat )
......
......@@ -168,7 +168,6 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
void displayInfoMessage( const QString &message, KMessageWidget::MessageType messageType = KMessageWidget::Information, int duration = -1 );;
public:
bool saveFile();
bool queryClose();
bool closeUrl();
bool closeUrl(bool promptToSave);
......@@ -220,6 +219,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
void slotRebuildBookmarkMenu();
public slots:
bool saveFile();
// connected to Shell action (and browserExtension), not local one
void slotPrint();
void restoreDocument(const KConfigGroup &group);
......@@ -309,6 +309,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
KAction *m_find;
KAction *m_findNext;
KAction *m_findPrev;
KAction *m_save;
KAction *m_saveAs;
KAction *m_saveCopyAs;
KAction *m_printPreview;
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="okular_part" version="36">
<kpartgui name="okular_part" version="37">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
<Action name="get_new_stuff" group="file_open"/>
<Action name="import_ps" group="file_open"/>
<Action name="file_save" group="file_save"/>
<Action name="file_save_as" group="file_save"/>
<Action name="file_reload" group="file_save"/>
<Action name="file_print" group="file_print"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment