There is a chance that this code is still useful for Qt 4. We keep
it around just in case.
For the case of Qt 4, this commit restores the code changed in
f8e40f8a, d255339a, and d4ff3a29.
Use QFontMetrics::boundingRect() instead. QFontMetrics::width() does
not actually calculate the width of the bounding box and is mostly
useful for knowing where to draw text after a string, taking into
account bearings. Indeed, it has been renamed to
QFontMetrics::horizontalAdvance().
For the code touched in this commit, we want to center a string.
Either method would likely be fine, but it is more easy to
understand exactly what QFontMetrics::boundingRect() does.
This commit does change functionality, although it should not be
noticeable.
Setting the family to "family" is already attempted above. A
different case was adapted to be this duplicate case at d4ff3a29,
but it should have just been removed.
Spotted by Enrico.
This commit fixes the following warning from Qt 5.14:
error: ‘void QTreeWidgetItem::setTextColor(int, const QColor&)’ is deprecated: Use QTreeWidgetItem::setForeground() instead [-Werror=deprecated-declarations]
setForeground was introduced in Qt 4.2 [1].
We have a couple of commented out uses of a setTextColor() method in
GuiDocument.cpp, but the QTextEdit::setTextColor() is not deprecated so no
change is needed.
[1] https://doc.qt.io/archives/qt-4.8/qtreewidgetitem.html#setForeground
This commit fixes a few warnings from Qt 5.14 like the following
one:
error: ‘void QComboBox::setAutoCompletion(bool)’ is deprecated: Use setCompleter() instead. [-Werror=deprecated-declarations]
We only generated setAutoCompletion() from setting the property in
the .ui files. There does not seem to be a .ui file property that
generates setCompleter(). However, the default in both Qt5 [1] and
Qt4 [2] is to enable case-insensitive autocompletion, which seems to
be the same type of autocompletion as when we were relying on
setAutoCompletion(true). Thus, we can remove the properties that set
autocomplete to true. There is only one file, SearchUi.ui, where we
were turning off the autocompletion; we now do so using
setCompleter(0) in GuiSearch::GuiSearch().
[1] https://doc.qt.io/qt-5/qcombobox.html#setCompleter
[2] https://doc.qt.io/archives/qt-4.8/qcombobox.html#setCompleter
Using a dialog may trigger a redraw at times where the metrics caches
have not been updated yet. To fix this, do as in paintEvent() and
abort caret blinking if there is an open undo group.
Move the decision to skip the caret painting to showCaret(), closer to
where real work happens. hideCaret () is now an alias for
showCaret(false), which allows some code refactoring.
See also commit c7496a11b2.
Fixes bug #11763 (although it does not trigger on master).
This is a mode for includeonly handling that is effective and still outputs
at least mostly correct counters and references. This is intended for non-
final editing work.
File format change.
Fix warnings coming from deprecations of QTextEdit::tabStopWidth()
and QFontMetrics::width(). Regarding tabStopWidth(), the ChangeLog
states the following [1]:
Introduced tabStopDistance property in QTextOption, QTextEdit and
QPlainTextEdit as replacement for the inconsistently named tabStop and
tabStopWidth properties. QTextOption::tabStop, QTextEdit::tabStopWidth and
QPlainTextEdit::tabStopWidth are now deprecated.
Note that QFontMetrics::horizontalAdvance() is what we want here, as
opposed to QFontMetrics::boundingRect(), because we want to know
where to draw the next character after the tab.
[1] https://code.qt.io/cgit/qt/qtbase.git/tree/dist/changes-5.10.0/?h=v5.10.0
Fix the following warning from Qt 5.14.1:
error: ‘static bool QPixmapCache::find(const QString&, QPixmap&)’ is deprecated: Use bool find(const QString &, QPixmap*) instead [-Werror=deprecated-declarations]
Fix the following warning from Qt 5.14.1:
error: ‘static QList<T> QList<T>::fromSet(const QSet<T>&) [with T = QString]’ is deprecated: Use QList<T>(set.begin(), set.end()) instead. [-Werror=deprecated-declarations]
Regarding QList::fromSet(), the documentation now states the
following [1]:
Since Qt 5.14, range constructors are available for Qt's generic
container classes and should be used in place of this method.
[1] https://doc.qt.io/qt-5/qlist.html
Fix the following warning:
error: ‘void QFileDialog::setConfirmOverwrite(bool)’ is deprecated: Use setOption(DontConfirmOverwrite, !enabled) instead [-Werror=deprecated-declarations]
Note in the change that "false" changes to "true" because the option
is *Dont*ConfirmOverwrite.
QFileDialog::setConfirmOverwrite() is obsolete at least since 4.8
and QFileDialog::setOption() is available since 4.5 [1].
[1] https://doc.qt.io/archives/qt-4.8/qfiledialog-obsolete.html
[2] https://doc.qt.io/qt-5/qfiledialog.html#setOption
Fixes the following warning:
error: ‘void QWidget::getContentsMargins(int*, int*, int*, int*) const’ is deprecated: use contentsMargins() [-Werror=deprecated-declarations]
The new code also has advantages in that 'l' can be set to const and
it is more readable because it is clear that only 'l' is used.
QWidget::getContentsMargins() was deprecated in 5.14.0 [1]. and
QWidget::contentsMargins() is available since 4.6 [2].
[1] https://code.qt.io/cgit/qt/qtbase.git/tree/dist/changes-5.14.0/?h=v5.14.0
[2] https://doc.qt.io/archives/qt-4.8/qlayout.html#contentsMargins
This commit replaces qSort with std::sort to fix warnings from compiling with
Qt 5.14.1. Below is one of the warnings:
error: ‘void qSort(RandomAccessIterator, RandomAccessIterator, LessThan) [with RandomAccessIterator = QList<lyx::ColorCode>::iterator; LessT$
an = bool (*)(lyx::ColorCode, lyx::ColorCode)]’ is deprecated: Use std::sort [-Werror=deprecated-declarations]
qSort() has been deprecated since Qt 5.2. Quoting from the ChangeLog [1]:
With STL no longer being optional for building and using Qt, a number of
parts of QtAlgorithms no longer make sense, and have therefore been
deprecated. Replacements are available in the STL, and generally have
much better performance
There are some cases that require more than just a trivial substitution, but
our code does not appear to use any of those cases.
For some discussion on the differences in speed of std::sort() and
qSort(), see the following:
https://phabricator.kde.org/D10857
These are just warnings now, but will likely be errors with Qt 6:
https://bugreports.qt.io/browse/QTBUG-73048
I tested that LyX can still be built against Qt 4.8.7 with this commit.
This commit follows 24926b2e, which also fixes some deprecation warnings.
[1]
https://code.qt.io/cgit/qt/qtbase.git/tree/dist/changes-5.2.0/?h=v5.2.0
These changes fix a few instances of the following type of warning:
error: ‘void QListWidget::setItemSelected(const QListWidgetItem*, bool)’ is deprecated: Use QListWidgetItem::setSelected() instead [-Werror=deprecated-declarations]
as well as similar warnings for setItemHidden() and
setItemExpanded(). These are just warnings now, but it is planned to
remove the methods for Qt 6:
https://bugreports.qt.io/browse/QTBUG-73048
I tested that LyX can still be built against Qt 4.8.7 with this
commit. Indeed, these methods have been deprecated for a while (it
is just that QT_DEPRECATED_WARNINGS was only turned on by default
starting with 5.13.0). See, e.g.,
https://doc.qt.io/archives/qt-4.7/qlistwidget-obsolete.html
Using a dialog may trigger a redraw at times where the metrics caches
have not been updated yet. To fix this, do as in paintEvent() and
abort caret blinking if there is an open undo group.
Move the decision to skip the caret painting to showCaret(), closer to
where real work happens. hideCaret () is now an alias for
showCaret(false), which allows some code refactoring.
See also commit c7496a11b2.
Fixes bug #11763 (although it does not trigger on master).
I've long wondered why dialogs seem to update twice when it seems
they just need to update once. It seems it was this code. But it
was only put there to deal with a problem with code in the button
controllers that was disabled in 2007! So I'm going to try removing
it. If we start seeing weird behavior with dialogs in master, then
this will be why.
In case of path names for external files containing symbolic links the real path
and the logical path name may be different for the same file or directory.
LyX is using QDir::tempPath() to create the path name of the temporary directory.
The Qt implementation is free to return the logical or the real path name here and
it happens to be different for various platforms and versions.
The most stable and clean solution is to use the real path name consistently.
As the xcb_send_event man page [1] states,
In order to properly initialize these bytes, we allocate 32 bytes
even though we only need less for an xcb_configure_notify_event_t
This commit fixes the following Valgrind error, which could be
triggered by selecting a letter in LyX:
==12698== Syscall param writev(vector[...]) points to uninitialised byte(s)
==12698== at 0x61F578D: __writev (writev.c:26)
==12698== by 0x61F578D: writev (writev.c:24)
==12698== by 0x4A83BFC: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==12698== by 0x4A83FD0: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==12698== by 0x4A84246: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==12698== by 0x4A84ACB: xcb_flush (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==12698== by 0x17C8F06: lyx::frontend::GuiApplication::nativeEventFilter(QByteArray const&, void*, long*) (GuiApplication.cpp:3366)
==12698== by 0x5AA4EEE: QAbstractEventDispatcher::filterNativeEvent(QByteArray const&, void*, long*) (qabstracteventdispatcher.cpp:484)
[1] https://www.x.org/releases/current/doc/man/man3/xcb_send_event.3.xhtml
/cvs/lyx/lyx-devel/src/frontends/qt/TocModel.cpp:356: warning: loop variable 'toc' has type 'const pair<std::string, shared_ptr<lyx::Toc> > &' (aka 'const pair<basic_string<char>, shared_ptr<vector<lyx::TocItem> > > &') but is initialized with type 'const std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<std::vector<lyx::TocItem, std::allocator<lyx::TocItem> > > >' resulting in a copy
/cvs/lyx/lyx-devel/src/frontends/qt/TocModel.cpp:356: use non-reference type 'pair<std::string, shared_ptr<lyx::Toc> >' (aka 'pair<basic_string<char>, shared_ptr<vector<lyx::TocItem> > >') to keep the copy or type 'const std::pair<const std::__cxx11::basic_string<char>, std::shared_ptr<std::vector<lyx::TocItem, std::allocator<lyx::TocItem> > > > &' to prevent copying
Easier just to use 'auto'.
There are two techniques that I know of for forcing the direction of a
string, regardlessly of whether its contents is naturally LtR, RtL or
undecided.
1/ The unicode LTR/LTR override characters. This is supposed to be the
clean way, however, it does not seem to work with Qt 5.14 (see
#11691).
2/ The undocumented QTextLayout::setFlags method. This is used
internally and allows to pass the (undocumented) flags
Qt::TextForceRightToLeft and Qt::TextForceLeftToRight. This was
used until we had issues with Qt 5.11 (see #11284).
In order to get the best of both worlds, this patch allows to enable
those two methods separately, and actually enables both at the same
time by default!
(hopefully) Fixes bug #11691.
We will replace this with a better solution
For now, only keep
- Changes::isChanged()
- Buffer::areChangesPresent(), replaced by a dummy function
Next step will be to provide a working areChangesPresent() and to
compute Inset::isChanged in updateBuffer.
This reverts commit 6d4e6aad24.
This requires to add a assertion_failed_msg handler. Take this
occasion to cleanup and uniformize the various boost.cpp files that we
have.
This adds 50k line of whatever to the source code.
Small helper lfun that makes LyX remove the aux file before doing the
next export. A bit more convenient than removing the files manually
or restarting LyX.
We tend to have insets which buffer() member is invalid. To help
debugging, this commit paints their background in red when devel-mode
is on.
To this end, a new method develMode() is added to the Painter class.
With this commit, it is easy to see that macro template do not have a
proper buffer set!
Horizontal scrolling used to be taken into account when updating caret
geometry. This is wrong since it may have changed when time comes to
draw the caret. This leads to a situation where the first apparition
of the caret is at a wrong place.
Now the extra horizontal offset is used at drawing time.
Fixes bug #11603.
The reader of CREDITS (GuiAbout.cpp) now ignores lines that start
with the number sign (#). This commit also introduces a commented
out header in CREDITS reminding any potential editor that all
changes will be overwritten by generate_contributions.py.
The provided working directory was not properly set when the underlying
process starts.
It is not clear, why only this one call to one.startscript()
needs fixing. OTOH, the other calls do not use 'Systemcall::DontWait'
as the first parameter.
When the cursor in RTL text, icons for "depth-increment" or
"layout-toggle Enumerate" look wrong.
To fix this, the lfun "bidi" is introduced. "bidi ltr func" behaves
like "func" in LTR text, but is unknown in RTL text. "bidi rtl" does
the opposite. This allows to add two icons, but only have one icon
available. When no document is available, only LTR is assumed.
To make this work, the handling of unknown functions in toolbar has
been changed so this these functions can change dynamically their
existence.
The icon themes `default', `oxygen' and `classic' have been updated
accordingly.
Fixes bug #4451.
In particular, the directory frontends/qt4 is renamed to frontends/qt.
Many configurations file have to be updated. All mentions of qt4 in
the source have been audited, and changed to qt if necessary.
The only part that has not been updated is the CMake build system.
By default, the behavior is the same as before, except that the
language of new document is not unconditionally en_US anymore.
The new checkbox "Respect OS keyboard language" (off by default)
governs this behavior.
Update prefs format to 30.
Instead of setting language from context when moving the cursor, set
it to the OS input language. This behavior will probably need to be
controlled by a preference, since not everybody changes keyboard
mapping when changing language.
This required to move BufferView::setCursorLanguage to
Cursor::setLanguageFromInput().
This bug provides two features:
1/ when a new document is created the language is set to the current
keyboard language.
2/ when keyboard is switched at OS level, the input language of
current window is changed. The language is set preferably to one of
those of the document. Ex. if the keyboard changes to en_GB but one
is typing a document in US English and Hebrew, then US English will
be selected rather that adding UK English to the list.
The implementation depends a lot on Qt. The platform status is :
* working on Windows 10
* not working with Linux (although 1/ works with Qt4); it seems that
Qt5 supports switching through ibus, but I do not know what this
means.
* not yet tested on macOS.
This addresses bugs #6450, #6247 and somehow #10514.
It is not a good idea to call caretPosAndHeight when the caret is in a
paragraph that is not in cached metrics. This can happen when not
using "cursor follows scrollbar".
This commit refactor things a bit so that testing is done in
BufferView.
This bug is not in 2.3.x.
Like with macOS, the Wayland compositor seems to require a
backingstore when doing partial updates like we do.
This extends the mechanism that has been introduced for macOS. This
has to be done at run time, not compile time.
This revives a patch by Uwe and extends it. Additional options to font
packages/fontspec can now be entered in Document Settings.
This is principally also true for TeX fonts, if the new TeXFont tag
MoreOptions is set. For the time being, I have only done this for
MinionPro, as a model and prove of concept.
Note that adding more TeXFonts requires a file format change,
respectively, and changes to tex2lyx (in the same way as I've done for
MinionPro).
This addresses #8226
With non-TeX fonts, the \inputencoding setting is overridden
by "utf8-plain" (pass-through). Keeping the old value allows
switching back to TeX fonts without the need to (re)set
the input encoding.
Also change back the GUI name of the "auto-legacy" setting
(cf. #11115).
The culprit here is the constructor QString(QByteArray const &): in
Qt4, it would interpret the byte array as latin1, and in Qt5 as utf8.
Therefore it is safer to use explicitly QString::fromUtf8 instead of
this constructor.
Several places where additionally simplified, in order to avoid some
extra conversions.
Ensure the default encoding "utf8" comes always first,
followed by other common variants.
The encodings were sorted based on the GUI name which leads to
the default setting moving from the top position in some localizations.
Prepare for languages that use CJK with TeX fonts and Polyglossia
with non-TeX fonts.
Korean is already supported by Polyglossia,
LyX support will follow (file version change).