#include "Session.h"
#include "version.h"
+#include "support/assert.h"
#include "support/debug.h"
#include "support/ExceptionMessage.h"
#include "support/FileName.h"
if (lyxrc.quit_on_last_window_closed)
setQuitOnLastWindowClosed(false);
*/
-#ifdef Q_WS_MAC
+#ifdef Q_WS_MACX
// FIXME: Do we need a lyxrc setting for this on Mac? This behaviour
// seems to be the default case for applications like LyX.
setQuitOnLastWindowClosed(false);
case LFUN_LYX_QUIT:
// quitting is triggered by the gui code
// (leaving the event loop).
- current_view_->message(from_utf8(N_("Exiting.")));
+ if (current_view_)
+ current_view_->message(from_utf8(N_("Exiting.")));
if (closeAllViews())
quit();
break;
case LFUN_BUFFER_NEW:
if (viewCount() == 0
- || (!lyxrc.open_buffers_in_tabs && current_view_->buffer() != 0))
- createView();
- current_view_->newDocument(to_utf8(cmd.argument()), false);
+ || (!lyxrc.open_buffers_in_tabs && current_view_->buffer() != 0)) {
+ createView(QString(), false); // keep hidden
+ current_view_->newDocument(to_utf8(cmd.argument()), false);
+ current_view_->show();
+ setActiveWindow(current_view_);
+ } else
+ current_view_->newDocument(to_utf8(cmd.argument()), false);
break;
case LFUN_BUFFER_NEW_TEMPLATE:
}
-void GuiApplication::createView(QString const & geometry_arg)
+void GuiApplication::createView(QString const & geometry_arg, bool autoShow)
{
// release the keyboard which might have been grabed by the global
// menubar on Mac to catch shortcuts even without any GuiView.
views_[id] = view;
updateIds(views_, view_ids_);
- view->show();
+ if (autoShow) {
+ view->show();
+ setActiveWindow(view);
+ }
+
if (!geometry_arg.isEmpty()) {
#ifdef Q_WS_WIN
int x, y;
#endif
}
view->setFocus();
- setActiveWindow(view);
- setCurrentView(*view);
+ setCurrentView(view);
}
docstring details = e.details_ + '\n';
details += theBufferList().emergencyWrite(buf);
theBufferList().release(buf);
- details += _("\nThe current document was closed.");
+ details += "\n" + _("The current document was closed.");
Alert::error(e.title_, details);
return false;
}
case WarningException:
Alert::warning(e.title_, e.details_);
return false;
- };
+ }
}
catch (exception const & e) {
docstring s = _("LyX has caught an exception, it will now "
bool GuiApplication::unregisterView(int id)
{
updateIds(views_, view_ids_);
- BOOST_ASSERT(views_.find(id) != views_.end());
- BOOST_ASSERT(views_[id]);
+ LASSERT(views_.find(id) != views_.end(), /**/);
+ LASSERT(views_[id], /**/);
map<int, GuiView *>::iterator it;
for (it = views_.begin(); it != views_.end(); ++it) {
GuiView & GuiApplication::view(int id) const
{
- BOOST_ASSERT(views_.find(id) != views_.end());
+ LASSERT(views_.find(id) != views_.end(), /**/);
return *views_.find(id)->second;
}
void GuiApplication::initGlobalMenu()
{
if (global_menubar_)
- menus().fillMenuBar(global_menubar_, 0);
+ menus().fillMenuBar(global_menubar_, 0, true);
}
global_menubar_->grabKeyboard();
}
+
////////////////////////////////////////////////////////////////////////
+//
// X11 specific stuff goes here...
+
#ifdef Q_WS_X11
bool GuiApplication::x11EventFilter(XEvent * xev)
{
} // namespace frontend
+void hideDialogs(std::string const & name, Inset * inset)
+{
+ if (theApp())
+ theApp()->hideDialogs(name, inset);
+}
+
+
////////////////////////////////////////////////////////////////////
//
// Font stuff
frontend::FontLoader & theFontLoader()
{
- BOOST_ASSERT(frontend::guiApp);
+ LASSERT(frontend::guiApp, /**/);
return frontend::guiApp->fontLoader();
}
frontend::FontMetrics const & theFontMetrics(FontInfo const & f)
{
- BOOST_ASSERT(frontend::guiApp);
+ LASSERT(frontend::guiApp, /**/);
return frontend::guiApp->fontLoader().metrics(f);
}
+////////////////////////////////////////////////////////////////////
+//
+// Misc stuff
+//
+////////////////////////////////////////////////////////////////////
+
frontend::Clipboard & theClipboard()
{
- BOOST_ASSERT(frontend::guiApp);
+ LASSERT(frontend::guiApp, /**/);
return frontend::guiApp->clipboard();
}
frontend::Selection & theSelection()
{
- BOOST_ASSERT(frontend::guiApp);
+ LASSERT(frontend::guiApp, /**/);
return frontend::guiApp->selection();
}