Skip to content

Commit

Permalink
Set better window titles for svg annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Nov 19, 2012
1 parent 463dec7 commit 5f02bc4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
77 changes: 39 additions & 38 deletions src/app/qgssvgannotationdialog.cpp
Expand Up @@ -22,24 +22,25 @@
#include <QFileInfo>
#include <QGraphicsScene>

QgsSvgAnnotationDialog::QgsSvgAnnotationDialog( QgsSvgAnnotationItem* item, QWidget * parent, Qt::WindowFlags f):
QgsSvgAnnotationDialog::QgsSvgAnnotationDialog( QgsSvgAnnotationItem* item, QWidget * parent, Qt::WindowFlags f ):
QDialog( parent, f ), mItem( item ), mEmbeddedWidget( 0 )
{
setupUi( this );
mEmbeddedWidget = new QgsAnnotationWidget( mItem );
mEmbeddedWidget->show();
mStackedWidget->addWidget( mEmbeddedWidget );
mStackedWidget->setCurrentWidget( mEmbeddedWidget );
setupUi( this );
setWindowTitle( tr( "SVG annotation" ) );
mEmbeddedWidget = new QgsAnnotationWidget( mItem );
mEmbeddedWidget->show();
mStackedWidget->addWidget( mEmbeddedWidget );
mStackedWidget->setCurrentWidget( mEmbeddedWidget );

if( mItem )
{
mFileLineEdit->setText( mItem->filePath() );
}
if ( mItem )
{
mFileLineEdit->setText( mItem->filePath() );
}

QObject::connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( applySettingsToItem() ) );
QPushButton* deleteButton = new QPushButton( tr( "Delete" ) );
QObject::connect( deleteButton, SIGNAL( clicked() ), this, SLOT( deleteItem() ) );
mButtonBox->addButton( deleteButton, QDialogButtonBox::RejectRole );
QObject::connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( applySettingsToItem() ) );
QPushButton* deleteButton = new QPushButton( tr( "Delete" ) );
QObject::connect( deleteButton, SIGNAL( clicked() ), this, SLOT( deleteItem() ) );
mButtonBox->addButton( deleteButton, QDialogButtonBox::RejectRole );
}

QgsSvgAnnotationDialog::QgsSvgAnnotationDialog(): QDialog(), mItem( 0 ), mEmbeddedWidget( 0 )
Expand All @@ -54,38 +55,38 @@ QgsSvgAnnotationDialog::~QgsSvgAnnotationDialog()

void QgsSvgAnnotationDialog::on_mBrowseToolButton_clicked()
{
QString directory;
QFileInfo fi( mFileLineEdit->text() );
if ( fi.exists() )
{
directory = fi.absolutePath();
}
QString filename = QFileDialog::getOpenFileName( 0, tr( "html" ), directory, "*.html" );
mFileLineEdit->setText( filename );
QString directory;
QFileInfo fi( mFileLineEdit->text() );
if ( fi.exists() )
{
directory = fi.absolutePath();
}
QString filename = QFileDialog::getOpenFileName( 0, tr( "Select SVG file" ), directory, tr( "SVG files" ) + " (*.svg)" );
mFileLineEdit->setText( filename );
}

void QgsSvgAnnotationDialog::applySettingsToItem()
{
if ( mEmbeddedWidget )
{
mEmbeddedWidget->apply();
}
if ( mEmbeddedWidget )
{
mEmbeddedWidget->apply();
}

if( mItem )
{
mItem->setFilePath( mFileLineEdit->text() );
mItem->update();
}
if ( mItem )
{
mItem->setFilePath( mFileLineEdit->text() );
mItem->update();
}

}

void QgsSvgAnnotationDialog::deleteItem()
{
QGraphicsScene* scene = mItem->scene();
if ( scene )
{
scene->removeItem( mItem );
}
delete mItem;
mItem = 0;
QGraphicsScene* scene = mItem->scene();
if ( scene )
{
scene->removeItem( mItem );
}
delete mItem;
mItem = 0;
}
2 changes: 1 addition & 1 deletion src/ui/qgsformannotationdialogbase.ui
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Form annotation</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
Expand Down

0 comments on commit 5f02bc4

Please sign in to comment.