2007-03-12 14:23:44 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file DockView.h
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DOCK_VIEW_H
|
|
|
|
#define DOCK_VIEW_H
|
|
|
|
|
2007-10-07 08:55:20 +00:00
|
|
|
#include "Dialog.h"
|
2007-09-08 16:04:25 +00:00
|
|
|
#include "GuiView.h"
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
2010-04-26 10:03:09 +00:00
|
|
|
#include <QKeyEvent>
|
2007-03-12 14:23:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
/// Dock Widget container for LyX dialogs.
|
2007-12-10 13:05:00 +00:00
|
|
|
/**
|
|
|
|
* This template class that encapsulates a given Widget inside a
|
|
|
|
* QDockWidget and presents a Dialog interface
|
|
|
|
* FIXME: create a DockView.cpp file
|
|
|
|
**/
|
2007-10-09 21:21:01 +00:00
|
|
|
class DockView : public QDockWidget, public Dialog
|
2007-03-12 14:23:44 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DockView(
|
2007-11-05 13:52:37 +00:00
|
|
|
GuiView & parent, ///< the main window where to dock.
|
2008-03-05 20:11:47 +00:00
|
|
|
QString const & name, ///< dialog identifier.
|
2008-02-05 12:43:19 +00:00
|
|
|
QString const & title, ///< dialog title.
|
2007-05-29 11:38:28 +00:00
|
|
|
Qt::DockWidgetArea area = Qt::LeftDockWidgetArea, ///< Position of the dock (and also drawer)
|
|
|
|
Qt::WindowFlags flags = 0
|
2007-09-10 22:32:59 +00:00
|
|
|
)
|
2008-02-05 12:43:19 +00:00
|
|
|
: QDockWidget(&parent, flags), Dialog(parent, name, title)
|
2007-03-12 14:23:44 +00:00
|
|
|
{
|
2008-06-09 14:09:27 +00:00
|
|
|
setObjectName(name);
|
2007-09-08 16:04:25 +00:00
|
|
|
parent.addDockWidget(area, this);
|
2008-10-03 13:45:56 +00:00
|
|
|
hide();
|
2007-03-12 14:23:44 +00:00
|
|
|
}
|
2007-10-08 20:14:58 +00:00
|
|
|
|
|
|
|
virtual ~DockView() {}
|
2007-03-12 14:23:44 +00:00
|
|
|
|
2007-12-09 22:35:04 +00:00
|
|
|
virtual QWidget * asQWidget() { return this; }
|
|
|
|
virtual QWidget const * asQWidget() const { return this; }
|
|
|
|
|
2008-10-03 13:34:10 +00:00
|
|
|
/// We don't want to restore geometry session for dock widgets.
|
|
|
|
void restoreSession() {}
|
|
|
|
|
2010-04-26 10:03:09 +00:00
|
|
|
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();
|
|
|
|
ev->accept();
|
|
|
|
}
|
|
|
|
}
|
2007-09-08 16:04:25 +00:00
|
|
|
/// Dialog inherited methods
|
2007-03-12 14:23:44 +00:00
|
|
|
//@{
|
2007-09-03 20:28:26 +00:00
|
|
|
void applyView() {}
|
2007-09-10 22:32:59 +00:00
|
|
|
bool isClosing() const { return false; }
|
Fix bug #6451 (last part): Crash when interacting with buffer-dependent dialog with no buffer open.
- First, the comment for isBufferDependent is corrected. It seems that the actual use of this function differs from the comment. As the comment said, I decided to close all dialogs that were buffer dependent, but this didn't seem to be correct for the view source pan, the outliner, and find-and-replace.
- Second, the dialogs that are buffer dependent are now closed, but dockviews are not, except for the spellchecker pane, which really depends on an open buffer, but I can't test that.
So, please test whether the spellchecker dockviewed window behaves as one expects.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34291 a592a061-630c-0410-9148-cb99ea01b6c8
2010-04-26 02:12:10 +00:00
|
|
|
bool needBufferOpen() const { return false; }
|
2007-03-12 14:23:44 +00:00
|
|
|
//@}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // frontend
|
|
|
|
} // lyx
|
|
|
|
|
2007-09-08 16:04:25 +00:00
|
|
|
#endif // DOCK_VIEW_H
|