From 32172e0e77bee1ae5ea781602c050feeb7896745 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 21 Jul 2014 23:08:05 +0200 Subject: [PATCH] Added save and save as items to the context menu. --HG-- branch : gsoc2014-dfighter --- .../translation_manager/uxt_editor.cpp | 32 +++++++++++++++++++ .../plugins/translation_manager/uxt_editor.h | 2 ++ 2 files changed, 34 insertions(+) diff --git a/code/studio/src/plugins/translation_manager/uxt_editor.cpp b/code/studio/src/plugins/translation_manager/uxt_editor.cpp index 6c108b667..b9548e0b5 100644 --- a/code/studio/src/plugins/translation_manager/uxt_editor.cpp +++ b/code/studio/src/plugins/translation_manager/uxt_editor.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -325,16 +326,22 @@ void UXTEditor::contextMenuEvent( QContextMenuEvent *e ) QAction *deleteAction = new QAction( "Delete row", menu ); QAction *markAction = new QAction( "Mark translated", menu ); QAction *unmarkAction = new QAction( "Mark not-translated", menu ); + QAction *saveAction = new QAction( "Save", menu ); + QAction *saveAsAction = new QAction( "Save as..", menu ); connect( insertAction, SIGNAL( triggered( bool ) ), this, SLOT( insertRow() ) ); connect( deleteAction, SIGNAL( triggered( bool ) ), this, SLOT( deleteRow() ) ); connect( markAction, SIGNAL( triggered( bool ) ), this, SLOT( markTranslated() ) ); connect( unmarkAction, SIGNAL( triggered( bool ) ), this, SLOT( markUntranslated() ) ); + connect( saveAction, SIGNAL( triggered( bool ) ), this, SLOT( onSaveClicked() ) ); + connect( saveAsAction, SIGNAL( triggered( bool ) ), this, SLOT( onSaveAsClicked() ) ); menu->addAction( insertAction ); menu->addAction( deleteAction ); menu->addAction( markAction ); menu->addAction( unmarkAction ); + menu->addAction( saveAction ); + menu->addAction( saveAsAction ); menu->exec( e->globalPos() ); } @@ -387,6 +394,31 @@ void UXTEditor::markUntranslated() markRowUntranslated( r ); } +void UXTEditor::onSaveClicked() +{ + save(); +} + +void UXTEditor::onSaveAsClicked() +{ + QString path = current_file; + int idx = path.lastIndexOf( '/' ); + if( idx < 0 ) + path = ""; + else + path = path.left( idx + 1 ); + + QString file = QFileDialog::getSaveFileName( this, + tr( "Save Uxt as.." ), + path, + tr( "Uxt files ( *.uxt)" ) ); + + if( file.isEmpty() ) + return; + + saveAs( file ); +} + void UXTEditor::setHeaderText( const QString &id, const QString &text ) { QTableWidgetItem *h1 = new QTableWidgetItem( id ); diff --git a/code/studio/src/plugins/translation_manager/uxt_editor.h b/code/studio/src/plugins/translation_manager/uxt_editor.h index b0f977709..b749e65e3 100644 --- a/code/studio/src/plugins/translation_manager/uxt_editor.h +++ b/code/studio/src/plugins/translation_manager/uxt_editor.h @@ -49,6 +49,8 @@ private Q_SLOTS: void onCellChanged( int row, int column ); void markTranslated(); void markUntranslated(); + void onSaveClicked(); + void onSaveAsClicked(); private: void setHeaderText( const QString &id, const QString &text );