summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Mihalache <[email protected]>2015-04-02 10:51:17 +0300
committerConstantin Mihalache <[email protected]>2015-04-02 10:51:17 +0300
commit986351f03a06b5cc1c7026555ea41784b7c6e4c3 (patch)
tree35f93393ae2420ad052bec927544efd15ea900c6
parent7109b1c67b6cde1a63dc6bbeee954cdb481745fe (diff)
Refactor code from EditPlacemarkDialog description to FormattedTextWidget.
Replace EditPlacemarkDialog description editing. Implement FormattedTextWidget to EditPolygonDialog, EditPolylineDialog and EditGroundOverlayDialog. REVIEW: 123122
-rw-r--r--src/lib/marble/CMakeLists.txt3
-rw-r--r--src/lib/marble/EditPlacemarkDialog.cpp211
-rw-r--r--src/lib/marble/EditPlacemarkDialog.h52
-rw-r--r--src/lib/marble/EditPlacemarkDialog.ui178
-rw-r--r--src/lib/marble/FormattedTextWidget.cpp271
-rw-r--r--src/lib/marble/FormattedTextWidget.h57
-rw-r--r--src/lib/marble/FormattedTextWidget.ui257
-rw-r--r--src/plugins/render/annotate/EditGroundOverlayDialog.cpp15
-rw-r--r--src/plugins/render/annotate/EditGroundOverlayDialog.ui5
-rw-r--r--src/plugins/render/annotate/EditPolygonDialog.cpp13
-rw-r--r--src/plugins/render/annotate/EditPolygonDialog.ui11
-rw-r--r--src/plugins/render/annotate/EditPolylineDialog.cpp15
-rw-r--r--src/plugins/render/annotate/EditPolylineDialog.ui9
13 files changed, 663 insertions, 434 deletions
diff --git a/src/lib/marble/CMakeLists.txt b/src/lib/marble/CMakeLists.txt
index 6c65015..bb22f76 100644
--- a/src/lib/marble/CMakeLists.txt
+++ b/src/lib/marble/CMakeLists.txt
@@ -201,6 +201,7 @@ set(marblewidget_SRCS
TourCaptureDialog.cpp
EditPlacemarkDialog.cpp
AddLinkDialog.cpp
+ FormattedTextWidget.cpp
AbstractDataPlugin.cpp
AbstractDataPluginModel.cpp
@@ -346,6 +347,7 @@ set (marblewidget_UI
TourCaptureDialog.ui
EditPlacemarkDialog.ui
AddLinkDialog.ui
+ FormattedTextWidget.ui
ElevationWidget.ui
)
@@ -567,6 +569,7 @@ install( FILES
PlanetFactory.h
EditPlacemarkDialog.h
AddLinkDialog.h
+ FormattedTextWidget.h
AbstractDataPlugin.h
AbstractDataPluginModel.h
diff --git a/src/lib/marble/EditPlacemarkDialog.cpp b/src/lib/marble/EditPlacemarkDialog.cpp
index 3d0d61f..6854813 100644
--- a/src/lib/marble/EditPlacemarkDialog.cpp
+++ b/src/lib/marble/EditPlacemarkDialog.cpp
@@ -25,6 +25,7 @@
#include <QFontComboBox>
#include <QPushButton>
#include <QLineEdit>
+#include <QVBoxLayout>
// Marble
#include "GeoDataStyle.h"
@@ -32,6 +33,7 @@
#include "MarbleWidget.h"
#include "MarbleLocale.h"
#include "AddLinkDialog.h"
+#include "FormattedTextWidget.h"
namespace Marble {
@@ -46,8 +48,8 @@ public:
// Attached to label/icon/text color selectors.
QColorDialog *m_iconColorDialog;
QColorDialog *m_labelColorDialog;
- QColorDialog *m_textColorDialog;
+ FormattedTextWidget *m_formattedTextWidget;
// Used to restore if the Cancel button is pressed.
QString m_initialDescription;
@@ -62,15 +64,14 @@ public:
Ui::ElevationWidget *m_elevationWidget;
MarbleLocale::MeasureUnit m_elevationUnit;
QString m_initialTargetId;
- QPushButton *m_textColorButton;
+
};
EditPlacemarkDialog::Private::Private( GeoDataPlacemark *placemark ) :
Ui::UiEditPlacemarkDialog(),
m_placemark( placemark ),
m_iconColorDialog( 0 ),
- m_labelColorDialog( 0 ),
- m_textColorButton( new QPushButton )
+ m_labelColorDialog( 0 )
{
// nothing to do
}
@@ -80,7 +81,6 @@ EditPlacemarkDialog::Private::~Private()
delete m_elevationWidget;
delete m_iconColorDialog;
delete m_labelColorDialog;
- delete m_textColorDialog;
}
EditPlacemarkDialog::EditPlacemarkDialog( GeoDataPlacemark *placemark, QWidget *parent ) :
@@ -89,6 +89,13 @@ EditPlacemarkDialog::EditPlacemarkDialog( GeoDataPlacemark *placemark, QWidget *
{
d->setupUi( this );
+ d->m_formattedTextWidget = new FormattedTextWidget( d->m_descriptionTab );
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget( d->m_formattedTextWidget );
+ layout->addWidget( d->m_isBalloonVisible );
+ d->m_descriptionTab->setLayout( layout );
+
// Store initial style so that it can be restored if the 'Cancel' button is pressed.
d->m_initialStyle = *placemark->style();
@@ -119,7 +126,7 @@ EditPlacemarkDialog::EditPlacemarkDialog( GeoDataPlacemark *placemark, QWidget *
connect( d->m_header, SIGNAL(valueChanged()), this, SLOT(
updateTextAnnotation()) );
- d->m_description->setHtml( placemark->description() );
+ d->m_formattedTextWidget->setText( placemark->description() );
d->m_initialDescription = placemark->description();
d->m_initialDescriptionIsCDATA = placemark->descriptionIsCDATA();
d->m_isBalloonVisible->setChecked( placemark->isBalloonVisible() );
@@ -197,38 +204,6 @@ EditPlacemarkDialog::EditPlacemarkDialog( GeoDataPlacemark *placemark, QWidget *
connect( d->m_iconColorDialog, SIGNAL(colorSelected(QColor)), this, SLOT(updateIconDialog(const QColor&)) );
connect( d->m_iconColorDialog, SIGNAL(colorSelected(QColor)), this, SLOT(updateTextAnnotation()) );
- d->m_formattedTextToolBar->setVisible( true );
- d->m_fontSize->setVisible( true );
- d->m_fontFamily->setVisible( true );
- QAction *separator = d->m_formattedTextToolBar->insertSeparator( d->m_actionAddImage );
- d->m_formattedTextToolBar->insertWidget( separator, d->m_textColorButton );
- d->m_textColorButton->setMaximumSize( 24, 24 );
- QPixmap textColorPixmap( d->m_textColorButton->iconSize().width(),
- d->m_textColorButton->iconSize().height() );
- textColorPixmap.fill( d->m_description->textCursor().charFormat().foreground().color() );
- d->m_textColorButton->setIcon( QIcon( textColorPixmap ) );
- d->m_textColorDialog = new QColorDialog( this );
- d->m_textColorDialog->setOption( QColorDialog::ShowAlphaChannel );
- d->m_textColorDialog->setCurrentColor( d->m_description->textCursor().charFormat().foreground().color() );
- d->m_fontSize->setValidator( new QIntValidator( 1, 9000, this ) );
- int index = d->m_fontSize->findText( QString::number( d->m_description->textCursor().charFormat().font().pointSize() ) );
- if( index != -1 ) {
- d->m_fontSize->setCurrentIndex( index );
- } else {
- d->m_fontSize->lineEdit()->setText( QString::number( d->m_description->textCursor().charFormat().font().pointSize() ) );
- }
- connect( d->m_textColorButton, SIGNAL( clicked() ), d->m_textColorDialog, SLOT( exec() ) );
- connect( d->m_textColorDialog, SIGNAL( colorSelected( QColor ) ), this, SLOT( setTextCursorColor( const QColor& ) ) );
- connect( d->m_isFormattedTextMode, SIGNAL( toggled( bool ) ), this, SLOT( toggleDescriptionEditMode( bool ) ) );
- connect( d->m_fontFamily, SIGNAL( currentFontChanged( QFont ) ), this, SLOT( setTextCursorFont( QFont ) ) );
- connect( d->m_fontSize, SIGNAL( editTextChanged( QString ) ), this, SLOT( setTextCursorFontSize( QString ) ) );
- connect( d->m_actionBold, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorBold( bool ) ) );
- connect( d->m_actionItalics, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorItalic( bool ) ) );
- connect( d->m_actionUnderlined, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorUnderlined( bool ) ) );
- connect( d->m_actionAddImage, SIGNAL( triggered() ), this, SLOT( addImageToDescription() ) );
- connect( d->m_actionAddLink, SIGNAL( triggered() ), this, SLOT( addLinkToDescription() ) );
- connect( d->m_description, SIGNAL( cursorPositionChanged() ), this, SLOT( updateDescriptionEditButtons() ) );
- connect( d->m_isPlacemarkVisible, SIGNAL( toggled(bool) ), this, SLOT( updateTextAnnotation() ) );
connect( d->m_isBalloonVisible, SIGNAL( toggled(bool) ), this, SLOT( updateTextAnnotation() ) );
// Promote "Ok" button to default button.
@@ -304,7 +279,7 @@ void EditPlacemarkDialog::setIdFieldVisible(bool visible)
void EditPlacemarkDialog::setReadOnly(bool state)
{
d->m_header->setReadOnly(state);
- d->m_description->setReadOnly(state);
+ d->m_formattedTextWidget->setReadOnly(state);
d->m_isBalloonVisible->setDisabled(state);
d->m_isPlacemarkVisible->setDisabled(state);
d->style_color_tab->setDisabled(state);
@@ -312,11 +287,7 @@ void EditPlacemarkDialog::setReadOnly(bool state)
void EditPlacemarkDialog::updateTextAnnotation()
{
- if( d->m_isFormattedTextMode->isChecked() ) {
- d->m_placemark->setDescription( d->m_description->toHtml() );
- } else {
- d->m_placemark->setDescription( d->m_description->toPlainText() );
- }
+ d->m_placemark->setDescription( d->m_formattedTextWidget->text() );
//allow for HTML in the description
d->m_placemark->setDescriptionCDATA( true );
d->m_placemark->setName( d->m_header->name() );
@@ -479,158 +450,6 @@ void EditPlacemarkDialog::restoreInitial( int result )
emit textAnnotationUpdated( d->m_placemark );
}
-void EditPlacemarkDialog::toggleDescriptionEditMode(bool isFormattedTextMode)
-{
- d->m_formattedTextToolBar->setVisible( isFormattedTextMode );
- d->m_fontSize->setVisible( isFormattedTextMode );
- d->m_fontFamily->setVisible( isFormattedTextMode );
- if( isFormattedTextMode ) {
- d->m_description->setHtml( d->m_description->toPlainText() );
- } else {
- QTextCursor cursor = d->m_description->textCursor();
- QTextCharFormat format;
- format.setFont( QFont() );
- format.setFontWeight( QFont::Normal );
- format.setFontItalic( false );
- format.setFontUnderline( false );
- format.clearForeground();
- cursor.setCharFormat( format );
- d->m_description->setTextCursor( cursor );
- d->m_description->setPlainText( d->m_description->toHtml() );
- }
-}
-
-void EditPlacemarkDialog::setTextCursorBold( bool bold )
-{
- QTextCursor cursor = d->m_description->textCursor();
- QTextCharFormat format;
- format.setFontWeight( bold ? QFont::Bold : QFont::Normal );
- cursor.mergeCharFormat( format );
- d->m_description->setTextCursor( cursor );
-}
-
-void EditPlacemarkDialog::setTextCursorItalic( bool italic )
-{
- QTextCursor cursor = d->m_description->textCursor();
- QTextCharFormat format;
- format.setFontItalic( italic );
- cursor.mergeCharFormat( format );
- d->m_description->setTextCursor( cursor );
-}
-
-void EditPlacemarkDialog::setTextCursorUnderlined( bool underlined )
-{
- QTextCursor cursor = d->m_description->textCursor();
- QTextCharFormat format;
- format.setFontUnderline( underlined );
- cursor.mergeCharFormat( format );
- d->m_description->setTextCursor( cursor );
-}
-
-void EditPlacemarkDialog::setTextCursorColor( const QColor &color )
-{
- QTextCursor cursor = d->m_description->textCursor();
- QTextCharFormat format;
- QBrush brush( color );
- format.setForeground( brush );
- cursor.mergeCharFormat( format );
- d->m_description->setTextCursor( cursor );
- QPixmap textColorPixmap( d->m_textColorButton->iconSize().width(),
- d->m_textColorButton->iconSize().height() );
- textColorPixmap.fill( format.foreground().color() );
- d->m_textColorButton->setIcon( QIcon( textColorPixmap ) );
- d->m_textColorDialog->setCurrentColor( format.foreground().color() );
-}
-
-void EditPlacemarkDialog::setTextCursorFont( const QFont &font )
-{
- QTextCursor cursor = d->m_description->textCursor();
- QTextCharFormat format;
- format.setFontFamily( font.family() );
- cursor.mergeCharFormat( format );
- d->m_description->setTextCursor( cursor );
-}
-
-void EditPlacemarkDialog::setTextCursorFontSize(const QString &fontSize)
-{
- bool ok = false;
- int size = fontSize.toInt( &ok );
- if( ok ) {
- QTextCursor cursor = d->m_description->textCursor();
- QTextCharFormat format;
- format.setFontPointSize( size );
- cursor.mergeCharFormat( format );
- d->m_description->setTextCursor( cursor );
- }
-}
-
-void EditPlacemarkDialog::addImageToDescription()
-{
- QString filename = QFileDialog::getOpenFileName( this, tr( "Choose image" ), tr( "All Supported Files (*.png *.jpg *.jpeg)" ) );
- QImage image( filename );
- if( !image.isNull() ) {
- QTextCursor cursor = d->m_description->textCursor();
- cursor.insertImage( image, filename );
- }
-}
-
-void EditPlacemarkDialog::addLinkToDescription()
-{
- QPointer<AddLinkDialog> dialog = new AddLinkDialog( this );
- if( dialog->exec() ) {
- QTextCharFormat oldFormat = d->m_description->textCursor().charFormat();
- QTextCharFormat linkFormat = oldFormat;
- linkFormat.setAnchor( true );
- linkFormat.setFontUnderline( true );
- linkFormat.setForeground( QApplication::palette().link() );
- linkFormat.setAnchorHref( dialog->url() );
- d->m_description->textCursor().insertText( dialog->name(), linkFormat );
- QTextCursor cursor = d->m_description->textCursor();
- cursor.setCharFormat( oldFormat );
- d->m_description->setTextCursor( cursor );
- d->m_description->textCursor().insertText( " " );
- }
-}
-
-void EditPlacemarkDialog::updateDescriptionEditButtons()
-{
- disconnect( d->m_actionBold, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorBold( bool ) ) );
- disconnect( d->m_actionItalics, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorItalic( bool ) ) );
- disconnect( d->m_actionUnderlined, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorUnderlined( bool ) ) );
- disconnect( d->m_fontFamily, SIGNAL( currentFontChanged( QFont ) ), this, SLOT( setTextCursorFont( QFont ) ) );
- disconnect( d->m_fontSize, SIGNAL( editTextChanged( QString ) ), this, SLOT( setTextCursorFontSize( QString ) ) );
-
- QTextCharFormat format = d->m_description->textCursor().charFormat();
-
- d->m_fontFamily->setCurrentFont( format.font() );
-
- if( format.fontWeight() == QFont::Bold ) {
- d->m_actionBold->setChecked( true );
- } else if ( format.fontWeight() == QFont::Normal ) {
- d->m_actionBold->setChecked( false );
- }
- d->m_actionItalics->setChecked( format.fontItalic() );
- d->m_actionUnderlined->setChecked( format.fontUnderline() );
-
- QPixmap textColorPixmap( d->m_textColorButton->iconSize().width(),
- d->m_textColorButton->iconSize().height() );
- textColorPixmap.fill( format.foreground().color() );
- d->m_textColorButton->setIcon( QIcon( textColorPixmap ) );
- d->m_textColorDialog->setCurrentColor( format.foreground().color() );
-
- int index = d->m_fontSize->findText( QString::number( d->m_description->textCursor().charFormat().font().pointSize() ) );
- if( index != -1 ) {
- d->m_fontSize->setCurrentIndex( index );
- } else {
- d->m_fontSize->lineEdit()->setText( QString::number( d->m_description->textCursor().charFormat().font().pointSize() ) );
- }
- connect( d->m_actionBold, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorBold( bool ) ) );
- connect( d->m_actionItalics, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorItalic( bool ) ) );
- connect( d->m_actionUnderlined, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorUnderlined( bool ) ) );
- connect( d->m_fontFamily, SIGNAL( currentFontChanged( QFont ) ), this, SLOT( setTextCursorFont( QFont ) ) );
- connect( d->m_fontSize, SIGNAL( editTextChanged( QString ) ), this, SLOT( setTextCursorFontSize( QString ) ) );
-}
-
}
#include "EditPlacemarkDialog.moc"
diff --git a/src/lib/marble/EditPlacemarkDialog.h b/src/lib/marble/EditPlacemarkDialog.h
index 015173c..1ff59c2 100644
--- a/src/lib/marble/EditPlacemarkDialog.h
+++ b/src/lib/marble/EditPlacemarkDialog.h
@@ -136,58 +136,6 @@ private slots:
/**
* @brief toogleDescriptionEditMode toggles edit mode for description field.
*/
- void toggleDescriptionEditMode( bool isFormattedTextMode = false );
-
- /**
- * @brief setTextCursorBold sets bold style for selected text in description field.
- * @param bold
- */
- void setTextCursorBold( bool bold );
-
- /**
- * @brief setTextCursorItalic sets italic style for selected text in description field.
- * @param italic
- */
- void setTextCursorItalic( bool italic );
-
- /**
- * @brief setTextCursorUnderlined sets underlined style for selected text in description field.
- * @param underlined
- */
- void setTextCursorUnderlined( bool underlined );
-
- /**
- * @brief setTextCursorColor sets color for selected text in description field.
- * @param color
- */
- void setTextCursorColor( const QColor &color );
-
- /**
- * @brief setTextCursorFont sets font for selected text in description field.
- * @param font
- */
- void setTextCursorFont( const QFont &font );
-
- /**
- * @brief setTextCursorFontSize sets font's size for selected text in description field.
- * @param font
- */
- void setTextCursorFontSize( const QString &fontSize );
-
- /**
- * @brief addImageToDescription adds image to description field.
- */
- void addImageToDescription();
-
- /**
- * @brief addLinkToDescription adds link to description field.
- */
- void addLinkToDescription();
-
- /**
- * @brief updateDescriptionEditButtons updates stated of buttons for editing description field.
- */
- void updateDescriptionEditButtons();
signals:
/**
diff --git a/src/lib/marble/EditPlacemarkDialog.ui b/src/lib/marble/EditPlacemarkDialog.ui
index e17bf14..b40c7ac 100644
--- a/src/lib/marble/EditPlacemarkDialog.ui
+++ b/src/lib/marble/EditPlacemarkDialog.ui
@@ -10,6 +10,12 @@
<height>372</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="windowTitle">
<string>Edit placemark</string>
</property>
@@ -31,165 +37,19 @@
<attribute name="title">
<string>Description</string>
</attribute>
- <layout class="QVBoxLayout" name="verticalLayout_3">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="QCheckBox" name="m_isFormattedTextMode">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>30</width>
- <height>0</height>
- </size>
- </property>
- <property name="text">
- <string>Formatted text</string>
- </property>
- <property name="checked">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QFontComboBox" name="m_fontFamily">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="m_fontSize">
- <property name="editable">
- <bool>true</bool>
- </property>
- <item>
- <property name="text">
- <string>6</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>8</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>9</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>10</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>11</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>12</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>14</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>16</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>18</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>20</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>24</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>36</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>48</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>72</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>96</string>
- </property>
- </item>
- </widget>
- </item>
- <item>
- <widget class="QToolBar" name="m_formattedTextToolBar">
- <property name="windowTitle">
- <string>toolBar</string>
- </property>
- <addaction name="separator"/>
- <addaction name="m_actionBold"/>
- <addaction name="m_actionItalics"/>
- <addaction name="m_actionUnderlined"/>
- <addaction name="m_actionAddImage"/>
- <addaction name="m_actionAddLink"/>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>0</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QTextEdit" name="m_description"/>
- </item>
- <item>
- <widget class="QCheckBox" name="m_isBalloonVisible">
- <property name="text">
- <string>Show Balloon Popup</string>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QCheckBox" name="m_isBalloonVisible">
+ <property name="geometry">
+ <rect>
+ <x>9</x>
+ <y>131</y>
+ <width>151</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Show Balloon Popup</string>
+ </property>
+ </widget>
</widget>
<widget class="QWidget" name="style_color_tab">
<attribute name="title">
diff --git a/src/lib/marble/FormattedTextWidget.cpp b/src/lib/marble/FormattedTextWidget.cpp
new file mode 100644
index 0000000..1da3813
--- /dev/null
+++ b/src/lib/marble/FormattedTextWidget.cpp
@@ -0,0 +1,271 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2014 Calin Cruceru <[email protected]>
+// Copyright 2015 Constantin Mihalache <[email protected]>
+//
+
+//self
+#include "FormattedTextWidget.h"
+#include "ui_FormattedTextWidget.h"
+
+//Qt
+#include <QFileDialog>
+#include <QMessageBox>
+#include <QFileInfo>
+#include <QColorDialog>
+#include <QCheckBox>
+#include <QToolBar>
+#include <QTextEdit>
+#include <QFontComboBox>
+#include <QPushButton>
+#include <QLineEdit>
+
+//Marble
+#include "MarbleWidget.h"
+#include "AddLinkDialog.h"
+
+namespace Marble{
+
+class FormattedTextWidget::Private : public Ui::FormattedTextWidget
+{
+public:
+ Private();
+ ~Private();
+
+ QColorDialog *m_textColorDialog;
+ QPushButton *m_textColorButton;
+};
+
+FormattedTextWidget::Private::Private() :
+ Ui::FormattedTextWidget(),
+ m_textColorDialog( 0 ),
+ m_textColorButton( new QPushButton )
+{
+ //nothing to do
+}
+
+FormattedTextWidget::Private::~Private()
+{
+ delete m_textColorDialog;
+ delete m_textColorButton;
+}
+
+FormattedTextWidget::FormattedTextWidget( QWidget *parent ) :
+ QWidget( parent ),
+ d( new Private() )
+{
+ d->setupUi( this );
+
+ QAction *separator = d->m_formattedTextToolBar->insertSeparator( d->m_actionAddImage );
+ d->m_formattedTextToolBar->insertWidget( separator, d->m_textColorButton );
+ d->m_textColorButton->setMaximumSize( 24, 24 );
+ QPixmap textColorPixmap( d->m_textColorButton->iconSize().width(),
+ d->m_textColorButton->iconSize().height() );
+ textColorPixmap.fill( d->m_description->textCursor().charFormat().foreground().color() );
+ d->m_textColorButton->setIcon( QIcon( textColorPixmap ) );
+ d->m_textColorDialog = new QColorDialog( this );
+ d->m_textColorDialog->setOption( QColorDialog::ShowAlphaChannel );
+ d->m_textColorDialog->setCurrentColor( d->m_description->textCursor().charFormat().foreground().color() );
+ d->m_fontSize->setValidator( new QIntValidator( 1, 9000, this ) );
+ int index = d->m_fontSize->findText( QString::number( d->m_description->textCursor().charFormat().font().pointSize() ) );
+ if( index != -1 ) {
+ d->m_fontSize->setCurrentIndex( index );
+ } else {
+ d->m_fontSize->lineEdit()->setText( QString::number( d->m_description->textCursor().charFormat().font().pointSize() ) );
+ }
+ connect( d->m_textColorButton, SIGNAL( clicked() ), d->m_textColorDialog, SLOT( exec() ) );
+ connect( d->m_textColorDialog, SIGNAL( colorSelected( QColor ) ), this, SLOT( setTextCursorColor( const QColor& ) ) );
+ connect( d->m_isFormattedTextMode, SIGNAL( toggled( bool ) ), this, SLOT( toggleDescriptionEditMode( bool ) ) );
+ connect( d->m_fontFamily, SIGNAL( currentFontChanged( QFont ) ), this, SLOT( setTextCursorFont( QFont ) ) );
+ connect( d->m_fontSize, SIGNAL( editTextChanged( QString ) ), this, SLOT( setTextCursorFontSize( QString ) ) );
+ connect( d->m_actionBold, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorBold( bool ) ) );
+ connect( d->m_actionItalics, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorItalic( bool ) ) );
+ connect( d->m_actionUnderlined, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorUnderlined( bool ) ) );
+ connect( d->m_actionAddImage, SIGNAL( triggered() ), this, SLOT( addImageToDescription() ) );
+ connect( d->m_actionAddLink, SIGNAL( triggered() ), this, SLOT( addLinkToDescription() ) );
+ connect( d->m_description, SIGNAL( cursorPositionChanged() ), this, SLOT( updateDescriptionEditButtons() ) );
+}
+
+FormattedTextWidget::~FormattedTextWidget()
+{
+ delete d;
+}
+
+void FormattedTextWidget::setText( const QString &text )
+{
+ d->m_description->setHtml( text );
+}
+
+const QString FormattedTextWidget::text()
+{
+ return d->m_description->toHtml();
+}
+
+void FormattedTextWidget::toggleDescriptionEditMode( bool isFormattedTextMode )
+{
+ d->m_formattedTextToolBar->setVisible( isFormattedTextMode );
+ d->m_fontSize->setVisible( isFormattedTextMode );
+ d->m_fontFamily->setVisible( isFormattedTextMode );
+ if( isFormattedTextMode ) {
+ d->m_description->setHtml( d->m_description->toPlainText() );
+ } else {
+ QTextCursor cursor = d->m_description->textCursor();
+ QTextCharFormat format;
+ format.setFont( QFont() );
+ format.setFontWeight( QFont::Normal );
+ format.setFontItalic( false );
+ format.setFontUnderline( false );
+ format.clearForeground();
+ cursor.setCharFormat( format );
+ d->m_description->setTextCursor( cursor );
+ d->m_description->setPlainText( d->m_description->toHtml() );
+ }
+}
+
+void FormattedTextWidget::setTextCursorBold( bool bold )
+{
+ QTextCursor cursor = d->m_description->textCursor();
+ QTextCharFormat format;
+ format.setFontWeight( bold ? QFont::Bold : QFont::Normal );
+ cursor.mergeCharFormat( format );
+ d->m_description->setTextCursor( cursor );
+}
+
+void FormattedTextWidget::setTextCursorItalic( bool italic )
+{
+ QTextCursor cursor = d->m_description->textCursor();
+ QTextCharFormat format;
+ format.setFontItalic( italic );
+ cursor.mergeCharFormat( format );
+ d->m_description->setTextCursor( cursor );
+}
+
+void FormattedTextWidget::setTextCursorUnderlined( bool underlined )
+{
+ QTextCursor cursor = d->m_description->textCursor();
+ QTextCharFormat format;
+ format.setFontUnderline( underlined );
+ cursor.mergeCharFormat( format );
+ d->m_description->setTextCursor( cursor );
+}
+
+void FormattedTextWidget::setTextCursorColor( const QColor &color )
+{
+ QTextCursor cursor = d->m_description->textCursor();
+ QTextCharFormat format;
+ QBrush brush( color );
+ format.setForeground( brush );
+ cursor.mergeCharFormat( format );
+ d->m_description->setTextCursor( cursor );
+ QPixmap textColorPixmap( d->m_textColorButton->iconSize().width(),
+ d->m_textColorButton->iconSize().height() );
+ textColorPixmap.fill( format.foreground().color() );
+ d->m_textColorButton->setIcon( QIcon( textColorPixmap ) );
+ d->m_textColorDialog->setCurrentColor( format.foreground().color() );
+}
+
+void FormattedTextWidget::setTextCursorFont( const QFont &font )
+{
+ QTextCursor cursor = d->m_description->textCursor();
+ QTextCharFormat format;
+ format.setFontFamily( font.family() );
+ cursor.mergeCharFormat( format );
+ d->m_description->setTextCursor( cursor );
+}
+
+void FormattedTextWidget::setTextCursorFontSize( const QString &fontSize )
+{
+ bool ok = false;
+ int size = fontSize.toInt( &ok );
+ if( ok ) {
+ QTextCursor cursor = d->m_description->textCursor();
+ QTextCharFormat format;
+ format.setFontPointSize( size );
+ cursor.mergeCharFormat( format );
+ d->m_description->setTextCursor( cursor );
+ }
+}
+
+void FormattedTextWidget::addImageToDescription()
+{
+ QString filename = QFileDialog::getOpenFileName( this, tr( "Choose image" ), tr( "All Supported Files (*.png *.jpg *.jpeg)" ) );
+ QImage image( filename );
+ if( !image.isNull() ) {
+ QTextCursor cursor = d->m_description->textCursor();
+ cursor.insertImage( image, filename );
+ }
+}
+
+void FormattedTextWidget::addLinkToDescription()
+{
+ QPointer<AddLinkDialog> dialog = new AddLinkDialog( this );
+ if( dialog->exec() ) {
+ QTextCharFormat oldFormat = d->m_description->textCursor().charFormat();
+ QTextCharFormat linkFormat = oldFormat;
+ linkFormat.setAnchor( true );
+ linkFormat.setFontUnderline( true );
+ linkFormat.setForeground( QApplication::palette().link() );
+ linkFormat.setAnchorHref( dialog->url() );
+ d->m_description->textCursor().insertText( dialog->name(), linkFormat );
+ QTextCursor cursor = d->m_description->textCursor();
+ cursor.setCharFormat( oldFormat );
+ d->m_description->setTextCursor( cursor );
+ d->m_description->textCursor().insertText( " " );
+ }
+}
+
+void FormattedTextWidget::updateDescriptionEditButtons()
+{
+ disconnect( d->m_actionBold, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorBold( bool ) ) );
+ disconnect( d->m_actionItalics, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorItalic( bool ) ) );
+ disconnect( d->m_actionUnderlined, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorUnderlined( bool ) ) );
+ disconnect( d->m_fontFamily, SIGNAL( currentFontChanged( QFont ) ), this, SLOT( setTextCursorFont( QFont ) ) );
+ disconnect( d->m_fontSize, SIGNAL( editTextChanged( QString ) ), this, SLOT( setTextCursorFontSize( QString ) ) );
+
+ QTextCharFormat format = d->m_description->textCursor().charFormat();
+
+ d->m_fontFamily->setCurrentFont( format.font() );
+
+ if( format.fontWeight() == QFont::Bold ) {
+ d->m_actionBold->setChecked( true );
+ } else if ( format.fontWeight() == QFont::Normal ) {
+ d->m_actionBold->setChecked( false );
+ }
+ d->m_actionItalics->setChecked( format.fontItalic() );
+ d->m_actionUnderlined->setChecked( format.fontUnderline() );
+
+ QPixmap textColorPixmap( d->m_textColorButton->iconSize().width(),
+ d->m_textColorButton->iconSize().height() );
+ textColorPixmap.fill( format.foreground().color() );
+ d->m_textColorButton->setIcon( QIcon( textColorPixmap ) );
+ d->m_textColorDialog->setCurrentColor( format.foreground().color() );
+
+ int index = d->m_fontSize->findText( QString::number( d->m_description->textCursor().charFormat().font().pointSize() ) );
+ if( index != -1 ) {
+ d->m_fontSize->setCurrentIndex( index );
+ } else {
+ d->m_fontSize->lineEdit()->setText( QString::number( d->m_description->textCursor().charFormat().font().pointSize() ) );
+ }
+ connect( d->m_actionBold, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorBold( bool ) ) );
+ connect( d->m_actionItalics, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorItalic( bool ) ) );
+ connect( d->m_actionUnderlined, SIGNAL( toggled( bool ) ), this, SLOT( setTextCursorUnderlined( bool ) ) );
+ connect( d->m_fontFamily, SIGNAL( currentFontChanged( QFont ) ), this, SLOT( setTextCursorFont( QFont ) ) );
+ connect( d->m_fontSize, SIGNAL( editTextChanged( QString ) ), this, SLOT( setTextCursorFontSize( QString ) ) );
+}
+
+void FormattedTextWidget::setReadOnly( bool state )
+{
+ d->m_description->setReadOnly( state );
+ d->m_formattedTextToolBar->setDisabled( state );
+ d->m_fontFamily->setDisabled( state );
+ d->m_fontSize->setDisabled( state );
+}
+
+}
+
+#include "FormattedTextWidget.moc"
diff --git a/src/lib/marble/FormattedTextWidget.h b/src/lib/marble/FormattedTextWidget.h
new file mode 100644
index 0000000..e18c592
--- /dev/null
+++ b/src/lib/marble/FormattedTextWidget.h
@@ -0,0 +1,57 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2014 Calin Cruceru <[email protected]>
+// Copyright 2015 Constantin Mihalache <[email protected]>
+//
+
+#ifndef FORMATTEDTEXTWIDGET_H
+#define FORMATTEDTEXTWIDGET_H
+
+// Marble
+#include "marble_export.h"
+
+//Qt
+#include <QWidget>
+#include <QString>
+
+namespace Marble {
+
+class MARBLE_EXPORT FormattedTextWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit FormattedTextWidget(QWidget *parent = 0);
+ ~FormattedTextWidget();
+
+ void setText( const QString &text );
+ const QString text();
+ void setReadOnly( bool state );
+
+private slots:
+ void toggleDescriptionEditMode( bool isFormattedTextMode = false );
+ void setTextCursorBold( bool bold );
+ void setTextCursorItalic( bool italic );
+ void setTextCursorUnderlined( bool underlined );
+ void setTextCursorColor( const QColor &color );
+ void setTextCursorFont( const QFont &font );
+ void setTextCursorFontSize( const QString &fontSize );
+ void addImageToDescription();
+ void addLinkToDescription();
+ void updateDescriptionEditButtons();
+
+signals:
+ void textUpdated();
+
+private:
+ class Private;
+ Private * const d;
+};
+}
+
+#endif // FORMATTEDTEXTWIDGET_H
diff --git a/src/lib/marble/FormattedTextWidget.ui b/src/lib/marble/FormattedTextWidget.ui
new file mode 100644
index 0000000..7ce51fd
--- /dev/null
+++ b/src/lib/marble/FormattedTextWidget.ui
@@ -0,0 +1,257 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FormattedTextWidget</class>
+ <widget class="QWidget" name="FormattedTextWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>645</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QCheckBox" name="m_isFormattedTextMode">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>135</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Formatted text</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QFontComboBox" name="m_fontFamily">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="m_fontSize">
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string>6</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>8</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>9</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>10</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>11</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>12</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>14</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>16</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>18</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>20</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>24</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>36</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>48</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>72</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>96</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolBar" name="m_formattedTextToolBar">
+ <property name="windowTitle">
+ <string>toolBar</string>
+ </property>
+ <addaction name="separator"/>
+ <addaction name="m_actionBold"/>
+ <addaction name="m_actionItalics"/>
+ <addaction name="m_actionUnderlined"/>
+ <addaction name="m_actionAddImage"/>
+ <addaction name="m_actionAddLink"/>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>13</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="m_description"/>
+ </item>
+ </layout>
+ <action name="m_actionBold">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="icon">
+ <iconset resource="libmarble.qrc">
+ <normaloff>:/icons/format-text-bold.png</normaloff>:/icons/format-text-bold.png</iconset>
+ </property>
+ <property name="text">
+ <string>Bold</string>
+ </property>
+ <property name="toolTip">
+ <string>Bold</string>
+ </property>
+ </action>
+ <action name="m_actionItalics">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="icon">
+ <iconset resource="libmarble.qrc">
+ <normaloff>:/icons/format-text-italic.png</normaloff>:/icons/format-text-italic.png</iconset>
+ </property>
+ <property name="text">
+ <string>Italics</string>
+ </property>
+ <property name="toolTip">
+ <string>Italics</string>
+ </property>
+ </action>
+ <action name="m_actionUnderlined">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="icon">
+ <iconset resource="libmarble.qrc">
+ <normaloff>:/icons/format-text-underline.png</normaloff>:/icons/format-text-underline.png</iconset>
+ </property>
+ <property name="text">
+ <string>Underlined</string>
+ </property>
+ <property name="toolTip">
+ <string>Underlined</string>
+ </property>
+ </action>
+ <action name="m_actionAddImage">
+ <property name="icon">
+ <iconset resource="libmarble.qrc">
+ <normaloff>:/icons/insert-image.png</normaloff>:/icons/insert-image.png</iconset>
+ </property>
+ <property name="text">
+ <string>Add image</string>
+ </property>
+ <property name="toolTip">
+ <string>Add image</string>
+ </property>
+ </action>
+ <action name="m_actionAddLink">
+ <property name="icon">
+ <iconset resource="libmarble.qrc">
+ <normaloff>:/icons/insert-link.png</normaloff>:/icons/insert-link.png</iconset>
+ </property>
+ <property name="text">
+ <string>Add link</string>
+ </property>
+ <property name="toolTip">
+ <string>Add link</string>
+ </property>
+ </action>
+ </widget>
+ <resources>
+ <include location="libmarble.qrc"/>
+ </resources>
+ <connections/>
+</ui>
diff --git a/src/plugins/render/annotate/EditGroundOverlayDialog.cpp b/src/plugins/render/annotate/EditGroundOverlayDialog.cpp
index df7d6d2..97e81e9 100644
--- a/src/plugins/render/annotate/EditGroundOverlayDialog.cpp
+++ b/src/plugins/render/annotate/EditGroundOverlayDialog.cpp
@@ -16,6 +16,10 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QPushButton>
+#include <QVBoxLayout>
+
+//Marble
+#include "FormattedTextWidget.h"
namespace Marble
{
@@ -26,6 +30,7 @@ class EditGroundOverlayDialog::Private : public Ui::UiEditGroundOverlayDialog
public:
GeoDataGroundOverlay *m_overlay;
TextureLayer *m_textureLayer;
+ FormattedTextWidget *m_formattedTextWidget;
Private( GeoDataGroundOverlay *overlay, TextureLayer *textureLayer );
~Private();
@@ -54,10 +59,16 @@ EditGroundOverlayDialog::EditGroundOverlayDialog( GeoDataGroundOverlay *overlay,
{
d->setupUi( this );
+ d->m_formattedTextWidget = new FormattedTextWidget( d->m_descriptionTab );
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget( d->m_formattedTextWidget );
+ d->m_descriptionTab->setLayout( layout );
+
d->m_header->setName( overlay->name() );
d->m_header->setIconLink( overlay->absoluteIconFile() );
d->m_header->setPositionVisible(false);
- d->m_description->setText( overlay->description() );
+ d->m_formattedTextWidget->setText( overlay->description() );
d->m_north->setRange( -90, 90 );
d->m_south->setRange( -90, 90 );
@@ -84,7 +95,7 @@ void EditGroundOverlayDialog::updateGroundOverlay()
{
d->m_overlay->setName( d->m_header->name() );
d->m_overlay->setIconFile( d->m_header->iconLink() );
- d->m_overlay->setDescription( d->m_description->toPlainText() );
+ d->m_overlay->setDescription( d->m_formattedTextWidget->text() );
d->m_overlay->latLonBox().setBoundaries( d->m_north->value(),
d->m_south->value(),
diff --git a/src/plugins/render/annotate/EditGroundOverlayDialog.ui b/src/plugins/render/annotate/EditGroundOverlayDialog.ui
index 1151b35..59fbb13 100644
--- a/src/plugins/render/annotate/EditGroundOverlayDialog.ui
+++ b/src/plugins/render/annotate/EditGroundOverlayDialog.ui
@@ -26,11 +26,6 @@
<attribute name="title">
<string>Description</string>
</attribute>
- <layout class="QVBoxLayout" name="verticalLayout_4">
- <item>
- <widget class="QTextEdit" name="m_description"/>
- </item>
- </layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
diff --git a/src/plugins/render/annotate/EditPolygonDialog.cpp b/src/plugins/render/annotate/EditPolygonDialog.cpp
index c647e6b..84e5697 100644
--- a/src/plugins/render/annotate/EditPolygonDialog.cpp
+++ b/src/plugins/render/annotate/EditPolygonDialog.cpp
@@ -15,12 +15,14 @@
// Qt
#include <QColorDialog>
#include <QMessageBox>
+#include <QVBoxLayout>
// Marble
#include "GeoDataStyle.h"
#include "GeoDataTypes.h"
#include "NodeModel.h"
#include "NodeItemDelegate.h"
+#include "FormattedTextWidget.h"
namespace Marble {
@@ -42,6 +44,7 @@ public:
NodeModel *m_nodeModel;
NodeItemDelegate *m_delegate;
+ FormattedTextWidget *m_formattedTextWidget;
};
EditPolygonDialog::Private::Private( GeoDataPlacemark *placemark ) :
@@ -68,6 +71,12 @@ EditPolygonDialog::EditPolygonDialog( GeoDataPlacemark *placemark, QWidget *pare
{
d->setupUi( this );
+ d->m_formattedTextWidget = new FormattedTextWidget( d->m_descriptionTab );
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(d->m_formattedTextWidget);
+ d->m_descriptionTab->setLayout(layout);
+
d->m_initialStyle = *placemark->style();
// If the polygon has just been drawn, assign it a default name.
@@ -78,7 +87,7 @@ EditPolygonDialog::EditPolygonDialog( GeoDataPlacemark *placemark, QWidget *pare
d->m_initialName = placemark->name();
connect( d->m_name, SIGNAL(editingFinished()), this, SLOT(updatePolygon()) );
- d->m_description->setText( placemark->description() );
+ d->m_formattedTextWidget->setText( placemark->description() );
d->m_initialDescription = placemark->description();
// Get the current style properties.
@@ -185,7 +194,7 @@ void EditPolygonDialog::updatePolygon()
GeoDataStyle *style = new GeoDataStyle( *d->m_placemark->style() );
d->m_placemark->setName( d->m_name->text() );
- d->m_placemark->setDescription( d->m_description->toPlainText() );
+ d->m_placemark->setDescription( d->m_formattedTextWidget->text() );
style->lineStyle().setWidth( d->m_linesWidth->value() );
// 0 corresponds to "Filled" and 1 corresponds to "Not Filled".
diff --git a/src/plugins/render/annotate/EditPolygonDialog.ui b/src/plugins/render/annotate/EditPolygonDialog.ui
index 563ca2d..1390232 100644
--- a/src/plugins/render/annotate/EditPolygonDialog.ui
+++ b/src/plugins/render/annotate/EditPolygonDialog.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>403</width>
+ <width>323</width>
<height>390</height>
</rect>
</property>
@@ -38,17 +38,12 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>2</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="m_descriptionTab">
<attribute name="title">
<string>Description</string>
</attribute>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QTextEdit" name="m_description"/>
- </item>
- </layout>
</widget>
<widget class="QWidget" name="m_styleTab">
<attribute name="title">
@@ -258,7 +253,7 @@
<bool>false</bool>
</property>
<attribute name="headerStretchLastSection">
- <bool>false</bool>
+ <bool>true</bool>
</attribute>
</widget>
</item>
diff --git a/src/plugins/render/annotate/EditPolylineDialog.cpp b/src/plugins/render/annotate/EditPolylineDialog.cpp
index a99a3e9..a06d55d 100644
--- a/src/plugins/render/annotate/EditPolylineDialog.cpp
+++ b/src/plugins/render/annotate/EditPolylineDialog.cpp
@@ -15,12 +15,14 @@
// Qt
#include <QColorDialog>
#include <QMessageBox>
+#include <QVBoxLayout>
// Marble
#include "GeoDataPlacemark.h"
#include "GeoDataStyle.h"
#include "GeoDataTypes.h"
#include "NodeModel.h"
+#include "FormattedTextWidget.h"
namespace Marble
@@ -39,6 +41,7 @@ public:
QString m_initialName;
QString m_initialDescription;
GeoDataLineStyle m_initialLineStyle;
+ FormattedTextWidget *m_formattedTextWidget;
NodeModel *m_nodeModel;
};
@@ -64,6 +67,12 @@ EditPolylineDialog::EditPolylineDialog( GeoDataPlacemark *placemark, QWidget *pa
{
d->setupUi( this );
+ d->m_formattedTextWidget = new FormattedTextWidget( d->m_descriptionTab );
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget( d->m_formattedTextWidget );
+ d->m_descriptionTab->setLayout( layout );
+
// If the polygon has just been drawn, assign it a default name.
if ( d->m_placemark->name().isNull() ) {
d->m_placemark->setName( tr("Untitled Path") );
@@ -74,8 +83,8 @@ EditPolylineDialog::EditPolylineDialog( GeoDataPlacemark *placemark, QWidget *pa
d->m_initialName = d->m_name->text();
connect( d->m_name, SIGNAL(editingFinished()), this, SLOT(updatePolyline()) );
- d->m_description->setText( placemark->description() );
- d->m_initialDescription = d->m_description->toPlainText();
+ d->m_formattedTextWidget->setText( placemark->description() );
+ d->m_initialDescription = d->m_formattedTextWidget->text();
d->m_linesWidth->setRange( 0.1, 5.0 );
@@ -149,7 +158,7 @@ void EditPolylineDialog::handleItemMoving( GeoDataPlacemark *item )
void EditPolylineDialog::updatePolyline()
{
- d->m_placemark->setDescription( d->m_description->toPlainText() );
+ d->m_placemark->setDescription( d->m_formattedTextWidget->text() );
d->m_placemark->setName( d->m_name->text() );
diff --git a/src/plugins/render/annotate/EditPolylineDialog.ui b/src/plugins/render/annotate/EditPolylineDialog.ui
index 3421a72..7bd3103 100644
--- a/src/plugins/render/annotate/EditPolylineDialog.ui
+++ b/src/plugins/render/annotate/EditPolylineDialog.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>350</width>
+ <width>357</width>
<height>390</height>
</rect>
</property>
@@ -44,11 +44,6 @@
<attribute name="title">
<string>Description</string>
</attribute>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <widget class="QTextEdit" name="m_description"/>
- </item>
- </layout>
</widget>
<widget class="QWidget" name="m_styleTab">
<attribute name="title">
@@ -177,7 +172,7 @@
<bool>false</bool>
</property>
<attribute name="headerStretchLastSection">
- <bool>false</bool>
+ <bool>true</bool>
</attribute>
</widget>
</item>