Commit 2821131b authored by Laurent Montel's avatar Laurent Montel 😁

Use slide container

parent 18d7e87e
......@@ -35,7 +35,8 @@
using namespace PimCommon;
TextEditFindBarBase::TextEditFindBarBase(QWidget * parent )
: QWidget( parent )
: QWidget( parent ),
mHideWhenClose(true)
{
QVBoxLayout *topLayout = new QVBoxLayout;
topLayout->setMargin(0);
......@@ -95,6 +96,11 @@ void TextEditFindBarBase::showFind()
}
}
void TextEditFindBarBase::setHideWhenClose(bool hide)
{
mHideWhenClose = hide;
}
void TextEditFindBarBase::showReplace()
{
if (viewIsReadOnly())
......@@ -145,12 +151,15 @@ void TextEditFindBarBase::autoSearch( const QString& str )
void TextEditFindBarBase::messageInfo( bool backward, bool isAutoSearch, bool found )
{
if ( !found && !isAutoSearch ) {
QString str = mLastSearchStr;
if (str.length()>39) {
str.truncate(40);
str += QLatin1String("...");
}
if ( backward ) {
Q_EMIT displayMessageIndicator(i18n( "Beginning of message reached.\nPhrase '%1' could not be found." ,mLastSearchStr ));
//KMessageBox::information( this, i18n( "Beginning of message reached.\nPhrase '%1' could not be found." ,mLastSearchStr ) );
Q_EMIT displayMessageIndicator(i18n( "Beginning of message reached.\nPhrase '%1' could not be found." , str ));
} else {
Q_EMIT displayMessageIndicator(i18n( "End of message reached.\nPhrase '%1' could not be found.", mLastSearchStr ));
//KMessageBox::information( this, i18n( "End of message reached.\nPhrase '%1' could not be found.", mLastSearchStr ) );
Q_EMIT displayMessageIndicator(i18n( "End of message reached.\nPhrase '%1' could not be found.", str ));
}
}
}
......@@ -204,7 +213,10 @@ void TextEditFindBarBase::closeBar()
mFindWidget->search()->setText( QString() );
mReplaceWidget->replace()->setText( QString() );
clearSelections();
hide();
if (mHideWhenClose) {
hide();
}
Q_EMIT hideFindBar();
}
bool TextEditFindBarBase::event(QEvent* e)
......
......@@ -41,9 +41,11 @@ public:
void showReplace();
void showFind();
void setHideWhenClose(bool hide);
Q_SIGNALS:
void displayMessageIndicator(const QString &message);
void hideFindBar();
protected:
virtual bool viewIsReadOnly() const = 0;
......@@ -77,6 +79,7 @@ protected:
QString mLastSearchStr;
TextFindWidget *mFindWidget;
TextReplaceWidget *mReplaceWidget;
bool mHideWhenClose;
};
}
......
......@@ -18,11 +18,14 @@
#include "plaintexteditorwidget.h"
#include "plaintexteditor.h"
#include "plaintexteditfindbar.h"
#include "pimcommon/widgets/slidecontainer.h"
#include <QVBoxLayout>
#include <QShortcut>
#include <QTextCursor>
using namespace PimCommon;
PlainTextEditorWidget::PlainTextEditorWidget(PlainTextEditor *customEditor, QWidget *parent)
......@@ -68,9 +71,16 @@ void PlainTextEditorWidget::init(PlainTextEditor *customEditor)
}
lay->addWidget(mEditor);
mSliderContainer = new PimCommon::SlideContainer(this);
mFindBar = new PimCommon::PlainTextEditFindBar( mEditor, this );
mFindBar->setHideWhenClose(false);
connect(mFindBar, SIGNAL(hideFindBar()), mSliderContainer, SLOT(slideOut()));
connect(mFindBar, SIGNAL(displayMessageIndicator(QString)), mEditor, SLOT(slotDisplayMessageIndicator(QString)));
lay->addWidget(mFindBar);
mSliderContainer->setContent(mFindBar);
lay->addWidget(mSliderContainer);
QShortcut *shortcut = new QShortcut( this );
shortcut->setKey( Qt::Key_F+Qt::CTRL );
......@@ -103,6 +113,7 @@ void PlainTextEditorWidget::slotReplace()
void PlainTextEditorWidget::slotFind()
{
mSliderContainer->slideIn();
if ( mEditor->textCursor().hasSelection() )
mFindBar->setText( mEditor->textCursor().selectedText() );
mEditor->moveCursor(QTextCursor::Start);
......
......@@ -24,6 +24,7 @@
namespace PimCommon {
class PlainTextEditor;
class PlainTextEditFindBar;
class SlideContainer;
class PIMCOMMON_EXPORT PlainTextEditorWidget : public QWidget
{
Q_OBJECT
......@@ -49,6 +50,7 @@ private:
void init(PlainTextEditor *customEditor = 0);
PimCommon::PlainTextEditFindBar *mFindBar;
PlainTextEditor *mEditor;
PimCommon::SlideContainer *mSliderContainer;
};
}
......
......@@ -23,6 +23,8 @@
#include <QShortcut>
#include <QTextCursor>
#include "pimcommon/widgets/slidecontainer.h"
using namespace PimCommon;
RichTextEditorWidget::RichTextEditorWidget(RichTextEditor *customEditor, QWidget *parent)
......@@ -93,9 +95,15 @@ void RichTextEditorWidget::init(RichTextEditor *customEditor)
}
lay->addWidget(mEditor);
mSliderContainer = new PimCommon::SlideContainer(this);
mFindBar = new PimCommon::RichTextEditFindBar( mEditor, this );
mFindBar->setHideWhenClose(false);
connect(mFindBar, SIGNAL(hideFindBar()), mSliderContainer, SLOT(slideOut()));
connect(mFindBar, SIGNAL(displayMessageIndicator(QString)), mEditor, SLOT(slotDisplayMessageIndicator(QString)));
lay->addWidget(mFindBar);
mSliderContainer->setContent(mFindBar);
lay->addWidget(mSliderContainer);
QShortcut *shortcut = new QShortcut( this );
shortcut->setKey( Qt::Key_F+Qt::CTRL );
......@@ -128,6 +136,7 @@ void RichTextEditorWidget::slotReplace()
void RichTextEditorWidget::slotFind()
{
mSliderContainer->slideIn();
if ( mEditor->textCursor().hasSelection() )
mFindBar->setText( mEditor->textCursor().selectedText() );
mEditor->moveCursor(QTextCursor::Start);
......
......@@ -25,6 +25,7 @@
namespace PimCommon {
class RichTextEditor;
class RichTextEditFindBar;
class SlideContainer;
class PIMCOMMON_EXPORT RichTextEditorWidget : public QWidget
{
Q_OBJECT
......@@ -58,6 +59,7 @@ private:
void init(RichTextEditor *customEditor = 0);
PimCommon::RichTextEditFindBar *mFindBar;
RichTextEditor *mEditor;
PimCommon::SlideContainer *mSliderContainer;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment