Added save and save as items to the context menu.
--HG-- branch : gsoc2014-dfighter
This commit is contained in:
parent
ed44cc4823
commit
32172e0e77
2 changed files with 34 additions and 0 deletions
|
@ -24,6 +24,7 @@
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
@ -325,16 +326,22 @@ void UXTEditor::contextMenuEvent( QContextMenuEvent *e )
|
||||||
QAction *deleteAction = new QAction( "Delete row", menu );
|
QAction *deleteAction = new QAction( "Delete row", menu );
|
||||||
QAction *markAction = new QAction( "Mark translated", menu );
|
QAction *markAction = new QAction( "Mark translated", menu );
|
||||||
QAction *unmarkAction = new QAction( "Mark not-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( insertAction, SIGNAL( triggered( bool ) ), this, SLOT( insertRow() ) );
|
||||||
connect( deleteAction, SIGNAL( triggered( bool ) ), this, SLOT( deleteRow() ) );
|
connect( deleteAction, SIGNAL( triggered( bool ) ), this, SLOT( deleteRow() ) );
|
||||||
connect( markAction, SIGNAL( triggered( bool ) ), this, SLOT( markTranslated() ) );
|
connect( markAction, SIGNAL( triggered( bool ) ), this, SLOT( markTranslated() ) );
|
||||||
connect( unmarkAction, SIGNAL( triggered( bool ) ), this, SLOT( markUntranslated() ) );
|
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( insertAction );
|
||||||
menu->addAction( deleteAction );
|
menu->addAction( deleteAction );
|
||||||
menu->addAction( markAction );
|
menu->addAction( markAction );
|
||||||
menu->addAction( unmarkAction );
|
menu->addAction( unmarkAction );
|
||||||
|
menu->addAction( saveAction );
|
||||||
|
menu->addAction( saveAsAction );
|
||||||
menu->exec( e->globalPos() );
|
menu->exec( e->globalPos() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,6 +394,31 @@ void UXTEditor::markUntranslated()
|
||||||
markRowUntranslated( r );
|
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 )
|
void UXTEditor::setHeaderText( const QString &id, const QString &text )
|
||||||
{
|
{
|
||||||
QTableWidgetItem *h1 = new QTableWidgetItem( id );
|
QTableWidgetItem *h1 = new QTableWidgetItem( id );
|
||||||
|
|
|
@ -49,6 +49,8 @@ private Q_SLOTS:
|
||||||
void onCellChanged( int row, int column );
|
void onCellChanged( int row, int column );
|
||||||
void markTranslated();
|
void markTranslated();
|
||||||
void markUntranslated();
|
void markUntranslated();
|
||||||
|
void onSaveClicked();
|
||||||
|
void onSaveAsClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setHeaderText( const QString &id, const QString &text );
|
void setHeaderText( const QString &id, const QString &text );
|
||||||
|
|
Loading…
Reference in a new issue