2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
* \file GuiView.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:29:47 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2006-03-05 17:24:44 +00:00
|
|
|
* \author John Levon
|
|
|
|
* \author Abdelrazak Younes
|
2008-11-14 15:29:47 +00:00
|
|
|
* \author Peter Kümmel
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-11-18 00:01:14 +00:00
|
|
|
#include "GuiView.h"
|
|
|
|
|
2007-12-02 17:50:08 +00:00
|
|
|
#include "Dialog.h"
|
2010-01-29 10:42:39 +00:00
|
|
|
#include "DispatchResult.h"
|
2008-02-07 00:05:18 +00:00
|
|
|
#include "FileDialog.h"
|
2009-04-04 09:14:38 +00:00
|
|
|
#include "FontLoader.h"
|
2007-11-17 22:37:33 +00:00
|
|
|
#include "GuiApplication.h"
|
2008-05-27 16:15:56 +00:00
|
|
|
#include "GuiCommandBuffer.h"
|
2008-04-21 19:12:15 +00:00
|
|
|
#include "GuiCompleter.h"
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiKeySymbol.h"
|
2009-04-08 21:06:58 +00:00
|
|
|
#include "GuiToc.h"
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiToolbar.h"
|
2010-01-07 14:25:15 +00:00
|
|
|
#include "GuiWorkArea.h"
|
2009-08-12 21:51:10 +00:00
|
|
|
#include "LayoutBox.h"
|
2007-12-26 10:55:43 +00:00
|
|
|
#include "Menus.h"
|
2008-05-02 12:09:51 +00:00
|
|
|
#include "TocModel.h"
|
2010-07-17 16:09:26 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
#include "frontends/alert.h"
|
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
#include "buffer_funcs.h"
|
2007-08-14 13:14:47 +00:00
|
|
|
#include "Buffer.h"
|
2007-11-12 23:23:19 +00:00
|
|
|
#include "BufferList.h"
|
2007-10-01 20:45:50 +00:00
|
|
|
#include "BufferParams.h"
|
2006-10-24 15:01:07 +00:00
|
|
|
#include "BufferView.h"
|
2010-02-22 02:01:04 +00:00
|
|
|
#include "Compare.h"
|
2008-02-06 23:54:13 +00:00
|
|
|
#include "Converter.h"
|
2007-10-11 09:59:01 +00:00
|
|
|
#include "Cursor.h"
|
2009-08-09 14:27:50 +00:00
|
|
|
#include "CutAndPaste.h"
|
2008-03-20 00:00:53 +00:00
|
|
|
#include "Encoding.h"
|
2007-11-12 23:23:19 +00:00
|
|
|
#include "ErrorList.h"
|
2008-02-06 23:54:13 +00:00
|
|
|
#include "Format.h"
|
2008-03-08 15:33:52 +00:00
|
|
|
#include "FuncStatus.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "FuncRequest.h"
|
2007-11-12 23:23:19 +00:00
|
|
|
#include "Intl.h"
|
2007-10-01 20:45:50 +00:00
|
|
|
#include "Layout.h"
|
2007-11-19 20:56:05 +00:00
|
|
|
#include "Lexer.h"
|
2009-09-23 09:07:24 +00:00
|
|
|
#include "LyXAction.h"
|
2007-11-12 23:23:19 +00:00
|
|
|
#include "LyX.h"
|
2007-08-14 13:14:47 +00:00
|
|
|
#include "LyXRC.h"
|
2007-11-19 20:56:05 +00:00
|
|
|
#include "LyXVC.h"
|
2007-10-01 20:45:50 +00:00
|
|
|
#include "Paragraph.h"
|
2009-08-01 17:34:44 +00:00
|
|
|
#include "SpellChecker.h"
|
2010-04-15 13:19:48 +00:00
|
|
|
#include "TexRow.h"
|
2007-11-07 23:25:08 +00:00
|
|
|
#include "TextClass.h"
|
2007-11-12 23:23:19 +00:00
|
|
|
#include "Text.h"
|
2008-05-25 08:30:06 +00:00
|
|
|
#include "Toolbars.h"
|
2007-08-21 07:33:46 +00:00
|
|
|
#include "version.h"
|
2006-10-24 15:01:07 +00:00
|
|
|
|
2009-04-04 09:14:38 +00:00
|
|
|
#include "support/convert.h"
|
2008-02-06 23:54:13 +00:00
|
|
|
#include "support/debug.h"
|
2008-08-13 14:25:56 +00:00
|
|
|
#include "support/ExceptionMessage.h"
|
2007-11-19 20:56:05 +00:00
|
|
|
#include "support/FileName.h"
|
2007-12-02 17:50:08 +00:00
|
|
|
#include "support/filetools.h"
|
2008-03-20 00:00:53 +00:00
|
|
|
#include "support/gettext.h"
|
2009-09-19 16:49:31 +00:00
|
|
|
#include "support/filetools.h"
|
2008-01-15 18:26:53 +00:00
|
|
|
#include "support/ForkedCalls.h"
|
2009-04-04 09:14:38 +00:00
|
|
|
#include "support/lassert.h"
|
2007-11-12 23:23:19 +00:00
|
|
|
#include "support/lstrings.h"
|
2007-11-19 12:03:38 +00:00
|
|
|
#include "support/os.h"
|
2007-12-02 17:50:08 +00:00
|
|
|
#include "support/Package.h"
|
2009-09-12 20:41:24 +00:00
|
|
|
#include "support/Path.h"
|
|
|
|
#include "support/Systemcall.h"
|
2007-11-12 23:23:19 +00:00
|
|
|
#include "support/Timeout.h"
|
2009-12-20 14:26:55 +00:00
|
|
|
#include "support/ProgressInterface.h"
|
2010-07-17 16:09:26 +00:00
|
|
|
#include "GuiProgress.h"
|
2007-11-12 23:23:19 +00:00
|
|
|
|
2006-10-22 14:37:32 +00:00
|
|
|
#include <QAction>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QApplication>
|
2006-10-22 14:37:32 +00:00
|
|
|
#include <QCloseEvent>
|
2007-11-22 23:47:13 +00:00
|
|
|
#include <QDebug>
|
2007-08-14 13:14:47 +00:00
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QDragEnterEvent>
|
|
|
|
#include <QDropEvent>
|
|
|
|
#include <QList>
|
2007-09-28 23:26:59 +00:00
|
|
|
#include <QMenu>
|
2008-02-07 00:10:34 +00:00
|
|
|
#include <QMenuBar>
|
2007-08-21 07:33:46 +00:00
|
|
|
#include <QPainter>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QPixmap>
|
2009-04-04 10:15:06 +00:00
|
|
|
#include <QPixmapCache>
|
2007-11-16 21:52:04 +00:00
|
|
|
#include <QPoint>
|
2007-08-14 13:14:47 +00:00
|
|
|
#include <QPushButton>
|
2007-11-15 12:58:44 +00:00
|
|
|
#include <QSettings>
|
|
|
|
#include <QShowEvent>
|
2007-11-11 10:09:48 +00:00
|
|
|
#include <QSplitter>
|
2007-08-21 07:33:46 +00:00
|
|
|
#include <QStackedWidget>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QStatusBar>
|
2009-12-21 15:07:51 +00:00
|
|
|
#include <QTime>
|
2007-11-18 23:49:52 +00:00
|
|
|
#include <QTimer>
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QToolBar>
|
2007-08-14 13:14:47 +00:00
|
|
|
#include <QUrl>
|
2008-02-11 23:52:25 +00:00
|
|
|
#include <QScrollBar>
|
2010-07-17 16:09:26 +00:00
|
|
|
|
|
|
|
|
2010-04-05 13:04:52 +00:00
|
|
|
|
2009-12-19 15:46:45 +00:00
|
|
|
#define EXPORT_in_THREAD 1
|
2009-12-18 22:51:06 +00:00
|
|
|
|
2009-12-13 21:00:46 +00:00
|
|
|
// QtConcurrent was introduced in Qt 4.4
|
|
|
|
#if (QT_VERSION >= 0x040400)
|
|
|
|
#include <QFuture>
|
|
|
|
#include <QFutureWatcher>
|
|
|
|
#include <QtConcurrentRun>
|
|
|
|
#endif
|
|
|
|
|
2010-04-22 11:16:58 +00:00
|
|
|
#include "support/bind.h"
|
2007-10-18 09:24:16 +00:00
|
|
|
|
2009-09-24 07:20:18 +00:00
|
|
|
#include <sstream>
|
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2007-12-12 18:57:56 +00:00
|
|
|
using namespace lyx::support;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
class BackgroundWidget : public QWidget
|
2006-10-31 14:12:46 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-11-22 23:47:13 +00:00
|
|
|
BackgroundWidget()
|
2007-06-11 14:53:36 +00:00
|
|
|
{
|
2007-11-22 23:47:13 +00:00
|
|
|
LYXERR(Debug::GUI, "show banner: " << lyxrc.show_banner);
|
2010-03-15 12:18:21 +00:00
|
|
|
if (!lyxrc.show_banner)
|
|
|
|
return;
|
2007-11-22 23:47:13 +00:00
|
|
|
/// The text to be written on top of the pixmap
|
2008-04-07 15:51:35 +00:00
|
|
|
QString const text = lyx_version ?
|
|
|
|
qt_("version ") + lyx_version : qt_("unknown version");
|
2009-04-03 17:00:09 +00:00
|
|
|
splash_ = getPixmap("images/", "banner", "png");
|
2007-11-22 23:47:13 +00:00
|
|
|
|
2007-11-22 23:29:53 +00:00
|
|
|
QPainter pain(&splash_);
|
2008-04-07 12:50:54 +00:00
|
|
|
pain.setPen(QColor(0, 0, 0));
|
2007-08-21 07:33:46 +00:00
|
|
|
QFont font;
|
|
|
|
// The font used to display the version info
|
|
|
|
font.setStyleHint(QFont::SansSerif);
|
|
|
|
font.setWeight(QFont::Bold);
|
2007-11-22 23:47:13 +00:00
|
|
|
font.setPointSize(int(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble()));
|
2010-03-15 12:39:06 +00:00
|
|
|
int width = QFontMetrics(font).width(text);
|
2007-08-21 07:33:46 +00:00
|
|
|
pain.setFont(font);
|
2010-03-15 12:39:06 +00:00
|
|
|
pain.drawText(397 - width, 15, text);
|
2010-01-08 20:08:48 +00:00
|
|
|
setFocusPolicy(Qt::StrongFocus);
|
2007-06-11 14:53:36 +00:00
|
|
|
}
|
2007-02-01 18:48:58 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
void paintEvent(QPaintEvent *)
|
2006-10-31 14:12:46 +00:00
|
|
|
{
|
2007-11-22 23:29:53 +00:00
|
|
|
int x = (width() - splash_.width()) / 2;
|
|
|
|
int y = (height() - splash_.height()) / 2;
|
2007-08-21 07:33:46 +00:00
|
|
|
QPainter pain(this);
|
2007-11-22 23:29:53 +00:00
|
|
|
pain.drawPixmap(x, y, splash_);
|
2007-02-01 18:48:58 +00:00
|
|
|
}
|
|
|
|
|
2010-01-08 20:08:48 +00:00
|
|
|
void keyPressEvent(QKeyEvent * ev)
|
|
|
|
{
|
|
|
|
KeySymbol sym;
|
|
|
|
setKeySymbol(&sym, ev);
|
|
|
|
if (sym.isOK()) {
|
|
|
|
guiApp->processKeySym(sym, q_key_state(ev->modifiers()));
|
|
|
|
ev->accept();
|
|
|
|
} else {
|
|
|
|
ev->ignore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-21 07:33:46 +00:00
|
|
|
private:
|
2007-11-22 23:29:53 +00:00
|
|
|
QPixmap splash_;
|
2006-10-31 14:12:46 +00:00
|
|
|
};
|
|
|
|
|
2008-11-15 16:29:58 +00:00
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
/// Toolbar store providing access to individual toolbars by name.
|
2009-12-20 15:07:15 +00:00
|
|
|
typedef map<string, GuiToolbar *> ToolbarMap;
|
2007-08-23 08:56:13 +00:00
|
|
|
|
2010-04-22 11:37:32 +00:00
|
|
|
typedef shared_ptr<Dialog> DialogPtr;
|
2007-11-18 00:01:14 +00:00
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
struct GuiView::GuiViewPrivate
|
2006-10-31 14:12:46 +00:00
|
|
|
{
|
2009-12-19 12:24:44 +00:00
|
|
|
GuiViewPrivate(GuiView * gv)
|
|
|
|
: gv_(gv), current_work_area_(0), current_main_work_area_(0),
|
2008-11-16 01:20:34 +00:00
|
|
|
layout_(0), autosave_timeout_(5000),
|
2008-02-27 10:35:28 +00:00
|
|
|
in_show_(false)
|
2007-11-18 23:30:41 +00:00
|
|
|
{
|
|
|
|
// hardcode here the platform specific icon size
|
2008-11-16 15:32:11 +00:00
|
|
|
smallIconSize = 14; // scaling problems
|
|
|
|
normalIconSize = 20; // ok, default
|
2010-03-05 18:07:05 +00:00
|
|
|
bigIconSize = 26; // better for some math icons
|
2007-11-18 23:30:41 +00:00
|
|
|
|
|
|
|
splitter_ = new QSplitter;
|
2007-11-22 23:47:13 +00:00
|
|
|
bg_widget_ = new BackgroundWidget;
|
2007-11-18 23:30:41 +00:00
|
|
|
stack_widget_ = new QStackedWidget;
|
|
|
|
stack_widget_->addWidget(bg_widget_);
|
|
|
|
stack_widget_->addWidget(splitter_);
|
|
|
|
setBackground();
|
2010-03-05 18:07:05 +00:00
|
|
|
|
|
|
|
// TODO cleanup, remove the singleton, handle multiple Windows?
|
|
|
|
progress_ = ProgressInterface::instance();
|
2010-09-07 14:11:28 +00:00
|
|
|
if (!dynamic_cast<GuiProgress*>(progress_)) {
|
2010-03-05 18:07:05 +00:00
|
|
|
progress_ = new GuiProgress(); // TODO who deletes it
|
2010-09-07 14:11:28 +00:00
|
|
|
ProgressInterface::setInstance(progress_);
|
2010-03-05 18:07:05 +00:00
|
|
|
}
|
|
|
|
QObject::connect(
|
2010-09-07 14:11:28 +00:00
|
|
|
dynamic_cast<GuiProgress*>(progress_),
|
|
|
|
SIGNAL(updateStatusBarMessage(QString const&)),
|
2010-03-05 18:07:05 +00:00
|
|
|
gv, SLOT(updateStatusBarMessage(QString const&)));
|
|
|
|
QObject::connect(
|
2010-09-07 14:11:28 +00:00
|
|
|
dynamic_cast<GuiProgress*>(progress_),
|
|
|
|
SIGNAL(clearMessageText()),
|
2010-03-05 18:07:05 +00:00
|
|
|
gv, SLOT(clearMessageText()));
|
2007-11-18 23:30:41 +00:00
|
|
|
}
|
2007-11-11 10:09:48 +00:00
|
|
|
|
|
|
|
~GuiViewPrivate()
|
|
|
|
{
|
|
|
|
delete splitter_;
|
2007-11-22 23:47:13 +00:00
|
|
|
delete bg_widget_;
|
2007-11-23 11:19:42 +00:00
|
|
|
delete stack_widget_;
|
2007-11-11 10:09:48 +00:00
|
|
|
}
|
2006-11-27 23:35:43 +00:00
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
QMenu * toolBarPopup(GuiView * parent)
|
2006-11-29 10:04:35 +00:00
|
|
|
{
|
2007-05-28 22:27:45 +00:00
|
|
|
// FIXME: translation
|
2007-08-31 05:53:55 +00:00
|
|
|
QMenu * menu = new QMenu(parent);
|
|
|
|
QActionGroup * iconSizeGroup = new QActionGroup(parent);
|
2006-11-29 10:04:35 +00:00
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
QAction * smallIcons = new QAction(iconSizeGroup);
|
2007-01-27 14:42:45 +00:00
|
|
|
smallIcons->setText(qt_("Small-sized icons"));
|
2006-11-29 10:04:35 +00:00
|
|
|
smallIcons->setCheckable(true);
|
2007-11-12 23:23:19 +00:00
|
|
|
QObject::connect(smallIcons, SIGNAL(triggered()),
|
|
|
|
parent, SLOT(smallSizedIcons()));
|
2006-11-29 10:04:35 +00:00
|
|
|
menu->addAction(smallIcons);
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
QAction * normalIcons = new QAction(iconSizeGroup);
|
2007-01-27 14:42:45 +00:00
|
|
|
normalIcons->setText(qt_("Normal-sized icons"));
|
2006-11-29 10:04:35 +00:00
|
|
|
normalIcons->setCheckable(true);
|
2007-11-12 23:23:19 +00:00
|
|
|
QObject::connect(normalIcons, SIGNAL(triggered()),
|
|
|
|
parent, SLOT(normalSizedIcons()));
|
2006-11-29 10:04:35 +00:00
|
|
|
menu->addAction(normalIcons);
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
QAction * bigIcons = new QAction(iconSizeGroup);
|
2007-01-27 14:42:45 +00:00
|
|
|
bigIcons->setText(qt_("Big-sized icons"));
|
2006-11-29 10:04:35 +00:00
|
|
|
bigIcons->setCheckable(true);
|
2007-11-12 23:23:19 +00:00
|
|
|
QObject::connect(bigIcons, SIGNAL(triggered()),
|
|
|
|
parent, SLOT(bigSizedIcons()));
|
2006-11-29 10:04:35 +00:00
|
|
|
menu->addAction(bigIcons);
|
|
|
|
|
2006-11-29 21:52:56 +00:00
|
|
|
unsigned int cur = parent->iconSize().width();
|
2006-11-29 10:04:35 +00:00
|
|
|
if ( cur == parent->d.smallIconSize)
|
|
|
|
smallIcons->setChecked(true);
|
|
|
|
else if (cur == parent->d.normalIconSize)
|
|
|
|
normalIcons->setChecked(true);
|
|
|
|
else if (cur == parent->d.bigIconSize)
|
|
|
|
bigIcons->setChecked(true);
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
2007-08-21 07:33:46 +00:00
|
|
|
|
|
|
|
void setBackground()
|
|
|
|
{
|
|
|
|
stack_widget_->setCurrentWidget(bg_widget_);
|
|
|
|
bg_widget_->setUpdatesEnabled(true);
|
2010-01-08 20:08:48 +00:00
|
|
|
bg_widget_->setFocus();
|
2007-08-21 07:33:46 +00:00
|
|
|
}
|
2007-11-11 10:09:48 +00:00
|
|
|
|
|
|
|
TabWorkArea * tabWorkArea(int i)
|
|
|
|
{
|
|
|
|
return dynamic_cast<TabWorkArea *>(splitter_->widget(i));
|
|
|
|
}
|
|
|
|
|
|
|
|
TabWorkArea * currentTabWorkArea()
|
|
|
|
{
|
|
|
|
if (splitter_->count() == 1)
|
|
|
|
// The first TabWorkArea is always the first one, if any.
|
|
|
|
return tabWorkArea(0);
|
|
|
|
|
|
|
|
for (int i = 0; i != splitter_->count(); ++i) {
|
2008-02-21 11:48:31 +00:00
|
|
|
TabWorkArea * twa = tabWorkArea(i);
|
2008-11-16 01:20:34 +00:00
|
|
|
if (current_main_work_area_ == twa->currentWorkArea())
|
2008-02-21 11:48:31 +00:00
|
|
|
return twa;
|
2007-11-11 10:09:48 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 20:05:01 +00:00
|
|
|
// None has the focus so we just take the first one.
|
|
|
|
return tabWorkArea(0);
|
2007-11-11 10:09:48 +00:00
|
|
|
}
|
2007-11-12 23:23:19 +00:00
|
|
|
|
2009-12-22 10:42:34 +00:00
|
|
|
#if (QT_VERSION >= 0x040400)
|
2009-12-19 12:24:44 +00:00
|
|
|
void setPreviewFuture(QFuture<docstring> const & f)
|
|
|
|
{
|
2010-01-05 13:33:29 +00:00
|
|
|
if (preview_watcher_.isRunning()) {
|
|
|
|
// we prefer to cancel this preview in order to keep a snappy
|
|
|
|
// interface.
|
|
|
|
return;
|
|
|
|
}
|
2009-12-19 12:24:44 +00:00
|
|
|
preview_watcher_.setFuture(f);
|
|
|
|
}
|
2009-12-22 10:42:34 +00:00
|
|
|
#endif
|
2009-12-19 12:24:44 +00:00
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
public:
|
2009-12-19 12:24:44 +00:00
|
|
|
GuiView * gv_;
|
2007-11-12 23:23:19 +00:00
|
|
|
GuiWorkArea * current_work_area_;
|
2008-11-16 01:20:34 +00:00
|
|
|
GuiWorkArea * current_main_work_area_;
|
2007-11-12 23:23:19 +00:00
|
|
|
QSplitter * splitter_;
|
|
|
|
QStackedWidget * stack_widget_;
|
|
|
|
BackgroundWidget * bg_widget_;
|
|
|
|
/// view's toolbars
|
2008-05-27 11:15:17 +00:00
|
|
|
ToolbarMap toolbars_;
|
2009-12-21 13:11:17 +00:00
|
|
|
ProgressInterface* progress_;
|
2007-11-20 22:03:56 +00:00
|
|
|
/// The main layout box.
|
2010-09-07 14:11:28 +00:00
|
|
|
/**
|
2007-11-20 22:03:56 +00:00
|
|
|
* \warning Don't Delete! The layout box is actually owned by
|
|
|
|
* whichever toolbar contains it. All the GuiView class needs is a
|
|
|
|
* means of accessing it.
|
|
|
|
*
|
|
|
|
* FIXME: replace that with a proper model so that we are not limited
|
|
|
|
* to only one dialog.
|
|
|
|
*/
|
2009-08-12 21:51:10 +00:00
|
|
|
LayoutBox * layout_;
|
2007-11-18 00:01:14 +00:00
|
|
|
|
|
|
|
///
|
2007-12-12 19:28:07 +00:00
|
|
|
map<string, DialogPtr> dialogs_;
|
2007-11-18 23:30:41 +00:00
|
|
|
|
|
|
|
unsigned int smallIconSize;
|
|
|
|
unsigned int normalIconSize;
|
|
|
|
unsigned int bigIconSize;
|
|
|
|
///
|
|
|
|
QTimer statusbar_timer_;
|
|
|
|
/// auto-saving of buffers
|
2007-11-22 23:29:53 +00:00
|
|
|
Timeout autosave_timeout_;
|
2007-11-22 23:47:13 +00:00
|
|
|
/// flag against a race condition due to multiclicks, see bug #1119
|
2007-11-18 00:01:14 +00:00
|
|
|
bool in_show_;
|
2008-05-02 12:09:51 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
TocModels toc_models_;
|
2009-12-13 21:00:46 +00:00
|
|
|
|
|
|
|
#if (QT_VERSION >= 0x040400)
|
|
|
|
///
|
2009-12-18 22:51:06 +00:00
|
|
|
QFutureWatcher<docstring> autosave_watcher_;
|
|
|
|
QFutureWatcher<docstring> preview_watcher_;
|
2010-03-13 11:39:50 +00:00
|
|
|
///
|
|
|
|
string last_export_format;
|
2009-12-22 10:42:34 +00:00
|
|
|
#else
|
2010-09-07 14:11:28 +00:00
|
|
|
struct DummyWatcher { bool isRunning(){return false;} };
|
2009-12-22 10:42:34 +00:00
|
|
|
DummyWatcher preview_watcher_;
|
2009-12-13 21:00:46 +00:00
|
|
|
#endif
|
2010-04-05 13:04:52 +00:00
|
|
|
|
|
|
|
static QSet<Buffer const *> busyBuffers;
|
|
|
|
static docstring previewAndDestroy(Buffer const * orig, Buffer * buffer, string const & format);
|
|
|
|
static docstring exportAndDestroy(Buffer const * orig, Buffer * buffer, string const & format);
|
|
|
|
static docstring saveAndDestroy(Buffer const * orig, Buffer * buffer, FileName const & fname);
|
|
|
|
|
2010-10-18 09:31:50 +00:00
|
|
|
// TODO syncFunc/previewFunc: use bind
|
2010-10-18 10:59:23 +00:00
|
|
|
bool asyncBufferProcessing(string const & argument,
|
|
|
|
Buffer const * used_buffer,
|
|
|
|
docstring const & msg,
|
|
|
|
docstring (*asyncFunc)(Buffer const *, Buffer *, string const &),
|
|
|
|
bool (Buffer::*syncFunc)(string const &, bool, bool) const,
|
|
|
|
bool (Buffer::*previewFunc)(string const &, bool) const);
|
2010-10-18 09:31:50 +00:00
|
|
|
|
|
|
|
|
2006-10-31 14:12:46 +00:00
|
|
|
};
|
|
|
|
|
2010-04-05 13:04:52 +00:00
|
|
|
QSet<Buffer const *> GuiView::GuiViewPrivate::busyBuffers;
|
|
|
|
|
2006-12-03 13:17:35 +00:00
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
GuiView::GuiView(int id)
|
2009-12-19 12:24:44 +00:00
|
|
|
: d(*new GuiViewPrivate(this)), id_(id), closing_(false)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-12-26 10:55:43 +00:00
|
|
|
// GuiToolbars *must* be initialised before the menu bar.
|
2008-10-27 09:06:50 +00:00
|
|
|
normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
|
2008-05-27 11:15:17 +00:00
|
|
|
constructToolbars();
|
2007-12-26 10:55:43 +00:00
|
|
|
|
2008-03-14 23:29:11 +00:00
|
|
|
// set ourself as the current view. This is needed for the menu bar
|
|
|
|
// filling, at least for the static special menu item on Mac. Otherwise
|
|
|
|
// they are greyed out.
|
2009-09-22 21:25:32 +00:00
|
|
|
guiApp->setCurrentView(this);
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2007-12-26 10:55:43 +00:00
|
|
|
// Fill up the menu bar.
|
2008-03-15 02:58:05 +00:00
|
|
|
guiApp->menus().fillMenuBar(menuBar(), this, true);
|
2007-11-18 23:30:41 +00:00
|
|
|
|
|
|
|
setCentralWidget(d.stack_widget_);
|
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
// Start autosave timer
|
|
|
|
if (lyxrc.autosave) {
|
2010-04-22 11:16:58 +00:00
|
|
|
d.autosave_timeout_.timeout.connect(bind(&GuiView::autoSave, this));
|
2007-11-22 23:29:53 +00:00
|
|
|
d.autosave_timeout_.setTimeout(lyxrc.autosave * 1000);
|
|
|
|
d.autosave_timeout_.start();
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
2007-11-22 23:29:53 +00:00
|
|
|
connect(&d.statusbar_timer_, SIGNAL(timeout()),
|
2007-11-18 23:30:41 +00:00
|
|
|
this, SLOT(clearMessage()));
|
2007-11-12 23:23:19 +00:00
|
|
|
|
2008-02-27 11:35:12 +00:00
|
|
|
// We don't want to keep the window in memory if it is closed.
|
2008-02-27 11:56:36 +00:00
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2008-02-27 11:35:12 +00:00
|
|
|
|
2008-04-07 15:51:35 +00:00
|
|
|
#if (!defined(Q_WS_WIN) && !defined(Q_WS_MACX))
|
2008-04-07 12:50:54 +00:00
|
|
|
// assign an icon to main form. We do not do it under Qt/Win or Qt/Mac,
|
2007-08-30 20:09:12 +00:00
|
|
|
// since the icon is provided in the application bundle.
|
2009-04-03 17:00:09 +00:00
|
|
|
setWindowIcon(getPixmap("images/", "lyx", "png"));
|
2006-03-05 17:24:44 +00:00
|
|
|
#endif
|
2007-08-14 13:14:47 +00:00
|
|
|
|
2010-01-29 08:19:45 +00:00
|
|
|
#if (QT_VERSION >= 0x040300)
|
|
|
|
// use tabbed dock area for multiple docks
|
|
|
|
// (such as "source" and "messages")
|
|
|
|
setDockOptions(QMainWindow::ForceTabbedDocks);
|
|
|
|
#endif
|
|
|
|
|
2007-08-14 13:14:47 +00:00
|
|
|
// For Drag&Drop.
|
|
|
|
setAcceptDrops(true);
|
2007-11-18 22:29:58 +00:00
|
|
|
|
2007-11-18 22:51:58 +00:00
|
|
|
statusBar()->setSizeGripEnabled(true);
|
2009-12-26 23:58:24 +00:00
|
|
|
updateStatusBar();
|
2007-11-18 22:51:58 +00:00
|
|
|
|
2009-12-22 10:04:30 +00:00
|
|
|
#if (QT_VERSION >= 0x040400)
|
|
|
|
connect(&d.autosave_watcher_, SIGNAL(finished()), this,
|
|
|
|
SLOT(threadFinished()));
|
2009-12-27 10:03:16 +00:00
|
|
|
connect(&d.preview_watcher_, SIGNAL(finished()), this,
|
|
|
|
SLOT(threadFinished()));
|
2009-12-22 10:04:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
|
|
|
|
SLOT(doShowDialog(QString const &, QString const &, Inset *)));
|
|
|
|
|
2007-11-18 23:30:41 +00:00
|
|
|
// Forbid too small unresizable window because it can happen
|
|
|
|
// with some window manager under X11.
|
|
|
|
setMinimumSize(300, 200);
|
2007-11-18 22:51:58 +00:00
|
|
|
|
2008-05-27 13:16:50 +00:00
|
|
|
if (lyxrc.allow_geometry_session) {
|
|
|
|
// Now take care of session management.
|
2008-06-19 17:30:30 +00:00
|
|
|
if (restoreLayout())
|
|
|
|
return;
|
2008-05-27 11:15:17 +00:00
|
|
|
}
|
2007-11-18 22:51:58 +00:00
|
|
|
|
2008-11-05 14:04:37 +00:00
|
|
|
// no session handling, default to a sane size.
|
2008-05-27 13:16:50 +00:00
|
|
|
setGeometry(50, 50, 690, 510);
|
|
|
|
initToolbars();
|
2008-11-05 14:04:37 +00:00
|
|
|
|
|
|
|
// clear session data if any.
|
2008-05-27 13:16:50 +00:00
|
|
|
QSettings settings;
|
2008-09-21 21:28:37 +00:00
|
|
|
settings.remove("views");
|
2008-05-27 13:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GuiView::~GuiView()
|
|
|
|
{
|
|
|
|
delete &d;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-18 22:51:06 +00:00
|
|
|
void GuiView::threadFinished()
|
2009-12-13 21:00:46 +00:00
|
|
|
{
|
|
|
|
#if (QT_VERSION >= 0x040400)
|
2009-12-18 22:51:06 +00:00
|
|
|
QFutureWatcher<docstring> const * watcher =
|
|
|
|
static_cast<QFutureWatcher<docstring> const *>(sender());
|
|
|
|
message(watcher->result());
|
2010-04-28 04:51:05 +00:00
|
|
|
updateToolbars();
|
2010-03-13 11:39:50 +00:00
|
|
|
errors(d.last_export_format);
|
2009-12-13 21:00:46 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-27 13:16:50 +00:00
|
|
|
void GuiView::saveLayout() const
|
|
|
|
{
|
|
|
|
QSettings settings;
|
2008-09-22 06:50:35 +00:00
|
|
|
settings.beginGroup("views");
|
|
|
|
settings.beginGroup(QString::number(id_));
|
2008-05-27 13:16:50 +00:00
|
|
|
#ifdef Q_WS_X11
|
2008-09-22 06:50:35 +00:00
|
|
|
settings.setValue("pos", pos());
|
|
|
|
settings.setValue("size", size());
|
2008-05-27 13:16:50 +00:00
|
|
|
#else
|
2008-09-22 06:50:35 +00:00
|
|
|
settings.setValue("geometry", saveGeometry());
|
2008-05-27 13:16:50 +00:00
|
|
|
#endif
|
2008-09-22 06:50:35 +00:00
|
|
|
settings.setValue("layout", saveState(0));
|
|
|
|
settings.setValue("icon_size", iconSize());
|
2008-05-27 13:16:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-19 17:30:30 +00:00
|
|
|
bool GuiView::restoreLayout()
|
2008-05-27 13:16:50 +00:00
|
|
|
{
|
|
|
|
QSettings settings;
|
2008-09-21 22:34:19 +00:00
|
|
|
settings.beginGroup("views");
|
|
|
|
settings.beginGroup(QString::number(id_));
|
|
|
|
QString const icon_key = "icon_size";
|
2008-06-19 20:48:49 +00:00
|
|
|
if (!settings.contains(icon_key))
|
2008-06-19 17:30:30 +00:00
|
|
|
return false;
|
|
|
|
|
2009-06-16 17:22:43 +00:00
|
|
|
//code below is skipped when when ~/.config/LyX is (re)created
|
2008-06-19 20:48:49 +00:00
|
|
|
setIconSize(settings.value(icon_key).toSize());
|
2007-11-18 22:51:58 +00:00
|
|
|
#ifdef Q_WS_X11
|
2008-09-22 06:48:08 +00:00
|
|
|
QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
|
|
|
|
QSize size = settings.value("size", QSize(690, 510)).toSize();
|
2007-11-18 22:51:58 +00:00
|
|
|
resize(size);
|
|
|
|
move(pos);
|
|
|
|
#else
|
2009-08-07 12:49:03 +00:00
|
|
|
// Work-around for bug #6034: the window ends up in an undetermined
|
|
|
|
// state when trying to restore a maximized window when it is
|
|
|
|
// already maximized.
|
|
|
|
if (!(windowState() & Qt::WindowMaximized))
|
|
|
|
if (!restoreGeometry(settings.value("geometry").toByteArray()))
|
|
|
|
setGeometry(50, 50, 690, 510);
|
2007-11-18 22:51:58 +00:00
|
|
|
#endif
|
2008-09-21 21:28:37 +00:00
|
|
|
// Make sure layout is correctly oriented.
|
|
|
|
setLayoutDirection(qApp->layoutDirection());
|
|
|
|
|
2008-06-09 15:01:45 +00:00
|
|
|
// Allow the toc and view-source dock widget to be restored if needed.
|
2009-06-22 22:08:04 +00:00
|
|
|
Dialog * dialog;
|
2009-06-23 08:20:10 +00:00
|
|
|
if ((dialog = findOrBuild("toc", true)))
|
2009-06-16 17:22:43 +00:00
|
|
|
// see bug 5082. At least setup title and enabled state.
|
|
|
|
// Visibility will be adjusted by restoreState below.
|
2009-06-22 22:08:04 +00:00
|
|
|
dialog->prepareView();
|
2009-06-23 08:20:10 +00:00
|
|
|
if ((dialog = findOrBuild("view-source", true)))
|
2009-06-22 22:08:04 +00:00
|
|
|
dialog->prepareView();
|
2009-12-28 21:55:50 +00:00
|
|
|
if ((dialog = findOrBuild("progress", true)))
|
|
|
|
dialog->prepareView();
|
2008-09-12 02:21:14 +00:00
|
|
|
|
2008-09-21 22:34:19 +00:00
|
|
|
if (!restoreState(settings.value("layout").toByteArray(), 0))
|
2008-05-27 11:15:17 +00:00
|
|
|
initToolbars();
|
2008-06-20 06:43:43 +00:00
|
|
|
updateDialogs();
|
2008-06-19 17:30:30 +00:00
|
|
|
return true;
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
GuiToolbar * GuiView::toolbar(string const & name)
|
|
|
|
{
|
|
|
|
ToolbarMap::iterator it = d.toolbars_.find(name);
|
|
|
|
if (it != d.toolbars_.end())
|
|
|
|
return it->second;
|
|
|
|
|
|
|
|
LYXERR(Debug::GUI, "Toolbar::display: no toolbar named " << name);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::constructToolbars()
|
|
|
|
{
|
|
|
|
ToolbarMap::iterator it = d.toolbars_.begin();
|
|
|
|
for (; it != d.toolbars_.end(); ++it)
|
|
|
|
delete it->second;
|
|
|
|
d.toolbars_.clear();
|
|
|
|
|
2009-08-15 14:34:00 +00:00
|
|
|
// I don't like doing this here, but the standard toolbar
|
|
|
|
// destroys this object when it's destroyed itself (vfr)
|
|
|
|
d.layout_ = new LayoutBox(*this);
|
|
|
|
d.stack_widget_->addWidget(d.layout_);
|
|
|
|
d.layout_->move(0,0);
|
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
// extracts the toolbars from the backend
|
|
|
|
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
|
|
|
|
Toolbars::Infos::iterator end = guiApp->toolbars().end();
|
|
|
|
for (; cit != end; ++cit)
|
|
|
|
d.toolbars_[cit->name] = new GuiToolbar(*cit, *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::initToolbars()
|
|
|
|
{
|
|
|
|
// extracts the toolbars from the backend
|
|
|
|
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
|
|
|
|
Toolbars::Infos::iterator end = guiApp->toolbars().end();
|
|
|
|
for (; cit != end; ++cit) {
|
|
|
|
GuiToolbar * tb = toolbar(cit->name);
|
|
|
|
if (!tb)
|
|
|
|
continue;
|
|
|
|
int const visibility = guiApp->toolbars().defaultVisibility(cit->name);
|
2010-01-27 17:19:14 +00:00
|
|
|
bool newline = !(visibility & Toolbars::SAMEROW);
|
2008-05-27 11:15:17 +00:00
|
|
|
tb->setVisible(false);
|
|
|
|
tb->setVisibility(visibility);
|
|
|
|
|
|
|
|
if (visibility & Toolbars::TOP) {
|
|
|
|
if (newline)
|
|
|
|
addToolBarBreak(Qt::TopToolBarArea);
|
|
|
|
addToolBar(Qt::TopToolBarArea, tb);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visibility & Toolbars::BOTTOM) {
|
|
|
|
// Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
|
|
|
|
#if (QT_VERSION >= 0x040202)
|
2010-01-27 17:23:40 +00:00
|
|
|
if (newline)
|
|
|
|
addToolBarBreak(Qt::BottomToolBarArea);
|
2008-05-27 11:15:17 +00:00
|
|
|
#endif
|
|
|
|
addToolBar(Qt::BottomToolBarArea, tb);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visibility & Toolbars::LEFT) {
|
|
|
|
// Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
|
|
|
|
#if (QT_VERSION >= 0x040202)
|
2010-01-27 17:23:40 +00:00
|
|
|
if (newline)
|
|
|
|
addToolBarBreak(Qt::LeftToolBarArea);
|
2008-05-27 11:15:17 +00:00
|
|
|
#endif
|
|
|
|
addToolBar(Qt::LeftToolBarArea, tb);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visibility & Toolbars::RIGHT) {
|
|
|
|
// Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
|
|
|
|
#if (QT_VERSION >= 0x040202)
|
2010-01-27 17:23:40 +00:00
|
|
|
if (newline)
|
|
|
|
addToolBarBreak(Qt::RightToolBarArea);
|
2008-05-27 11:15:17 +00:00
|
|
|
#endif
|
|
|
|
addToolBar(Qt::RightToolBarArea, tb);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (visibility & Toolbars::ON)
|
|
|
|
tb->setVisible(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-02 12:09:51 +00:00
|
|
|
TocModels & GuiView::tocModels()
|
|
|
|
{
|
|
|
|
return d.toc_models_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
void GuiView::setFocus()
|
2006-12-23 17:09:50 +00:00
|
|
|
{
|
2008-11-16 01:20:34 +00:00
|
|
|
LYXERR(Debug::DEBUG, "GuiView::setFocus()" << this);
|
2010-01-10 19:08:41 +00:00
|
|
|
QMainWindow::setFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::focusInEvent(QFocusEvent * e)
|
|
|
|
{
|
|
|
|
LYXERR(Debug::DEBUG, "GuiView::focusInEvent()" << this);
|
|
|
|
QMainWindow::focusInEvent(e);
|
2010-02-09 16:11:13 +00:00
|
|
|
// Make sure guiApp points to the correct view.
|
2008-10-03 07:54:32 +00:00
|
|
|
guiApp->setCurrentView(this);
|
2010-01-10 19:08:41 +00:00
|
|
|
if (currentMainWorkArea())
|
|
|
|
currentMainWorkArea()->setFocus();
|
|
|
|
else if (currentWorkArea())
|
|
|
|
currentWorkArea()->setFocus();
|
2010-01-08 20:08:48 +00:00
|
|
|
else
|
|
|
|
d.bg_widget_->setFocus();
|
2006-12-23 17:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-22 23:47:13 +00:00
|
|
|
QMenu * GuiView::createPopupMenu()
|
2006-11-08 23:10:46 +00:00
|
|
|
{
|
2006-11-29 10:04:35 +00:00
|
|
|
return d.toolBarPopup(this);
|
2006-11-08 23:10:46 +00:00
|
|
|
}
|
2006-10-23 16:29:24 +00:00
|
|
|
|
2006-12-03 13:17:35 +00:00
|
|
|
|
2007-11-16 21:52:04 +00:00
|
|
|
void GuiView::showEvent(QShowEvent * e)
|
|
|
|
{
|
|
|
|
LYXERR(Debug::GUI, "Passed Geometry "
|
|
|
|
<< size().height() << "x" << size().width()
|
|
|
|
<< "+" << pos().x() << "+" << pos().y());
|
2007-11-15 12:58:44 +00:00
|
|
|
|
|
|
|
if (d.splitter_->count() == 0)
|
|
|
|
// No work area, switch to the background widget.
|
|
|
|
d.setBackground();
|
|
|
|
|
|
|
|
QMainWindow::showEvent(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-07 22:07:38 +00:00
|
|
|
bool GuiView::closeScheduled()
|
|
|
|
{
|
|
|
|
closing_ = true;
|
|
|
|
return close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-16 01:20:34 +00:00
|
|
|
/** Destroy only all tabbed WorkAreas. Destruction of other WorkAreas
|
|
|
|
** is responsibility of the container (e.g., dialog)
|
|
|
|
**/
|
2007-11-05 13:52:37 +00:00
|
|
|
void GuiView::closeEvent(QCloseEvent * close_event)
|
2006-12-02 17:39:31 +00:00
|
|
|
{
|
2008-11-16 01:20:34 +00:00
|
|
|
LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
|
2010-04-05 13:04:52 +00:00
|
|
|
|
|
|
|
if (!GuiViewPrivate::busyBuffers.isEmpty()) {
|
2010-05-15 02:58:23 +00:00
|
|
|
Alert::warning(_("Exit LyX"), _("LyX could not be closed because documents are processed by LyX."));
|
2010-04-05 13:04:52 +00:00
|
|
|
close_event->setAccepted(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-06-07 22:07:38 +00:00
|
|
|
// If the user pressed the x (so we didn't call closeView
|
|
|
|
// programmatically), we want to clear all existing entries.
|
|
|
|
if (!closing_)
|
|
|
|
theSession().lastOpened().clear();
|
2008-06-19 15:39:15 +00:00
|
|
|
closing_ = true;
|
|
|
|
|
2009-08-19 20:06:57 +00:00
|
|
|
writeSession();
|
|
|
|
|
2008-03-14 23:25:56 +00:00
|
|
|
// it can happen that this event arrives without selecting the view,
|
|
|
|
// e.g. when clicking the close button on a background window.
|
2008-10-03 07:54:32 +00:00
|
|
|
setFocus();
|
2009-08-18 20:48:15 +00:00
|
|
|
if (!closeWorkAreaAll()) {
|
2009-08-06 23:17:16 +00:00
|
|
|
closing_ = false;
|
|
|
|
close_event->ignore();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-15 16:03:11 +00:00
|
|
|
// Make sure that nothing will use this to be closed View.
|
2009-08-06 23:17:16 +00:00
|
|
|
guiApp->unregisterView(this);
|
|
|
|
|
|
|
|
if (isFullScreen()) {
|
|
|
|
// Switch off fullscreen before closing.
|
|
|
|
toggleFullScreen();
|
|
|
|
updateDialogs();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the timer time out will not trigger a statusbar update.
|
|
|
|
d.statusbar_timer_.stop();
|
|
|
|
|
|
|
|
// Saving fullscreen requires additional tweaks in the toolbar code.
|
|
|
|
// It wouldn't also work under linux natively.
|
|
|
|
if (lyxrc.allow_geometry_session) {
|
|
|
|
// Save this window geometry and layout.
|
|
|
|
saveLayout();
|
|
|
|
// Then the toolbar private states.
|
|
|
|
ToolbarMap::iterator end = d.toolbars_.end();
|
|
|
|
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
|
|
|
it->second->saveSession();
|
|
|
|
// Now take care of all other dialogs:
|
|
|
|
map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
|
|
|
|
for (; it!= d.dialogs_.end(); ++it)
|
|
|
|
it->second->saveSession();
|
|
|
|
}
|
|
|
|
|
|
|
|
close_event->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
void GuiView::dragEnterEvent(QDragEnterEvent * event)
|
2007-08-14 13:14:47 +00:00
|
|
|
{
|
|
|
|
if (event->mimeData()->hasUrls())
|
|
|
|
event->accept();
|
|
|
|
/// \todo Ask lyx-devel is this is enough:
|
|
|
|
/// if (event->mimeData()->hasFormat("text/plain"))
|
|
|
|
/// event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-15 16:29:58 +00:00
|
|
|
void GuiView::dropEvent(QDropEvent * event)
|
2007-08-14 13:14:47 +00:00
|
|
|
{
|
|
|
|
QList<QUrl> files = event->mimeData()->urls();
|
|
|
|
if (files.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2007-11-22 23:34:57 +00:00
|
|
|
LYXERR(Debug::GUI, "GuiView::dropEvent: got URLs!");
|
2007-08-31 05:53:55 +00:00
|
|
|
for (int i = 0; i != files.size(); ++i) {
|
2007-12-12 19:57:42 +00:00
|
|
|
string const file = os::internal_path(fromqstr(
|
2007-08-14 13:14:47 +00:00
|
|
|
files.at(i).toLocalFile()));
|
2009-12-12 15:25:45 +00:00
|
|
|
if (file.empty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
string const ext = support::getExtension(file);
|
|
|
|
vector<const Format *> found_formats;
|
|
|
|
|
|
|
|
// Find all formats that have the correct extension.
|
2010-09-07 14:11:28 +00:00
|
|
|
vector<const Format *> const & import_formats
|
2009-12-12 15:25:45 +00:00
|
|
|
= theConverters().importableFormats();
|
|
|
|
vector<const Format *>::const_iterator it = import_formats.begin();
|
|
|
|
for (; it != import_formats.end(); ++it)
|
|
|
|
if ((*it)->extension() == ext)
|
|
|
|
found_formats.push_back(*it);
|
|
|
|
|
|
|
|
FuncRequest cmd;
|
|
|
|
if (found_formats.size() >= 1) {
|
|
|
|
if (found_formats.size() > 1) {
|
|
|
|
//FIXME: show a dialog to choose the correct importable format
|
|
|
|
LYXERR(Debug::FILES,
|
|
|
|
"Multiple importable formats found, selecting first");
|
|
|
|
}
|
|
|
|
string const arg = found_formats[0]->name() + " " + file;
|
|
|
|
cmd = FuncRequest(LFUN_BUFFER_IMPORT, arg);
|
2010-09-07 14:11:28 +00:00
|
|
|
}
|
2009-12-12 15:25:45 +00:00
|
|
|
else {
|
|
|
|
//FIXME: do we have to explicitly check whether it's a lyx file?
|
|
|
|
LYXERR(Debug::FILES,
|
|
|
|
"No formats found, trying to open it as a lyx file");
|
|
|
|
cmd = FuncRequest(LFUN_FILE_OPEN, file);
|
2008-11-15 16:29:58 +00:00
|
|
|
}
|
2009-12-12 15:25:45 +00:00
|
|
|
|
2010-01-01 03:11:56 +00:00
|
|
|
// Asynchronously post the event. DropEvent usually comes
|
2009-12-12 15:25:45 +00:00
|
|
|
// from the BufferView. But reloading a file might close
|
|
|
|
// the BufferView from within its own event handler.
|
|
|
|
guiApp->dispatchDelayed(cmd);
|
|
|
|
event->accept();
|
2007-08-14 13:14:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
void GuiView::message(docstring const & str)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2008-01-15 18:26:53 +00:00
|
|
|
if (ForkedProcess::iAmAChild())
|
|
|
|
return;
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2009-12-21 13:11:17 +00:00
|
|
|
// call is moved to GUI-thread by GuiProgress
|
|
|
|
d.progress_->appendMessage(toqstr(str));
|
|
|
|
}
|
2008-01-15 18:26:53 +00:00
|
|
|
|
2009-12-21 13:11:17 +00:00
|
|
|
|
2010-03-05 18:07:05 +00:00
|
|
|
void GuiView::clearMessageText()
|
|
|
|
{
|
|
|
|
message(docstring());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::updateStatusBarMessage(QString const & str)
|
2009-12-21 13:11:17 +00:00
|
|
|
{
|
|
|
|
statusBar()->showMessage(str);
|
2007-11-18 23:30:41 +00:00
|
|
|
d.statusbar_timer_.stop();
|
2007-11-22 23:29:53 +00:00
|
|
|
d.statusbar_timer_.start(3000);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
void GuiView::smallSizedIcons()
|
2006-11-29 10:04:35 +00:00
|
|
|
{
|
2007-11-15 12:58:44 +00:00
|
|
|
setIconSize(QSize(d.smallIconSize, d.smallIconSize));
|
2006-11-29 10:04:35 +00:00
|
|
|
}
|
|
|
|
|
2006-12-03 13:17:35 +00:00
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
void GuiView::normalSizedIcons()
|
2006-11-29 10:04:35 +00:00
|
|
|
{
|
2007-11-15 12:58:44 +00:00
|
|
|
setIconSize(QSize(d.normalIconSize, d.normalIconSize));
|
2006-11-29 10:04:35 +00:00
|
|
|
}
|
|
|
|
|
2006-12-03 13:17:35 +00:00
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
void GuiView::bigSizedIcons()
|
2006-11-29 10:04:35 +00:00
|
|
|
{
|
2007-11-15 12:58:44 +00:00
|
|
|
setIconSize(QSize(d.bigIconSize, d.bigIconSize));
|
2006-11-29 10:04:35 +00:00
|
|
|
}
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-11-13 13:23:44 +00:00
|
|
|
void GuiView::clearMessage()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2009-12-25 23:29:07 +00:00
|
|
|
// FIXME: This code was introduced in r19643 to fix bug #4123. However,
|
|
|
|
// the hasFocus function mostly returns false, even if the focus is on
|
|
|
|
// a workarea in this view.
|
|
|
|
//if (!hasFocus())
|
|
|
|
// return;
|
2009-09-30 07:40:27 +00:00
|
|
|
showMessage();
|
2007-11-18 23:30:41 +00:00
|
|
|
d.statusbar_timer_.stop();
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
2006-12-03 13:17:35 +00:00
|
|
|
|
2007-11-11 22:30:21 +00:00
|
|
|
void GuiView::updateWindowTitle(GuiWorkArea * wa)
|
|
|
|
{
|
2010-01-07 19:54:42 +00:00
|
|
|
if (wa != d.current_work_area_
|
2010-03-05 18:07:05 +00:00
|
|
|
|| wa->bufferView().buffer().isInternal())
|
2007-11-11 22:30:21 +00:00
|
|
|
return;
|
|
|
|
setWindowTitle(qt_("LyX: ") + wa->windowTitle());
|
|
|
|
setWindowIconText(wa->windowIconText());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
|
2006-10-31 14:12:46 +00:00
|
|
|
{
|
2007-08-21 07:33:46 +00:00
|
|
|
disconnectBuffer();
|
|
|
|
disconnectBufferView();
|
2007-10-06 15:48:58 +00:00
|
|
|
connectBufferView(wa->bufferView());
|
|
|
|
connectBuffer(wa->bufferView().buffer());
|
2007-11-11 22:30:21 +00:00
|
|
|
d.current_work_area_ = wa;
|
|
|
|
QObject::connect(wa, SIGNAL(titleChanged(GuiWorkArea *)),
|
|
|
|
this, SLOT(updateWindowTitle(GuiWorkArea *)));
|
|
|
|
updateWindowTitle(wa);
|
2007-08-21 07:33:46 +00:00
|
|
|
|
2008-04-27 22:24:20 +00:00
|
|
|
structureChanged();
|
|
|
|
|
2008-05-04 07:50:00 +00:00
|
|
|
// The document settings needs to be reinitialised.
|
|
|
|
updateDialog("document", "");
|
|
|
|
|
2008-04-27 22:24:20 +00:00
|
|
|
// Buffer-dependent dialogs must be updated. This is done here because
|
|
|
|
// some dialogs require buffer()->text.
|
|
|
|
updateDialogs();
|
2006-10-31 14:12:46 +00:00
|
|
|
}
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-03-14 23:24:59 +00:00
|
|
|
void GuiView::on_lastWorkAreaRemoved()
|
|
|
|
{
|
2008-06-19 15:39:15 +00:00
|
|
|
if (closing_)
|
|
|
|
// We already are in a close event. Nothing more to do.
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (d.splitter_->count() > 1)
|
|
|
|
// We have a splitter so don't close anything.
|
|
|
|
return;
|
|
|
|
|
2008-06-20 06:35:42 +00:00
|
|
|
// Reset and updates the dialogs.
|
|
|
|
d.toc_models_.reset(0);
|
|
|
|
updateDialog("document", "");
|
|
|
|
updateDialogs();
|
|
|
|
|
2008-08-11 12:57:02 +00:00
|
|
|
resetWindowTitleAndIconText();
|
2009-12-26 23:58:24 +00:00
|
|
|
updateStatusBar();
|
2008-08-11 12:57:02 +00:00
|
|
|
|
2008-06-20 06:35:42 +00:00
|
|
|
if (lyxrc.open_buffers_in_tabs)
|
|
|
|
// Nothing more to do, the window should stay open.
|
2008-06-19 15:39:15 +00:00
|
|
|
return;
|
|
|
|
|
2008-06-20 06:35:42 +00:00
|
|
|
if (guiApp->viewIds().size() > 1) {
|
|
|
|
close();
|
|
|
|
return;
|
2008-06-19 15:39:15 +00:00
|
|
|
}
|
2008-06-20 06:35:42 +00:00
|
|
|
|
|
|
|
#ifdef Q_WS_MACX
|
|
|
|
// On Mac we also close the last window because the application stay
|
|
|
|
// resident in memory. On other platforms we don't close the last
|
|
|
|
// window because this would quit the application.
|
2008-06-19 15:55:34 +00:00
|
|
|
close();
|
2008-06-20 06:35:42 +00:00
|
|
|
#endif
|
2008-03-14 23:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
void GuiView::updateStatusBar()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
// let the user see the explicit message
|
2007-11-18 23:30:41 +00:00
|
|
|
if (d.statusbar_timer_.isActive())
|
2006-03-05 17:24:44 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-30 07:40:27 +00:00
|
|
|
showMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::showMessage()
|
|
|
|
{
|
2009-10-04 20:58:20 +00:00
|
|
|
QString msg = toqstr(theGuiApp()->viewStatusMessage());
|
2009-09-30 07:40:27 +00:00
|
|
|
if (msg.isEmpty()) {
|
|
|
|
BufferView const * bv = currentBufferView();
|
|
|
|
if (bv)
|
|
|
|
msg = toqstr(bv->cursor().currentState());
|
|
|
|
else
|
|
|
|
msg = qt_("Welcome to LyX!");
|
|
|
|
}
|
|
|
|
statusBar()->showMessage(msg);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
bool GuiView::event(QEvent * e)
|
2006-12-20 21:28:05 +00:00
|
|
|
{
|
|
|
|
switch (e->type())
|
|
|
|
{
|
2007-08-15 08:29:10 +00:00
|
|
|
// Useful debug code:
|
|
|
|
//case QEvent::ActivationChange:
|
|
|
|
//case QEvent::WindowDeactivate:
|
|
|
|
//case QEvent::Paint:
|
|
|
|
//case QEvent::Enter:
|
|
|
|
//case QEvent::Leave:
|
|
|
|
//case QEvent::HoverEnter:
|
|
|
|
//case QEvent::HoverLeave:
|
|
|
|
//case QEvent::HoverMove:
|
|
|
|
//case QEvent::StatusTip:
|
|
|
|
//case QEvent::DragEnter:
|
|
|
|
//case QEvent::DragLeave:
|
|
|
|
//case QEvent::Drop:
|
|
|
|
// break;
|
|
|
|
|
2007-10-16 06:50:09 +00:00
|
|
|
case QEvent::WindowActivate: {
|
2009-09-22 21:25:32 +00:00
|
|
|
GuiView * old_view = guiApp->currentView();
|
|
|
|
if (this == old_view) {
|
2008-03-04 10:43:35 +00:00
|
|
|
setFocus();
|
|
|
|
return QMainWindow::event(e);
|
|
|
|
}
|
2009-09-23 07:14:20 +00:00
|
|
|
if (old_view && old_view->currentBufferView()) {
|
2009-09-22 21:25:32 +00:00
|
|
|
// save current selection to the selection buffer to allow
|
|
|
|
// middle-button paste in this window.
|
|
|
|
cap::saveSelection(old_view->currentBufferView()->cursor());
|
|
|
|
}
|
2008-03-15 02:42:59 +00:00
|
|
|
guiApp->setCurrentView(this);
|
2007-11-11 10:09:48 +00:00
|
|
|
if (d.current_work_area_) {
|
|
|
|
BufferView & bv = d.current_work_area_->bufferView();
|
2007-10-03 07:17:58 +00:00
|
|
|
connectBufferView(bv);
|
|
|
|
connectBuffer(bv.buffer());
|
2007-10-03 08:03:01 +00:00
|
|
|
// The document structure, name and dialogs might have
|
|
|
|
// changed in another view.
|
2008-04-27 22:24:20 +00:00
|
|
|
structureChanged();
|
2008-05-04 07:50:00 +00:00
|
|
|
// The document settings needs to be reinitialised.
|
|
|
|
updateDialog("document", "");
|
2008-04-27 22:24:20 +00:00
|
|
|
updateDialogs();
|
2007-11-11 22:30:21 +00:00
|
|
|
} else {
|
2008-08-11 12:57:02 +00:00
|
|
|
resetWindowTitleAndIconText();
|
2007-10-03 07:17:58 +00:00
|
|
|
}
|
2008-02-12 15:44:45 +00:00
|
|
|
setFocus();
|
2007-10-03 07:12:28 +00:00
|
|
|
return QMainWindow::event(e);
|
2007-10-16 06:50:09 +00:00
|
|
|
}
|
2008-01-10 09:04:30 +00:00
|
|
|
|
2007-08-15 08:29:10 +00:00
|
|
|
case QEvent::ShortcutOverride: {
|
2008-05-15 09:14:09 +00:00
|
|
|
|
2009-05-03 23:33:39 +00:00
|
|
|
// See bug 4888
|
|
|
|
#if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
|
2008-05-15 09:42:28 +00:00
|
|
|
if (isFullScreen() && menuBar()->isHidden()) {
|
|
|
|
QKeyEvent * ke = static_cast<QKeyEvent*>(e);
|
2008-05-15 23:26:31 +00:00
|
|
|
// FIXME: we should also try to detect special LyX shortcut such as
|
2008-05-16 08:11:37 +00:00
|
|
|
// Alt-P and Alt-M. Right now there is a hack in
|
|
|
|
// GuiWorkArea::processKeySym() that hides again the menubar for
|
|
|
|
// those cases.
|
2008-11-29 17:29:13 +00:00
|
|
|
if (ke->modifiers() & Qt::AltModifier && ke->key() != Qt::Key_Alt) {
|
2008-05-15 23:26:31 +00:00
|
|
|
menuBar()->show();
|
2008-11-29 17:29:13 +00:00
|
|
|
return QMainWindow::event(e);
|
|
|
|
}
|
2008-05-15 09:14:09 +00:00
|
|
|
}
|
2008-08-05 13:03:31 +00:00
|
|
|
#endif
|
2010-01-08 20:08:48 +00:00
|
|
|
return QMainWindow::event(e);
|
2006-12-20 21:28:05 +00:00
|
|
|
}
|
2008-01-10 09:04:30 +00:00
|
|
|
|
2007-08-15 08:29:10 +00:00
|
|
|
default:
|
|
|
|
return QMainWindow::event(e);
|
|
|
|
}
|
2006-12-20 21:28:05 +00:00
|
|
|
}
|
|
|
|
|
2008-08-11 12:57:02 +00:00
|
|
|
void GuiView::resetWindowTitleAndIconText()
|
|
|
|
{
|
2010-03-05 18:07:05 +00:00
|
|
|
setWindowTitle(qt_("LyX"));
|
|
|
|
setWindowIconText(qt_("LyX"));
|
2008-08-11 12:57:02 +00:00
|
|
|
}
|
2006-12-20 21:28:05 +00:00
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
bool GuiView::focusNextPrevChild(bool /*next*/)
|
2006-12-22 16:13:19 +00:00
|
|
|
{
|
2006-12-23 17:09:50 +00:00
|
|
|
setFocus();
|
2006-12-22 16:13:19 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-07 22:09:59 +00:00
|
|
|
bool GuiView::busy() const
|
2010-06-04 13:24:03 +00:00
|
|
|
{
|
|
|
|
return busy_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-02 23:50:42 +00:00
|
|
|
void GuiView::setBusy(bool busy)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2010-06-04 13:24:03 +00:00
|
|
|
busy_ = busy;
|
2007-11-11 10:09:48 +00:00
|
|
|
if (d.current_work_area_) {
|
2008-02-03 07:46:45 +00:00
|
|
|
d.current_work_area_->setUpdatesEnabled(!busy);
|
2008-02-02 23:50:42 +00:00
|
|
|
if (busy)
|
2007-11-11 10:09:48 +00:00
|
|
|
d.current_work_area_->stopBlinkingCursor();
|
2007-08-21 07:33:46 +00:00
|
|
|
else
|
2007-11-11 10:09:48 +00:00
|
|
|
d.current_work_area_->startBlinkingCursor();
|
2007-08-21 07:33:46 +00:00
|
|
|
}
|
2006-10-26 13:29:10 +00:00
|
|
|
|
2008-02-02 23:50:42 +00:00
|
|
|
if (busy)
|
2006-06-04 20:49:09 +00:00
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
2007-08-21 07:33:46 +00:00
|
|
|
else
|
2006-03-05 17:24:44 +00:00
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
}
|
|
|
|
|
2006-09-10 11:03:21 +00:00
|
|
|
|
2007-11-13 09:52:28 +00:00
|
|
|
GuiWorkArea * GuiView::workArea(Buffer & buffer)
|
2007-08-21 07:33:46 +00:00
|
|
|
{
|
2008-11-16 01:20:34 +00:00
|
|
|
if (currentWorkArea()
|
2010-03-05 18:07:05 +00:00
|
|
|
&& ¤tWorkArea()->bufferView().buffer() == &buffer)
|
2008-11-16 01:20:34 +00:00
|
|
|
return (GuiWorkArea *) currentWorkArea();
|
2008-02-21 11:48:31 +00:00
|
|
|
if (TabWorkArea * twa = d.currentTabWorkArea())
|
|
|
|
return twa->workArea(buffer);
|
2007-11-11 10:09:48 +00:00
|
|
|
return 0;
|
2007-08-21 07:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-13 09:52:28 +00:00
|
|
|
GuiWorkArea * GuiView::addWorkArea(Buffer & buffer)
|
2007-08-21 07:33:46 +00:00
|
|
|
{
|
2007-11-11 10:09:48 +00:00
|
|
|
// Automatically create a TabWorkArea if there are none yet.
|
2010-09-07 14:11:28 +00:00
|
|
|
TabWorkArea * tab_widget = d.splitter_->count()
|
2008-02-20 21:46:49 +00:00
|
|
|
? d.currentTabWorkArea() : addTabWorkArea();
|
2007-11-19 10:04:14 +00:00
|
|
|
return tab_widget->addWorkArea(buffer, *this);
|
2007-08-21 07:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 21:46:49 +00:00
|
|
|
TabWorkArea * GuiView::addTabWorkArea()
|
2007-11-11 10:09:48 +00:00
|
|
|
{
|
|
|
|
TabWorkArea * twa = new TabWorkArea;
|
|
|
|
QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
|
|
|
|
this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
|
2008-03-14 23:24:59 +00:00
|
|
|
QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
|
|
|
|
this, SLOT(on_lastWorkAreaRemoved()));
|
|
|
|
|
2007-11-11 10:09:48 +00:00
|
|
|
d.splitter_->addWidget(twa);
|
|
|
|
d.stack_widget_->setCurrentWidget(d.splitter_);
|
2008-02-20 21:46:49 +00:00
|
|
|
return twa;
|
2007-11-11 10:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-13 09:52:28 +00:00
|
|
|
GuiWorkArea const * GuiView::currentWorkArea() const
|
2007-08-21 07:33:46 +00:00
|
|
|
{
|
2007-11-11 10:09:48 +00:00
|
|
|
return d.current_work_area_;
|
2007-08-21 07:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-16 01:20:34 +00:00
|
|
|
GuiWorkArea * GuiView::currentWorkArea()
|
|
|
|
{
|
|
|
|
return d.current_work_area_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GuiWorkArea const * GuiView::currentMainWorkArea() const
|
|
|
|
{
|
2010-02-26 14:07:21 +00:00
|
|
|
if (!d.currentTabWorkArea())
|
|
|
|
return 0;
|
2008-11-16 01:20:34 +00:00
|
|
|
return d.currentTabWorkArea()->currentWorkArea();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GuiWorkArea * GuiView::currentMainWorkArea()
|
|
|
|
{
|
2010-02-26 14:07:21 +00:00
|
|
|
if (!d.currentTabWorkArea())
|
|
|
|
return 0;
|
2008-11-16 01:20:34 +00:00
|
|
|
return d.currentTabWorkArea()->currentWorkArea();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-26 23:55:16 +00:00
|
|
|
void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
|
2007-08-21 07:33:46 +00:00
|
|
|
{
|
2008-11-16 01:20:34 +00:00
|
|
|
LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
|
2010-02-26 14:07:21 +00:00
|
|
|
if (!wa) {
|
|
|
|
d.current_work_area_ = 0;
|
2008-11-16 01:20:34 +00:00
|
|
|
d.setBackground();
|
|
|
|
return;
|
2007-11-11 10:09:48 +00:00
|
|
|
}
|
2010-02-26 14:07:21 +00:00
|
|
|
|
|
|
|
// FIXME: I've no clue why this is here and why it accesses
|
|
|
|
// theGuiApp()->currentView, which might be 0 (bug 6464).
|
|
|
|
// See also 27525 (vfr).
|
2010-09-07 14:11:28 +00:00
|
|
|
if (theGuiApp()->currentView() == this
|
|
|
|
&& theGuiApp()->currentView()->currentWorkArea() == wa)
|
2008-11-16 15:32:11 +00:00
|
|
|
return;
|
|
|
|
|
2009-09-05 14:29:11 +00:00
|
|
|
if (currentBufferView())
|
|
|
|
cap::saveSelection(currentBufferView()->cursor());
|
2009-08-09 14:27:50 +00:00
|
|
|
|
2008-11-16 15:32:11 +00:00
|
|
|
theGuiApp()->setCurrentView(this);
|
|
|
|
d.current_work_area_ = wa;
|
|
|
|
for (int i = 0; i != d.splitter_->count(); ++i) {
|
|
|
|
if (d.tabWorkArea(i)->setCurrentWorkArea(wa)) {
|
|
|
|
//if (d.current_main_work_area_)
|
|
|
|
// d.current_main_work_area_->setFrameStyle(QFrame::NoFrame);
|
|
|
|
d.current_main_work_area_ = wa;
|
|
|
|
//d.current_main_work_area_->setFrameStyle(QFrame::Box | QFrame::Plain);
|
|
|
|
//d.current_main_work_area_->setLineWidth(2);
|
|
|
|
LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
|
|
|
|
return;
|
2008-11-16 01:20:34 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-16 15:32:11 +00:00
|
|
|
LYXERR(Debug::DEBUG, "This is not a tabbed wa");
|
|
|
|
on_currentWorkAreaChanged(wa);
|
|
|
|
BufferView & bv = wa->bufferView();
|
|
|
|
bv.cursor().fixIfBroken();
|
|
|
|
bv.updateMetrics();
|
|
|
|
wa->setUpdatesEnabled(true);
|
2008-11-16 01:20:34 +00:00
|
|
|
LYXERR(Debug::DEBUG, "Current wa: " << currentWorkArea() << ", Current main wa: " << currentMainWorkArea());
|
2007-08-21 07:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-26 23:55:16 +00:00
|
|
|
void GuiView::removeWorkArea(GuiWorkArea * wa)
|
2007-08-21 07:33:46 +00:00
|
|
|
{
|
2008-09-29 08:42:18 +00:00
|
|
|
LASSERT(wa, return);
|
2007-11-26 23:55:16 +00:00
|
|
|
if (wa == d.current_work_area_) {
|
2007-08-21 07:33:46 +00:00
|
|
|
disconnectBuffer();
|
|
|
|
disconnectBufferView();
|
2007-11-11 10:09:48 +00:00
|
|
|
d.current_work_area_ = 0;
|
2008-11-16 01:20:34 +00:00
|
|
|
d.current_main_work_area_ = 0;
|
2007-08-21 07:33:46 +00:00
|
|
|
}
|
|
|
|
|
2008-11-16 01:20:34 +00:00
|
|
|
bool found_twa = false;
|
2007-11-11 10:09:48 +00:00
|
|
|
for (int i = 0; i != d.splitter_->count(); ++i) {
|
|
|
|
TabWorkArea * twa = d.tabWorkArea(i);
|
2008-11-16 01:20:34 +00:00
|
|
|
if (twa->removeWorkArea(wa)) {
|
|
|
|
// Found in this tab group, and deleted the GuiWorkArea.
|
|
|
|
found_twa = true;
|
|
|
|
if (twa->count() != 0) {
|
|
|
|
if (d.current_work_area_ == 0)
|
|
|
|
// This means that we are closing the current GuiWorkArea, so
|
|
|
|
// switch to the next GuiWorkArea in the found TabWorkArea.
|
|
|
|
setCurrentWorkArea(twa->currentWorkArea());
|
|
|
|
} else {
|
|
|
|
// No more WorkAreas in this tab group, so delete it.
|
|
|
|
delete twa;
|
|
|
|
}
|
2007-11-11 10:09:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-11-16 01:20:34 +00:00
|
|
|
}
|
2007-08-21 07:33:46 +00:00
|
|
|
|
2008-11-16 01:20:34 +00:00
|
|
|
// It is not a tabbed work area (i.e., the search work area), so it
|
|
|
|
// should be deleted by other means.
|
|
|
|
LASSERT(found_twa, /* */);
|
2007-11-11 10:09:48 +00:00
|
|
|
|
2008-11-16 01:20:34 +00:00
|
|
|
if (d.current_work_area_ == 0) {
|
|
|
|
if (d.splitter_->count() != 0) {
|
|
|
|
TabWorkArea * twa = d.currentTabWorkArea();
|
|
|
|
setCurrentWorkArea(twa->currentWorkArea());
|
|
|
|
} else {
|
|
|
|
// No more work areas, switch to the background widget.
|
|
|
|
setCurrentWorkArea(0);
|
|
|
|
}
|
2007-11-11 10:09:48 +00:00
|
|
|
}
|
2007-08-21 07:33:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-14 22:58:57 +00:00
|
|
|
LayoutBox * GuiView::getLayoutDialog() const
|
2007-10-01 20:45:50 +00:00
|
|
|
{
|
2009-08-14 22:58:57 +00:00
|
|
|
return d.layout_;
|
2007-11-20 22:03:56 +00:00
|
|
|
}
|
2007-10-01 20:45:50 +00:00
|
|
|
|
|
|
|
|
2007-11-20 22:03:56 +00:00
|
|
|
void GuiView::updateLayoutList()
|
|
|
|
{
|
|
|
|
if (d.layout_)
|
|
|
|
d.layout_->updateContents(false);
|
2007-10-01 20:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-05 13:52:37 +00:00
|
|
|
void GuiView::updateToolbars()
|
2007-10-01 20:45:50 +00:00
|
|
|
{
|
2008-05-27 11:15:17 +00:00
|
|
|
ToolbarMap::iterator end = d.toolbars_.end();
|
2007-11-11 10:09:48 +00:00
|
|
|
if (d.current_work_area_) {
|
2007-10-01 20:45:50 +00:00
|
|
|
bool const math =
|
2010-03-17 13:37:15 +00:00
|
|
|
d.current_work_area_->bufferView().cursor().inMathed()
|
|
|
|
&& !d.current_work_area_->bufferView().cursor().inRegexped();
|
2007-10-01 20:45:50 +00:00
|
|
|
bool const table =
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
|
|
|
|
bool const review =
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
|
2010-04-16 10:51:20 +00:00
|
|
|
lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onOff(true);
|
2007-12-23 00:47:37 +00:00
|
|
|
bool const mathmacrotemplate =
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_IN_MATHMACROTEMPLATE)).enabled();
|
2007-12-23 00:49:18 +00:00
|
|
|
|
2008-05-27 11:15:17 +00:00
|
|
|
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
|
|
|
it->second->update(math, table, review, mathmacrotemplate);
|
2007-10-01 20:45:50 +00:00
|
|
|
} else
|
2008-05-27 11:15:17 +00:00
|
|
|
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
|
|
|
it->second->update(false, false, false, false);
|
2007-10-01 20:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
void GuiView::setBuffer(Buffer * newBuffer)
|
|
|
|
{
|
2009-12-20 15:07:15 +00:00
|
|
|
LYXERR(Debug::DEBUG, "Setting buffer: " << newBuffer << endl);
|
2008-09-29 08:42:18 +00:00
|
|
|
LASSERT(newBuffer, return);
|
2007-11-12 23:23:19 +00:00
|
|
|
setBusy(true);
|
|
|
|
|
2007-11-13 09:52:28 +00:00
|
|
|
GuiWorkArea * wa = workArea(*newBuffer);
|
2007-11-12 23:23:19 +00:00
|
|
|
if (wa == 0) {
|
2010-03-03 22:13:45 +00:00
|
|
|
newBuffer->masterBuffer()->updateBuffer();
|
2007-11-12 23:23:19 +00:00
|
|
|
wa = addWorkArea(*newBuffer);
|
|
|
|
} else {
|
|
|
|
//Disconnect the old buffer...there's no new one.
|
|
|
|
disconnectBuffer();
|
|
|
|
}
|
|
|
|
connectBuffer(*newBuffer);
|
|
|
|
connectBufferView(wa->bufferView());
|
|
|
|
setCurrentWorkArea(wa);
|
|
|
|
|
|
|
|
setBusy(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::connectBuffer(Buffer & buf)
|
|
|
|
{
|
|
|
|
buf.setGuiDelegate(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::disconnectBuffer()
|
|
|
|
{
|
2007-11-13 09:52:28 +00:00
|
|
|
if (d.current_work_area_)
|
2009-08-19 20:55:02 +00:00
|
|
|
d.current_work_area_->bufferView().buffer().setGuiDelegate(0);
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::connectBufferView(BufferView & bv)
|
|
|
|
{
|
|
|
|
bv.setGuiDelegate(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::disconnectBufferView()
|
|
|
|
{
|
2007-11-13 09:52:28 +00:00
|
|
|
if (d.current_work_area_)
|
|
|
|
d.current_work_area_->bufferView().setGuiDelegate(0);
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-21 12:26:41 +00:00
|
|
|
void GuiView::errors(string const & error_type, bool from_master)
|
2007-11-12 23:23:19 +00:00
|
|
|
{
|
2010-03-10 14:46:28 +00:00
|
|
|
ErrorList & el = from_master ?
|
|
|
|
currentBufferView()->buffer().masterBuffer()->errorList(error_type)
|
|
|
|
: currentBufferView()->buffer().errorList(error_type);
|
2009-06-21 12:26:41 +00:00
|
|
|
string data = error_type;
|
|
|
|
if (from_master)
|
|
|
|
data = "from_master|" + error_type;
|
2007-11-12 23:23:19 +00:00
|
|
|
if (!el.empty())
|
2009-06-21 12:26:41 +00:00
|
|
|
showDialog("errorlist", data);
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-20 15:07:15 +00:00
|
|
|
void GuiView::updateTocItem(string const & type, DocIterator const & dit)
|
2008-09-30 09:50:54 +00:00
|
|
|
{
|
|
|
|
d.toc_models_.updateItem(toqstr(type), dit);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-28 04:57:31 +00:00
|
|
|
void GuiView::structureChanged()
|
|
|
|
{
|
2009-08-22 16:16:56 +00:00
|
|
|
d.toc_models_.reset(documentBufferView());
|
2008-05-03 08:24:05 +00:00
|
|
|
// Navigator needs more than a simple update in this case. It needs to be
|
|
|
|
// rebuilt.
|
2008-04-28 04:57:31 +00:00
|
|
|
updateDialog("toc", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
void GuiView::updateDialog(string const & name, string const & data)
|
|
|
|
{
|
2007-11-18 00:01:14 +00:00
|
|
|
if (!isDialogVisible(name))
|
|
|
|
return;
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (it == d.dialogs_.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Dialog * const dialog = it->second.get();
|
|
|
|
if (dialog->isVisibleView())
|
2008-05-02 21:38:23 +00:00
|
|
|
dialog->initialiseParams(data);
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-22 16:16:56 +00:00
|
|
|
BufferView * GuiView::documentBufferView()
|
|
|
|
{
|
|
|
|
return currentMainWorkArea()
|
|
|
|
? ¤tMainWorkArea()->bufferView()
|
|
|
|
: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-07 14:11:28 +00:00
|
|
|
BufferView const * GuiView::documentBufferView() const
|
2009-09-05 14:29:11 +00:00
|
|
|
{
|
|
|
|
return currentMainWorkArea()
|
|
|
|
? ¤tMainWorkArea()->bufferView()
|
|
|
|
: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BufferView * GuiView::currentBufferView()
|
|
|
|
{
|
|
|
|
return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BufferView const * GuiView::currentBufferView() const
|
2007-11-12 23:23:19 +00:00
|
|
|
{
|
2007-11-13 09:52:28 +00:00
|
|
|
return d.current_work_area_ ? &d.current_work_area_->bufferView() : 0;
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-07 14:20:58 +00:00
|
|
|
#if (QT_VERSION >= 0x040400)
|
2010-04-05 13:04:52 +00:00
|
|
|
docstring GuiView::GuiViewPrivate::saveAndDestroy(Buffer const * orig, Buffer * buffer, FileName const & fname)
|
2009-12-13 21:00:46 +00:00
|
|
|
{
|
|
|
|
bool failed = true;
|
|
|
|
FileName const tmp_ret = FileName::tempName("lyxauto");
|
|
|
|
if (!tmp_ret.empty()) {
|
|
|
|
if (buffer->writeFile(tmp_ret))
|
|
|
|
failed = !tmp_ret.moveTo(fname);
|
|
|
|
}
|
|
|
|
if (failed) {
|
|
|
|
// failed to write/rename tmp_ret so try writing direct
|
|
|
|
failed = buffer->writeFile(fname);
|
|
|
|
}
|
|
|
|
delete buffer;
|
2010-04-05 13:04:52 +00:00
|
|
|
busyBuffers.remove(orig);
|
2009-12-18 22:51:06 +00:00
|
|
|
return failed
|
|
|
|
? _("Automatic save failed!")
|
|
|
|
: _("Automatic save done.");
|
2009-12-13 21:00:46 +00:00
|
|
|
}
|
2010-01-07 14:20:58 +00:00
|
|
|
#endif
|
2009-12-13 21:00:46 +00:00
|
|
|
|
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
void GuiView::autoSave()
|
|
|
|
{
|
2007-11-15 20:04:51 +00:00
|
|
|
LYXERR(Debug::INFO, "Running autoSave()");
|
2007-11-12 23:23:19 +00:00
|
|
|
|
2009-12-13 21:00:46 +00:00
|
|
|
Buffer * buffer = documentBufferView()
|
|
|
|
? &documentBufferView()->buffer() : 0;
|
|
|
|
if (!buffer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
#if (QT_VERSION >= 0x040400)
|
2010-04-05 13:04:52 +00:00
|
|
|
GuiViewPrivate::busyBuffers.insert(buffer);
|
|
|
|
QFuture<docstring> f = QtConcurrent::run(GuiViewPrivate::saveAndDestroy, buffer, buffer->clone(),
|
2010-04-21 01:19:33 +00:00
|
|
|
buffer->getAutosaveFileName());
|
2009-12-13 21:00:46 +00:00
|
|
|
d.autosave_watcher_.setFuture(f);
|
|
|
|
#else
|
|
|
|
buffer->autoSave();
|
|
|
|
#endif
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-13 09:52:28 +00:00
|
|
|
void GuiView::resetAutosaveTimers()
|
2007-11-12 23:23:19 +00:00
|
|
|
{
|
|
|
|
if (lyxrc.autosave)
|
2007-11-22 23:29:53 +00:00
|
|
|
d.autosave_timeout_.restart();
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-22 15:01:36 +00:00
|
|
|
bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
2007-11-19 20:56:05 +00:00
|
|
|
{
|
|
|
|
bool enable = true;
|
2009-09-05 15:09:45 +00:00
|
|
|
Buffer * buf = currentBufferView()
|
|
|
|
? ¤tBufferView()->buffer() : 0;
|
2009-09-12 20:41:24 +00:00
|
|
|
Buffer * doc_buffer = documentBufferView()
|
|
|
|
? &(documentBufferView()->buffer()) : 0;
|
2007-11-19 20:56:05 +00:00
|
|
|
|
2009-09-23 09:07:24 +00:00
|
|
|
// Check whether we need a buffer
|
2010-04-09 19:00:42 +00:00
|
|
|
if (!lyxaction.funcHasFlag(cmd.action(), LyXAction::NoBuffer) && !buf) {
|
2009-09-23 09:07:24 +00:00
|
|
|
// no, exit directly
|
|
|
|
flag.message(from_utf8(N_("Command not allowed with"
|
2010-03-05 18:07:05 +00:00
|
|
|
"out any document open")));
|
2009-09-23 09:07:24 +00:00
|
|
|
flag.setEnabled(false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-04-09 19:00:42 +00:00
|
|
|
if (cmd.origin() == FuncRequest::TOC) {
|
2009-04-11 11:43:13 +00:00
|
|
|
GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
|
2010-04-16 12:49:27 +00:00
|
|
|
if (!toc || !toc->getStatus(documentBufferView()->cursor(), cmd, flag))
|
2009-04-11 11:43:13 +00:00
|
|
|
flag.setEnabled(false);
|
2009-04-08 21:06:58 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-04-09 19:00:42 +00:00
|
|
|
switch(cmd.action()) {
|
2009-09-19 14:05:52 +00:00
|
|
|
case LFUN_BUFFER_IMPORT:
|
|
|
|
break;
|
|
|
|
|
2009-12-18 22:51:06 +00:00
|
|
|
case LFUN_MASTER_BUFFER_UPDATE:
|
2010-09-07 14:11:28 +00:00
|
|
|
case LFUN_MASTER_BUFFER_VIEW:
|
2009-12-20 15:43:52 +00:00
|
|
|
enable = doc_buffer && doc_buffer->parent() != 0
|
|
|
|
&& !d.preview_watcher_.isRunning();
|
2009-12-18 22:51:06 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BUFFER_UPDATE:
|
|
|
|
case LFUN_BUFFER_VIEW: {
|
2009-12-20 15:43:52 +00:00
|
|
|
if (!doc_buffer || d.preview_watcher_.isRunning()) {
|
2009-12-18 22:51:06 +00:00
|
|
|
enable = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
string format = to_utf8(cmd.argument());
|
|
|
|
if (cmd.argument().empty())
|
|
|
|
format = doc_buffer->getDefaultOutputFormat();
|
|
|
|
enable = doc_buffer->isExportableFormat(format);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-09-12 20:41:24 +00:00
|
|
|
case LFUN_BUFFER_RELOAD:
|
|
|
|
enable = doc_buffer && !doc_buffer->isUnnamed()
|
|
|
|
&& doc_buffer->fileName().exists()
|
|
|
|
&& (!doc_buffer->isClean()
|
|
|
|
|| doc_buffer->isExternallyModified(Buffer::timestamp_method));
|
|
|
|
break;
|
|
|
|
|
2009-09-19 16:49:31 +00:00
|
|
|
case LFUN_BUFFER_CHILD_OPEN:
|
|
|
|
enable = doc_buffer;
|
|
|
|
break;
|
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
case LFUN_BUFFER_WRITE:
|
2009-09-12 20:55:35 +00:00
|
|
|
enable = doc_buffer && (doc_buffer->isUnnamed() || !doc_buffer->isClean());
|
2007-12-04 22:21:25 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-22 21:46:16 +00:00
|
|
|
//FIXME: This LFUN should be moved to GuiApplication.
|
|
|
|
case LFUN_BUFFER_WRITE_ALL: {
|
|
|
|
// We enable the command only if there are some modified buffers
|
|
|
|
Buffer * first = theBufferList().first();
|
|
|
|
enable = false;
|
|
|
|
if (!first)
|
|
|
|
break;
|
|
|
|
Buffer * b = first;
|
|
|
|
// We cannot use a for loop as the buffer list is a cycle.
|
|
|
|
do {
|
|
|
|
if (!b->isClean()) {
|
|
|
|
enable = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
b = theBufferList().next(b);
|
2010-09-07 14:11:28 +00:00
|
|
|
} while (b != first);
|
2009-09-22 21:46:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
case LFUN_BUFFER_WRITE_AS:
|
2009-09-12 20:55:35 +00:00
|
|
|
enable = doc_buffer;
|
2007-12-04 22:21:25 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-19 14:34:46 +00:00
|
|
|
case LFUN_BUFFER_CLOSE:
|
|
|
|
enable = doc_buffer;
|
|
|
|
break;
|
|
|
|
|
2009-08-19 21:12:53 +00:00
|
|
|
case LFUN_BUFFER_CLOSE_ALL:
|
|
|
|
enable = theBufferList().last() != theBufferList().first();
|
2009-08-07 00:41:39 +00:00
|
|
|
break;
|
|
|
|
|
2008-02-20 21:46:49 +00:00
|
|
|
case LFUN_SPLIT_VIEW:
|
2008-07-19 13:17:46 +00:00
|
|
|
if (cmd.getArg(0) == "vertical")
|
2009-09-12 20:55:35 +00:00
|
|
|
enable = doc_buffer && (d.splitter_->count() == 1 ||
|
2008-07-19 13:17:46 +00:00
|
|
|
d.splitter_->orientation() == Qt::Vertical);
|
|
|
|
else
|
2009-09-12 20:55:35 +00:00
|
|
|
enable = doc_buffer && (d.splitter_->count() == 1 ||
|
2008-07-19 13:17:46 +00:00
|
|
|
d.splitter_->orientation() == Qt::Horizontal);
|
2008-02-20 21:46:49 +00:00
|
|
|
break;
|
|
|
|
|
2008-02-21 14:53:09 +00:00
|
|
|
case LFUN_CLOSE_TAB_GROUP:
|
|
|
|
enable = d.currentTabWorkArea();
|
|
|
|
break;
|
|
|
|
|
2010-01-30 16:07:53 +00:00
|
|
|
case LFUN_TOOLBAR_TOGGLE: {
|
|
|
|
string const name = cmd.getArg(0);
|
|
|
|
if (GuiToolbar * t = toolbar(name))
|
2008-05-27 11:15:17 +00:00
|
|
|
flag.setOnOff(t->isVisible());
|
2010-01-30 16:07:53 +00:00
|
|
|
else {
|
|
|
|
enable = false;
|
2010-09-07 14:11:28 +00:00
|
|
|
docstring const msg =
|
2010-01-30 16:07:53 +00:00
|
|
|
bformat(_("Unknown toolbar \"%1$s\""), from_utf8(name));
|
|
|
|
flag.message(msg);
|
|
|
|
}
|
2007-11-19 20:56:05 +00:00
|
|
|
break;
|
2010-01-30 16:07:53 +00:00
|
|
|
}
|
2007-11-19 20:56:05 +00:00
|
|
|
|
2009-10-04 21:03:37 +00:00
|
|
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
2010-09-07 14:11:28 +00:00
|
|
|
enable = buf;
|
2009-10-04 21:03:37 +00:00
|
|
|
break;
|
|
|
|
|
2008-03-17 14:22:30 +00:00
|
|
|
case LFUN_UI_TOGGLE:
|
|
|
|
flag.setOnOff(isFullScreen());
|
|
|
|
break;
|
|
|
|
|
2009-09-12 21:12:24 +00:00
|
|
|
case LFUN_DIALOG_DISCONNECT_INSET:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DIALOG_HIDE:
|
|
|
|
// FIXME: should we check if the dialog is shown?
|
|
|
|
break;
|
|
|
|
|
2007-11-19 20:56:05 +00:00
|
|
|
case LFUN_DIALOG_TOGGLE:
|
|
|
|
flag.setOnOff(isDialogVisible(cmd.getArg(0)));
|
|
|
|
// fall through to set "enable"
|
|
|
|
case LFUN_DIALOG_SHOW: {
|
|
|
|
string const name = cmd.getArg(0);
|
2009-09-12 20:55:35 +00:00
|
|
|
if (!doc_buffer)
|
2007-11-19 20:56:05 +00:00
|
|
|
enable = name == "aboutlyx"
|
|
|
|
|| name == "file" //FIXME: should be removed.
|
|
|
|
|| name == "prefs"
|
2009-10-24 15:47:05 +00:00
|
|
|
|| name == "texinfo"
|
2009-12-22 10:04:30 +00:00
|
|
|
|| name == "progress"
|
2009-10-24 15:47:05 +00:00
|
|
|
|| name == "compare";
|
2007-11-19 20:56:05 +00:00
|
|
|
else if (name == "print")
|
2009-09-12 20:55:35 +00:00
|
|
|
enable = doc_buffer->isExportable("dvi")
|
2007-11-19 20:56:05 +00:00
|
|
|
&& lyxrc.print_command != "none";
|
2009-08-01 16:55:15 +00:00
|
|
|
else if (name == "character" || name == "symbols") {
|
2010-04-30 08:27:03 +00:00
|
|
|
if (!buf || buf->isReadonly())
|
2007-11-19 20:56:05 +00:00
|
|
|
enable = false;
|
|
|
|
else {
|
2009-07-16 10:08:13 +00:00
|
|
|
// FIXME we should consider passthru
|
|
|
|
// paragraphs too.
|
2009-09-05 14:29:11 +00:00
|
|
|
Inset const & in = currentBufferView()->cursor().inset();
|
2009-07-16 10:08:13 +00:00
|
|
|
enable = !in.getLayout().isPassThru();
|
2007-11-19 20:56:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "latexlog")
|
2009-09-12 20:55:35 +00:00
|
|
|
enable = FileName(doc_buffer->logName()).isReadableFile();
|
2007-11-19 20:56:05 +00:00
|
|
|
else if (name == "spellchecker")
|
2009-09-12 20:55:35 +00:00
|
|
|
enable = theSpellChecker() && !doc_buffer->isReadonly();
|
2007-11-19 20:56:05 +00:00
|
|
|
else if (name == "vclog")
|
2009-09-12 20:55:35 +00:00
|
|
|
enable = doc_buffer->lyxvc().inUse();
|
2007-11-19 20:56:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_DIALOG_UPDATE: {
|
|
|
|
string const name = cmd.getArg(0);
|
|
|
|
if (!buf)
|
|
|
|
enable = name == "prefs";
|
|
|
|
break;
|
|
|
|
}
|
2009-09-19 11:54:23 +00:00
|
|
|
|
|
|
|
case LFUN_COMMAND_EXECUTE:
|
|
|
|
case LFUN_MESSAGE:
|
2009-09-12 21:12:24 +00:00
|
|
|
case LFUN_MENU_OPEN:
|
|
|
|
// Nothing to check.
|
|
|
|
break;
|
2007-11-19 20:56:05 +00:00
|
|
|
|
2008-02-21 19:42:34 +00:00
|
|
|
case LFUN_COMPLETION_INLINE:
|
|
|
|
if (!d.current_work_area_
|
2010-03-05 18:07:05 +00:00
|
|
|
|| !d.current_work_area_->completer().inlinePossible(
|
2009-09-05 14:29:11 +00:00
|
|
|
currentBufferView()->cursor()))
|
2010-03-05 18:07:05 +00:00
|
|
|
enable = false;
|
2008-02-21 19:42:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_COMPLETION_POPUP:
|
|
|
|
if (!d.current_work_area_
|
2010-03-05 18:07:05 +00:00
|
|
|
|| !d.current_work_area_->completer().popupPossible(
|
2009-09-05 14:29:11 +00:00
|
|
|
currentBufferView()->cursor()))
|
2010-03-05 18:07:05 +00:00
|
|
|
enable = false;
|
2008-02-21 19:42:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_COMPLETION_COMPLETE:
|
|
|
|
if (!d.current_work_area_
|
2009-09-05 14:29:11 +00:00
|
|
|
|| !d.current_work_area_->completer().inlinePossible(
|
|
|
|
currentBufferView()->cursor()))
|
2010-03-05 18:07:05 +00:00
|
|
|
enable = false;
|
2008-02-21 19:42:34 +00:00
|
|
|
break;
|
|
|
|
|
2008-09-08 00:24:47 +00:00
|
|
|
case LFUN_COMPLETION_ACCEPT:
|
2008-11-16 16:34:16 +00:00
|
|
|
if (!d.current_work_area_
|
2010-03-05 18:07:05 +00:00
|
|
|
|| (!d.current_work_area_->completer().popupVisible()
|
2008-11-16 16:34:16 +00:00
|
|
|
&& !d.current_work_area_->completer().inlineVisible()
|
|
|
|
&& !d.current_work_area_->completer().completionAvailable()))
|
|
|
|
enable = false;
|
|
|
|
break;
|
|
|
|
|
2009-04-04 09:14:38 +00:00
|
|
|
case LFUN_COMPLETION_CANCEL:
|
2008-09-08 00:13:55 +00:00
|
|
|
if (!d.current_work_area_
|
2010-03-05 18:07:05 +00:00
|
|
|
|| (!d.current_work_area_->completer().popupVisible()
|
2008-09-08 00:13:55 +00:00
|
|
|
&& !d.current_work_area_->completer().inlineVisible()))
|
|
|
|
enable = false;
|
|
|
|
break;
|
|
|
|
|
2009-04-04 09:14:38 +00:00
|
|
|
case LFUN_BUFFER_ZOOM_OUT:
|
2009-09-12 20:55:35 +00:00
|
|
|
enable = doc_buffer && lyxrc.zoom > 10;
|
2009-04-04 09:14:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BUFFER_ZOOM_IN:
|
2009-09-12 20:55:35 +00:00
|
|
|
enable = doc_buffer;
|
2009-04-04 09:14:38 +00:00
|
|
|
break;
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2009-09-12 21:12:24 +00:00
|
|
|
case LFUN_BUFFER_NEXT:
|
|
|
|
case LFUN_BUFFER_PREVIOUS:
|
|
|
|
// FIXME: should we check is there is an previous or next buffer?
|
|
|
|
break;
|
2009-09-09 05:49:51 +00:00
|
|
|
case LFUN_BUFFER_SWITCH:
|
|
|
|
// toggle on the current buffer, but do not toggle off
|
|
|
|
// the other ones (is that a good idea?)
|
2009-09-12 20:41:24 +00:00
|
|
|
if (doc_buffer
|
|
|
|
&& to_utf8(cmd.argument()) == doc_buffer->absFileName())
|
2009-09-09 05:49:51 +00:00
|
|
|
flag.setOnOff(true);
|
|
|
|
break;
|
2009-04-04 09:14:38 +00:00
|
|
|
|
2009-09-12 20:41:24 +00:00
|
|
|
case LFUN_VC_REGISTER:
|
|
|
|
enable = doc_buffer && !doc_buffer->lyxvc().inUse();
|
|
|
|
break;
|
|
|
|
case LFUN_VC_CHECK_IN:
|
|
|
|
enable = doc_buffer && doc_buffer->lyxvc().checkInEnabled();
|
|
|
|
break;
|
|
|
|
case LFUN_VC_CHECK_OUT:
|
|
|
|
enable = doc_buffer && doc_buffer->lyxvc().checkOutEnabled();
|
|
|
|
break;
|
|
|
|
case LFUN_VC_LOCKING_TOGGLE:
|
|
|
|
enable = doc_buffer && !doc_buffer->isReadonly()
|
|
|
|
&& doc_buffer->lyxvc().lockingToggleEnabled();
|
2010-02-12 07:21:11 +00:00
|
|
|
flag.setOnOff(enable && doc_buffer->lyxvc().locking());
|
2009-09-12 20:41:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_VC_REVERT:
|
2010-10-08 05:30:07 +00:00
|
|
|
enable = doc_buffer && doc_buffer->lyxvc().inUse() && !doc_buffer->isReadonly();
|
2009-09-12 20:41:24 +00:00
|
|
|
break;
|
|
|
|
case LFUN_VC_UNDO_LAST:
|
|
|
|
enable = doc_buffer && doc_buffer->lyxvc().undoLastEnabled();
|
|
|
|
break;
|
2009-10-14 19:18:06 +00:00
|
|
|
case LFUN_VC_REPO_UPDATE:
|
2010-10-08 05:30:07 +00:00
|
|
|
enable = doc_buffer && doc_buffer->lyxvc().repoUpdateEnabled();
|
2009-10-06 23:20:52 +00:00
|
|
|
break;
|
2009-09-12 20:41:24 +00:00
|
|
|
case LFUN_VC_COMMAND: {
|
|
|
|
if (cmd.argument().empty())
|
|
|
|
enable = false;
|
|
|
|
if (!doc_buffer && contains(cmd.getArg(0), 'D'))
|
|
|
|
enable = false;
|
|
|
|
break;
|
|
|
|
}
|
2010-02-12 14:09:44 +00:00
|
|
|
case LFUN_VC_COMPARE:
|
2010-09-07 11:28:57 +00:00
|
|
|
enable = doc_buffer && doc_buffer->lyxvc().prepareFileRevisionEnabled();
|
2010-02-12 14:09:44 +00:00
|
|
|
break;
|
2009-09-12 20:41:24 +00:00
|
|
|
|
2009-09-23 13:45:58 +00:00
|
|
|
case LFUN_SERVER_GOTO_FILE_ROW:
|
2010-04-16 08:09:07 +00:00
|
|
|
break;
|
2010-04-15 13:19:48 +00:00
|
|
|
case LFUN_FORWARD_SEARCH:
|
2010-04-16 08:09:07 +00:00
|
|
|
enable = !(lyxrc.forward_search_dvi.empty() && lyxrc.forward_search_pdf.empty());
|
2009-09-23 13:45:58 +00:00
|
|
|
break;
|
|
|
|
|
2007-11-19 20:56:05 +00:00
|
|
|
default:
|
2008-05-22 15:01:36 +00:00
|
|
|
return false;
|
2007-11-19 20:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!enable)
|
2008-05-29 15:14:00 +00:00
|
|
|
flag.setEnabled(false);
|
2007-11-19 20:56:05 +00:00
|
|
|
|
2008-05-22 15:01:36 +00:00
|
|
|
return true;
|
2007-11-19 20:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-07 11:57:13 +00:00
|
|
|
static FileName selectTemplateFile()
|
|
|
|
{
|
2008-03-05 23:10:53 +00:00
|
|
|
FileDialog dlg(qt_("Select template file"));
|
|
|
|
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
2010-10-08 05:34:48 +00:00
|
|
|
dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
|
2007-12-07 11:57:13 +00:00
|
|
|
|
2008-04-20 19:56:01 +00:00
|
|
|
FileDialog::Result result = dlg.open(toqstr(lyxrc.template_path),
|
2010-03-05 18:07:05 +00:00
|
|
|
QStringList(qt_("LyX Documents (*.lyx)")));
|
2007-12-07 11:57:13 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return FileName();
|
2008-03-05 23:10:53 +00:00
|
|
|
if (result.second.isEmpty())
|
2007-12-07 11:57:13 +00:00
|
|
|
return FileName();
|
2008-03-05 23:10:53 +00:00
|
|
|
return FileName(fromqstr(result.second));
|
2007-12-07 11:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-17 16:09:26 +00:00
|
|
|
Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
|
2008-02-06 23:02:57 +00:00
|
|
|
{
|
|
|
|
setBusy(true);
|
|
|
|
|
|
|
|
Buffer * newBuffer = checkAndLoadLyXFile(filename);
|
|
|
|
|
|
|
|
if (!newBuffer) {
|
|
|
|
message(_("Document not loaded."));
|
|
|
|
setBusy(false);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2008-02-06 23:02:57 +00:00
|
|
|
setBuffer(newBuffer);
|
|
|
|
|
|
|
|
// scroll to the position when the file was last closed
|
|
|
|
if (lyxrc.use_lastfilepos) {
|
|
|
|
LastFilePosSection::FilePos filepos =
|
2008-07-14 08:35:00 +00:00
|
|
|
theSession().lastFilePos().load(filename);
|
2009-09-05 14:29:11 +00:00
|
|
|
documentBufferView()->moveToPosition(filepos.pit, filepos.pos, 0, 0);
|
2008-02-06 23:02:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (tolastfiles)
|
2008-07-14 08:35:00 +00:00
|
|
|
theSession().lastFiles().add(filename);
|
2008-02-06 23:02:57 +00:00
|
|
|
|
|
|
|
setBusy(false);
|
|
|
|
return newBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::openDocument(string const & fname)
|
|
|
|
{
|
|
|
|
string initpath = lyxrc.document_path;
|
|
|
|
|
2009-09-05 15:09:45 +00:00
|
|
|
if (documentBufferView()) {
|
|
|
|
string const trypath = documentBufferView()->buffer().filePath();
|
2008-02-06 23:02:57 +00:00
|
|
|
// If directory is writeable, use this as default.
|
|
|
|
if (FileName(trypath).isDirWritable())
|
|
|
|
initpath = trypath;
|
|
|
|
}
|
|
|
|
|
|
|
|
string filename;
|
|
|
|
|
|
|
|
if (fname.empty()) {
|
2008-03-05 23:10:53 +00:00
|
|
|
FileDialog dlg(qt_("Select document to open"), LFUN_FILE_OPEN);
|
|
|
|
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
|
|
|
dlg.setButton2(qt_("Examples|#E#e"),
|
2010-04-21 01:19:09 +00:00
|
|
|
toqstr(addPath(package().system_support().absFileName(), "examples")));
|
2008-02-06 23:02:57 +00:00
|
|
|
|
2008-07-10 12:44:50 +00:00
|
|
|
QStringList filter(qt_("LyX Documents (*.lyx)"));
|
|
|
|
filter << qt_("LyX-1.3.x Documents (*.lyx13)")
|
|
|
|
<< qt_("LyX-1.4.x Documents (*.lyx14)")
|
2008-11-30 19:14:34 +00:00
|
|
|
<< qt_("LyX-1.5.x Documents (*.lyx15)")
|
|
|
|
<< qt_("LyX-1.6.x Documents (*.lyx16)");
|
2008-02-06 23:02:57 +00:00
|
|
|
FileDialog::Result result =
|
2008-07-10 12:44:50 +00:00
|
|
|
dlg.open(toqstr(initpath), filter);
|
2008-02-06 23:02:57 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
filename = fromqstr(result.second);
|
2008-02-06 23:02:57 +00:00
|
|
|
|
|
|
|
// check selected filename
|
|
|
|
if (filename.empty()) {
|
|
|
|
message(_("Canceled."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
filename = fname;
|
|
|
|
|
|
|
|
// get absolute path of file and add ".lyx" to the filename if
|
2010-09-07 14:11:28 +00:00
|
|
|
// necessary.
|
|
|
|
FileName const fullname =
|
2008-02-06 23:02:57 +00:00
|
|
|
fileSearch(string(), filename, "lyx", support::may_not_exist);
|
|
|
|
if (!fullname.empty())
|
2010-04-21 01:19:09 +00:00
|
|
|
filename = fullname.absFileName();
|
2008-02-06 23:02:57 +00:00
|
|
|
|
2008-09-08 15:46:23 +00:00
|
|
|
if (!fullname.onlyPath().isDirectory()) {
|
|
|
|
Alert::warning(_("Invalid filename"),
|
2009-05-02 08:43:22 +00:00
|
|
|
bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
|
2010-04-21 01:19:09 +00:00
|
|
|
from_utf8(fullname.absFileName())));
|
2008-09-08 15:46:23 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-04-09 19:38:28 +00:00
|
|
|
|
2010-09-07 14:11:28 +00:00
|
|
|
// if the file doesn't exist and isn't already open (bug 6645),
|
2010-04-09 19:38:28 +00:00
|
|
|
// let the user create one
|
|
|
|
if (!fullname.exists() && !theBufferList().exists(fullname)) {
|
2008-02-06 23:02:57 +00:00
|
|
|
// the user specifically chose this name. Believe him.
|
|
|
|
Buffer * const b = newFile(filename, string(), true);
|
|
|
|
if (b)
|
|
|
|
setBuffer(b);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
docstring const disp_fn = makeDisplayPath(filename);
|
|
|
|
message(bformat(_("Opening document %1$s..."), disp_fn));
|
|
|
|
|
|
|
|
docstring str2;
|
|
|
|
Buffer * buf = loadDocument(fullname);
|
|
|
|
if (buf) {
|
2010-07-09 14:37:00 +00:00
|
|
|
// I don't think this is needed, since it will be done in setBuffer().
|
|
|
|
// buf->updateBuffer();
|
2008-02-06 23:02:57 +00:00
|
|
|
setBuffer(buf);
|
|
|
|
buf->errors("Parse");
|
|
|
|
str2 = bformat(_("Document %1$s opened."), disp_fn);
|
2008-07-29 11:55:27 +00:00
|
|
|
if (buf->lyxvc().inUse())
|
2008-07-29 13:25:07 +00:00
|
|
|
str2 += " " + from_utf8(buf->lyxvc().versionString()) +
|
|
|
|
" " + _("Version control detected.");
|
2008-02-06 23:02:57 +00:00
|
|
|
} else {
|
|
|
|
str2 = bformat(_("Could not open document %1$s"), disp_fn);
|
|
|
|
}
|
|
|
|
message(str2);
|
|
|
|
}
|
|
|
|
|
2008-02-06 23:54:13 +00:00
|
|
|
// FIXME: clean that
|
2008-02-07 09:51:49 +00:00
|
|
|
static bool import(GuiView * lv, FileName const & filename,
|
|
|
|
string const & format, ErrorList & errorList)
|
2008-02-06 23:54:13 +00:00
|
|
|
{
|
2010-04-21 01:19:09 +00:00
|
|
|
FileName const lyxfile(support::changeExtension(filename.absFileName(), ".lyx"));
|
2008-02-06 23:54:13 +00:00
|
|
|
|
|
|
|
string loader_format;
|
|
|
|
vector<string> loaders = theConverters().loaders();
|
|
|
|
if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
|
|
|
|
for (vector<string>::const_iterator it = loaders.begin();
|
2010-03-05 18:07:05 +00:00
|
|
|
it != loaders.end(); ++it) {
|
2008-02-07 09:51:49 +00:00
|
|
|
if (!theConverters().isReachable(format, *it))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
string const tofile =
|
2010-04-21 01:19:09 +00:00
|
|
|
support::changeExtension(filename.absFileName(),
|
2008-02-07 09:51:49 +00:00
|
|
|
formats.extension(*it));
|
|
|
|
if (!theConverters().convert(0, filename, FileName(tofile),
|
|
|
|
filename, format, *it, errorList))
|
|
|
|
return false;
|
|
|
|
loader_format = *it;
|
|
|
|
break;
|
2008-02-06 23:54:13 +00:00
|
|
|
}
|
|
|
|
if (loader_format.empty()) {
|
|
|
|
frontend::Alert::error(_("Couldn't import file"),
|
2010-03-05 18:07:05 +00:00
|
|
|
bformat(_("No information for importing the format %1$s."),
|
2008-02-06 23:54:13 +00:00
|
|
|
formats.prettyName(format)));
|
|
|
|
return false;
|
|
|
|
}
|
2008-02-07 09:51:49 +00:00
|
|
|
} else
|
2008-02-06 23:54:13 +00:00
|
|
|
loader_format = format;
|
|
|
|
|
|
|
|
if (loader_format == "lyx") {
|
|
|
|
Buffer * buf = lv->loadDocument(lyxfile);
|
2008-02-07 09:51:49 +00:00
|
|
|
if (!buf)
|
2008-02-06 23:54:13 +00:00
|
|
|
return false;
|
2010-07-09 14:37:00 +00:00
|
|
|
// I don't think this is needed, since it will be done in setBuffer().
|
|
|
|
// buf->updateBuffer();
|
2008-02-06 23:54:13 +00:00
|
|
|
lv->setBuffer(buf);
|
|
|
|
buf->errors("Parse");
|
|
|
|
} else {
|
2010-04-21 01:19:09 +00:00
|
|
|
Buffer * const b = newFile(lyxfile.absFileName(), string(), true);
|
2008-02-07 09:51:49 +00:00
|
|
|
if (!b)
|
2008-02-06 23:54:13 +00:00
|
|
|
return false;
|
2008-02-07 09:51:49 +00:00
|
|
|
lv->setBuffer(b);
|
2008-02-06 23:54:13 +00:00
|
|
|
bool as_paragraphs = loader_format == "textparagraph";
|
2010-04-21 01:19:09 +00:00
|
|
|
string filename2 = (loader_format == format) ? filename.absFileName()
|
|
|
|
: support::changeExtension(filename.absFileName(),
|
2008-02-06 23:54:13 +00:00
|
|
|
formats.extension(loader_format));
|
2009-09-05 14:29:11 +00:00
|
|
|
lv->currentBufferView()->insertPlaintextFile(FileName(filename2),
|
|
|
|
as_paragraphs);
|
2009-09-22 21:25:32 +00:00
|
|
|
guiApp->setCurrentView(lv);
|
2008-02-06 23:54:13 +00:00
|
|
|
lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::importDocument(string const & argument)
|
|
|
|
{
|
|
|
|
string format;
|
|
|
|
string filename = split(argument, format, ' ');
|
|
|
|
|
|
|
|
LYXERR(Debug::INFO, format << " file: " << filename);
|
|
|
|
|
|
|
|
// need user interaction
|
|
|
|
if (filename.empty()) {
|
|
|
|
string initpath = lyxrc.document_path;
|
2009-09-05 15:09:45 +00:00
|
|
|
if (documentBufferView()) {
|
|
|
|
string const trypath = documentBufferView()->buffer().filePath();
|
2008-02-06 23:54:13 +00:00
|
|
|
// If directory is writeable, use this as default.
|
|
|
|
if (FileName(trypath).isDirWritable())
|
|
|
|
initpath = trypath;
|
|
|
|
}
|
|
|
|
|
|
|
|
docstring const text = bformat(_("Select %1$s file to import"),
|
|
|
|
formats.prettyName(format));
|
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
FileDialog dlg(toqstr(text), LFUN_BUFFER_IMPORT);
|
|
|
|
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
|
|
|
dlg.setButton2(qt_("Examples|#E#e"),
|
2010-04-21 01:19:09 +00:00
|
|
|
toqstr(addPath(package().system_support().absFileName(), "examples")));
|
2008-02-06 23:54:13 +00:00
|
|
|
|
|
|
|
docstring filter = formats.prettyName(format);
|
|
|
|
filter += " (*.";
|
|
|
|
// FIXME UNICODE
|
|
|
|
filter += from_utf8(formats.extension(format));
|
|
|
|
filter += ')';
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
2008-04-20 19:56:01 +00:00
|
|
|
dlg.open(toqstr(initpath), fileFilters(toqstr(filter)));
|
2008-02-06 23:54:13 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
filename = fromqstr(result.second);
|
2008-02-06 23:54:13 +00:00
|
|
|
|
|
|
|
// check selected filename
|
|
|
|
if (filename.empty())
|
|
|
|
message(_("Canceled."));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filename.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// get absolute path of file
|
2008-04-21 06:53:00 +00:00
|
|
|
FileName const fullname(support::makeAbsPath(filename));
|
2008-02-06 23:54:13 +00:00
|
|
|
|
2010-04-21 01:19:09 +00:00
|
|
|
FileName const lyxfile(support::changeExtension(fullname.absFileName(), ".lyx"));
|
2008-02-06 23:54:13 +00:00
|
|
|
|
|
|
|
// Check if the document already is open
|
2008-07-29 08:16:09 +00:00
|
|
|
Buffer * buf = theBufferList().getBuffer(lyxfile);
|
2008-02-06 23:54:13 +00:00
|
|
|
if (buf) {
|
|
|
|
setBuffer(buf);
|
|
|
|
if (!closeBuffer()) {
|
|
|
|
message(_("Canceled."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-21 01:19:09 +00:00
|
|
|
docstring const displaypath = makeDisplayPath(lyxfile.absFileName(), 30);
|
2008-02-07 09:51:49 +00:00
|
|
|
|
2008-02-06 23:54:13 +00:00
|
|
|
// if the file exists already, and we didn't do
|
|
|
|
// -i lyx thefile.lyx, warn
|
|
|
|
if (lyxfile.exists() && fullname != lyxfile) {
|
|
|
|
|
|
|
|
docstring text = bformat(_("The document %1$s already exists.\n\n"
|
2008-02-07 09:51:49 +00:00
|
|
|
"Do you want to overwrite that document?"), displaypath);
|
2008-02-06 23:54:13 +00:00
|
|
|
int const ret = Alert::prompt(_("Overwrite document?"),
|
|
|
|
text, 0, 1, _("&Overwrite"), _("&Cancel"));
|
|
|
|
|
|
|
|
if (ret == 1) {
|
|
|
|
message(_("Canceled."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-07 09:51:49 +00:00
|
|
|
message(bformat(_("Importing %1$s..."), displaypath));
|
2008-02-06 23:54:13 +00:00
|
|
|
ErrorList errorList;
|
2008-02-07 09:51:49 +00:00
|
|
|
if (import(this, fullname, format, errorList))
|
|
|
|
message(_("imported."));
|
|
|
|
else
|
|
|
|
message(_("file not imported!"));
|
|
|
|
|
2008-02-06 23:54:13 +00:00
|
|
|
// FIXME (Abdel 12/08/06): Is there a need to display the error list here?
|
|
|
|
}
|
|
|
|
|
2008-02-06 23:02:57 +00:00
|
|
|
|
2007-12-07 11:57:13 +00:00
|
|
|
void GuiView::newDocument(string const & filename, bool from_template)
|
|
|
|
{
|
2007-12-07 22:28:03 +00:00
|
|
|
FileName initpath(lyxrc.document_path);
|
2009-09-05 15:09:45 +00:00
|
|
|
if (documentBufferView()) {
|
|
|
|
FileName const trypath(documentBufferView()->buffer().filePath());
|
2007-12-07 11:57:13 +00:00
|
|
|
// If directory is writeable, use this as default.
|
|
|
|
if (trypath.isDirWritable())
|
|
|
|
initpath = trypath;
|
2007-12-07 22:28:03 +00:00
|
|
|
}
|
2007-12-07 11:57:13 +00:00
|
|
|
|
2009-01-08 00:29:06 +00:00
|
|
|
string templatefile;
|
|
|
|
if (from_template) {
|
2010-04-21 01:19:09 +00:00
|
|
|
templatefile = selectTemplateFile().absFileName();
|
2009-01-08 00:29:06 +00:00
|
|
|
if (templatefile.empty())
|
|
|
|
return;
|
|
|
|
}
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2007-12-07 11:57:13 +00:00
|
|
|
Buffer * b;
|
|
|
|
if (filename.empty())
|
2009-10-24 14:20:00 +00:00
|
|
|
b = newUnnamedFile(initpath, to_utf8(_("newfile")), templatefile);
|
2007-12-07 11:57:13 +00:00
|
|
|
else
|
|
|
|
b = newFile(filename, templatefile, true);
|
|
|
|
|
|
|
|
if (b)
|
|
|
|
setBuffer(b);
|
2009-01-05 09:56:37 +00:00
|
|
|
|
2010-09-07 14:11:28 +00:00
|
|
|
// If no new document could be created, it is unsure
|
2009-01-05 09:56:37 +00:00
|
|
|
// whether there is a valid BufferView.
|
2009-09-05 14:29:11 +00:00
|
|
|
if (currentBufferView())
|
2009-01-05 09:56:37 +00:00
|
|
|
// Ensure the cursor is correctly positioned on screen.
|
2009-09-05 14:29:11 +00:00
|
|
|
currentBufferView()->showCursor();
|
2007-12-07 11:57:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-02 17:50:08 +00:00
|
|
|
void GuiView::insertLyXFile(docstring const & fname)
|
|
|
|
{
|
2009-09-05 14:29:11 +00:00
|
|
|
BufferView * bv = documentBufferView();
|
2007-12-02 17:50:08 +00:00
|
|
|
if (!bv)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// FIXME UNICODE
|
|
|
|
FileName filename(to_utf8(fname));
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2007-12-02 17:50:08 +00:00
|
|
|
if (!filename.empty()) {
|
|
|
|
bv->insertLyXFile(filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Launch a file browser
|
|
|
|
// FIXME UNICODE
|
|
|
|
string initpath = lyxrc.document_path;
|
|
|
|
string const trypath = bv->buffer().filePath();
|
|
|
|
// If directory is writeable, use this as default.
|
|
|
|
if (FileName(trypath).isDirWritable())
|
|
|
|
initpath = trypath;
|
|
|
|
|
|
|
|
// FIXME UNICODE
|
2008-03-05 23:10:53 +00:00
|
|
|
FileDialog dlg(qt_("Select LyX document to insert"), LFUN_FILE_INSERT);
|
|
|
|
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
|
|
|
dlg.setButton2(qt_("Examples|#E#e"),
|
2010-04-21 01:19:09 +00:00
|
|
|
toqstr(addPath(package().system_support().absFileName(),
|
2007-12-02 17:50:08 +00:00
|
|
|
"examples")));
|
|
|
|
|
2008-04-20 19:56:01 +00:00
|
|
|
FileDialog::Result result = dlg.open(toqstr(initpath),
|
2010-03-05 18:07:05 +00:00
|
|
|
QStringList(qt_("LyX Documents (*.lyx)")));
|
2007-12-02 17:50:08 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// FIXME UNICODE
|
2008-03-05 23:10:53 +00:00
|
|
|
filename.set(fromqstr(result.second));
|
2007-12-02 17:50:08 +00:00
|
|
|
|
|
|
|
// check selected filename
|
|
|
|
if (filename.empty()) {
|
|
|
|
// emit message signal.
|
|
|
|
message(_("Canceled."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bv->insertLyXFile(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-02 20:05:17 +00:00
|
|
|
void GuiView::insertPlaintextFile(docstring const & fname,
|
|
|
|
bool asParagraph)
|
|
|
|
{
|
2009-09-05 14:29:11 +00:00
|
|
|
BufferView * bv = documentBufferView();
|
2009-05-12 18:41:08 +00:00
|
|
|
if (!bv)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!fname.empty() && !FileName::isAbsolute(to_utf8(fname))) {
|
|
|
|
message(_("Absolute filename expected."));
|
2007-12-02 20:05:17 +00:00
|
|
|
return;
|
2009-05-12 18:41:08 +00:00
|
|
|
}
|
2007-12-02 20:05:17 +00:00
|
|
|
|
|
|
|
// FIXME UNICODE
|
|
|
|
FileName filename(to_utf8(fname));
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2007-12-02 20:05:17 +00:00
|
|
|
if (!filename.empty()) {
|
|
|
|
bv->insertPlaintextFile(filename, asParagraph);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
FileDialog dlg(qt_("Select file to insert"), (asParagraph ?
|
2007-12-02 20:05:17 +00:00
|
|
|
LFUN_FILE_INSERT_PLAINTEXT_PARA : LFUN_FILE_INSERT_PLAINTEXT));
|
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
|
2009-01-09 07:35:20 +00:00
|
|
|
QStringList(qt_("All Files (*)")));
|
2007-12-02 20:05:17 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// FIXME UNICODE
|
2008-03-05 23:10:53 +00:00
|
|
|
filename.set(fromqstr(result.second));
|
2007-12-02 20:05:17 +00:00
|
|
|
|
|
|
|
// check selected filename
|
|
|
|
if (filename.empty()) {
|
|
|
|
// emit message signal.
|
|
|
|
message(_("Canceled."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bv->insertPlaintextFile(filename, asParagraph);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
|
|
|
|
{
|
|
|
|
FileName fname = b.fileName();
|
|
|
|
FileName const oldname = fname;
|
|
|
|
|
|
|
|
if (!newname.empty()) {
|
|
|
|
// FIXME UNICODE
|
2010-04-21 01:19:09 +00:00
|
|
|
fname = support::makeAbsPath(to_utf8(newname), oldname.onlyPath().absFileName());
|
2007-12-04 22:21:25 +00:00
|
|
|
} else {
|
|
|
|
// Switch to this Buffer.
|
|
|
|
setBuffer(&b);
|
|
|
|
|
2009-04-04 03:10:54 +00:00
|
|
|
// No argument? Ask user through dialog.
|
2007-12-04 22:21:25 +00:00
|
|
|
// FIXME UNICODE
|
2008-03-05 23:10:53 +00:00
|
|
|
FileDialog dlg(qt_("Choose a filename to save document as"),
|
2007-12-04 22:21:25 +00:00
|
|
|
LFUN_BUFFER_WRITE_AS);
|
2008-03-05 23:10:53 +00:00
|
|
|
dlg.setButton1(qt_("Documents|#o#O"), toqstr(lyxrc.document_path));
|
|
|
|
dlg.setButton2(qt_("Templates|#T#t"), toqstr(lyxrc.template_path));
|
2007-12-04 22:21:25 +00:00
|
|
|
|
2010-04-21 01:19:31 +00:00
|
|
|
if (!isLyXFileName(fname.absFileName()))
|
2007-12-04 22:21:25 +00:00
|
|
|
fname.changeExtension(".lyx");
|
|
|
|
|
|
|
|
FileDialog::Result result =
|
2010-04-21 01:19:09 +00:00
|
|
|
dlg.save(toqstr(fname.onlyPath().absFileName()),
|
2010-03-05 18:07:05 +00:00
|
|
|
QStringList(qt_("LyX Documents (*.lyx)")),
|
|
|
|
toqstr(fname.onlyFileName()));
|
2007-12-04 22:21:25 +00:00
|
|
|
|
|
|
|
if (result.first == FileDialog::Later)
|
|
|
|
return false;
|
|
|
|
|
2008-03-05 23:10:53 +00:00
|
|
|
fname.set(fromqstr(result.second));
|
2007-12-04 22:21:25 +00:00
|
|
|
|
|
|
|
if (fname.empty())
|
|
|
|
return false;
|
|
|
|
|
2010-04-21 01:19:31 +00:00
|
|
|
if (!isLyXFileName(fname.absFileName()))
|
2007-12-04 22:21:25 +00:00
|
|
|
fname.changeExtension(".lyx");
|
|
|
|
}
|
|
|
|
|
2010-03-09 03:25:47 +00:00
|
|
|
// fname is now the new Buffer location.
|
2007-12-04 22:21:25 +00:00
|
|
|
if (FileName(fname).exists()) {
|
2010-04-21 01:19:09 +00:00
|
|
|
docstring const file = makeDisplayPath(fname.absFileName(), 30);
|
2007-12-04 22:21:25 +00:00
|
|
|
docstring text = bformat(_("The document %1$s already "
|
|
|
|
"exists.\n\nDo you want to "
|
2010-09-07 14:11:28 +00:00
|
|
|
"overwrite that document?"),
|
2007-12-04 22:21:25 +00:00
|
|
|
file);
|
|
|
|
int const ret = Alert::prompt(_("Overwrite document?"),
|
|
|
|
text, 0, 2, _("&Overwrite"), _("&Rename"), _("&Cancel"));
|
|
|
|
switch (ret) {
|
|
|
|
case 0: break;
|
|
|
|
case 1: return renameBuffer(b, docstring());
|
|
|
|
case 2: return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-21 01:19:33 +00:00
|
|
|
FileName oldauto = b.getAutosaveFileName();
|
2009-05-03 10:21:21 +00:00
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
// Ok, change the name of the buffer
|
2010-04-21 01:19:09 +00:00
|
|
|
b.setFileName(fname.absFileName());
|
2007-12-04 22:21:25 +00:00
|
|
|
b.markDirty();
|
|
|
|
bool unnamed = b.isUnnamed();
|
|
|
|
b.setUnnamed(false);
|
|
|
|
b.saveCheckSum(fname);
|
|
|
|
|
2009-05-03 10:21:21 +00:00
|
|
|
// bring the autosave file with us, just in case.
|
|
|
|
b.moveAutosaveFile(oldauto);
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
if (!saveBuffer(b)) {
|
2010-04-21 01:19:33 +00:00
|
|
|
oldauto = b.getAutosaveFileName();
|
2010-04-21 01:19:09 +00:00
|
|
|
b.setFileName(oldname.absFileName());
|
2007-12-04 22:21:25 +00:00
|
|
|
b.setUnnamed(unnamed);
|
|
|
|
b.saveCheckSum(oldname);
|
2009-05-03 10:21:21 +00:00
|
|
|
b.moveAutosaveFile(oldauto);
|
2007-12-04 22:21:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-03-09 03:25:47 +00:00
|
|
|
// the file has now been saved to the new location.
|
|
|
|
// we need to check that the locations of child buffers
|
|
|
|
// are still valid.
|
|
|
|
b.checkChildBuffers();
|
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-17 16:09:26 +00:00
|
|
|
bool GuiView::saveBuffer(Buffer & b)
|
2007-12-04 22:21:25 +00:00
|
|
|
{
|
2008-11-16 01:20:34 +00:00
|
|
|
if (workArea(b) && workArea(b)->inDialogMode())
|
|
|
|
return true;
|
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
if (b.isUnnamed())
|
|
|
|
return renameBuffer(b, docstring());
|
|
|
|
|
2010-07-17 16:09:26 +00:00
|
|
|
if (b.save()) {
|
2008-07-14 08:35:00 +00:00
|
|
|
theSession().lastFiles().add(b.fileName());
|
2007-12-04 22:21:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Switch to this Buffer.
|
|
|
|
setBuffer(&b);
|
|
|
|
|
|
|
|
// FIXME: we don't tell the user *WHY* the save failed !!
|
|
|
|
docstring const file = makeDisplayPath(b.absFileName(), 30);
|
|
|
|
docstring text = bformat(_("The document %1$s could not be saved.\n\n"
|
|
|
|
"Do you want to rename the document and "
|
|
|
|
"try again?"), file);
|
|
|
|
int const ret = Alert::prompt(_("Rename and save?"),
|
|
|
|
text, 0, 2, _("&Rename"), _("&Retry"), _("&Cancel"));
|
|
|
|
switch (ret) {
|
|
|
|
case 0:
|
|
|
|
if (!renameBuffer(b, docstring()))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
break;
|
2008-01-17 19:01:01 +00:00
|
|
|
case 2:
|
|
|
|
return false;
|
2007-12-04 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
2010-07-17 16:09:26 +00:00
|
|
|
return saveBuffer(b);
|
2007-12-04 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-15 14:07:05 +00:00
|
|
|
bool GuiView::hideWorkArea(GuiWorkArea * wa)
|
2009-08-14 23:12:21 +00:00
|
|
|
{
|
2009-08-15 21:29:14 +00:00
|
|
|
return closeWorkArea(wa, false);
|
2009-08-14 23:12:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-17 22:33:49 +00:00
|
|
|
bool GuiView::closeWorkArea(GuiWorkArea * wa)
|
|
|
|
{
|
2009-08-18 00:04:19 +00:00
|
|
|
Buffer & buf = wa->bufferView().buffer();
|
|
|
|
return closeWorkArea(wa, !buf.parent());
|
2009-08-17 22:33:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
bool GuiView::closeBuffer()
|
|
|
|
{
|
2009-08-15 21:29:14 +00:00
|
|
|
GuiWorkArea * wa = currentMainWorkArea();
|
2010-01-08 09:29:17 +00:00
|
|
|
setCurrentWorkArea(wa);
|
2009-08-15 21:29:14 +00:00
|
|
|
Buffer & buf = wa->bufferView().buffer();
|
|
|
|
return wa && closeWorkArea(wa, !buf.parent());
|
2007-12-04 22:21:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-19 20:06:57 +00:00
|
|
|
void GuiView::writeSession() const {
|
|
|
|
GuiWorkArea const * active_wa = currentMainWorkArea();
|
|
|
|
for (int i = 0; i < d.splitter_->count(); ++i) {
|
|
|
|
TabWorkArea * twa = d.tabWorkArea(i);
|
|
|
|
for (int j = 0; j < twa->count(); ++j) {
|
|
|
|
GuiWorkArea * wa = static_cast<GuiWorkArea *>(twa->widget(j));
|
|
|
|
Buffer & buf = wa->bufferView().buffer();
|
|
|
|
theSession().lastOpened().add(buf.fileName(), wa == active_wa);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-18 20:48:15 +00:00
|
|
|
bool GuiView::closeBufferAll()
|
2009-08-18 20:12:34 +00:00
|
|
|
{
|
2009-08-19 21:12:53 +00:00
|
|
|
// Close the workareas in all other views
|
|
|
|
QList<int> const ids = guiApp->viewIds();
|
|
|
|
for (int i = 0; i != ids.size(); ++i) {
|
|
|
|
if (id_ != ids[i] && !guiApp->view(ids[i]).closeWorkAreaAll())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close our own workareas
|
2009-08-18 20:48:15 +00:00
|
|
|
if (!closeWorkAreaAll())
|
2009-08-18 20:12:34 +00:00
|
|
|
return false;
|
|
|
|
|
2009-08-18 20:48:15 +00:00
|
|
|
// Now close the hidden buffers. We prevent hidden buffers from being
|
|
|
|
// dirty, so we can just close them.
|
2009-08-18 20:12:34 +00:00
|
|
|
theBufferList().closeAll();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-18 20:48:15 +00:00
|
|
|
bool GuiView::closeWorkAreaAll()
|
2009-08-18 20:12:34 +00:00
|
|
|
{
|
2009-08-21 20:29:40 +00:00
|
|
|
setCurrentWorkArea(currentMainWorkArea());
|
2009-08-18 20:12:34 +00:00
|
|
|
|
|
|
|
// We might be in a situation that there is still a tabWorkArea, but
|
2010-09-07 14:11:28 +00:00
|
|
|
// there are no tabs anymore. This can happen when we get here after a
|
2009-08-18 20:12:34 +00:00
|
|
|
// TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how
|
|
|
|
// many TabWorkArea's have no documents anymore.
|
|
|
|
int empty_twa = 0;
|
|
|
|
|
|
|
|
// We have to call count() each time, because it can happen that
|
|
|
|
// more than one splitter will disappear in one iteration (bug 5998).
|
|
|
|
for (; d.splitter_->count() > empty_twa; ) {
|
|
|
|
TabWorkArea * twa = d.tabWorkArea(empty_twa);
|
2009-08-18 20:48:15 +00:00
|
|
|
|
2009-08-18 20:12:34 +00:00
|
|
|
if (twa->count() == 0)
|
|
|
|
++empty_twa;
|
|
|
|
else {
|
|
|
|
setCurrentWorkArea(twa->currentWorkArea());
|
2009-08-21 20:29:40 +00:00
|
|
|
if (!closeTabWorkArea(twa))
|
2009-08-18 20:12:34 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-21 20:29:40 +00:00
|
|
|
bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer)
|
2007-12-04 22:21:25 +00:00
|
|
|
{
|
2009-10-29 23:22:50 +00:00
|
|
|
if (!wa)
|
|
|
|
return false;
|
|
|
|
|
2009-08-17 21:25:27 +00:00
|
|
|
Buffer & buf = wa->bufferView().buffer();
|
|
|
|
|
2010-04-05 13:04:52 +00:00
|
|
|
if (close_buffer && GuiViewPrivate::busyBuffers.contains(&buf)) {
|
2010-05-15 02:58:23 +00:00
|
|
|
Alert::warning(_("Close document "), _("Document could not be closed because it is processed by LyX."));
|
2010-04-05 13:04:52 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-10-29 23:22:50 +00:00
|
|
|
if (close_buffer)
|
|
|
|
return closeBuffer(buf);
|
|
|
|
else {
|
|
|
|
if (!inMultiTabs(wa))
|
|
|
|
if (!saveBufferIfNeeded(buf, true))
|
|
|
|
return false;
|
|
|
|
removeWorkArea(wa);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GuiView::closeBuffer(Buffer & buf)
|
|
|
|
{
|
2009-08-18 21:18:21 +00:00
|
|
|
// If we are in a close_event all children will be closed in some time,
|
|
|
|
// so no need to do it here. This will ensure that the children end up
|
|
|
|
// in the session file in the correct order. If we close the master
|
|
|
|
// buffer, we can close or release the child buffers here too.
|
2009-10-29 23:22:50 +00:00
|
|
|
if (!closing_) {
|
2010-09-29 13:05:57 +00:00
|
|
|
ListOfBuffers clist = buf.getChildren();
|
2010-09-29 12:19:57 +00:00
|
|
|
ListOfBuffers::const_iterator it = clist.begin();
|
2010-09-29 11:55:10 +00:00
|
|
|
ListOfBuffers::const_iterator const bend = clist.end();
|
2010-09-29 12:19:57 +00:00
|
|
|
for (; it != bend; ++it) {
|
2009-08-17 21:25:27 +00:00
|
|
|
// If a child is dirty, do not close
|
|
|
|
// without user intervention
|
|
|
|
//FIXME: should we look in other tabworkareas?
|
2009-08-18 21:18:21 +00:00
|
|
|
Buffer * child_buf = *it;
|
|
|
|
GuiWorkArea * child_wa = workArea(*child_buf);
|
|
|
|
if (child_wa) {
|
|
|
|
if (!closeWorkArea(child_wa, true))
|
|
|
|
return false;
|
|
|
|
} else
|
|
|
|
theBufferList().releaseChild(&buf, child_buf);
|
2009-08-17 21:25:27 +00:00
|
|
|
}
|
|
|
|
}
|
2008-02-27 11:05:58 +00:00
|
|
|
// goto bookmark to update bookmark pit.
|
|
|
|
//FIXME: we should update only the bookmarks related to this buffer!
|
2008-11-16 01:20:34 +00:00
|
|
|
LYXERR(Debug::DEBUG, "GuiView::closeBuffer()");
|
2008-07-14 08:35:00 +00:00
|
|
|
for (size_t i = 0; i < theSession().bookmarks().size(); ++i)
|
2010-02-09 16:11:13 +00:00
|
|
|
guiApp->gotoBookmark(i+1, false, false);
|
2008-02-27 11:05:58 +00:00
|
|
|
|
2009-10-29 23:22:50 +00:00
|
|
|
if (saveBufferIfNeeded(buf, false)) {
|
2010-03-26 23:15:37 +00:00
|
|
|
buf.removeAutosaveFile();
|
2009-10-29 23:22:50 +00:00
|
|
|
theBufferList().release(&buf);
|
2007-12-04 22:21:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-08-12 18:50:09 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-21 20:29:40 +00:00
|
|
|
bool GuiView::closeTabWorkArea(TabWorkArea * twa)
|
2009-08-18 19:04:39 +00:00
|
|
|
{
|
|
|
|
while (twa == d.currentTabWorkArea()) {
|
|
|
|
twa->setCurrentIndex(twa->count()-1);
|
|
|
|
|
|
|
|
GuiWorkArea * wa = twa->currentWorkArea();
|
|
|
|
Buffer & b = wa->bufferView().buffer();
|
|
|
|
|
|
|
|
// We only want to close the buffer if the same buffer is not visible
|
|
|
|
// in another view, and if this is not a child and if we are closing
|
|
|
|
// a view (not a tabgroup).
|
2010-09-07 14:11:28 +00:00
|
|
|
bool const close_buffer =
|
2009-08-18 20:48:15 +00:00
|
|
|
!inMultiViews(wa) && !b.parent() && closing_;
|
2009-08-18 19:04:39 +00:00
|
|
|
|
2009-08-21 20:29:40 +00:00
|
|
|
if (!closeWorkArea(wa, close_buffer))
|
2009-08-18 19:04:39 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-14 23:12:21 +00:00
|
|
|
bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
|
2009-08-12 18:50:09 +00:00
|
|
|
{
|
|
|
|
if (buf.isClean() || buf.paragraphs().empty())
|
|
|
|
return true;
|
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
// Switch to this Buffer.
|
|
|
|
setBuffer(&buf);
|
|
|
|
|
|
|
|
docstring file;
|
|
|
|
// FIXME: Unicode?
|
|
|
|
if (buf.isUnnamed())
|
|
|
|
file = from_utf8(buf.fileName().onlyFileName());
|
|
|
|
else
|
|
|
|
file = buf.fileName().displayName(30);
|
|
|
|
|
2008-02-27 10:35:28 +00:00
|
|
|
// Bring this window to top before asking questions.
|
|
|
|
raise();
|
|
|
|
activateWindow();
|
|
|
|
|
2009-08-14 23:12:21 +00:00
|
|
|
int ret;
|
|
|
|
if (hiding && buf.isUnnamed()) {
|
|
|
|
docstring const text = bformat(_("The document %1$s has not been "
|
2010-03-05 18:07:05 +00:00
|
|
|
"saved yet.\n\nDo you want to save "
|
|
|
|
"the document?"), file);
|
2010-09-07 14:11:28 +00:00
|
|
|
ret = Alert::prompt(_("Save new document?"),
|
2009-08-14 23:12:21 +00:00
|
|
|
text, 0, 1, _("&Save"), _("&Cancel"));
|
|
|
|
if (ret == 1)
|
|
|
|
++ret;
|
|
|
|
} else {
|
|
|
|
docstring const text = bformat(_("The document %1$s has unsaved changes."
|
|
|
|
"\n\nDo you want to save the document or discard the changes?"), file);
|
|
|
|
ret = Alert::prompt(_("Save changed document?"),
|
|
|
|
text, 0, 2, _("&Save"), _("&Discard"), _("&Cancel"));
|
|
|
|
}
|
2007-12-04 22:21:25 +00:00
|
|
|
|
|
|
|
switch (ret) {
|
|
|
|
case 0:
|
|
|
|
if (!saveBuffer(buf))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
// if we crash after this we could
|
|
|
|
// have no autosave file but I guess
|
|
|
|
// this is really improbable (Jug)
|
2010-03-26 23:15:37 +00:00
|
|
|
// Sometime improbable things happen, bug 6857 (ps)
|
|
|
|
// buf.removeAutosaveFile();
|
2009-08-16 00:26:14 +00:00
|
|
|
if (hiding)
|
2009-08-14 23:12:21 +00:00
|
|
|
// revert all changes
|
2010-01-08 02:15:56 +00:00
|
|
|
buf.reload();
|
2009-08-16 00:26:14 +00:00
|
|
|
buf.markClean();
|
2007-12-04 22:21:25 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-15 21:46:39 +00:00
|
|
|
bool GuiView::inMultiTabs(GuiWorkArea * wa)
|
|
|
|
{
|
|
|
|
Buffer & buf = wa->bufferView().buffer();
|
|
|
|
|
|
|
|
for (int i = 0; i != d.splitter_->count(); ++i) {
|
|
|
|
GuiWorkArea * wa_ = d.tabWorkArea(i)->workArea(buf);
|
|
|
|
if (wa_ && wa_ != wa)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return inMultiViews(wa);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-15 18:13:21 +00:00
|
|
|
bool GuiView::inMultiViews(GuiWorkArea * wa)
|
|
|
|
{
|
|
|
|
QList<int> const ids = guiApp->viewIds();
|
|
|
|
Buffer & buf = wa->bufferView().buffer();
|
|
|
|
|
|
|
|
int found_twa = 0;
|
|
|
|
for (int i = 0; i != ids.size() && found_twa <= 1; ++i) {
|
|
|
|
if (id_ == ids[i])
|
|
|
|
continue;
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2009-08-15 18:13:21 +00:00
|
|
|
if (guiApp->view(ids[i]).workArea(buf))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-25 14:34:42 +00:00
|
|
|
void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
|
|
|
|
{
|
2009-09-05 15:09:45 +00:00
|
|
|
Buffer * const curbuf = documentBufferView()
|
|
|
|
? &documentBufferView()->buffer() : 0;
|
2009-03-25 14:34:42 +00:00
|
|
|
Buffer * nextbuf = curbuf;
|
|
|
|
while (true) {
|
|
|
|
if (np == NEXTBUFFER)
|
|
|
|
nextbuf = theBufferList().next(nextbuf);
|
|
|
|
else
|
|
|
|
nextbuf = theBufferList().previous(nextbuf);
|
|
|
|
if (nextbuf == curbuf)
|
|
|
|
break;
|
|
|
|
if (nextbuf == 0) {
|
|
|
|
nextbuf = curbuf;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (workArea(*nextbuf))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
setBuffer(nextbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-12 20:41:24 +00:00
|
|
|
/// make sure the document is saved
|
|
|
|
static bool ensureBufferClean(Buffer * buffer)
|
|
|
|
{
|
|
|
|
LASSERT(buffer, return false);
|
|
|
|
if (buffer->isClean() && !buffer->isUnnamed())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
docstring const file = buffer->fileName().displayName(30);
|
|
|
|
docstring title;
|
|
|
|
docstring text;
|
|
|
|
if (!buffer->isUnnamed()) {
|
|
|
|
text = bformat(_("The document %1$s has unsaved "
|
2010-03-05 18:07:05 +00:00
|
|
|
"changes.\n\nDo you want to save "
|
|
|
|
"the document?"), file);
|
2009-09-12 20:41:24 +00:00
|
|
|
title = _("Save changed document?");
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2009-09-12 20:41:24 +00:00
|
|
|
} else {
|
|
|
|
text = bformat(_("The document %1$s has not been "
|
2010-03-05 18:07:05 +00:00
|
|
|
"saved yet.\n\nDo you want to save "
|
|
|
|
"the document?"), file);
|
2009-09-12 20:41:24 +00:00
|
|
|
title = _("Save new document?");
|
|
|
|
}
|
|
|
|
int const ret = Alert::prompt(title, text, 0, 1, _("&Save"), _("&Cancel"));
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
dispatch(FuncRequest(LFUN_BUFFER_WRITE));
|
|
|
|
|
|
|
|
return buffer->isClean() && !buffer->isUnnamed();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-17 10:44:53 +00:00
|
|
|
bool GuiView::reloadBuffer()
|
2009-09-12 20:41:24 +00:00
|
|
|
{
|
|
|
|
Buffer * buf = &documentBufferView()->buffer();
|
2010-10-17 10:44:53 +00:00
|
|
|
return buf->reload();
|
2009-09-12 20:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-24 18:47:43 +00:00
|
|
|
void GuiView::checkExternallyModifiedBuffers()
|
|
|
|
{
|
|
|
|
BufferList::iterator bit = theBufferList().begin();
|
|
|
|
BufferList::iterator const bend = theBufferList().end();
|
|
|
|
for (; bit != bend; ++bit) {
|
2009-12-23 12:42:14 +00:00
|
|
|
if ((*bit)->fileName().exists()
|
2010-03-05 18:07:05 +00:00
|
|
|
&& (*bit)->isExternallyModified(Buffer::checksum_method)) {
|
2009-11-24 18:47:43 +00:00
|
|
|
docstring text = bformat(_("Document \n%1$s\n has been externally modified."
|
|
|
|
" Reload now? Any local changes will be lost."),
|
|
|
|
from_utf8((*bit)->absFileName()));
|
|
|
|
int const ret = Alert::prompt(_("Reload externally changed document?"),
|
|
|
|
text, 0, 1, _("&Reload"), _("&Cancel"));
|
|
|
|
if (!ret)
|
2010-01-08 02:15:56 +00:00
|
|
|
(*bit)->reload();
|
2009-11-24 18:47:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-17 10:44:53 +00:00
|
|
|
void GuiView::dispatchVC(FuncRequest const & cmd, DispatchResult & dr)
|
2009-09-12 20:41:24 +00:00
|
|
|
{
|
|
|
|
Buffer * buffer = documentBufferView()
|
|
|
|
? &(documentBufferView()->buffer()) : 0;
|
|
|
|
|
2010-04-09 19:00:42 +00:00
|
|
|
switch (cmd.action()) {
|
2009-09-12 20:41:24 +00:00
|
|
|
case LFUN_VC_REGISTER:
|
|
|
|
if (!buffer || !ensureBufferClean(buffer))
|
|
|
|
break;
|
|
|
|
if (!buffer->lyxvc().inUse()) {
|
2010-10-17 10:44:53 +00:00
|
|
|
if (buffer->lyxvc().registrer()) {
|
2009-09-12 20:41:24 +00:00
|
|
|
reloadBuffer();
|
2010-10-17 10:44:53 +00:00
|
|
|
dr.suppressMessageUpdate();
|
|
|
|
}
|
2009-09-12 20:41:24 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_CHECK_IN:
|
|
|
|
if (!buffer || !ensureBufferClean(buffer))
|
|
|
|
break;
|
|
|
|
if (buffer->lyxvc().inUse() && !buffer->isReadonly()) {
|
2010-10-17 10:44:53 +00:00
|
|
|
dr.setMessage(buffer->lyxvc().checkIn());
|
|
|
|
if (!dr.message().empty())
|
2010-01-10 15:47:40 +00:00
|
|
|
reloadBuffer();
|
2009-09-12 20:41:24 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_CHECK_OUT:
|
|
|
|
if (!buffer || !ensureBufferClean(buffer))
|
|
|
|
break;
|
|
|
|
if (buffer->lyxvc().inUse()) {
|
2010-10-17 10:44:53 +00:00
|
|
|
dr.setMessage(buffer->lyxvc().checkOut());
|
2009-09-12 20:41:24 +00:00
|
|
|
reloadBuffer();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_LOCKING_TOGGLE:
|
|
|
|
LASSERT(buffer, return);
|
|
|
|
if (!ensureBufferClean(buffer) || buffer->isReadonly())
|
|
|
|
break;
|
|
|
|
if (buffer->lyxvc().inUse()) {
|
|
|
|
string res = buffer->lyxvc().lockingToggle();
|
|
|
|
if (res.empty()) {
|
|
|
|
frontend::Alert::error(_("Revision control error."),
|
|
|
|
_("Error when setting the locking property."));
|
|
|
|
} else {
|
2010-10-17 10:44:53 +00:00
|
|
|
dr.setMessage(res);
|
2009-09-12 20:41:24 +00:00
|
|
|
reloadBuffer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_REVERT:
|
|
|
|
LASSERT(buffer, return);
|
|
|
|
buffer->lyxvc().revert();
|
|
|
|
reloadBuffer();
|
2010-10-17 10:44:53 +00:00
|
|
|
dr.suppressMessageUpdate();
|
2009-09-12 20:41:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_VC_UNDO_LAST:
|
|
|
|
LASSERT(buffer, return);
|
|
|
|
buffer->lyxvc().undoLast();
|
|
|
|
reloadBuffer();
|
2010-10-17 10:44:53 +00:00
|
|
|
dr.suppressMessageUpdate();
|
2009-09-12 20:41:24 +00:00
|
|
|
break;
|
|
|
|
|
2009-10-14 19:18:06 +00:00
|
|
|
case LFUN_VC_REPO_UPDATE:
|
2009-10-06 23:20:52 +00:00
|
|
|
LASSERT(buffer, return);
|
|
|
|
if (ensureBufferClean(buffer)) {
|
2010-10-17 10:44:53 +00:00
|
|
|
dr.setMessage(buffer->lyxvc().repoUpdate());
|
2009-11-24 18:47:43 +00:00
|
|
|
checkExternallyModifiedBuffers();
|
2009-10-06 23:20:52 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-09-12 20:41:24 +00:00
|
|
|
case LFUN_VC_COMMAND: {
|
|
|
|
string flag = cmd.getArg(0);
|
|
|
|
if (buffer && contains(flag, 'R') && !ensureBufferClean(buffer))
|
|
|
|
break;
|
|
|
|
docstring message;
|
|
|
|
if (contains(flag, 'M')) {
|
|
|
|
if (!Alert::askForText(message, _("LyX VC: Log Message")))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
string path = cmd.getArg(1);
|
|
|
|
if (contains(path, "$$p") && buffer)
|
|
|
|
path = subst(path, "$$p", buffer->filePath());
|
|
|
|
LYXERR(Debug::LYXVC, "Directory: " << path);
|
|
|
|
FileName pp(path);
|
|
|
|
if (!pp.isReadableDirectory()) {
|
|
|
|
lyxerr << _("Directory is not accessible.") << endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
support::PathChanger p(pp);
|
|
|
|
|
|
|
|
string command = cmd.getArg(2);
|
|
|
|
if (command.empty())
|
|
|
|
break;
|
|
|
|
if (buffer) {
|
|
|
|
command = subst(command, "$$i", buffer->absFileName());
|
|
|
|
command = subst(command, "$$p", buffer->filePath());
|
|
|
|
}
|
|
|
|
command = subst(command, "$$m", to_utf8(message));
|
|
|
|
LYXERR(Debug::LYXVC, "Command: " << command);
|
|
|
|
Systemcall one;
|
|
|
|
one.startscript(Systemcall::Wait, command);
|
|
|
|
|
|
|
|
if (!buffer)
|
|
|
|
break;
|
|
|
|
if (contains(flag, 'I'))
|
|
|
|
buffer->markDirty();
|
|
|
|
if (contains(flag, 'R'))
|
|
|
|
reloadBuffer();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2010-02-12 14:09:44 +00:00
|
|
|
|
|
|
|
case LFUN_VC_COMPARE: {
|
2010-02-15 07:10:59 +00:00
|
|
|
|
2010-09-07 11:28:57 +00:00
|
|
|
if (cmd.argument().empty()) {
|
|
|
|
lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, "comparehistory"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-02-15 07:10:59 +00:00
|
|
|
string rev1 = cmd.getArg(0);
|
2010-02-12 14:09:44 +00:00
|
|
|
string f1, f2;
|
|
|
|
|
|
|
|
// f1
|
|
|
|
if (!buffer->lyxvc().prepareFileRevision(rev1, f1))
|
|
|
|
break;
|
|
|
|
|
2010-02-15 07:10:59 +00:00
|
|
|
if (isStrInt(rev1) && convert<int>(rev1) <= 0) {
|
2010-02-12 14:09:44 +00:00
|
|
|
f2 = buffer->absFileName();
|
|
|
|
} else {
|
2010-02-15 07:10:59 +00:00
|
|
|
string rev2 = cmd.getArg(1);
|
2010-02-15 09:05:16 +00:00
|
|
|
if (rev2.empty())
|
2010-02-12 14:09:44 +00:00
|
|
|
break;
|
|
|
|
// f2
|
|
|
|
if (!buffer->lyxvc().prepareFileRevision(rev2, f2))
|
|
|
|
break;
|
|
|
|
}
|
2010-09-07 11:29:11 +00:00
|
|
|
|
2010-09-07 11:58:42 +00:00
|
|
|
LYXERR(Debug::LYXVC, "Launching comparison for fetched revisions:\n" <<
|
2010-09-07 11:29:11 +00:00
|
|
|
f1 << "\n" << f2 << "\n" );
|
2010-09-07 19:03:28 +00:00
|
|
|
string par = "compare run " + quoteName(f1) + " " + quoteName(f2);
|
2010-09-07 11:29:02 +00:00
|
|
|
lyx::dispatch(FuncRequest(LFUN_DIALOG_SHOW, par));
|
2010-02-15 09:05:16 +00:00
|
|
|
break;
|
2010-02-12 14:09:44 +00:00
|
|
|
}
|
|
|
|
|
2009-09-21 08:20:02 +00:00
|
|
|
default:
|
|
|
|
break;
|
2009-09-12 20:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-19 16:49:31 +00:00
|
|
|
void GuiView::openChildDocument(string const & fname)
|
|
|
|
{
|
|
|
|
LASSERT(documentBufferView(), return);
|
|
|
|
Buffer & buffer = documentBufferView()->buffer();
|
|
|
|
FileName const filename = support::makeAbsPath(fname, buffer.filePath());
|
|
|
|
documentBufferView()->saveBookmark(false);
|
|
|
|
Buffer * child = 0;
|
|
|
|
bool parsed = false;
|
|
|
|
if (theBufferList().exists(filename)) {
|
|
|
|
child = theBufferList().getBuffer(filename);
|
|
|
|
} else {
|
|
|
|
message(bformat(_("Opening child document %1$s..."),
|
2010-04-21 01:19:09 +00:00
|
|
|
makeDisplayPath(filename.absFileName())));
|
2009-09-19 16:49:31 +00:00
|
|
|
child = loadDocument(filename, false);
|
|
|
|
parsed = true;
|
|
|
|
}
|
|
|
|
if (!child)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Set the parent name of the child document.
|
|
|
|
// This makes insertion of citations and references in the child work,
|
|
|
|
// when the target is in the parent or another child document.
|
|
|
|
child->setParent(&buffer);
|
2010-07-09 14:37:00 +00:00
|
|
|
|
2010-09-07 14:11:28 +00:00
|
|
|
// I don't think this is needed, since it will be called in
|
2010-07-09 14:37:00 +00:00
|
|
|
// setBuffer().
|
|
|
|
// child->masterBuffer()->updateBuffer();
|
2009-09-19 16:49:31 +00:00
|
|
|
setBuffer(child);
|
|
|
|
if (parsed)
|
|
|
|
child->errors("Parse");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-23 13:45:58 +00:00
|
|
|
bool GuiView::goToFileRow(string const & argument)
|
|
|
|
{
|
|
|
|
string file_name;
|
|
|
|
int row;
|
2009-12-22 21:44:14 +00:00
|
|
|
size_t i = argument.find_last_of(' ');
|
|
|
|
if (i != string::npos) {
|
|
|
|
file_name = os::internal_path(trim(argument.substr(0, i)));
|
|
|
|
istringstream is(argument.substr(i + 1));
|
|
|
|
is >> row;
|
|
|
|
if (is.fail())
|
|
|
|
i = string::npos;
|
|
|
|
}
|
|
|
|
if (i == string::npos) {
|
|
|
|
LYXERR0("Wrong argument: " << argument);
|
|
|
|
return false;
|
|
|
|
}
|
2009-09-23 13:45:58 +00:00
|
|
|
Buffer * buf = 0;
|
2010-04-21 01:19:09 +00:00
|
|
|
string const abstmp = package().temp_dir().absFileName();
|
2009-09-23 13:45:58 +00:00
|
|
|
string const realtmp = package().temp_dir().realPath();
|
|
|
|
// We have to use os::path_prefix_is() here, instead of
|
|
|
|
// simply prefixIs(), because the file name comes from
|
|
|
|
// an external application and may need case adjustment.
|
|
|
|
if (os::path_prefix_is(file_name, abstmp, os::CASE_ADJUSTED)
|
|
|
|
|| os::path_prefix_is(file_name, realtmp, os::CASE_ADJUSTED)) {
|
|
|
|
// Needed by inverse dvi search. If it is a file
|
|
|
|
// in tmpdir, call the apropriated function.
|
|
|
|
// If tmpdir is a symlink, we may have the real
|
|
|
|
// path passed back, so we correct for that.
|
|
|
|
if (!prefixIs(file_name, abstmp))
|
|
|
|
file_name = subst(file_name, realtmp, abstmp);
|
|
|
|
buf = theBufferList().getBufferFromTmp(file_name);
|
|
|
|
} else {
|
|
|
|
// Must replace extension of the file to be .lyx
|
|
|
|
// and get full path
|
|
|
|
FileName const s = fileSearch(string(),
|
2010-03-05 18:07:05 +00:00
|
|
|
support::changeExtension(file_name, ".lyx"), "lyx");
|
2009-09-23 13:45:58 +00:00
|
|
|
// Either change buffer or load the file
|
|
|
|
if (theBufferList().exists(s))
|
|
|
|
buf = theBufferList().getBuffer(s);
|
|
|
|
else if (s.exists()) {
|
|
|
|
buf = loadDocument(s);
|
2010-07-09 14:37:00 +00:00
|
|
|
if (!buf)
|
|
|
|
return false;
|
|
|
|
// I don't think this is needed. loadDocument() calls
|
|
|
|
// setBuffer(), which calls updateBuffer().
|
|
|
|
// buf->updateBuffer();
|
2009-09-23 13:45:58 +00:00
|
|
|
buf->errors("Parse");
|
|
|
|
} else {
|
|
|
|
message(bformat(
|
|
|
|
_("File does not exist: %1$s"),
|
|
|
|
makeDisplayPath(file_name)));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setBuffer(buf);
|
|
|
|
documentBufferView()->setCursorFromRow(row);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-07 14:20:58 +00:00
|
|
|
#if (QT_VERSION >= 0x040400)
|
2010-04-05 13:04:52 +00:00
|
|
|
docstring GuiView::GuiViewPrivate::exportAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
|
2009-12-18 22:51:06 +00:00
|
|
|
{
|
2010-01-10 13:25:41 +00:00
|
|
|
bool const update_unincluded =
|
|
|
|
buffer->params().maintain_unincluded_children
|
|
|
|
&& !buffer->params().getIncludedChildren().empty();
|
|
|
|
bool const success = buffer->doExport(format, true, update_unincluded);
|
2009-12-18 22:51:06 +00:00
|
|
|
delete buffer;
|
2010-04-05 13:04:52 +00:00
|
|
|
busyBuffers.remove(orig);
|
2009-12-18 22:51:06 +00:00
|
|
|
return success
|
2009-12-19 20:23:18 +00:00
|
|
|
? bformat(_("Successful export to format: %1$s"), from_utf8(format))
|
|
|
|
: bformat(_("Error exporting to format: %1$s"), from_utf8(format));
|
2009-12-18 22:51:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-05 13:04:52 +00:00
|
|
|
docstring GuiView::GuiViewPrivate::previewAndDestroy(Buffer const * orig, Buffer * buffer, string const & format)
|
2009-12-18 22:51:06 +00:00
|
|
|
{
|
2010-01-10 13:25:41 +00:00
|
|
|
bool const update_unincluded =
|
|
|
|
buffer->params().maintain_unincluded_children
|
|
|
|
&& !buffer->params().getIncludedChildren().empty();
|
|
|
|
bool const success = buffer->preview(format, update_unincluded);
|
2009-12-18 22:51:06 +00:00
|
|
|
delete buffer;
|
2010-04-05 13:04:52 +00:00
|
|
|
busyBuffers.remove(orig);
|
2009-12-18 22:51:06 +00:00
|
|
|
return success
|
2009-12-19 20:23:18 +00:00
|
|
|
? bformat(_("Successful preview of format: %1$s"), from_utf8(format))
|
|
|
|
: bformat(_("Error previewing format: %1$s"), from_utf8(format));
|
2009-12-18 22:51:06 +00:00
|
|
|
}
|
2010-01-07 14:20:58 +00:00
|
|
|
#endif
|
2009-12-18 22:51:06 +00:00
|
|
|
|
|
|
|
|
2010-10-18 10:16:32 +00:00
|
|
|
bool GuiView::GuiViewPrivate::asyncBufferProcessing(
|
2010-10-18 09:31:50 +00:00
|
|
|
string const & argument,
|
|
|
|
Buffer const * used_buffer,
|
|
|
|
docstring const & msg,
|
|
|
|
docstring (*asyncFunc)(Buffer const *, Buffer *, string const &),
|
|
|
|
bool (Buffer::*syncFunc)(string const &, bool, bool) const,
|
|
|
|
bool (Buffer::*previewFunc)(string const &, bool) const)
|
|
|
|
{
|
2010-10-18 10:16:32 +00:00
|
|
|
if (!used_buffer) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-10-18 09:31:50 +00:00
|
|
|
string format = argument;
|
|
|
|
if (format.empty()) {
|
|
|
|
format = used_buffer->getDefaultOutputFormat();
|
|
|
|
}
|
|
|
|
#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
|
|
|
|
if (!msg.empty()) {
|
|
|
|
progress_->clearMessages();
|
|
|
|
gv_->message(msg);
|
|
|
|
}
|
|
|
|
GuiViewPrivate::busyBuffers.insert(used_buffer);
|
|
|
|
QFuture<docstring> f = QtConcurrent::run(
|
|
|
|
asyncFunc,
|
|
|
|
used_buffer,
|
|
|
|
used_buffer->clone(),
|
|
|
|
format);
|
|
|
|
setPreviewFuture(f);
|
|
|
|
last_export_format = used_buffer->bufferFormat();
|
|
|
|
(void) syncFunc;
|
|
|
|
(void) previewFunc;
|
2010-10-18 10:16:32 +00:00
|
|
|
// We are asynchronous, so we don't know here anything about the success
|
|
|
|
return true;
|
2010-10-18 09:31:50 +00:00
|
|
|
#else
|
|
|
|
bool const update_unincluded =
|
|
|
|
used_buffer->params().maintain_unincluded_children &&
|
|
|
|
!used_buffer->params().getIncludedChildren().empty();
|
|
|
|
if (syncFunc) {
|
2010-10-18 10:16:32 +00:00
|
|
|
return (used_buffer->*syncFunc)(format, true, update_unincluded);
|
2010-10-18 09:31:50 +00:00
|
|
|
} else if (previewFunc) {
|
2010-10-18 10:16:32 +00:00
|
|
|
return (used_buffer->*previewFunc)(format, update_unincluded);
|
2010-10-18 09:31:50 +00:00
|
|
|
}
|
|
|
|
(void) asyncFunc;
|
2010-10-18 11:30:30 +00:00
|
|
|
return false;
|
2010-10-18 09:31:50 +00:00
|
|
|
#endif
|
|
|
|
}
|
2010-10-18 08:18:56 +00:00
|
|
|
|
2010-01-29 10:42:39 +00:00
|
|
|
void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
2007-11-12 23:23:19 +00:00
|
|
|
{
|
2009-09-05 14:29:11 +00:00
|
|
|
BufferView * bv = currentBufferView();
|
2007-11-23 11:45:20 +00:00
|
|
|
// By default we won't need any update.
|
2010-10-13 17:28:55 +00:00
|
|
|
dr.screenUpdate(Update::None);
|
2010-01-29 10:42:39 +00:00
|
|
|
// assume cmd will be dispatched
|
|
|
|
dr.dispatched(true);
|
2009-09-12 20:41:24 +00:00
|
|
|
|
|
|
|
Buffer * doc_buffer = documentBufferView()
|
|
|
|
? &(documentBufferView()->buffer()) : 0;
|
|
|
|
|
2010-04-09 19:00:42 +00:00
|
|
|
if (cmd.origin() == FuncRequest::TOC) {
|
2009-04-08 21:06:58 +00:00
|
|
|
GuiToc * toc = static_cast<GuiToc*>(findOrBuild("toc", false));
|
2010-01-29 10:42:39 +00:00
|
|
|
// FIXME: do we need to pass a DispatchResult object here?
|
2009-04-08 21:06:58 +00:00
|
|
|
toc->doDispatch(bv->cursor(), cmd);
|
2010-01-29 10:42:39 +00:00
|
|
|
return;
|
2009-04-08 21:06:58 +00:00
|
|
|
}
|
|
|
|
|
2009-12-18 22:51:06 +00:00
|
|
|
string const argument = to_utf8(cmd.argument());
|
|
|
|
|
2010-04-09 19:00:42 +00:00
|
|
|
switch(cmd.action()) {
|
2009-09-19 16:49:31 +00:00
|
|
|
case LFUN_BUFFER_CHILD_OPEN:
|
|
|
|
openChildDocument(to_utf8(cmd.argument()));
|
|
|
|
break;
|
|
|
|
|
2008-02-06 23:54:13 +00:00
|
|
|
case LFUN_BUFFER_IMPORT:
|
|
|
|
importDocument(to_utf8(cmd.argument()));
|
|
|
|
break;
|
|
|
|
|
2009-12-18 22:51:06 +00:00
|
|
|
case LFUN_BUFFER_EXPORT: {
|
|
|
|
if (!doc_buffer)
|
|
|
|
break;
|
2010-01-30 11:34:28 +00:00
|
|
|
// GCC only sees strfwd.h when building merged
|
|
|
|
if (::lyx::operator==(cmd.argument(), "custom")) {
|
2010-10-18 10:16:32 +00:00
|
|
|
dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"), dr);
|
2009-12-18 22:51:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-10-18 10:16:32 +00:00
|
|
|
#if 0
|
|
|
|
// TODO Remove if we could export asynchronous
|
2010-02-24 17:02:52 +00:00
|
|
|
if (!doc_buffer->doExport(argument, false)) {
|
2010-01-29 10:42:39 +00:00
|
|
|
dr.setError(true);
|
|
|
|
dr.setMessage(bformat(_("Error exporting to format: %1$s."),
|
2009-12-18 22:51:06 +00:00
|
|
|
cmd.argument()));
|
|
|
|
}
|
2010-10-18 10:16:32 +00:00
|
|
|
#else
|
2010-10-18 10:55:01 +00:00
|
|
|
/* TODO/Review: Is it a problem to also export the children?
|
2010-10-18 10:59:23 +00:00
|
|
|
See the update_unincluded flag */
|
2010-10-18 10:16:32 +00:00
|
|
|
d.asyncBufferProcessing(argument,
|
2010-10-18 10:59:23 +00:00
|
|
|
doc_buffer,
|
|
|
|
_("Exporting ..."),
|
|
|
|
&GuiViewPrivate::exportAndDestroy,
|
|
|
|
&Buffer::doExport,
|
|
|
|
0);
|
2010-10-18 10:16:32 +00:00
|
|
|
// TODO Inform user about success
|
|
|
|
#endif
|
2009-12-18 22:51:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_BUFFER_UPDATE: {
|
2010-10-18 09:31:50 +00:00
|
|
|
d.asyncBufferProcessing(argument,
|
2010-10-18 10:59:23 +00:00
|
|
|
doc_buffer,
|
|
|
|
_("Exporting ..."),
|
|
|
|
&GuiViewPrivate::exportAndDestroy,
|
|
|
|
&Buffer::doExport,
|
|
|
|
0);
|
2009-12-18 22:51:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LFUN_BUFFER_VIEW: {
|
2010-10-18 09:31:50 +00:00
|
|
|
d.asyncBufferProcessing(argument,
|
2010-10-18 10:59:23 +00:00
|
|
|
doc_buffer,
|
|
|
|
_("Previewing ..."),
|
|
|
|
&GuiViewPrivate::previewAndDestroy,
|
|
|
|
0,
|
|
|
|
&Buffer::preview);
|
2009-12-18 22:51:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LFUN_MASTER_BUFFER_UPDATE: {
|
2010-10-18 09:31:50 +00:00
|
|
|
d.asyncBufferProcessing(argument,
|
2010-10-18 10:59:23 +00:00
|
|
|
(doc_buffer ? doc_buffer->masterBuffer() : 0),
|
|
|
|
docstring(),
|
|
|
|
&GuiViewPrivate::exportAndDestroy,
|
|
|
|
&Buffer::doExport,
|
|
|
|
0);
|
2009-12-18 22:51:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LFUN_MASTER_BUFFER_VIEW: {
|
2010-10-18 09:31:50 +00:00
|
|
|
d.asyncBufferProcessing(argument,
|
2010-10-18 10:59:23 +00:00
|
|
|
(doc_buffer ? doc_buffer->masterBuffer() : 0),
|
|
|
|
docstring(),
|
|
|
|
&GuiViewPrivate::previewAndDestroy,
|
|
|
|
0, &Buffer::preview);
|
2009-12-18 22:51:06 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-06-07 21:57:37 +00:00
|
|
|
case LFUN_BUFFER_SWITCH: {
|
2010-06-17 21:18:08 +00:00
|
|
|
string const file_name = to_utf8(cmd.argument());
|
|
|
|
if (!FileName::isAbsolute(file_name)) {
|
|
|
|
dr.setError(true);
|
|
|
|
dr.setMessage(_("Absolute filename expected."));
|
2010-06-07 21:57:37 +00:00
|
|
|
break;
|
2010-06-17 21:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Buffer * buffer = theBufferList().getBuffer(FileName(file_name));
|
2010-06-07 21:57:37 +00:00
|
|
|
if (!buffer) {
|
|
|
|
dr.setError(true);
|
|
|
|
dr.setMessage(_("Document not loaded"));
|
|
|
|
break;
|
2010-09-07 14:11:28 +00:00
|
|
|
}
|
2010-06-17 21:18:08 +00:00
|
|
|
|
|
|
|
// Do we open or switch to the buffer in this view ?
|
2010-09-07 14:11:28 +00:00
|
|
|
if (workArea(*buffer)
|
2010-06-17 21:18:08 +00:00
|
|
|
|| lyxrc.open_buffers_in_tabs || !documentBufferView()) {
|
2010-06-07 21:57:37 +00:00
|
|
|
setBuffer(buffer);
|
|
|
|
break;
|
2010-09-07 14:11:28 +00:00
|
|
|
}
|
|
|
|
|
2010-06-17 21:18:08 +00:00
|
|
|
// Look for the buffer in other views
|
2010-06-07 21:57:37 +00:00
|
|
|
QList<int> const ids = guiApp->viewIds();
|
|
|
|
int i = 0;
|
|
|
|
for (; i != ids.size(); ++i) {
|
|
|
|
GuiView & gv = guiApp->view(ids[i]);
|
|
|
|
if (gv.workArea(*buffer)) {
|
|
|
|
gv.activateWindow();
|
|
|
|
gv.setBuffer(buffer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-06-17 21:18:08 +00:00
|
|
|
|
|
|
|
// If necessary, open a new window as a last resort
|
2010-06-07 21:57:37 +00:00
|
|
|
if (i == ids.size()) {
|
2010-06-17 21:18:08 +00:00
|
|
|
lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW));
|
|
|
|
lyx::dispatch(cmd);
|
2009-05-11 23:53:50 +00:00
|
|
|
}
|
2007-11-12 23:23:19 +00:00
|
|
|
break;
|
2010-06-07 21:57:37 +00:00
|
|
|
}
|
2007-11-13 14:04:32 +00:00
|
|
|
|
2007-11-23 12:37:09 +00:00
|
|
|
case LFUN_BUFFER_NEXT:
|
2009-03-25 14:34:42 +00:00
|
|
|
gotoNextOrPreviousBuffer(NEXTBUFFER);
|
2007-11-23 12:37:09 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BUFFER_PREVIOUS:
|
2009-03-25 14:34:42 +00:00
|
|
|
gotoNextOrPreviousBuffer(PREVBUFFER);
|
2007-11-23 12:37:09 +00:00
|
|
|
break;
|
|
|
|
|
2007-11-14 11:14:06 +00:00
|
|
|
case LFUN_COMMAND_EXECUTE: {
|
|
|
|
bool const show_it = cmd.argument() != "off";
|
2008-05-27 11:15:17 +00:00
|
|
|
// FIXME: this is a hack, "minibuffer" should not be
|
|
|
|
// hardcoded.
|
2008-05-27 16:15:56 +00:00
|
|
|
if (GuiToolbar * t = toolbar("minibuffer")) {
|
2008-05-27 11:15:17 +00:00
|
|
|
t->setVisible(show_it);
|
2008-05-27 17:29:36 +00:00
|
|
|
if (show_it && t->commandBuffer())
|
|
|
|
t->commandBuffer()->setFocus();
|
2008-05-27 16:15:56 +00:00
|
|
|
}
|
2007-11-13 14:04:32 +00:00
|
|
|
break;
|
2007-11-14 11:14:06 +00:00
|
|
|
}
|
2007-11-13 14:49:50 +00:00
|
|
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
2009-08-14 22:58:57 +00:00
|
|
|
d.layout_->showPopup();
|
2007-11-13 14:49:50 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_MENU_OPEN:
|
2008-03-09 11:22:39 +00:00
|
|
|
if (QMenu * menu = guiApp->menus().menu(toqstr(cmd.argument()), *this))
|
2007-12-26 12:40:58 +00:00
|
|
|
menu->exec(QCursor::pos());
|
2007-11-13 14:49:50 +00:00
|
|
|
break;
|
|
|
|
|
2007-12-02 17:50:08 +00:00
|
|
|
case LFUN_FILE_INSERT:
|
|
|
|
insertLyXFile(cmd.argument());
|
|
|
|
break;
|
2007-12-02 20:05:17 +00:00
|
|
|
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
|
|
|
|
insertPlaintextFile(cmd.argument(), true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_FILE_INSERT_PLAINTEXT:
|
|
|
|
insertPlaintextFile(cmd.argument(), false);
|
|
|
|
break;
|
|
|
|
|
2009-09-12 20:41:24 +00:00
|
|
|
case LFUN_BUFFER_RELOAD: {
|
2009-09-12 20:55:35 +00:00
|
|
|
LASSERT(doc_buffer, break);
|
2009-09-12 20:41:24 +00:00
|
|
|
docstring const file = makeDisplayPath(doc_buffer->absFileName(), 20);
|
|
|
|
docstring text = bformat(_("Any changes will be lost. Are you sure "
|
2010-03-05 18:07:05 +00:00
|
|
|
"you want to revert to the saved version of the document %1$s?"), file);
|
2009-09-12 20:41:24 +00:00
|
|
|
int const ret = Alert::prompt(_("Revert to saved document?"),
|
|
|
|
text, 1, 1, _("&Revert"), _("&Cancel"));
|
|
|
|
|
2009-11-23 22:40:59 +00:00
|
|
|
if (ret == 0) {
|
|
|
|
doc_buffer->markClean();
|
2009-09-12 20:41:24 +00:00
|
|
|
reloadBuffer();
|
2010-07-09 14:37:00 +00:00
|
|
|
dr.forceBufferUpdate();
|
2009-11-23 22:40:59 +00:00
|
|
|
}
|
2009-09-12 20:41:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-12-04 22:21:25 +00:00
|
|
|
case LFUN_BUFFER_WRITE:
|
2009-09-12 20:55:35 +00:00
|
|
|
LASSERT(doc_buffer, break);
|
|
|
|
saveBuffer(*doc_buffer);
|
2007-12-04 22:21:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BUFFER_WRITE_AS:
|
2009-09-12 20:55:35 +00:00
|
|
|
LASSERT(doc_buffer, break);
|
|
|
|
renameBuffer(*doc_buffer, cmd.argument());
|
2007-12-04 22:21:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BUFFER_WRITE_ALL: {
|
|
|
|
Buffer * first = theBufferList().first();
|
|
|
|
if (!first)
|
|
|
|
break;
|
|
|
|
message(_("Saving all documents..."));
|
|
|
|
// We cannot use a for loop as the buffer list cycles.
|
|
|
|
Buffer * b = first;
|
|
|
|
do {
|
2008-03-26 10:32:20 +00:00
|
|
|
if (!b->isClean()) {
|
|
|
|
saveBuffer(*b);
|
|
|
|
LYXERR(Debug::ACTION, "Saved " << b->absFileName());
|
|
|
|
}
|
2007-12-04 22:21:25 +00:00
|
|
|
b = theBufferList().next(b);
|
2010-09-07 14:11:28 +00:00
|
|
|
} while (b != first);
|
2010-01-30 15:40:18 +00:00
|
|
|
dr.setMessage(_("All documents saved."));
|
2007-12-04 22:21:25 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-12-02 17:50:08 +00:00
|
|
|
|
2009-09-19 14:34:46 +00:00
|
|
|
case LFUN_BUFFER_CLOSE:
|
|
|
|
closeBuffer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_BUFFER_CLOSE_ALL:
|
|
|
|
closeBufferAll();
|
|
|
|
break;
|
|
|
|
|
2007-11-13 14:49:50 +00:00
|
|
|
case LFUN_TOOLBAR_TOGGLE: {
|
|
|
|
string const name = cmd.getArg(0);
|
2008-05-27 11:15:17 +00:00
|
|
|
if (GuiToolbar * t = toolbar(name))
|
|
|
|
t->toggle();
|
2007-11-13 14:49:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-11-19 20:56:05 +00:00
|
|
|
case LFUN_DIALOG_UPDATE: {
|
|
|
|
string const name = to_utf8(cmd.argument());
|
2009-09-27 10:29:13 +00:00
|
|
|
if (currentBufferView()) {
|
|
|
|
Inset * inset = currentBufferView()->editedInset(name);
|
|
|
|
// Can only update a dialog connected to an existing inset
|
|
|
|
if (!inset)
|
|
|
|
break;
|
2009-09-27 10:36:24 +00:00
|
|
|
// FIXME: get rid of this indirection; GuiView ask the inset
|
|
|
|
// if he is kind enough to update itself...
|
2007-11-19 20:56:05 +00:00
|
|
|
FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
|
2010-01-29 10:42:39 +00:00
|
|
|
//FIXME: pass DispatchResult here?
|
2009-09-05 14:29:11 +00:00
|
|
|
inset->dispatch(currentBufferView()->cursor(), fr);
|
2007-11-19 20:56:05 +00:00
|
|
|
} else if (name == "paragraph") {
|
|
|
|
lyx::dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
|
2008-11-23 14:12:39 +00:00
|
|
|
} else if (name == "prefs" || name == "document") {
|
2007-11-19 20:56:05 +00:00
|
|
|
updateDialog(name, string());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_DIALOG_TOGGLE: {
|
|
|
|
if (isDialogVisible(cmd.getArg(0)))
|
2010-01-29 10:42:39 +00:00
|
|
|
dispatch(FuncRequest(LFUN_DIALOG_HIDE, cmd.argument()), dr);
|
2007-11-19 20:56:05 +00:00
|
|
|
else
|
2010-01-29 10:42:39 +00:00
|
|
|
dispatch(FuncRequest(LFUN_DIALOG_SHOW, cmd.argument()), dr);
|
2007-11-19 20:56:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_DIALOG_DISCONNECT_INSET:
|
|
|
|
disconnectDialog(to_utf8(cmd.argument()));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LFUN_DIALOG_HIDE: {
|
|
|
|
guiApp->hideDialogs(to_utf8(cmd.argument()), 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LFUN_DIALOG_SHOW: {
|
|
|
|
string const name = cmd.getArg(0);
|
|
|
|
string data = trim(to_utf8(cmd.argument()).substr(name.size()));
|
|
|
|
|
|
|
|
if (name == "character") {
|
|
|
|
data = freefont2string();
|
|
|
|
if (!data.empty())
|
|
|
|
showDialog("character", data);
|
|
|
|
} else if (name == "latexlog") {
|
2010-09-07 14:11:28 +00:00
|
|
|
Buffer::LogType type;
|
2009-09-12 20:55:35 +00:00
|
|
|
string const logfile = doc_buffer->logName(&type);
|
2007-11-19 20:56:05 +00:00
|
|
|
switch (type) {
|
|
|
|
case Buffer::latexlog:
|
|
|
|
data = "latex ";
|
|
|
|
break;
|
|
|
|
case Buffer::buildlog:
|
|
|
|
data = "literate ";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
data += Lexer::quoteString(logfile);
|
|
|
|
showDialog("log", data);
|
|
|
|
} else if (name == "vclog") {
|
|
|
|
string const data = "vc " +
|
2009-09-12 20:55:35 +00:00
|
|
|
Lexer::quoteString(doc_buffer->lyxvc().getLogFile());
|
2007-11-19 20:56:05 +00:00
|
|
|
showDialog("log", data);
|
2008-02-07 13:18:07 +00:00
|
|
|
} else if (name == "symbols") {
|
|
|
|
data = bv->cursor().getEncoding()->name();
|
|
|
|
if (!data.empty())
|
|
|
|
showDialog("symbols", data);
|
2008-11-15 16:33:02 +00:00
|
|
|
// bug 5274
|
|
|
|
} else if (name == "prefs" && isFullScreen()) {
|
2010-01-30 16:41:28 +00:00
|
|
|
lfunUiToggle("fullscreen");
|
2008-11-15 16:33:02 +00:00
|
|
|
showDialog("prefs", data);
|
2007-11-19 20:56:05 +00:00
|
|
|
} else
|
|
|
|
showDialog(name, data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-09-19 11:54:23 +00:00
|
|
|
case LFUN_MESSAGE:
|
2010-01-30 15:40:18 +00:00
|
|
|
dr.setMessage(cmd.argument());
|
2009-09-19 11:54:23 +00:00
|
|
|
break;
|
|
|
|
|
2010-01-30 16:41:28 +00:00
|
|
|
case LFUN_UI_TOGGLE: {
|
|
|
|
string arg = cmd.getArg(0);
|
|
|
|
if (!lfunUiToggle(arg)) {
|
|
|
|
docstring const msg = "ui-toggle " + _("%1$s unknown command!");
|
|
|
|
dr.setMessage(bformat(msg, from_utf8(arg)));
|
|
|
|
}
|
2008-02-20 15:11:47 +00:00
|
|
|
// Make sure the keyboard focus stays in the work area.
|
|
|
|
setFocus();
|
2008-02-07 00:12:48 +00:00
|
|
|
break;
|
2010-01-30 16:41:28 +00:00
|
|
|
}
|
2008-02-07 00:12:48 +00:00
|
|
|
|
2009-09-12 20:55:35 +00:00
|
|
|
case LFUN_SPLIT_VIEW: {
|
|
|
|
LASSERT(doc_buffer, break);
|
|
|
|
string const orientation = cmd.getArg(0);
|
|
|
|
d.splitter_->setOrientation(orientation == "vertical"
|
|
|
|
? Qt::Vertical : Qt::Horizontal);
|
|
|
|
TabWorkArea * twa = addTabWorkArea();
|
|
|
|
GuiWorkArea * wa = twa->addWorkArea(*doc_buffer, *this);
|
|
|
|
setCurrentWorkArea(wa);
|
2008-02-22 17:36:40 +00:00
|
|
|
break;
|
2009-09-12 20:55:35 +00:00
|
|
|
}
|
2008-02-21 14:53:09 +00:00
|
|
|
case LFUN_CLOSE_TAB_GROUP:
|
2008-02-21 15:09:10 +00:00
|
|
|
if (TabWorkArea * twa = d.currentTabWorkArea()) {
|
2009-08-21 20:29:40 +00:00
|
|
|
closeTabWorkArea(twa);
|
2009-08-15 15:47:12 +00:00
|
|
|
d.current_work_area_ = 0;
|
2008-02-21 15:09:10 +00:00
|
|
|
twa = d.currentTabWorkArea();
|
|
|
|
// Switch to the next GuiWorkArea in the found TabWorkArea.
|
2008-07-10 12:44:50 +00:00
|
|
|
if (twa) {
|
|
|
|
// Make sure the work area is up to date.
|
2008-11-16 01:20:34 +00:00
|
|
|
setCurrentWorkArea(twa->currentWorkArea());
|
2008-07-10 12:44:50 +00:00
|
|
|
} else {
|
2008-11-16 01:20:34 +00:00
|
|
|
setCurrentWorkArea(0);
|
2008-07-10 12:44:50 +00:00
|
|
|
}
|
2008-02-21 15:09:10 +00:00
|
|
|
}
|
2008-02-22 17:36:40 +00:00
|
|
|
break;
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2008-09-08 00:27:07 +00:00
|
|
|
case LFUN_COMPLETION_INLINE:
|
|
|
|
if (d.current_work_area_)
|
|
|
|
d.current_work_area_->completer().showInline();
|
|
|
|
break;
|
|
|
|
|
2008-02-21 19:42:34 +00:00
|
|
|
case LFUN_COMPLETION_POPUP:
|
|
|
|
if (d.current_work_area_)
|
|
|
|
d.current_work_area_->completer().showPopup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case LFUN_COMPLETION_COMPLETE:
|
|
|
|
if (d.current_work_area_)
|
|
|
|
d.current_work_area_->completer().tab();
|
2008-02-21 14:53:09 +00:00
|
|
|
break;
|
|
|
|
|
2008-09-08 00:13:55 +00:00
|
|
|
case LFUN_COMPLETION_CANCEL:
|
|
|
|
if (d.current_work_area_) {
|
|
|
|
if (d.current_work_area_->completer().popupVisible())
|
|
|
|
d.current_work_area_->completer().hidePopup();
|
|
|
|
else
|
|
|
|
d.current_work_area_->completer().hideInline();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-09-08 00:24:47 +00:00
|
|
|
case LFUN_COMPLETION_ACCEPT:
|
|
|
|
if (d.current_work_area_)
|
|
|
|
d.current_work_area_->completer().activate();
|
|
|
|
break;
|
|
|
|
|
2009-04-04 09:14:38 +00:00
|
|
|
case LFUN_BUFFER_ZOOM_IN:
|
|
|
|
case LFUN_BUFFER_ZOOM_OUT:
|
|
|
|
if (cmd.argument().empty()) {
|
2010-04-09 19:00:42 +00:00
|
|
|
if (cmd.action() == LFUN_BUFFER_ZOOM_IN)
|
2009-04-04 09:14:38 +00:00
|
|
|
lyxrc.zoom += 20;
|
|
|
|
else
|
|
|
|
lyxrc.zoom -= 20;
|
|
|
|
} else
|
|
|
|
lyxrc.zoom += convert<int>(cmd.argument());
|
|
|
|
|
|
|
|
if (lyxrc.zoom < 10)
|
|
|
|
lyxrc.zoom = 10;
|
2010-09-07 14:11:28 +00:00
|
|
|
|
2009-04-04 09:14:38 +00:00
|
|
|
// The global QPixmapCache is used in GuiPainter to cache text
|
|
|
|
// painting so we must reset it.
|
|
|
|
QPixmapCache::clear();
|
|
|
|
guiApp->fontLoader().update();
|
|
|
|
lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
|
|
|
|
break;
|
2008-09-08 00:24:47 +00:00
|
|
|
|
2009-09-12 20:41:24 +00:00
|
|
|
case LFUN_VC_REGISTER:
|
|
|
|
case LFUN_VC_CHECK_IN:
|
|
|
|
case LFUN_VC_CHECK_OUT:
|
2009-10-14 19:18:06 +00:00
|
|
|
case LFUN_VC_REPO_UPDATE:
|
2009-09-12 20:41:24 +00:00
|
|
|
case LFUN_VC_LOCKING_TOGGLE:
|
|
|
|
case LFUN_VC_REVERT:
|
|
|
|
case LFUN_VC_UNDO_LAST:
|
|
|
|
case LFUN_VC_COMMAND:
|
2010-02-15 09:05:16 +00:00
|
|
|
case LFUN_VC_COMPARE:
|
2010-10-17 10:44:53 +00:00
|
|
|
dispatchVC(cmd, dr);
|
2009-09-12 20:41:24 +00:00
|
|
|
break;
|
|
|
|
|
2009-09-23 13:45:58 +00:00
|
|
|
case LFUN_SERVER_GOTO_FILE_ROW:
|
|
|
|
goToFileRow(to_utf8(cmd.argument()));
|
|
|
|
break;
|
|
|
|
|
2010-04-15 13:19:48 +00:00
|
|
|
case LFUN_FORWARD_SEARCH: {
|
|
|
|
FileName const path(doc_buffer->temppath());
|
|
|
|
string const texname = doc_buffer->latexName();
|
2010-04-21 01:19:09 +00:00
|
|
|
FileName const dviname(addName(path.absFileName(),
|
2010-04-18 10:54:43 +00:00
|
|
|
support::changeExtension(texname, "dvi")));
|
2010-04-21 01:19:09 +00:00
|
|
|
FileName const pdfname(addName(path.absFileName(),
|
2010-04-18 10:54:43 +00:00
|
|
|
support::changeExtension(texname, "pdf")));
|
|
|
|
if (!dviname.exists() && !pdfname.exists()) {
|
|
|
|
dr.setMessage(_("Please, preview the document first."));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
string outname = dviname.onlyFileName();
|
|
|
|
string command = lyxrc.forward_search_dvi;
|
|
|
|
if (!dviname.exists() ||
|
|
|
|
pdfname.lastModified() > dviname.lastModified()) {
|
|
|
|
outname = pdfname.onlyFileName();
|
2010-04-15 23:32:52 +00:00
|
|
|
command = lyxrc.forward_search_pdf;
|
|
|
|
}
|
2010-04-15 13:19:48 +00:00
|
|
|
|
|
|
|
int row = doc_buffer->texrow().getRowFromIdPos(bv->cursor().paragraph().id(), bv->cursor().pos());
|
2010-04-16 18:30:52 +00:00
|
|
|
LYXERR(Debug::ACTION, "Forward search: row:" << row
|
2010-04-18 10:54:43 +00:00
|
|
|
<< " id:" << bv->cursor().paragraph().id());
|
2010-04-16 08:18:28 +00:00
|
|
|
if (!row || command.empty()) {
|
|
|
|
dr.setMessage(_("Couldn't proceed."));
|
2010-04-15 13:19:48 +00:00
|
|
|
break;
|
2010-04-16 08:18:28 +00:00
|
|
|
}
|
2010-04-15 13:19:48 +00:00
|
|
|
string texrow = convert<string>(row);
|
|
|
|
|
|
|
|
command = subst(command, "$$n", texrow);
|
|
|
|
command = subst(command, "$$t", texname);
|
|
|
|
command = subst(command, "$$o", outname);
|
|
|
|
|
2010-04-15 23:32:52 +00:00
|
|
|
PathChanger p(path);
|
2010-04-15 13:19:48 +00:00
|
|
|
Systemcall one;
|
2010-04-16 16:22:08 +00:00
|
|
|
one.startscript(Systemcall::DontWait, command);
|
2010-04-15 13:19:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-11-12 23:23:19 +00:00
|
|
|
default:
|
2010-01-29 10:42:39 +00:00
|
|
|
dr.dispatched(false);
|
2008-05-15 09:14:09 +00:00
|
|
|
break;
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
2007-11-23 09:44:02 +00:00
|
|
|
|
2008-08-05 13:03:31 +00:00
|
|
|
// Part of automatic menu appearance feature.
|
2008-05-15 11:02:23 +00:00
|
|
|
if (isFullScreen()) {
|
2009-05-26 21:41:45 +00:00
|
|
|
if (menuBar()->isVisible() && lyxrc.full_screen_menubar)
|
2008-05-15 11:02:23 +00:00
|
|
|
menuBar()->hide();
|
|
|
|
if (statusBar()->isVisible())
|
|
|
|
statusBar()->hide();
|
|
|
|
}
|
|
|
|
|
2010-01-29 10:42:39 +00:00
|
|
|
return;
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-30 16:41:28 +00:00
|
|
|
bool GuiView::lfunUiToggle(string const & ui_component)
|
2008-02-09 17:54:28 +00:00
|
|
|
{
|
2010-01-30 16:41:28 +00:00
|
|
|
if (ui_component == "scrollbar") {
|
2008-02-11 23:52:25 +00:00
|
|
|
// hide() is of no help
|
|
|
|
if (d.current_work_area_->verticalScrollBarPolicy() ==
|
|
|
|
Qt::ScrollBarAlwaysOff)
|
|
|
|
|
|
|
|
d.current_work_area_->setVerticalScrollBarPolicy(
|
|
|
|
Qt::ScrollBarAsNeeded);
|
|
|
|
else
|
|
|
|
d.current_work_area_->setVerticalScrollBarPolicy(
|
|
|
|
Qt::ScrollBarAlwaysOff);
|
2010-01-30 16:41:28 +00:00
|
|
|
} else if (ui_component == "statusbar") {
|
2008-02-09 17:54:28 +00:00
|
|
|
statusBar()->setVisible(!statusBar()->isVisible());
|
2010-01-30 16:41:28 +00:00
|
|
|
} else if (ui_component == "menubar") {
|
2008-02-09 17:54:28 +00:00
|
|
|
menuBar()->setVisible(!menuBar()->isVisible());
|
2010-01-30 16:41:28 +00:00
|
|
|
} else
|
2008-02-09 17:54:28 +00:00
|
|
|
#if QT_VERSION >= 0x040300
|
2010-01-30 16:41:28 +00:00
|
|
|
if (ui_component == "frame") {
|
2008-02-09 17:54:28 +00:00
|
|
|
int l, t, r, b;
|
|
|
|
getContentsMargins(&l, &t, &r, &b);
|
|
|
|
//are the frames in default state?
|
2008-03-04 18:53:44 +00:00
|
|
|
d.current_work_area_->setFrameStyle(QFrame::NoFrame);
|
2008-02-09 17:54:28 +00:00
|
|
|
if (l == 0) {
|
|
|
|
setContentsMargins(-2, -2, -2, -2);
|
|
|
|
} else {
|
|
|
|
setContentsMargins(0, 0, 0, 0);
|
|
|
|
}
|
2010-01-30 16:41:28 +00:00
|
|
|
} else
|
2008-02-09 17:54:28 +00:00
|
|
|
#endif
|
2010-01-30 16:41:28 +00:00
|
|
|
if (ui_component == "fullscreen") {
|
2008-05-27 12:01:50 +00:00
|
|
|
toggleFullScreen();
|
2010-01-30 16:41:28 +00:00
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
return true;
|
2008-05-27 12:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::toggleFullScreen()
|
|
|
|
{
|
2008-02-09 17:54:28 +00:00
|
|
|
if (isFullScreen()) {
|
2008-02-20 14:27:52 +00:00
|
|
|
for (int i = 0; i != d.splitter_->count(); ++i)
|
|
|
|
d.tabWorkArea(i)->setFullScreen(false);
|
2008-02-09 17:54:28 +00:00
|
|
|
#if QT_VERSION >= 0x040300
|
|
|
|
setContentsMargins(0, 0, 0, 0);
|
|
|
|
#endif
|
2008-03-30 22:27:17 +00:00
|
|
|
setWindowState(windowState() ^ Qt::WindowFullScreen);
|
2008-05-27 13:30:40 +00:00
|
|
|
restoreLayout();
|
2008-02-09 17:54:28 +00:00
|
|
|
menuBar()->show();
|
|
|
|
statusBar()->show();
|
|
|
|
} else {
|
2008-11-15 16:33:02 +00:00
|
|
|
// bug 5274
|
|
|
|
hideDialogs("prefs", 0);
|
2008-02-09 18:29:15 +00:00
|
|
|
for (int i = 0; i != d.splitter_->count(); ++i)
|
|
|
|
d.tabWorkArea(i)->setFullScreen(true);
|
2008-02-09 17:54:28 +00:00
|
|
|
#if QT_VERSION >= 0x040300
|
|
|
|
setContentsMargins(-2, -2, -2, -2);
|
|
|
|
#endif
|
2008-05-27 13:16:50 +00:00
|
|
|
saveLayout();
|
2008-03-30 22:27:17 +00:00
|
|
|
setWindowState(windowState() ^ Qt::WindowFullScreen);
|
2008-02-20 14:27:52 +00:00
|
|
|
statusBar()->hide();
|
2009-05-26 21:41:45 +00:00
|
|
|
if (lyxrc.full_screen_menubar)
|
|
|
|
menuBar()->hide();
|
2008-05-27 11:34:59 +00:00
|
|
|
if (lyxrc.full_screen_toolbars) {
|
|
|
|
ToolbarMap::iterator end = d.toolbars_.end();
|
|
|
|
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
|
|
|
it->second->hide();
|
|
|
|
}
|
2008-02-09 17:54:28 +00:00
|
|
|
}
|
2008-10-23 20:46:53 +00:00
|
|
|
|
|
|
|
// give dialogs like the TOC a chance to adapt
|
|
|
|
updateDialogs();
|
2008-02-09 17:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-12 23:23:19 +00:00
|
|
|
Buffer const * GuiView::updateInset(Inset const * inset)
|
|
|
|
{
|
2010-04-05 14:24:27 +00:00
|
|
|
if (!inset)
|
2007-11-12 23:23:19 +00:00
|
|
|
return 0;
|
|
|
|
|
2010-04-05 14:24:27 +00:00
|
|
|
Buffer const * inset_buffer = &(inset->buffer());
|
2007-11-13 09:52:28 +00:00
|
|
|
|
2010-04-05 14:24:27 +00:00
|
|
|
for (int i = 0; i != d.splitter_->count(); ++i) {
|
|
|
|
GuiWorkArea * wa = d.tabWorkArea(i)->currentWorkArea();
|
|
|
|
if (!wa)
|
|
|
|
continue;
|
|
|
|
Buffer const * buffer = &(wa->bufferView().buffer());
|
|
|
|
if (inset_buffer == buffer)
|
|
|
|
wa->scheduleRedraw();
|
|
|
|
}
|
|
|
|
return inset_buffer;
|
2007-11-13 09:52:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::restartCursor()
|
|
|
|
{
|
|
|
|
/* When we move around, or type, it's nice to be able to see
|
|
|
|
* the cursor immediately after the keypress.
|
|
|
|
*/
|
|
|
|
if (d.current_work_area_)
|
|
|
|
d.current_work_area_->startBlinkingCursor();
|
2007-11-20 22:23:06 +00:00
|
|
|
|
2008-02-27 11:23:41 +00:00
|
|
|
// Take this occasion to update the other GUI elements.
|
2008-05-02 20:58:25 +00:00
|
|
|
updateDialogs();
|
2008-06-12 16:00:36 +00:00
|
|
|
updateStatusBar();
|
2007-11-12 23:23:19 +00:00
|
|
|
}
|
|
|
|
|
2008-02-21 19:42:34 +00:00
|
|
|
|
2008-02-29 09:18:46 +00:00
|
|
|
void GuiView::updateCompletion(Cursor & cur, bool start, bool keep)
|
2008-02-21 19:42:34 +00:00
|
|
|
{
|
|
|
|
if (d.current_work_area_)
|
2008-02-29 09:18:46 +00:00
|
|
|
d.current_work_area_->completer().updateVisibility(cur, start, keep);
|
2008-02-21 19:42:34 +00:00
|
|
|
}
|
|
|
|
|
2007-11-18 23:49:52 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
// This list should be kept in sync with the list of insets in
|
|
|
|
// src/insets/Inset.cpp. I.e., if a dialog goes with an inset, the
|
|
|
|
// dialog should have the same name as the inset.
|
2008-06-24 23:07:38 +00:00
|
|
|
// Changes should be also recorded in LFUN_DIALOG_SHOW doxygen
|
|
|
|
// docs in LyXAction.cpp.
|
2007-11-18 23:49:52 +00:00
|
|
|
|
|
|
|
char const * const dialognames[] = {
|
2010-09-07 11:28:57 +00:00
|
|
|
|
2007-11-18 23:49:52 +00:00
|
|
|
"aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
|
2010-09-07 11:28:57 +00:00
|
|
|
"citation", "compare", "comparehistory", "document", "errorlist", "ert",
|
|
|
|
"external", "file", "findreplace", "findreplaceadv", "float", "graphics",
|
|
|
|
"href", "include", "index", "index_print", "info", "listings", "label", "line",
|
2010-09-07 00:41:00 +00:00
|
|
|
"log", "mathdelimiter", "mathmatrix", "mathspace", "nomenclature",
|
|
|
|
"nomencl_print", "note", "paragraph", "phantom", "prefs", "print", "ref",
|
|
|
|
"sendto", "space", "spellchecker", "symbols", "tabular", "tabularcreate",
|
2010-09-07 11:28:57 +00:00
|
|
|
"thesaurus", "texinfo", "toc", "view-source", "vspace", "wrap", "progress"};
|
2007-11-18 23:49:52 +00:00
|
|
|
|
|
|
|
char const * const * const end_dialognames =
|
|
|
|
dialognames + (sizeof(dialognames) / sizeof(char *));
|
|
|
|
|
|
|
|
class cmpCStr {
|
|
|
|
public:
|
|
|
|
cmpCStr(char const * name) : name_(name) {}
|
|
|
|
bool operator()(char const * other) {
|
|
|
|
return strcmp(other, name_) == 0;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
char const * name_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
bool isValidName(string const & name)
|
|
|
|
{
|
2007-12-12 19:28:07 +00:00
|
|
|
return find_if(dialognames, end_dialognames,
|
2010-03-05 18:07:05 +00:00
|
|
|
cmpCStr(name.c_str())) != end_dialognames;
|
2007-11-18 23:49:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
2007-11-18 00:01:14 +00:00
|
|
|
|
2007-11-21 15:12:47 +00:00
|
|
|
void GuiView::resetDialogs()
|
|
|
|
{
|
2010-02-09 17:06:40 +00:00
|
|
|
// Make sure that no LFUN uses any GuiView.
|
2009-09-22 21:25:32 +00:00
|
|
|
guiApp->setCurrentView(0);
|
2008-06-25 18:03:38 +00:00
|
|
|
saveLayout();
|
|
|
|
menuBar()->clear();
|
|
|
|
constructToolbars();
|
2008-10-22 18:02:09 +00:00
|
|
|
guiApp->menus().fillMenuBar(menuBar(), this, false);
|
2009-08-14 22:58:57 +00:00
|
|
|
d.layout_->updateContents(true);
|
2007-11-22 07:33:18 +00:00
|
|
|
// Now update controls with current buffer.
|
2009-09-22 21:25:32 +00:00
|
|
|
guiApp->setCurrentView(this);
|
2008-06-25 18:03:38 +00:00
|
|
|
restoreLayout();
|
2007-11-22 07:33:18 +00:00
|
|
|
restartCursor();
|
2007-11-21 15:12:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-25 07:23:30 +00:00
|
|
|
Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
|
2007-11-18 00:01:14 +00:00
|
|
|
{
|
|
|
|
if (!isValidName(name))
|
|
|
|
return 0;
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
map<string, DialogPtr>::iterator it = d.dialogs_.find(name);
|
2007-11-18 00:01:14 +00:00
|
|
|
|
2008-10-03 13:17:22 +00:00
|
|
|
if (it != d.dialogs_.end()) {
|
|
|
|
if (hide_it)
|
|
|
|
it->second->hideView();
|
2007-11-18 00:01:14 +00:00
|
|
|
return it->second.get();
|
2008-10-03 13:17:22 +00:00
|
|
|
}
|
2007-11-18 00:01:14 +00:00
|
|
|
|
2007-12-10 13:05:00 +00:00
|
|
|
Dialog * dialog = build(name);
|
|
|
|
d.dialogs_[name].reset(dialog);
|
|
|
|
if (lyxrc.allow_geometry_session)
|
|
|
|
dialog->restoreSession();
|
2008-06-25 07:23:30 +00:00
|
|
|
if (hide_it)
|
|
|
|
dialog->hideView();
|
2007-12-10 13:05:00 +00:00
|
|
|
return dialog;
|
2007-11-18 00:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::showDialog(string const & name, string const & data,
|
|
|
|
Inset * inset)
|
2009-12-21 13:11:17 +00:00
|
|
|
{
|
|
|
|
triggerShowDialog(toqstr(name), toqstr(data), inset);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::doShowDialog(QString const & qname, QString const & qdata,
|
|
|
|
Inset * inset)
|
2007-11-18 00:01:14 +00:00
|
|
|
{
|
2007-11-18 23:30:41 +00:00
|
|
|
if (d.in_show_)
|
2007-11-18 00:01:14 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-21 13:11:17 +00:00
|
|
|
const string name = fromqstr(qname);
|
|
|
|
const string data = fromqstr(qdata);
|
|
|
|
|
2007-11-18 23:30:41 +00:00
|
|
|
d.in_show_ = true;
|
2008-08-13 14:25:56 +00:00
|
|
|
try {
|
|
|
|
Dialog * dialog = findOrBuild(name, false);
|
|
|
|
if (dialog) {
|
2010-04-26 10:03:09 +00:00
|
|
|
bool const visible = dialog->isVisibleView();
|
2008-08-13 14:25:56 +00:00
|
|
|
dialog->showData(data);
|
2009-09-27 10:29:13 +00:00
|
|
|
if (inset && currentBufferView())
|
|
|
|
currentBufferView()->editInset(name, inset);
|
2010-04-26 10:03:09 +00:00
|
|
|
// We only set the focus to the new dialog if it was not yet
|
|
|
|
// visible in order not to change the existing previous behaviour
|
2010-09-07 14:11:28 +00:00
|
|
|
if (visible) {
|
2010-04-26 10:03:09 +00:00
|
|
|
// activateWindow is needed for floating dockviews
|
2010-04-26 10:26:06 +00:00
|
|
|
dialog->asQWidget()->raise();
|
2010-04-26 10:03:09 +00:00
|
|
|
dialog->asQWidget()->activateWindow();
|
|
|
|
dialog->asQWidget()->setFocus();
|
|
|
|
}
|
2008-08-13 14:25:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (ExceptionMessage const & ex) {
|
|
|
|
d.in_show_ = false;
|
|
|
|
throw ex;
|
2007-11-18 00:01:14 +00:00
|
|
|
}
|
2007-11-18 23:30:41 +00:00
|
|
|
d.in_show_ = false;
|
2007-11-18 00:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GuiView::isDialogVisible(string const & name) const
|
|
|
|
{
|
2007-12-12 19:28:07 +00:00
|
|
|
map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (it == d.dialogs_.end())
|
|
|
|
return false;
|
2009-05-14 23:46:42 +00:00
|
|
|
return it->second.get()->isVisibleView() && !it->second.get()->isClosing();
|
2007-11-18 00:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::hideDialog(string const & name, Inset * inset)
|
|
|
|
{
|
2007-12-12 19:28:07 +00:00
|
|
|
map<string, DialogPtr>::const_iterator it = d.dialogs_.find(name);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (it == d.dialogs_.end())
|
|
|
|
return;
|
|
|
|
|
2009-09-27 10:29:13 +00:00
|
|
|
if (inset && currentBufferView()
|
|
|
|
&& inset != currentBufferView()->editedInset(name))
|
2007-11-18 00:01:14 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
Dialog * const dialog = it->second.get();
|
|
|
|
if (dialog->isVisibleView())
|
2007-12-09 22:35:04 +00:00
|
|
|
dialog->hideView();
|
2009-09-27 10:29:13 +00:00
|
|
|
if (currentBufferView())
|
|
|
|
currentBufferView()->editInset(name, 0);
|
2007-11-18 00:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::disconnectDialog(string const & name)
|
|
|
|
{
|
|
|
|
if (!isValidName(name))
|
|
|
|
return;
|
2009-09-27 10:29:13 +00:00
|
|
|
if (currentBufferView())
|
|
|
|
currentBufferView()->editInset(name, 0);
|
2007-11-18 00:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiView::hideAll() const
|
|
|
|
{
|
2007-12-12 19:28:07 +00:00
|
|
|
map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
|
|
|
|
map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
|
2007-11-18 00:01:14 +00:00
|
|
|
|
|
|
|
for(; it != end; ++it)
|
2007-12-09 22:35:04 +00:00
|
|
|
it->second->hideView();
|
2007-11-18 00:01:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-27 22:24:20 +00:00
|
|
|
void GuiView::updateDialogs()
|
2007-11-18 00:01:14 +00:00
|
|
|
{
|
2007-12-12 19:28:07 +00:00
|
|
|
map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
|
|
|
|
map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
|
2007-11-18 00:01:14 +00:00
|
|
|
|
|
|
|
for(; it != end; ++it) {
|
|
|
|
Dialog * dialog = it->second.get();
|
2010-01-13 20:25:17 +00:00
|
|
|
if (dialog) {
|
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
|
|
|
if (dialog->needBufferOpen() && !documentBufferView())
|
2010-01-13 20:25:17 +00:00
|
|
|
hideDialog(fromqstr(dialog->name()), 0);
|
|
|
|
else if (dialog->isVisibleView())
|
|
|
|
dialog->checkStatus();
|
|
|
|
}
|
2007-11-18 00:01:14 +00:00
|
|
|
}
|
2008-04-27 22:24:20 +00:00
|
|
|
updateToolbars();
|
|
|
|
updateLayoutList();
|
2007-11-18 00:01:14 +00:00
|
|
|
}
|
|
|
|
|
2010-02-15 23:17:45 +00:00
|
|
|
Dialog * createDialog(GuiView & lv, string const & name);
|
2007-11-18 00:01:14 +00:00
|
|
|
|
|
|
|
// will be replaced by a proper factory...
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiAbout(GuiView & lv);
|
|
|
|
Dialog * createGuiBibtex(GuiView & lv);
|
|
|
|
Dialog * createGuiChanges(GuiView & lv);
|
|
|
|
Dialog * createGuiCharacter(GuiView & lv);
|
|
|
|
Dialog * createGuiCitation(GuiView & lv);
|
2009-10-24 15:47:05 +00:00
|
|
|
Dialog * createGuiCompare(GuiView & lv);
|
2010-09-07 11:28:57 +00:00
|
|
|
Dialog * createGuiCompareHistory(GuiView & lv);
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiDelimiter(GuiView & lv);
|
|
|
|
Dialog * createGuiDocument(GuiView & lv);
|
|
|
|
Dialog * createGuiErrorList(GuiView & lv);
|
|
|
|
Dialog * createGuiExternal(GuiView & lv);
|
|
|
|
Dialog * createGuiGraphics(GuiView & lv);
|
|
|
|
Dialog * createGuiInclude(GuiView & lv);
|
2009-04-17 09:22:44 +00:00
|
|
|
Dialog * createGuiIndex(GuiView & lv);
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiLabel(GuiView & lv);
|
|
|
|
Dialog * createGuiListings(GuiView & lv);
|
|
|
|
Dialog * createGuiLog(GuiView & lv);
|
|
|
|
Dialog * createGuiMathMatrix(GuiView & lv);
|
|
|
|
Dialog * createGuiNomenclature(GuiView & lv);
|
2009-01-25 23:50:54 +00:00
|
|
|
Dialog * createGuiNote(GuiView & lv);
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiParagraph(GuiView & lv);
|
2009-02-05 18:09:36 +00:00
|
|
|
Dialog * createGuiPhantom(GuiView & lv);
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiPreferences(GuiView & lv);
|
|
|
|
Dialog * createGuiPrint(GuiView & lv);
|
2009-04-17 14:29:32 +00:00
|
|
|
Dialog * createGuiPrintindex(GuiView & lv);
|
2009-05-22 16:26:15 +00:00
|
|
|
Dialog * createGuiPrintNomencl(GuiView & lv);
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiRef(GuiView & lv);
|
|
|
|
Dialog * createGuiSearch(GuiView & lv);
|
2008-11-16 01:20:34 +00:00
|
|
|
Dialog * createGuiSearchAdv(GuiView & lv);
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiSendTo(GuiView & lv);
|
|
|
|
Dialog * createGuiShowFile(GuiView & lv);
|
|
|
|
Dialog * createGuiSpellchecker(GuiView & lv);
|
2008-02-07 13:18:07 +00:00
|
|
|
Dialog * createGuiSymbols(GuiView & lv);
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiTabularCreate(GuiView & lv);
|
|
|
|
Dialog * createGuiTexInfo(GuiView & lv);
|
|
|
|
Dialog * createGuiToc(GuiView & lv);
|
|
|
|
Dialog * createGuiThesaurus(GuiView & lv);
|
|
|
|
Dialog * createGuiHyperlink(GuiView & lv);
|
|
|
|
Dialog * createGuiViewSource(GuiView & lv);
|
|
|
|
Dialog * createGuiWrap(GuiView & lv);
|
2009-12-22 10:04:30 +00:00
|
|
|
Dialog * createGuiProgressView(GuiView & lv);
|
2009-12-21 11:48:19 +00:00
|
|
|
|
|
|
|
|
2007-11-18 00:01:14 +00:00
|
|
|
|
|
|
|
Dialog * GuiView::build(string const & name)
|
|
|
|
{
|
2008-09-29 08:42:18 +00:00
|
|
|
LASSERT(isValidName(name), return 0);
|
2007-11-18 00:01:14 +00:00
|
|
|
|
2010-02-15 23:17:45 +00:00
|
|
|
Dialog * dialog = createDialog(*this, name);
|
|
|
|
if (dialog)
|
|
|
|
return dialog;
|
|
|
|
|
2007-11-18 00:01:14 +00:00
|
|
|
if (name == "aboutlyx")
|
|
|
|
return createGuiAbout(*this);
|
|
|
|
if (name == "bibtex")
|
|
|
|
return createGuiBibtex(*this);
|
|
|
|
if (name == "changes")
|
|
|
|
return createGuiChanges(*this);
|
|
|
|
if (name == "character")
|
|
|
|
return createGuiCharacter(*this);
|
|
|
|
if (name == "citation")
|
|
|
|
return createGuiCitation(*this);
|
2009-10-24 15:47:05 +00:00
|
|
|
if (name == "compare")
|
|
|
|
return createGuiCompare(*this);
|
2010-09-07 11:28:57 +00:00
|
|
|
if (name == "comparehistory")
|
|
|
|
return createGuiCompareHistory(*this);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (name == "document")
|
|
|
|
return createGuiDocument(*this);
|
|
|
|
if (name == "errorlist")
|
|
|
|
return createGuiErrorList(*this);
|
|
|
|
if (name == "external")
|
|
|
|
return createGuiExternal(*this);
|
|
|
|
if (name == "file")
|
|
|
|
return createGuiShowFile(*this);
|
|
|
|
if (name == "findreplace")
|
|
|
|
return createGuiSearch(*this);
|
2008-11-16 01:20:34 +00:00
|
|
|
if (name == "findreplaceadv")
|
|
|
|
return createGuiSearchAdv(*this);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (name == "graphics")
|
|
|
|
return createGuiGraphics(*this);
|
2009-05-22 16:41:20 +00:00
|
|
|
if (name == "href")
|
|
|
|
return createGuiHyperlink(*this);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (name == "include")
|
|
|
|
return createGuiInclude(*this);
|
2009-04-17 09:22:44 +00:00
|
|
|
if (name == "index")
|
|
|
|
return createGuiIndex(*this);
|
2009-05-22 16:41:20 +00:00
|
|
|
if (name == "index_print")
|
|
|
|
return createGuiPrintindex(*this);
|
2010-09-07 14:11:28 +00:00
|
|
|
if (name == "label")
|
|
|
|
return createGuiLabel(*this);
|
2009-05-22 16:41:20 +00:00
|
|
|
if (name == "listings")
|
|
|
|
return createGuiListings(*this);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (name == "log")
|
|
|
|
return createGuiLog(*this);
|
|
|
|
if (name == "mathdelimiter")
|
|
|
|
return createGuiDelimiter(*this);
|
|
|
|
if (name == "mathmatrix")
|
|
|
|
return createGuiMathMatrix(*this);
|
2009-05-22 16:41:20 +00:00
|
|
|
if (name == "nomenclature")
|
|
|
|
return createGuiNomenclature(*this);
|
|
|
|
if (name == "nomencl_print")
|
|
|
|
return createGuiPrintNomencl(*this);
|
2009-01-25 23:50:54 +00:00
|
|
|
if (name == "note")
|
|
|
|
return createGuiNote(*this);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (name == "paragraph")
|
|
|
|
return createGuiParagraph(*this);
|
2009-02-05 18:09:36 +00:00
|
|
|
if (name == "phantom")
|
|
|
|
return createGuiPhantom(*this);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (name == "prefs")
|
|
|
|
return createGuiPreferences(*this);
|
|
|
|
if (name == "print")
|
|
|
|
return createGuiPrint(*this);
|
|
|
|
if (name == "ref")
|
|
|
|
return createGuiRef(*this);
|
|
|
|
if (name == "sendto")
|
|
|
|
return createGuiSendTo(*this);
|
|
|
|
if (name == "spellchecker")
|
|
|
|
return createGuiSpellchecker(*this);
|
2008-02-07 13:18:07 +00:00
|
|
|
if (name == "symbols")
|
|
|
|
return createGuiSymbols(*this);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (name == "tabularcreate")
|
|
|
|
return createGuiTabularCreate(*this);
|
|
|
|
if (name == "texinfo")
|
|
|
|
return createGuiTexInfo(*this);
|
|
|
|
if (name == "thesaurus")
|
|
|
|
return createGuiThesaurus(*this);
|
2009-02-05 18:09:36 +00:00
|
|
|
if (name == "toc")
|
|
|
|
return createGuiToc(*this);
|
2009-05-22 16:41:20 +00:00
|
|
|
if (name == "view-source")
|
|
|
|
return createGuiViewSource(*this);
|
2007-11-18 00:01:14 +00:00
|
|
|
if (name == "wrap")
|
|
|
|
return createGuiWrap(*this);
|
2009-12-22 10:04:30 +00:00
|
|
|
if (name == "progress")
|
|
|
|
return createGuiProgressView(*this);
|
2007-11-18 00:01:14 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiView.cpp"
|