mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Some cosmetic changes so that GuiWorkArea can be embeddable in a Qt designer dialog.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27499 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
97707102da
commit
0685dfef74
@ -233,14 +233,28 @@ SyntheticMouseEvent::SyntheticMouseEvent()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
GuiWorkArea::GuiWorkArea(QWidget *)
|
||||||
GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & lv)
|
: buffer_view_(0), lyx_view_(0),
|
||||||
: buffer_view_(new BufferView(buffer)), lyx_view_(&lv),
|
|
||||||
cursor_visible_(false),
|
cursor_visible_(false),
|
||||||
need_resize_(false), schedule_redraw_(false),
|
need_resize_(false), schedule_redraw_(false),
|
||||||
preedit_lines_(1), completer_(new GuiCompleter(this))
|
preedit_lines_(1), completer_(new GuiCompleter(this))
|
||||||
{
|
{
|
||||||
buffer.workAreaManager().add(this);
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & gv)
|
||||||
|
: buffer_view_(0), lyx_view_(0),
|
||||||
|
cursor_visible_(false),
|
||||||
|
need_resize_(false), schedule_redraw_(false),
|
||||||
|
preedit_lines_(1), completer_(new GuiCompleter(this))
|
||||||
|
{
|
||||||
|
setGuiView(gv);
|
||||||
|
setBuffer(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiWorkArea::init()
|
||||||
|
{
|
||||||
// Setup the signals
|
// Setup the signals
|
||||||
connect(&cursor_timeout_, SIGNAL(timeout()),
|
connect(&cursor_timeout_, SIGNAL(timeout()),
|
||||||
this, SLOT(toggleCursor()));
|
this, SLOT(toggleCursor()));
|
||||||
@ -258,17 +272,6 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & lv)
|
|||||||
cursor_ = new frontend::CursorWidget();
|
cursor_ = new frontend::CursorWidget();
|
||||||
cursor_->hide();
|
cursor_->hide();
|
||||||
|
|
||||||
// HACK: Prevents an additional redraw when the scrollbar pops up
|
|
||||||
// which regularily happens on documents with more than one page.
|
|
||||||
// The policy should be set to "Qt::ScrollBarAsNeeded" soon.
|
|
||||||
// Since we have no geometry information yet, we assume that
|
|
||||||
// a document needs a scrollbar if there is more then four
|
|
||||||
// paragraph in the outermost text.
|
|
||||||
if (buffer.text().paragraphs().size() > 4)
|
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
|
||||||
QTimer::singleShot(50, this, SLOT(fixVerticalScrollBar()));
|
|
||||||
|
|
||||||
|
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
@ -285,7 +288,7 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & lv)
|
|||||||
// the viewport because we have our own backing pixmap.
|
// the viewport because we have our own backing pixmap.
|
||||||
viewport()->setAttribute(Qt::WA_NoSystemBackground);
|
viewport()->setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
|
||||||
setFocusPolicy(Qt::WheelFocus);
|
setFocusPolicy(Qt::StrongFocus);
|
||||||
|
|
||||||
viewport()->setCursor(Qt::IBeamCursor);
|
viewport()->setCursor(Qt::IBeamCursor);
|
||||||
|
|
||||||
@ -303,6 +306,8 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & lv)
|
|||||||
// Enables input methods for asian languages.
|
// Enables input methods for asian languages.
|
||||||
// Must be set when creating custom text editing widgets.
|
// Must be set when creating custom text editing widgets.
|
||||||
setAttribute(Qt::WA_InputMethodEnabled, true);
|
setAttribute(Qt::WA_InputMethodEnabled, true);
|
||||||
|
|
||||||
|
dialogMode_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -316,6 +321,31 @@ GuiWorkArea::~GuiWorkArea()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiWorkArea::setGuiView(GuiView & gv)
|
||||||
|
{
|
||||||
|
lyx_view_ = &gv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiWorkArea::setBuffer(Buffer & buffer)
|
||||||
|
{
|
||||||
|
delete buffer_view_;
|
||||||
|
buffer_view_ = new BufferView(buffer),
|
||||||
|
buffer.workAreaManager().add(this);
|
||||||
|
|
||||||
|
// HACK: Prevents an additional redraw when the scrollbar pops up
|
||||||
|
// which regularily happens on documents with more than one page.
|
||||||
|
// The policy should be set to "Qt::ScrollBarAsNeeded" soon.
|
||||||
|
// Since we have no geometry information yet, we assume that
|
||||||
|
// a document needs a scrollbar if there is more then four
|
||||||
|
// paragraph in the outermost text.
|
||||||
|
if (buffer.text().paragraphs().size() > 4)
|
||||||
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
|
QTimer::singleShot(50, this, SLOT(fixVerticalScrollBar()));
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiWorkArea::fixVerticalScrollBar()
|
void GuiWorkArea::fixVerticalScrollBar()
|
||||||
{
|
{
|
||||||
if (!isFullScreen())
|
if (!isFullScreen())
|
||||||
@ -660,9 +690,15 @@ void GuiWorkArea::contextMenuEvent(QContextMenuEvent * e)
|
|||||||
|
|
||||||
void GuiWorkArea::focusInEvent(QFocusEvent * e)
|
void GuiWorkArea::focusInEvent(QFocusEvent * e)
|
||||||
{
|
{
|
||||||
if (lyx_view_->currentWorkArea() != this)
|
LYXERR(Debug::DEBUG, "GuiWorkArea::focusInEvent(): " << this << std::endl);
|
||||||
|
GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
|
||||||
|
if (old_gwa)
|
||||||
|
old_gwa->stopBlinkingCursor();
|
||||||
lyx_view_->setCurrentWorkArea(this);
|
lyx_view_->setCurrentWorkArea(this);
|
||||||
|
|
||||||
|
//if (lyx_view_->currentWorkArea() != this) {
|
||||||
|
// lyx_view_->setCurrentWorkArea(this);
|
||||||
|
|
||||||
startBlinkingCursor();
|
startBlinkingCursor();
|
||||||
QAbstractScrollArea::focusInEvent(e);
|
QAbstractScrollArea::focusInEvent(e);
|
||||||
}
|
}
|
||||||
@ -670,6 +706,7 @@ void GuiWorkArea::focusInEvent(QFocusEvent * e)
|
|||||||
|
|
||||||
void GuiWorkArea::focusOutEvent(QFocusEvent * e)
|
void GuiWorkArea::focusOutEvent(QFocusEvent * e)
|
||||||
{
|
{
|
||||||
|
LYXERR(Debug::DEBUG, "GuiWorkArea::focusOutEvent(): " << this << std::endl);
|
||||||
stopBlinkingCursor();
|
stopBlinkingCursor();
|
||||||
QAbstractScrollArea::focusOutEvent(e);
|
QAbstractScrollArea::focusOutEvent(e);
|
||||||
}
|
}
|
||||||
@ -835,6 +872,18 @@ void GuiWorkArea::generateSyntheticMouseEvent()
|
|||||||
|
|
||||||
void GuiWorkArea::keyPressEvent(QKeyEvent * ev)
|
void GuiWorkArea::keyPressEvent(QKeyEvent * ev)
|
||||||
{
|
{
|
||||||
|
// Do not process here some keys if dialogMode_ is set
|
||||||
|
if (dialogMode_
|
||||||
|
&& (ev->modifiers() == Qt::NoModifier
|
||||||
|
|| ev->modifiers() == Qt::ShiftModifier)
|
||||||
|
&& (ev->key() == Qt::Key_Escape
|
||||||
|
|| ev->key() == Qt::Key_Enter
|
||||||
|
|| ev->key() == Qt::Key_Return)
|
||||||
|
) {
|
||||||
|
ev->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// intercept some keys if completion popup is visible
|
// intercept some keys if completion popup is visible
|
||||||
if (completer_->popupVisible()) {
|
if (completer_->popupVisible()) {
|
||||||
switch (ev->key()) {
|
switch (ev->key()) {
|
||||||
|
@ -101,10 +101,19 @@ class GuiWorkArea : public QAbstractScrollArea, public WorkArea
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
GuiWorkArea(Buffer & buffer, GuiView & lv);
|
GuiWorkArea(QWidget *);
|
||||||
|
///
|
||||||
|
GuiWorkArea(Buffer & buffer, GuiView & gv);
|
||||||
///
|
///
|
||||||
~GuiWorkArea();
|
~GuiWorkArea();
|
||||||
|
|
||||||
|
///
|
||||||
|
void setBuffer(Buffer &);
|
||||||
|
///
|
||||||
|
void setGuiView(GuiView &);
|
||||||
|
/// Dummy methods for Designer.
|
||||||
|
void setWidgetResizable(bool) {}
|
||||||
|
void setWidget(QWidget *) {}
|
||||||
///
|
///
|
||||||
void setFullScreen(bool full_screen);
|
void setFullScreen(bool full_screen);
|
||||||
/// is LyXView in fullscreen mode?
|
/// is LyXView in fullscreen mode?
|
||||||
@ -127,9 +136,20 @@ public:
|
|||||||
///
|
///
|
||||||
void resizeBufferView();
|
void resizeBufferView();
|
||||||
|
|
||||||
|
bool isInDialog() {
|
||||||
|
return dialogMode_;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
GuiCompleter & completer() { return *completer_; }
|
GuiCompleter & completer() { return *completer_; }
|
||||||
|
|
||||||
|
/// Return true if dialogMode is set
|
||||||
|
bool& dialogMode() { return dialogMode_; }
|
||||||
|
|
||||||
|
/// Return the GuiView this workArea belongs to
|
||||||
|
GuiView const & view() const { return *lyx_view_; }
|
||||||
|
GuiView & view() { return *lyx_view_; }
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
///
|
///
|
||||||
void titleChanged(GuiWorkArea *);
|
void titleChanged(GuiWorkArea *);
|
||||||
@ -153,6 +173,8 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class GuiCompleter;
|
friend class GuiCompleter;
|
||||||
|
///
|
||||||
|
void init();
|
||||||
|
|
||||||
/// update the passed area.
|
/// update the passed area.
|
||||||
void update(int x, int y, int w, int h);
|
void update(int x, int y, int w, int h);
|
||||||
@ -238,6 +260,10 @@ private:
|
|||||||
|
|
||||||
///
|
///
|
||||||
GuiCompleter * completer_;
|
GuiCompleter * completer_;
|
||||||
|
|
||||||
|
/// Special mode in which Esc and Enter (with or without Shift)
|
||||||
|
/// are ignored
|
||||||
|
bool dialogMode_;
|
||||||
}; // GuiWorkArea
|
}; // GuiWorkArea
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user