- Albert's r760478 to make the text widget a KTextEdit
- my r784138 to get and set the annotation text in a better way

svn path=/branches/KDE/4.0/kdegraphics/okular/; revision=789327
remotes/origin/KDE/4.0
Pino Toscano 18 years ago
parent cebe91d5f8
commit f71c12aaf7
  1. 28
      ui/annotwindow.cpp

@ -23,15 +23,15 @@
#include <qpushbutton.h>
#include <qsizegrip.h>
#include <qstyle.h>
#include <qtextedit.h>
#include <qtoolbutton.h>
#include <kglobal.h>
#include <klocale.h>
#include <ktextedit.h>
#include <kdebug.h>
// local includes
#include "core/annotations.h"
#include "guiutils.h"
class CloseButton
: public QPushButton
@ -163,7 +163,7 @@ AnnotWindow::AnnotWindow( QWidget * parent, Okular::Annotation * annot)
setAutoFillBackground( true );
setFrameStyle( Panel | Raised );
textEdit=new QTextEdit(m_annot->window().text(), this);
textEdit = new KTextEdit( GuiUtils::contents( m_annot ), this );
connect(textEdit,SIGNAL(textChanged()),
this,SLOT(slotsaveWindowText()));
@ -201,7 +201,27 @@ void AnnotWindow::slotOptionBtn()
void AnnotWindow::slotsaveWindowText()
{
m_annot->window().setText( textEdit->toPlainText() );
const QString newText = textEdit->toPlainText();
// 1. window text
if ( !m_annot->window().text().isEmpty() )
{
m_annot->window().setText( newText );
return;
}
// 2. if Text and InPlace, the inplace text
if ( m_annot->subType() == Okular::Annotation::AText )
{
Okular::TextAnnotation * txtann = static_cast< Okular::TextAnnotation * >( m_annot );
if ( txtann->textType() == Okular::TextAnnotation::InPlace )
{
txtann->setInplaceText( newText );
return;
}
}
// 3. contents
m_annot->setContents( newText );
}
#include "annotwindow.moc"

Loading…
Cancel
Save