return;
/// The text to be written on top of the pixmap
QString const htext = qt_("The Document\nProcessor[[welcome banner]]");
- QString const htextsize = qt_("1.0[[possibly scale the welcome banner text size]]");
+ QString const htextsize = qt_("1.0[[translating this to different value scales the welcome banner text size for your language]]");
/// The text to be written on top of the pixmap
QString const text = lyx_version ?
qt_("version ") + lyx_version : qt_("unknown version");
-#if QT_VERSION >= 0x050000
QString imagedir = "images/";
FileName fname = imageLibFileSearch(imagedir, "banner", "svgz");
QSvgRenderer svgRenderer(toqstr(fname.absFileName()));
} else {
splash_ = getPixmap("images/", "banner", "png");
}
-#else
- splash_ = getPixmap("images/", "banner", "svgz,png");
-#endif
QPainter pain(&splash_);
pain.setPen(QColor(0, 0, 0));
/// Current ratio between physical pixels and device-independent pixels
double pixelRatio() const {
-#if QT_VERSION >= 0x050000
return qt_scale_factor * devicePixelRatio();
-#else
- return 1.0;
-#endif
}
qreal fontSize() const {
/// Ratio between physical pixels and device-independent pixels of splash image
double splashPixelRatio() const {
-#if QT_VERSION >= 0x050000
return splash_.devicePixelRatio();
-#else
- return 1.0;
-#endif
}
};
setAttribute(Qt::WA_DeleteOnClose, true);
#if !(defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)) && !defined(Q_OS_MAC)
- // QIcon::fromTheme was introduced in Qt 4.6
-#if (QT_VERSION >= 0x040600)
// assign an icon to main form. We do not do it under Qt/Win or Qt/Mac,
// since the icon is provided in the application bundle. We use a themed
// version when available and use the bundled one as fallback.
setWindowIcon(QIcon::fromTheme("lyx", getPixmap("images/", "lyx", "svg,png")));
-#else
- setWindowIcon(getPixmap("images/", "lyx", "svg,png"));
-#endif
#endif
resetWindowTitle();
processStop, SLOT(show()));
connect(&d.processing_thread_watcher_, SIGNAL(finished()),
processStop, SLOT(hide()));
- connect(processStop, SIGNAL(pressed()), this, SLOT(checkCancelBackground()));
+ connect(processStop, SIGNAL(clicked()), this, SLOT(checkCancelBackground()));
+
+ connect(this, SIGNAL(scriptKilled()), busySVG, SLOT(hide()));
+ connect(this, SIGNAL(scriptKilled()), processStop, SLOT(hide()));
stat_counts_ = new GuiClickableLabel(statusBar());
stat_counts_->setAlignment(Qt::AlignCenter);
- stat_counts_->setFrameStyle(QFrame::StyledPanel);
stat_counts_->hide();
statusBar()->addPermanentWidget(stat_counts_);
connect(stat_counts_, SIGNAL(clicked()), this, SLOT(statsPressed()));
zoom_slider_ = new QSlider(Qt::Horizontal, statusBar());
- // Small size slider for macOS to prevent the status bar from enlarging
- zoom_slider_->setAttribute(Qt::WA_MacSmallSize);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
zoom_slider_->setFixedWidth(fm.horizontalAdvance('x') * 15);
#else
zoom_out_->setFixedSize(s);
zoom_out_->setAlignment(Qt::AlignCenter);
- statusBar()->addPermanentWidget(zoom_out_);
- zoom_out_->setEnabled(currentBufferView());
- statusBar()->addPermanentWidget(zoom_slider_);
+
+ zoom_widget_ = new QWidget(statusBar());
+ zoom_widget_->setAttribute(Qt::WA_MacSmallSize);
+ zoom_widget_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
+ zoom_widget_->setLayout(new QHBoxLayout());
+ zoom_widget_->layout()->setSpacing(5);
+ zoom_widget_->layout()->setContentsMargins(0,0,0,0);
+ zoom_widget_->layout()->addWidget(zoom_out_);
+ zoom_widget_->layout()->addWidget(zoom_slider_);
+ zoom_widget_->layout()->addWidget(zoom_in_);
+ statusBar()->addPermanentWidget(zoom_widget_);
+ zoom_out_->setEnabled(currentBufferView()
+ && zoom_slider_->value() > zoom_slider_->minimum());
zoom_slider_->setEnabled(currentBufferView());
- zoom_in_->setEnabled(currentBufferView());
- statusBar()->addPermanentWidget(zoom_in_);
+ zoom_in_->setEnabled(currentBufferView()
+ && zoom_slider_->value() < zoom_slider_->maximum());
connect(zoom_slider_, SIGNAL(sliderMoved(int)), this, SLOT(zoomSliderMoved(int)));
connect(zoom_slider_, SIGNAL(valueChanged(int)), this, SLOT(zoomValueChanged(int)));
connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
SLOT(doShowDialog(QString const &, QString const &, Inset *)));
- // set custom application bars context menu, e.g. tool bar and menu bar
- setContextMenuPolicy(Qt::CustomContextMenu);
- connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
- SLOT(toolBarPopup(const QPoint &)));
-
// Forbid too small unresizable window because it can happen
// with some window manager under X11.
setMinimumSize(300, 200);
int const ret =
Alert::prompt(ttl, msg, 1, 1,
_("&Cancel export"), _("Co&ntinue"));
- if (ret == 0)
- Systemcall::killscript();
+ if (ret == 0) {
+ cancelExport();
+ }
}
void GuiView::statsPressed()
dispatch(FuncRequest(LFUN_BUFFER_ZOOM, convert<string>(value)), dr);
scheduleRedrawWorkAreas();
zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), value)));
+ zoom_in_->setEnabled(currentBufferView()
+ && value < zoom_slider_->maximum());
+ zoom_out_->setEnabled(currentBufferView()
+ && value > zoom_slider_->minimum());
}
settings.setValue("devel_mode", devel_mode_);
settings.beginGroup("views");
settings.beginGroup(QString::number(id_));
- if (guiApp->platformName() == "qt4x11" || guiApp->platformName() == "xcb") {
+ if (guiApp->platformName() == "xcb") {
settings.setValue("pos", pos());
settings.setValue("size", size());
} else
settings.setValue("layout", saveState(0));
settings.setValue("icon_size", toqstr(d.iconSize(iconSize())));
settings.setValue("zoom_value_visible", zoom_value_->isVisible());
- settings.setValue("zoom_slider_visible", zoom_slider_->isVisible());
+ settings.setValue("zoom_slider_visible", zoom_widget_->isVisible());
settings.setValue("word_count_enabled", word_count_enabled_);
settings.setValue("char_count_enabled", char_count_enabled_);
settings.setValue("char_nb_count_enabled", char_nb_count_enabled_);
void GuiView::setCurrentZoom(const int v)
{
+ Q_EMIT currentZoomChanged(v);
lyxrc.currentZoom = v;
zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), v)));
- Q_EMIT currentZoomChanged(v);
+ zoom_in_->setEnabled(currentBufferView() && v < zoom_slider_->maximum());
+ zoom_out_->setEnabled(currentBufferView() && v > zoom_slider_->minimum());
}
zoom_value_->setVisible(settings.value("zoom_value_visible", true).toBool());
bool const show_zoom_slider = settings.value("zoom_slider_visible", true).toBool();
- zoom_slider_->setVisible(show_zoom_slider);
- zoom_in_->setVisible(show_zoom_slider);
- zoom_out_->setVisible(show_zoom_slider);
+ zoom_widget_->setVisible(show_zoom_slider);
word_count_enabled_ = settings.value("word_count_enabled", true).toBool();
char_count_enabled_ = settings.value("char_count_enabled", true).toBool();
char_nb_count_enabled_ = settings.value("char_nb_count_enabled", true).toBool();
stat_counts_->setVisible(word_count_enabled_ || char_count_enabled_ || char_nb_count_enabled_);
- if (guiApp->platformName() == "qt4x11" || guiApp->platformName() == "xcb") {
+ if (guiApp->platformName() == "xcb") {
QPoint pos = settings.value("pos", QPoint(50, 50)).toPoint();
QSize size = settings.value("size", QSize(690, 510)).toSize();
resize(size);
if (tb && tb->isMovable())
toolbarsMovable_ = true;
}
-#if QT_VERSION >= 0x050200
// set unified mac toolbars only when not movable as recommended:
// https://doc.qt.io/qt-5/qmainwindow.html#unifiedTitleAndToolBarOnMac-prop
setUnifiedTitleAndToolBarOnMac(!toolbarsMovable_);
-#endif
}
{
LYXERR(Debug::DEBUG, "GuiView::closeEvent()");
+ // FIXME Bug #12828 bites here. If there is some other View open, then
+ // we really should only refuse to close if one of the Buffers open here
+ // is being processed.
if (!GuiViewPrivate::busyBuffers.isEmpty()) {
Alert::warning(_("Exit LyX"),
_("LyX could not be closed because documents are being processed by LyX."));
// buffer-save has changed too.
updateToolbars();
}
-#ifndef Q_WS_MAC
title += from_ascii(" - LyX");
-#endif
setWindowTitle(toqstr(title));
// Sets the path for the window: this is used by OSX to
// allow a context click on the title bar showing a menu
updateDialogs();
zoom_slider_->setEnabled(currentBufferView());
zoom_value_->setEnabled(currentBufferView());
- zoom_in_->setEnabled(currentBufferView());
- zoom_out_->setEnabled(currentBufferView());
+ zoom_in_->setEnabled(currentBufferView()
+ && zoom_slider_->value() < zoom_slider_->maximum());
+ zoom_out_->setEnabled(currentBufferView()
+ && zoom_slider_->value() > zoom_slider_->minimum());
}
return QMainWindow::event(e);
}
- case QEvent::ApplicationPaletteChange: {
- // runtime switch from/to dark mode
- refillToolbars();
- return QMainWindow::event(e);
- }
-
case QEvent::Gesture: {
QGestureEvent *ge = static_cast<QGestureEvent*>(e);
QGesture *gp = ge->gesture(Qt::PinchGesture);
return QMainWindow::event(e);
}
+ // dark/light mode runtime switch support, OS-dependent.
+ // 1. Mac OS X
+ // Limit to Q_OS_MAC as this unnecessarily would also
+ // trigger on Linux with grave performance issues
+#ifdef Q_OS_MAC
+ case QEvent::ApplicationPaletteChange: {
+ // We need to update metrics here to avoid a crash (#12786)
+ theBufferList().changed(true);
+ refillToolbars();
+ return QMainWindow::event(e);
+ }
+#endif
+ // 2. Linux
+ case QEvent::StyleChange: {
+ // We need to update metrics here to avoid a crash (#12786)
+ theBufferList().changed(true);
+ return QMainWindow::event(e);
+ }
+
default:
return QMainWindow::event(e);
}
double GuiView::pixelRatio() const
{
-#if QT_VERSION >= 0x050000
return qt_scale_factor * devicePixelRatio();
-#else
- return 1.0;
-#endif
}
QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
this, SLOT(on_lastWorkAreaRemoved()));
- d.splitter_->addWidget(twa);
+ d.splitter_->insertWidget(d.splitter_->indexOf(d.currentTabWorkArea()) + 1,
+ twa);
d.stack_widget_->setCurrentWidget(d.splitter_);
return twa;
}
break;
}
+ case LFUN_CHANGES_TRACK: {
+ if (!doc_buffer) {
+ enable = false;
+ break;
+ }
+ return doc_buffer->getStatus(cmd, flag);
+ }
+
case LFUN_VIEW_SPLIT:
if (cmd.getArg(0) == "vertical")
enable = doc_buffer && (d.splitter_->count() == 1 ||
d.splitter_->orientation() == Qt::Horizontal);
break;
+ case LFUN_TAB_GROUP_NEXT:
+ case LFUN_TAB_GROUP_PREVIOUS:
+ enable = (d.splitter_->count() > 1);
+ break;
+
case LFUN_TAB_GROUP_CLOSE:
enable = d.tabWorkAreaCount() > 1;
break;
if (cmd.argument() == "zoomlevel") {
flag.setOnOff(zoom_value_ ? zoom_value_->isVisible() : false);
} else if (cmd.argument() == "zoomslider") {
- flag.setOnOff(zoom_slider_ ? zoom_slider_->isVisible() : false);
+ flag.setOnOff(zoom_widget_ ? zoom_widget_->isVisible() : false);
} else if (cmd.argument() == "statistics-w") {
flag.setOnOff(word_count_enabled_);
} else if (cmd.argument() == "statistics-cb") {
}
-void GuiView::openDocument(string const & fname)
+void GuiView::openDocuments(string const & fname, int origin)
{
string initpath = lyxrc.document_path;
initpath = trypath;
}
- string filename;
+ QStringList files;
if (fname.empty()) {
- FileDialog dlg(qt_("Select document to open"));
+ FileDialog dlg(qt_("Select documents to open"));
dlg.setButton1(qt_("D&ocuments"), toqstr(lyxrc.document_path));
dlg.setButton2(qt_("&Examples"), toqstr(lyxrc.example_path));
QStringList const filter({
qt_("LyX Documents (*.lyx)"),
qt_("LyX Document Backups (*.lyx~)"),
- qt_("All Files (*.*)")
+ qt_("All Files") + " " + wildcardAllFiles()
});
- FileDialog::Result result =
- dlg.open(toqstr(initpath), filter);
+ FileDialog::Results results =
+ dlg.openMulti(toqstr(initpath), filter);
- if (result.first == FileDialog::Later)
+ if (results.first == FileDialog::Later)
return;
- filename = fromqstr(result.second);
+ files = results.second;
// check selected filename
- if (filename.empty()) {
+ if (files.isEmpty()) {
message(_("Canceled."));
return;
}
} else
- filename = fname;
-
- // get absolute path of file and add ".lyx" to the filename if
- // necessary.
- FileName const fullname =
- fileSearch(string(), filename, "lyx", support::may_not_exist);
- if (!fullname.empty())
- filename = fullname.absFileName();
-
- if (!fullname.onlyPath().isDirectory()) {
- Alert::warning(_("Invalid filename"),
- bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
- from_utf8(fullname.absFileName())));
- return;
- }
+ files << toqstr(fname);
+
+ // iterate over all selected files
+ for (auto const & file : files) {
+ string filename = fromqstr(file);
+
+ // get absolute path of file and add ".lyx" to the filename if
+ // necessary.
+ FileName const fullname =
+ fileSearch(string(), filename, "lyx", support::may_not_exist);
+ if (!fullname.empty())
+ filename = fullname.absFileName();
+
+ if (!fullname.onlyPath().isDirectory()) {
+ Alert::warning(_("Invalid filename"),
+ bformat(_("The directory in the given path\n%1$s\ndoes not exist."),
+ from_utf8(fullname.absFileName())));
+ continue;
+ }
- // if the file doesn't exist and isn't already open (bug 6645),
- // let the user create one
- if (!fullname.exists() && !theBufferList().exists(fullname) &&
- !LyXVC::file_not_found_hook(fullname)) {
- // the user specifically chose this name. Believe him.
- Buffer * const b = newFile(filename, string(), true);
- if (b)
- setBuffer(b);
- return;
- }
+ // if the file doesn't exist and isn't already open (bug 6645),
+ // let the user create one
+ if (!fullname.exists() && !theBufferList().exists(fullname) &&
+ !LyXVC::file_not_found_hook(fullname)) {
+ // see bug #12609
+ if (origin == FuncRequest::MENU) {
+ docstring const & msg =
+ bformat(_("File\n"
+ "%1$s\n"
+ "does not exist. Create empty file?"),
+ from_utf8(filename));
+ int ret = Alert::prompt(_("File does not exist"),
+ msg, 0, 1,
+ _("Create &File"),
+ _("&Cancel"));
+ if (ret == 1)
+ continue;
+ }
+ Buffer * const b = newFile(filename, string(), true);
+ if (b)
+ setBuffer(b);
+ continue;
+ }
- docstring const disp_fn = makeDisplayPath(filename);
- message(bformat(_("Opening document %1$s..."), disp_fn));
+ docstring const disp_fn = makeDisplayPath(filename);
+ message(bformat(_("Opening document %1$s..."), disp_fn));
- docstring str2;
- Buffer * buf = loadDocument(fullname);
- if (buf) {
- str2 = bformat(_("Document %1$s opened."), disp_fn);
- if (buf->lyxvc().inUse())
- str2 += " " + from_utf8(buf->lyxvc().versionString()) +
- " " + _("Version control detected.");
- } else {
- str2 = bformat(_("Could not open document %1$s"), disp_fn);
+ docstring str2;
+ Buffer * buf = loadDocument(fullname);
+ if (buf) {
+ str2 = bformat(_("Document %1$s opened."), disp_fn);
+ if (buf->lyxvc().inUse())
+ str2 += " " + from_utf8(buf->lyxvc().versionString()) +
+ " " + _("Version control detected.");
+ } else {
+ str2 = bformat(_("Could not open document %1$s"), disp_fn);
+ }
+ message(str2);
}
- message(str2);
}
// FIXME: clean that
for (int i = 0; i < nwa; ++i) {
if (&workArea(i)->bufferView().buffer() == curbuf) {
int next_index;
- if (np == NEXTBUFFER)
+ if (np == NEXT)
next_index = (i == nwa - 1 ? 0 : i + 1);
else
next_index = (i == 0 ? nwa - 1 : i - 1);
}
+void GuiView::gotoNextTabWorkArea(NextOrPrevious np)
+{
+ int count = d.splitter_->count();
+ for (int i = 0; i < count; ++i) {
+ if (d.tabWorkArea(i) == d.currentTabWorkArea()) {
+ int new_index;
+ if (np == NEXT)
+ new_index = (i == count - 1 ? 0 : i + 1);
+ else
+ new_index = (i == 0 ? count - 1 : i - 1);
+ setCurrentWorkArea(d.tabWorkArea(new_index)->currentWorkArea());
+ break;
+ }
+ }
+}
+
+
/// make sure the document is saved
static bool ensureBufferClean(Buffer * buffer)
{
}
-void GuiView::toolBarPopup(const QPoint & /*pos*/)
-{
- QMenu * menu = guiApp->menus().menu(toqstr("context-toolbars"), * this);
- menu->exec(QCursor::pos());
-}
-
-
template<class T>
Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func,
Buffer const * orig, Buffer * clone, string const & format)
break;
}
case LFUN_EXPORT_CANCEL: {
- Systemcall::killscript();
+ cancelExport();
break;
}
case LFUN_BUFFER_SWITCH: {
}
case LFUN_BUFFER_NEXT:
- gotoNextOrPreviousBuffer(NEXTBUFFER, false);
+ gotoNextOrPreviousBuffer(NEXT, false);
break;
case LFUN_BUFFER_MOVE_NEXT:
- gotoNextOrPreviousBuffer(NEXTBUFFER, true);
+ gotoNextOrPreviousBuffer(NEXT, true);
break;
case LFUN_BUFFER_PREVIOUS:
- gotoNextOrPreviousBuffer(PREVBUFFER, false);
+ gotoNextOrPreviousBuffer(PREV, false);
break;
case LFUN_BUFFER_MOVE_PREVIOUS:
- gotoNextOrPreviousBuffer(PREVBUFFER, true);
+ gotoNextOrPreviousBuffer(PREV, true);
break;
case LFUN_BUFFER_CHKTEX:
doc_buffer->runChktex();
break;
+ case LFUN_CHANGES_TRACK: {
+ // the actual dispatch is done in Buffer
+ dispatchToBufferView(cmd, dr);
+ // but we inform the GUI (document settings) if this is toggled
+ LASSERT(doc_buffer, break);
+ Q_EMIT changeTrackingToggled(doc_buffer->params().track_changes);
+ break;
+ }
+
case LFUN_COMMAND_EXECUTE: {
command_execute_ = true;
minibuffer_focus_ = true;
FileDialog dlg(qt_("Select file to insert"));
FileDialog::Result result = dlg.open(toqstr(bv->buffer().filePath()),
- QStringList(qt_("All Files (*)")));
+ QStringList(qt_("All Files")+ " " + wildcardAllFiles()));
if (result.first == FileDialog::Later || result.second.isEmpty()) {
dr.setMessage(_("Canceled."));
? Qt::Vertical : Qt::Horizontal);
TabWorkArea * twa = addTabWorkArea();
GuiWorkArea * wa = twa->addWorkArea(*doc_buffer, *this);
+
+ wa->bufferView().copySettingsFrom(*bv);
+ dr.screenUpdate(Update::ForceAll);
setCurrentWorkArea(wa);
break;
}
+
+ case LFUN_TAB_GROUP_NEXT:
+ gotoNextTabWorkArea(NEXT);
+ break;
+
+ case LFUN_TAB_GROUP_PREVIOUS:
+ gotoNextTabWorkArea(PREV);
+ break;
+
case LFUN_TAB_GROUP_CLOSE:
if (TabWorkArea * twa = d.currentTabWorkArea()) {
closeTabWorkArea(twa);
break;
case LFUN_CITATION_OPEN: {
- string pdfv, psv;
- if (theFormats().getFormat("pdf"))
- pdfv = theFormats().getFormat("pdf")->viewer();
- if (theFormats().getFormat("ps"))
- psv = theFormats().getFormat("ps")->viewer();
- frontend::showTarget(argument, pdfv, psv);
+ LASSERT(doc_buffer, break);
+ frontend::showTarget(argument, *doc_buffer);
break;
}
} else if (ui_component == "zoomlevel") {
zoom_value_->setVisible(!zoom_value_->isVisible());
} else if (ui_component == "zoomslider") {
- zoom_slider_->setVisible(!zoom_slider_->isVisible());
- zoom_in_->setVisible(zoom_slider_->isVisible());
- zoom_out_->setVisible(zoom_slider_->isVisible());
+ zoom_widget_->setVisible(!zoom_widget_->isVisible());
} else if (ui_component == "statistics-w") {
word_count_enabled_ = !word_count_enabled_;
if (statsEnabled())
}
+void GuiView::cancelExport()
+{
+ Systemcall::killscript();
+ // stop busy signal immediately so that in the subsequent
+ // "Export canceled" prompt the status bar icons are accurate.
+ Q_EMIT scriptKilled();
+}
+
+
void GuiView::toggleFullScreen()
{
setWindowState(windowState() ^ Qt::WindowFullScreen);
return dialog;
dialog = build(name);
- d.dialogs_[name].reset(dialog);
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
- // Force a uniform style for group boxes
- // On Mac non-flat works better, on Linux flat is standard
- flatGroupBoxes(dialog->asQWidget(), guiApp->platformName() != "cocoa");
-#endif
- if (lyxrc.allow_geometry_session)
- dialog->restoreSession();
- if (hide_it)
- dialog->hideView();
+ if (dialog) {
+
+ d.dialogs_[name].reset(dialog);
+ // Force a uniform style for group boxes
+ // On Mac non-flat works better, on Linux flat is standard
+ flatGroupBoxes(dialog->asQWidget(), guiApp->platformName() != "cocoa");
+ if (lyxrc.allow_geometry_session)
+ dialog->restoreSession();
+ if (hide_it)
+ dialog->hideView();
+ }
return dialog;
}