mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
New virtual method frontend::Dialog::on_BufferViewChanged()
This is called anytime the buffer view attached to the GuiView changes.
This commit is contained in:
parent
9b4926c6e6
commit
f4c390712e
@ -264,6 +264,8 @@ protected:
|
|||||||
void setTitle(QString const & title) { title_ = title; }
|
void setTitle(QString const & title) { title_ = title; }
|
||||||
///
|
///
|
||||||
virtual void apply();
|
virtual void apply();
|
||||||
|
/// To be called when the buffer view has changed
|
||||||
|
virtual void on_bufferViewChanged() = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/** The Dialog's name is the means by which a dialog identifies
|
/** The Dialog's name is the means by which a dialog identifies
|
||||||
|
51
src/frontends/qt4/DialogView.cpp
Normal file
51
src/frontends/qt4/DialogView.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file DialogView.cpp
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "DialogView.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
DialogView::DialogView(GuiView & lv, QString const & name, QString const & title)
|
||||||
|
: QDialog(&lv), Dialog(lv, name, "LyX: " + title)
|
||||||
|
{
|
||||||
|
connect(&lv, SIGNAL(bufferViewChanged()),
|
||||||
|
this, SLOT(on_bufferViewChanged()));
|
||||||
|
|
||||||
|
// remove question marks from Windows dialogs
|
||||||
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogView::closeEvent(QCloseEvent * ev)
|
||||||
|
{
|
||||||
|
clearParams();
|
||||||
|
Dialog::disconnect();
|
||||||
|
ev->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DialogView::hideEvent(QHideEvent * ev)
|
||||||
|
{
|
||||||
|
if (!ev->spontaneous()) {
|
||||||
|
clearParams();
|
||||||
|
Dialog::disconnect();
|
||||||
|
ev->accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace frontend
|
||||||
|
} // namespace lyx
|
||||||
|
|
||||||
|
#include "moc_DialogView.cpp"
|
@ -23,17 +23,14 @@ namespace frontend {
|
|||||||
|
|
||||||
class DialogView : public QDialog, public Dialog
|
class DialogView : public QDialog, public Dialog
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// \param lv is the access point for the dialog to the LyX kernel.
|
/// \param lv is the access point for the dialog to the LyX kernel.
|
||||||
/// \param name is the identifier given to the dialog by its parent
|
/// \param name is the identifier given to the dialog by its parent
|
||||||
/// container.
|
/// container.
|
||||||
/// \param title is the window title used for decoration.
|
/// \param title is the window title used for decoration.
|
||||||
DialogView(GuiView & lv, QString const & name, QString const & title)
|
DialogView(GuiView & lv, QString const & name, QString const & title);
|
||||||
: QDialog(&lv), Dialog(lv, name, "LyX: " + title)
|
|
||||||
{
|
|
||||||
// remove question marks from Windows dialogs
|
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual QWidget * asQWidget() { return this; }
|
virtual QWidget * asQWidget() { return this; }
|
||||||
virtual QWidget const * asQWidget() const { return this; }
|
virtual QWidget const * asQWidget() const { return this; }
|
||||||
@ -47,21 +44,12 @@ protected:
|
|||||||
bool needBufferOpen() const { return isBufferDependent(); }
|
bool needBufferOpen() const { return isBufferDependent(); }
|
||||||
//@}
|
//@}
|
||||||
/// Any dialog that overrides this method should make sure to call it.
|
/// Any dialog that overrides this method should make sure to call it.
|
||||||
void closeEvent(QCloseEvent * ev)
|
void closeEvent(QCloseEvent * ev);
|
||||||
{
|
|
||||||
clearParams();
|
|
||||||
Dialog::disconnect();
|
|
||||||
ev->accept();
|
|
||||||
}
|
|
||||||
/// Any dialog that overrides this method should make sure to call it.
|
/// Any dialog that overrides this method should make sure to call it.
|
||||||
void hideEvent(QHideEvent * ev)
|
void hideEvent(QHideEvent * ev);
|
||||||
{
|
|
||||||
if (!ev->spontaneous()) {
|
protected Q_SLOTS:
|
||||||
clearParams();
|
void on_bufferViewChanged() {};
|
||||||
Dialog::disconnect();
|
|
||||||
ev->accept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
54
src/frontends/qt4/DockView.cpp
Normal file
54
src/frontends/qt4/DockView.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
// -*- C++ -*-
|
||||||
|
/**
|
||||||
|
* \file DockView.cpp
|
||||||
|
* This file is part of LyX, the document processor.
|
||||||
|
* Licence details can be found in the file COPYING.
|
||||||
|
*
|
||||||
|
* \author Abdelrazak Younes
|
||||||
|
*
|
||||||
|
* Full author contact details are available in file CREDITS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "DockView.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace lyx {
|
||||||
|
namespace frontend {
|
||||||
|
|
||||||
|
|
||||||
|
DockView::DockView(GuiView & parent, QString const & name,
|
||||||
|
QString const & title, Qt::DockWidgetArea area,
|
||||||
|
Qt::WindowFlags flags)
|
||||||
|
: QDockWidget(&parent, flags), Dialog(parent, name, title)
|
||||||
|
{
|
||||||
|
setObjectName(name);
|
||||||
|
parent.addDockWidget(area, this);
|
||||||
|
hide();
|
||||||
|
connect(&parent, SIGNAL(bufferViewChanged()),
|
||||||
|
this, SLOT(on_bufferViewChanged()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DockView::keyPressEvent(QKeyEvent * ev)
|
||||||
|
{
|
||||||
|
if (ev->key() == Qt::Key_Escape) {
|
||||||
|
QMainWindow * mw = static_cast<QMainWindow *>(parent());
|
||||||
|
if (!mw) {
|
||||||
|
ev->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mw->activateWindow();
|
||||||
|
mw->setFocus();
|
||||||
|
if (isFloating())
|
||||||
|
hide();
|
||||||
|
ev->accept();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // frontend
|
||||||
|
} // lyx
|
||||||
|
|
||||||
|
#include "moc_DockView.cpp"
|
@ -29,20 +29,16 @@ namespace frontend {
|
|||||||
**/
|
**/
|
||||||
class DockView : public QDockWidget, public Dialog
|
class DockView : public QDockWidget, public Dialog
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DockView(
|
DockView(GuiView & parent, ///< the main window where to dock.
|
||||||
GuiView & parent, ///< the main window where to dock.
|
QString const & name, ///< dialog identifier.
|
||||||
QString const & name, ///< dialog identifier.
|
QString const & title, ///< dialog title.
|
||||||
QString const & title, ///< dialog title.
|
Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of
|
||||||
Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
|
///the dock (and
|
||||||
Qt::WindowFlags flags = 0
|
///also drawer)
|
||||||
)
|
Qt::WindowFlags flags = 0);
|
||||||
: QDockWidget(&parent, flags), Dialog(parent, name, title)
|
|
||||||
{
|
|
||||||
setObjectName(name);
|
|
||||||
parent.addDockWidget(area, this);
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~DockView() {}
|
virtual ~DockView() {}
|
||||||
|
|
||||||
@ -52,27 +48,17 @@ public:
|
|||||||
/// We don't want to restore geometry session for dock widgets.
|
/// We don't want to restore geometry session for dock widgets.
|
||||||
void restoreSession() {}
|
void restoreSession() {}
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent * ev)
|
void keyPressEvent(QKeyEvent * ev);
|
||||||
{
|
|
||||||
if (ev->key() == Qt::Key_Escape) {
|
|
||||||
QMainWindow * mw = static_cast<QMainWindow *>(parent());
|
|
||||||
if (!mw) {
|
|
||||||
ev->ignore();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mw->activateWindow();
|
|
||||||
mw->setFocus();
|
|
||||||
if (isFloating())
|
|
||||||
hide();
|
|
||||||
ev->accept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// Dialog inherited methods
|
/// Dialog inherited methods
|
||||||
//@{
|
//@{
|
||||||
void applyView() {}
|
void applyView() {}
|
||||||
bool isClosing() const { return false; }
|
bool isClosing() const { return false; }
|
||||||
bool needBufferOpen() const { return false; }
|
bool needBufferOpen() const { return false; }
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
void on_bufferViewChanged() {} //override
|
||||||
};
|
};
|
||||||
|
|
||||||
} // frontend
|
} // frontend
|
||||||
|
@ -28,6 +28,9 @@ GuiDialog::GuiDialog(GuiView & lv, QString const & name, QString const & title)
|
|||||||
: QDialog(&lv), Dialog(lv, name, "LyX: " + title), updating_(false),
|
: QDialog(&lv), Dialog(lv, name, "LyX: " + title), updating_(false),
|
||||||
is_closing_(false)
|
is_closing_(false)
|
||||||
{
|
{
|
||||||
|
connect(&lv, SIGNAL(bufferViewChanged()),
|
||||||
|
this, SLOT(on_bufferViewChanged()));
|
||||||
|
|
||||||
// remove question marks from Windows dialogs
|
// remove question marks from Windows dialogs
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,9 @@ public Q_SLOTS:
|
|||||||
///
|
///
|
||||||
void closeEvent(QCloseEvent * e);
|
void closeEvent(QCloseEvent * e);
|
||||||
|
|
||||||
|
protected Q_SLOTS:
|
||||||
|
void on_bufferViewChanged() {};//override
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Check whether we may apply our data.
|
/** Check whether we may apply our data.
|
||||||
*
|
*
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#include "GuiView.h"
|
#include "GuiView.h"
|
||||||
|
|
||||||
#include "Dialog.h"
|
|
||||||
#include "DispatchResult.h"
|
#include "DispatchResult.h"
|
||||||
#include "FileDialog.h"
|
#include "FileDialog.h"
|
||||||
#include "FontLoader.h"
|
#include "FontLoader.h"
|
||||||
@ -1194,25 +1193,31 @@ void GuiView::updateWindowTitle(GuiWorkArea * wa)
|
|||||||
void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
|
void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
|
||||||
{
|
{
|
||||||
if (d.current_work_area_)
|
if (d.current_work_area_)
|
||||||
QObject::disconnect(d.current_work_area_, SIGNAL(busy(bool)),
|
// disconnect the current work area from all slots
|
||||||
this, SLOT(setBusy(bool)));
|
QObject::disconnect(d.current_work_area_, 0, this, 0);
|
||||||
disconnectBuffer();
|
disconnectBuffer();
|
||||||
disconnectBufferView();
|
disconnectBufferView();
|
||||||
connectBufferView(wa->bufferView());
|
connectBufferView(wa->bufferView());
|
||||||
connectBuffer(wa->bufferView().buffer());
|
connectBuffer(wa->bufferView().buffer());
|
||||||
d.current_work_area_ = wa;
|
d.current_work_area_ = wa;
|
||||||
QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
|
QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
|
||||||
this, SLOT(updateWindowTitle(GuiWorkArea *)));
|
this, SLOT(updateWindowTitle(GuiWorkArea *)));
|
||||||
QObject::connect(wa, SIGNAL(busy(bool)), this, SLOT(setBusy(bool)));
|
QObject::connect(wa, SIGNAL(busy(bool)),
|
||||||
updateWindowTitle(wa);
|
this, SLOT(setBusy(bool)));
|
||||||
|
QObject::connect(wa, SIGNAL(bufferViewChanged()),
|
||||||
|
this, SIGNAL(bufferViewChanged()));
|
||||||
|
Q_EMIT updateWindowTitle(wa);
|
||||||
|
Q_EMIT bufferViewChanged();
|
||||||
|
|
||||||
structureChanged();
|
structureChanged();
|
||||||
|
|
||||||
// The document settings needs to be reinitialised.
|
// The document settings needs to be reinitialised.
|
||||||
|
// TODO: no longer needed now there is bufferViewChanged?
|
||||||
updateDialog("document", "");
|
updateDialog("document", "");
|
||||||
|
|
||||||
// Buffer-dependent dialogs must be updated. This is done here because
|
// Buffer-dependent dialogs must be updated. This is done here because
|
||||||
// some dialogs require buffer()->text.
|
// some dialogs require buffer()->text.
|
||||||
|
// TODO: no longer needed now there is bufferViewChanged?
|
||||||
updateDialogs();
|
updateDialogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1228,6 +1233,8 @@ void GuiView::on_lastWorkAreaRemoved()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Reset and updates the dialogs.
|
// Reset and updates the dialogs.
|
||||||
|
Q_EMIT bufferViewChanged();
|
||||||
|
// TODO: no longer needed now there is bufferViewChanged?
|
||||||
d.toc_models_.reset(0);
|
d.toc_models_.reset(0);
|
||||||
updateDialog("document", "");
|
updateDialog("document", "");
|
||||||
updateDialogs();
|
updateDialogs();
|
||||||
@ -1310,19 +1317,10 @@ bool GuiView::event(QEvent * e)
|
|||||||
cap::saveSelection(old_view->currentBufferView()->cursor());
|
cap::saveSelection(old_view->currentBufferView()->cursor());
|
||||||
}
|
}
|
||||||
guiApp->setCurrentView(this);
|
guiApp->setCurrentView(this);
|
||||||
if (d.current_work_area_) {
|
if (d.current_work_area_)
|
||||||
BufferView & bv = d.current_work_area_->bufferView();
|
on_currentWorkAreaChanged(d.current_work_area_);
|
||||||
connectBufferView(bv);
|
else
|
||||||
connectBuffer(bv.buffer());
|
|
||||||
// The document structure, name and dialogs might have
|
|
||||||
// changed in another view.
|
|
||||||
structureChanged();
|
|
||||||
// The document settings needs to be reinitialised.
|
|
||||||
updateDialog("document", "");
|
|
||||||
updateDialogs();
|
|
||||||
} else {
|
|
||||||
resetWindowTitle();
|
resetWindowTitle();
|
||||||
}
|
|
||||||
setFocus();
|
setFocus();
|
||||||
return QMainWindow::event(e);
|
return QMainWindow::event(e);
|
||||||
}
|
}
|
||||||
@ -1477,6 +1475,7 @@ void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
|
|||||||
if (!wa) {
|
if (!wa) {
|
||||||
d.current_work_area_ = 0;
|
d.current_work_area_ = 0;
|
||||||
d.setBackground();
|
d.setBackground();
|
||||||
|
Q_EMIT bufferViewChanged();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,6 +214,8 @@ public:
|
|||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void closing(int);
|
void closing(int);
|
||||||
void triggerShowDialog(QString const & qname, QString const & qdata, Inset * inset);
|
void triggerShowDialog(QString const & qname, QString const & qdata, Inset * inset);
|
||||||
|
// emitted when the work area or its buffer view changed
|
||||||
|
void bufferViewChanged();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
///
|
///
|
||||||
|
@ -392,6 +392,7 @@ void GuiWorkArea::setBuffer(Buffer & buffer)
|
|||||||
if (buffer.text().paragraphs().size() > 4)
|
if (buffer.text().paragraphs().size() > 4)
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
QTimer::singleShot(50, this, SLOT(fixVerticalScrollBar()));
|
QTimer::singleShot(50, this, SLOT(fixVerticalScrollBar()));
|
||||||
|
Q_EMIT bufferViewChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,6 +100,8 @@ Q_SIGNALS:
|
|||||||
void titleChanged(GuiWorkArea *);
|
void titleChanged(GuiWorkArea *);
|
||||||
///
|
///
|
||||||
void busy(bool);
|
void busy(bool);
|
||||||
|
///
|
||||||
|
void bufferViewChanged();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
/// Scroll the BufferView.
|
/// Scroll the BufferView.
|
||||||
|
@ -61,6 +61,8 @@ SOURCEFILES = \
|
|||||||
CategorizedCombo.cpp \
|
CategorizedCombo.cpp \
|
||||||
ColorCache.cpp \
|
ColorCache.cpp \
|
||||||
CustomizedWidgets.cpp \
|
CustomizedWidgets.cpp \
|
||||||
|
DialogView.cpp \
|
||||||
|
DockView.cpp \
|
||||||
EmptyTable.cpp \
|
EmptyTable.cpp \
|
||||||
FancyLineEdit.cpp \
|
FancyLineEdit.cpp \
|
||||||
FileDialog.cpp \
|
FileDialog.cpp \
|
||||||
@ -159,8 +161,6 @@ SOURCEFILES = \
|
|||||||
NOMOCHEADER = \
|
NOMOCHEADER = \
|
||||||
ButtonController.h \
|
ButtonController.h \
|
||||||
ColorCache.h \
|
ColorCache.h \
|
||||||
DialogView.h \
|
|
||||||
DockView.h \
|
|
||||||
FileDialog.h \
|
FileDialog.h \
|
||||||
GuiFontExample.h \
|
GuiFontExample.h \
|
||||||
GuiFontLoader.h \
|
GuiFontLoader.h \
|
||||||
@ -180,6 +180,8 @@ MOCHEADER = \
|
|||||||
BulletsModule.h \
|
BulletsModule.h \
|
||||||
CategorizedCombo.h \
|
CategorizedCombo.h \
|
||||||
CustomizedWidgets.h \
|
CustomizedWidgets.h \
|
||||||
|
DialogView.h \
|
||||||
|
DockView.h \
|
||||||
EmptyTable.h \
|
EmptyTable.h \
|
||||||
FancyLineEdit.h \
|
FancyLineEdit.h \
|
||||||
FindAndReplace.h \
|
FindAndReplace.h \
|
||||||
|
Loading…
Reference in New Issue
Block a user