#define EXPORT_in_THREAD 1
-// QtConcurrent was introduced in Qt 4.4
-#if (QT_VERSION >= 0x040400)
#include <QFuture>
#include <QFutureWatcher>
#include <QtConcurrentRun>
-#endif
#include "support/bind.h"
return count;
}
-#if (QT_VERSION >= 0x040400)
void setPreviewFuture(QFuture<Buffer::ExportStatus> const & f)
{
if (processing_thread_watcher_.isRunning()) {
}
processing_thread_watcher_.setFuture(f);
}
-#endif
public:
GuiView * gv_;
///
TocModels toc_models_;
-#if (QT_VERSION >= 0x040400)
///
QFutureWatcher<docstring> autosave_watcher_;
QFutureWatcher<Buffer::ExportStatus> processing_thread_watcher_;
///
string last_export_format;
string processing_format;
-#else
- struct DummyWatcher { bool isRunning(){return false;} };
- DummyWatcher processing_thread_watcher_;
-#endif
static QSet<Buffer const *> busyBuffers;
static Buffer::ExportStatus previewAndDestroy(Buffer const * orig, Buffer * buffer, string const & format);
#endif
-#if (QT_VERSION >= 0x040300)
// use tabbed dock area for multiple docks
// (such as "source" and "messages")
setDockOptions(QMainWindow::ForceTabbedDocks);
-#endif
// For Drag&Drop.
setAcceptDrops(true);
-#if (QT_VERSION >= 0x040400)
-
// add busy indicator to statusbar
QLabel * busylabel = new QLabel(statusBar());
statusBar()->addPermanentWidget(busylabel);
connect(&d.processing_thread_watcher_, SIGNAL(finished()), this,
SLOT(processingThreadFinished()));
-#endif
-
connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
SLOT(doShowDialog(QString const &, QString const &, Inset *)));
}
-#if QT_VERSION >= 0x040400
-
void GuiView::processingThreadStarted()
{
}
updateToolbars();
}
-#else
-
-void GuiView::processingThreadStarted()
-{
-}
-
-
-void GuiView::processingThreadFinished()
-{
-}
-
-
-void GuiView::autoSaveThreadFinished()
-{
-}
-#endif
-
void GuiView::saveLayout() const
{
}
if (visibility & Toolbars::BOTTOM) {
- // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
-#if (QT_VERSION >= 0x040202)
if (newline)
addToolBarBreak(Qt::BottomToolBarArea);
-#endif
addToolBar(Qt::BottomToolBarArea, tb);
}
if (visibility & Toolbars::LEFT) {
- // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
-#if (QT_VERSION >= 0x040202)
if (newline)
addToolBarBreak(Qt::LeftToolBarArea);
-#endif
addToolBar(Qt::LeftToolBarArea, tb);
}
if (visibility & Toolbars::RIGHT) {
- // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
-#if (QT_VERSION >= 0x040202)
if (newline)
addToolBarBreak(Qt::RightToolBarArea);
-#endif
addToolBar(Qt::RightToolBarArea, tb);
}
}
case QEvent::ShortcutOverride: {
-
-// See bug 4888
-#if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
+ // See bug 4888
if (isFullScreen() && menuBar()->isHidden()) {
QKeyEvent * ke = static_cast<QKeyEvent*>(e);
// FIXME: we should also try to detect special LyX shortcut such as
return QMainWindow::event(e);
}
}
-#endif
return QMainWindow::event(e);
}
if (!bv)
return;
-#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
+#if EXPORT_in_THREAD
// We are called with from_master == false by default, so we
// have to figure out whether that is the case or not.
ErrorList & el = bv->buffer().errorList(error_type);
}
-#if (QT_VERSION >= 0x040400)
docstring GuiView::GuiViewPrivate::autosaveAndDestroy(
Buffer const * orig, Buffer * clone)
{
? _("Automatic save done.")
: _("Automatic save failed!");
}
-#endif
void GuiView::autoSave()
}
-#if (QT_VERSION >= 0x040400)
template<class T>
Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func, Buffer const * orig, Buffer * clone, string const & format)
{
return runAndDestroy(lyx::bind(mem_func, clone, _1), orig, clone, format);
}
-#else
-
-// not used, but the linker needs them
-
-Buffer::ExportStatus GuiView::GuiViewPrivate::compileAndDestroy(
- Buffer const *, Buffer *, string const &)
-{
- return Buffer::ExportSuccess;
-}
-
-
-Buffer::ExportStatus GuiView::GuiViewPrivate::exportAndDestroy(
- Buffer const *, Buffer *, string const &)
-{
- return Buffer::ExportSuccess;
-}
-
-
-Buffer::ExportStatus GuiView::GuiViewPrivate::previewAndDestroy(
- Buffer const *, Buffer *, string const &)
-{
- return Buffer::ExportSuccess;
-}
-
-#endif
-
bool GuiView::GuiViewPrivate::asyncBufferProcessing(
string const & argument,
if (format.empty())
format = used_buffer->params().getDefaultOutputFormat();
processing_format = format;
-#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
+#if EXPORT_in_THREAD
if (!msg.empty()) {
progress_->clearMessages();
gv_->message(msg);
dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"), dr);
break;
}
-#if QT_VERSION < 0x040400
- if (!doc_buffer->doExport(argument, false)) {
- dr.setError(true);
- dr.setMessage(bformat(_("Error exporting to format: %1$s"),
- cmd.argument()));
- }
-#else
/* TODO/Review: Is it a problem to also export the children?
See the update_unincluded flag */
d.asyncBufferProcessing(argument,
&Buffer::doExport,
0);
// TODO Inform user about success
-#endif
break;
}
} else if (ui_component == "menubar") {
menuBar()->setVisible(!menuBar()->isVisible());
} else
-#if QT_VERSION >= 0x040300
if (ui_component == "frame") {
int l, t, r, b;
getContentsMargins(&l, &t, &r, &b);
setContentsMargins(0, 0, 0, 0);
}
} else
-#endif
if (ui_component == "fullscreen") {
toggleFullScreen();
} else
if (isFullScreen()) {
for (int i = 0; i != d.splitter_->count(); ++i)
d.tabWorkArea(i)->setFullScreen(false);
-#if QT_VERSION >= 0x040300
setContentsMargins(0, 0, 0, 0);
-#endif
setWindowState(windowState() ^ Qt::WindowFullScreen);
restoreLayout();
menuBar()->show();
hideDialogs("prefs", 0);
for (int i = 0; i != d.splitter_->count(); ++i)
d.tabWorkArea(i)->setFullScreen(true);
-#if QT_VERSION >= 0x040300
setContentsMargins(-2, -2, -2, -2);
-#endif
saveLayout();
setWindowState(windowState() ^ Qt::WindowFullScreen);
statusBar()->hide();
// Example for the format: "Sun Nov 6 10:39:39 2011\n"
// Generously remove trailing '\n' (and other whitespace if needed)
t = trim(t, " \t\r\n");
-#if QT_VERSION >= 0x040400
// toDateTime() is too stupid to recognize variable amounts of
// whitespace (needed because ctime() outputs double spaces before
// single digit day numbers and hours)
return static_cast<time_t>(-1);
}
return loc_dt.toTime_t();
-#elif defined(_WIN32)
-#error "The minimum required Qt version on windows is Qt 4.4."
-#else
- // strptime() is not available on windows (defined by POSIX)
-
- // strptime() uses the current locale, so we need to switch to "C"
- LYXERR(Debug::LOCALE, "Setting LC_ALL and LC_TIME to C");
- string oldLC_ALL = getEnv("LC_ALL");
- string oldLC_TIME = getEnv("LC_TIME");
- if (!setEnv("LC_ALL", "C"))
- LYXERR(Debug::LOCALE, "\t... LC_ALL failed!");
- if (!setEnv("LC_TIME", "C"))
- LYXERR(Debug::LOCALE, "\t... LC_TIME failed!");
-
- struct tm loc_tm;
- char const * const format = "%a%n%b%n%d%n%T%n%Y";
- char * remainder = strptime(t.c_str(), format, &loc_tm);
-
- LYXERR(Debug::LOCALE, "Resetting LC_ALL and LC_TIME");
- if(!setEnv("LC_TIME", oldLC_TIME))
- LYXERR(Debug::LOCALE, "\t... LC_TIME failed!");
- if (!setEnv("LC_ALL", oldLC_ALL))
- LYXERR(Debug::LOCALE, "\t... LC_ALL failed!");
-
- if (!remainder) {
- LYXERR(Debug::LOCALE, "Could not parse `" << t
- << "´ (invalid format)");
- return static_cast<time_t>(-1);
- }
- if (*remainder != '\0') {
- LYXERR(Debug::LOCALE, "Could not parse `" << t
- << "´ (excess characters)");
- return static_cast<time_t>(-1);
- }
- return mktime(&loc_tm);
-#endif
}
} // namespace support