Added save and save as items to the context menu.

This commit is contained in:
dfighter1985 2014-07-21 23:08:05 +02:00
parent d63c78b503
commit 7c0cd64ae7
2 changed files with 34 additions and 0 deletions

View file

@ -24,6 +24,7 @@
#include <QContextMenuEvent>
#include <QMessageBox>
#include <QMenu>
#include <QFileDialog>
#include <QFile>
#include <QTextStream>
@ -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 );

View file

@ -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 );