[LyX/master] Warn user when OUTLINE_IN/OUT is about to flatten the structure (#11178)

2023-02-22 Thread Juergen Spitzmueller
commit c5e4043fa3553987f34f32819471ff8b00f5932a
Author: Juergen Spitzmueller 
Date:   Wed Feb 22 17:31:32 2023 +0100

Warn user when OUTLINE_IN/OUT is about to flatten the structure (#11178)
---
 src/Text3.cpp |   39 +++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/Text3.cpp b/src/Text3.cpp
index d077dde..a45eb39 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -560,6 +560,45 @@ static void outline(OutlineOp mode, Cursor & cur, Text * 
text)
}
case OutlineIn:
case OutlineOut: {
+   // We first iterate without actually doing something
+   // in order to check whether the action flattens the 
structure.
+   // If so, warn (#11178).
+   ParagraphList::iterator cstart = start;
+   bool strucchange = false;
+   for (; cstart != finish; ++cstart) {
+   toclevel = buf.text().getTocLevel(distance(bgn, 
cstart));
+   if (toclevel == Layout::NOT_IN_TOC)
+   continue;
+   
+   DocumentClass const & tc = 
buf.params().documentClass();
+   int const newtoclevel =
+   (mode == OutlineIn ? toclevel + 1 : 
toclevel - 1);
+   
+   bool found = false;
+   for (auto const & lay : tc) {
+   if (lay.toclevel == newtoclevel
+   && lay.isNumHeadingLabelType()
+   && 
cstart->layout().isNumHeadingLabelType()) {
+   found = true;
+   break;
+   }
+   }
+   if (!found) {
+   strucchange = true;
+   break;
+   }
+   }
+   if (strucchange
+   && frontend::Alert::prompt(_("Action flattens 
document structure"),
+  _("This action will 
cause some headings that have been "
+"on different level 
before to be on the same level "
+"since there is no 
more lower or higher heading level. "
+"Continue still?"),
+  1, 1,
+  _(", continue 
nonetheless"),
+  _(", quit 
operation")) == 1)
+   break;
+
pit_type const len = distance(start, finish);
buf.undo().recordUndo(cur, pit, pit + len - 1);
for (; start != finish; ++start) {
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix equation numbers after row operation (#12665)

2023-02-22 Thread Scott Kostyshak
commit 83af3dfd2969e6dbe2b515aabfe5cf71c64cf6a8
Author: Scott Kostyshak 
Date:   Wed Feb 22 11:12:56 2023 -0500

Fix equation numbers after row operation (#12665)

After removing/adding rows, the corresponding equation numbers in
the LyX display were not updated (although if you clicked outside
the math inset they were).

Now they are updated immediately after the operation.
---
 src/mathed/InsetMathGrid.cpp |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/mathed/InsetMathGrid.cpp b/src/mathed/InsetMathGrid.cpp
index 0061bdd..65cd662 100644
--- a/src/mathed/InsetMathGrid.cpp
+++ b/src/mathed/InsetMathGrid.cpp
@@ -1550,6 +1550,7 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest 
& cmd)
cur.undispatched();
break;
}
+   cur.forceBufferUpdate();
// perhaps this should be FINISHED_BACKWARD -- just for clarity?
//lyxerr << "returning FINISHED_LEFT" << endl;
break;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix another old outliner bug (#9375)

2023-02-22 Thread Juergen Spitzmueller
commit 8fd1aaa46ea85dde9a0b19b427b72b406605a4d2
Author: Juergen Spitzmueller 
Date:   Wed Feb 22 16:33:37 2023 +0100

Fix another old outliner bug (#9375)

Parts, chapters and sections have different LabelTypes, but this does
not mean they cannot be transformed into each other while doing
OUTLINE_IN/OUT

Not sure why the labeltype check is here anyway, but let's keep it.
---
 src/Layout.h  |5 +
 src/Text3.cpp |6 +++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/Layout.h b/src/Layout.h
index 6efc512..6581155 100644
--- a/src/Layout.h
+++ b/src/Layout.h
@@ -292,6 +292,11 @@ public:
|| labeltype == LABEL_CENTERED
|| labeltype == LABEL_BIBLIO;
}
+   bool isNumHeadingLabelType() const {
+   return labeltype == LABEL_ABOVE
+   || labeltype == LABEL_CENTERED
+   || labeltype == LABEL_STATIC;
+   }
///
bool addToToc() const { return add_to_toc_; }
///
diff --git a/src/Text3.cpp b/src/Text3.cpp
index 148b1d4..d077dde 100644
--- a/src/Text3.cpp
+++ b/src/Text3.cpp
@@ -570,11 +570,11 @@ static void outline(OutlineOp mode, Cursor & cur, Text * 
text)
DocumentClass const & tc = 
buf.params().documentClass();
int const newtoclevel =
(mode == OutlineIn ? toclevel + 1 : 
toclevel - 1);
-   LabelType const oldlabeltype = 
start->layout().labeltype;
 
for (auto const & lay : tc) {
-   if (lay.toclevel ==  newtoclevel &&
-lay.labeltype == oldlabeltype) 
{
+   if (lay.toclevel == newtoclevel
+   && lay.isNumHeadingLabelType()
+   && 
start->layout().isNumHeadingLabelType()) {
start->setLayout(lay);
break;
}
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Properly reset tree depth in outliner with keep when outliner is re-filled

2023-02-22 Thread Juergen Spitzmueller
commit 41d95a45d9640f95ad59670e96140dcc17c02be2
Author: Juergen Spitzmueller 
Date:   Wed Feb 22 15:24:15 2023 +0100

Properly reset tree depth in outliner with keep when outliner is re-filled

Fixes a 13 year old bug (#6675)
---
 src/frontends/qt/TocWidget.cpp |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/frontends/qt/TocWidget.cpp b/src/frontends/qt/TocWidget.cpp
index 7d0de63..03d870a 100644
--- a/src/frontends/qt/TocWidget.cpp
+++ b/src/frontends/qt/TocWidget.cpp
@@ -614,6 +614,8 @@ void TocWidget::init(QString const & str)
typeCO->setCurrentIndex(new_index);
typeCO->blockSignals(false);
updateViewNow();
+   if (persistent_)
+   setTreeDepth(depth_);
 }
 
 } // namespace frontend
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Whitespace

2023-02-22 Thread Juergen Spitzmueller
commit 08fc56486e5d4fab79912c916fe72860533b8c74
Author: Juergen Spitzmueller 
Date:   Wed Feb 22 14:53:25 2023 +0100

Whitespace
---
 src/frontends/qt/TocWidget.cpp |2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt/TocWidget.cpp b/src/frontends/qt/TocWidget.cpp
index 04be808..7d0de63 100644
--- a/src/frontends/qt/TocWidget.cpp
+++ b/src/frontends/qt/TocWidget.cpp
@@ -193,7 +193,6 @@ bool TocWidget::getStatus(Cursor & cur, FuncRequest const & 
cmd,
 void TocWidget::doDispatch(Cursor & cur, FuncRequest const & cmd,
DispatchResult & dr)
 {
-
Inset * inset = itemInset();
 
QModelIndex const & index = tocTV->currentIndex();
@@ -379,7 +378,6 @@ void TocWidget::outline(FuncCode func_code)
 
 void TocWidget::sendDispatch(FuncRequest fr)
 {
-
fr.setViewOrigin(_view_);
GuiWorkArea * old_wa = gui_view_.currentWorkArea();
GuiWorkArea * doc_wa = gui_view_.currentMainWorkArea();
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Amend 4cd568d31266

2023-02-22 Thread Juergen Spitzmueller
commit ceb03b1815583a7daf6166562f6d928d7d38b356
Author: Juergen Spitzmueller 
Date:   Wed Feb 22 14:35:53 2023 +0100

Amend 4cd568d31266
---
 src/frontends/qt/TocWidget.cpp |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/frontends/qt/TocWidget.cpp b/src/frontends/qt/TocWidget.cpp
index ef1a289..04be808 100644
--- a/src/frontends/qt/TocWidget.cpp
+++ b/src/frontends/qt/TocWidget.cpp
@@ -503,6 +503,7 @@ void TocWidget::updateView()
finishUpdateView();
timer_->start(300);
}
+   keep_expanded_ = false;
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Do not change outliner tree depth when not appropriate

2023-02-22 Thread Juergen Spitzmueller
commit 4cd568d3126670503ffab49c87ba21b27a8bdc27
Author: Juergen Spitzmueller 
Date:   Wed Feb 22 14:23:04 2023 +0100

Do not change outliner tree depth when not appropriate

This fixes expansion/collapsing on double-click (#12672)
---
 src/frontends/qt/TocWidget.cpp |   18 +-
 src/frontends/qt/TocWidget.h   |3 +++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/frontends/qt/TocWidget.cpp b/src/frontends/qt/TocWidget.cpp
index fcbd605..ef1a289 100644
--- a/src/frontends/qt/TocWidget.cpp
+++ b/src/frontends/qt/TocWidget.cpp
@@ -47,8 +47,8 @@ namespace lyx {
 namespace frontend {
 
 TocWidget::TocWidget(GuiView & gui_view, QWidget * parent)
-   : QWidget(parent), depth_(0), persistent_(false), gui_view_(gui_view),
- timer_(new QTimer(this))
+   : QWidget(parent), depth_(0), persistent_(false), keep_expanded_(false),
+ gui_view_(gui_view), timer_(new QTimer(this))
 {
setupUi(this);
 
@@ -263,7 +263,8 @@ void TocWidget::on_tocTV_activated(QModelIndex const & 
index)
 
 void TocWidget::on_tocTV_pressed(QModelIndex const & index)
 {
-
+   DocIterator const & dit = gui_view_.documentBufferView()->cursor();
+   keep_expanded_ = gui_view_.tocModels().currentIndex(current_type_, dit) 
== index;
Qt::MouseButtons const button = QApplication::mouseButtons();
if (button & Qt::LeftButton) {
goTo(index);
@@ -273,6 +274,12 @@ void TocWidget::on_tocTV_pressed(QModelIndex const & index)
 }
 
 
+void TocWidget::on_tocTV_doubleClicked(QModelIndex const &)
+{
+   keep_expanded_ = true;
+}
+
+
 void TocWidget::goTo(QModelIndex const & index)
 {
LYXERR(Debug::GUI, "goto " << index.row()
@@ -492,7 +499,7 @@ void TocWidget::updateView()
// Expensive operations are on a timer.  We finish the update 
immediately
// for sparse edition actions, i.e. there was no edition/cursor movement
// recently, then every 300ms.
-   if (!timer_->isActive()) {
+   if (!timer_->isActive() && !keep_expanded_) {
finishUpdateView();
timer_->start(300);
}
@@ -512,8 +519,9 @@ void TocWidget::finishUpdateView()
// text and moving with arrows. For bigger operations, this is 
negligible,
// and outweighted by TocModels::reset() anyway.
if (canNavigate()) {
-   if (!persistent_)
+   if (!persistent_ && !keep_expanded_)
setTreeDepth(depth_);
+   keep_expanded_ = false;
persistentCB->setChecked(persistent_);
// select the item at current cursor location
if (gui_view_.documentBufferView()) {
diff --git a/src/frontends/qt/TocWidget.h b/src/frontends/qt/TocWidget.h
index 2838adb..079fd24 100644
--- a/src/frontends/qt/TocWidget.h
+++ b/src/frontends/qt/TocWidget.h
@@ -69,6 +69,7 @@ protected Q_SLOTS:
 
void on_tocTV_activated(QModelIndex const &);
void on_tocTV_pressed(QModelIndex const &);
+   void on_tocTV_doubleClicked(QModelIndex const &);
void on_updateTB_clicked();
void on_sortCB_stateChanged(int state);
void on_persistentCB_stateChanged(int state);
@@ -115,6 +116,8 @@ private:
int depth_;
/// persistence of uncollapsed nodes in toc view
bool persistent_;
+   /// keep uncollapsed nodes in this event
+   bool keep_expanded_;
///
GuiView & gui_view_;
// Timer for scheduling expensive update operations
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Update sk.po

2023-02-22 Thread Kornel Benko
commit 6e35cae618f311574fdd7678c44d350df6dc2c56
Author: Kornel Benko 
Date:   Wed Feb 22 12:18:22 2023 +0100

Update sk.po
---
 po/sk.po |   85 -
 1 files changed, 56 insertions(+), 29 deletions(-)

diff --git a/po/sk.po b/po/sk.po
index c14c09e..b379388 100644
--- a/po/sk.po
+++ b/po/sk.po
@@ -8,8 +8,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: LyX-2.4\n"
 "Report-Msgid-Bugs-To: lyx-de...@lists.lyx.org\n"
-"POT-Creation-Date: 2023-02-19 12:35+0100\n"
-"PO-Revision-Date: 2023-02-19 11:39+\n"
+"POT-Creation-Date: 2023-02-22 11:59+0100\n"
+"PO-Revision-Date: 2023-02-22 11:16+\n"
 "Last-Translator: Kornel Benko \n"
 "Language-Team: Slovak \n"
 "Language: sk\n"
@@ -6408,6 +6408,30 @@ msgstr "Vnútiť plný titul"
 msgid "Use full title even if shorttitle exists"
 msgstr "Použiť plný titul aj keď krátky titul existuje"
 
+#: lib/citeengines/biblatex-natbib.citeengine:153
+#: lib/citeengines/biblatex.citeengine:145
+#: lib/citeengines/jurabib.citeengine:130 lib/citeengines/natbib.citeengine:124
+msgid " et al."
+msgstr " a kol."
+
+#: lib/citeengines/biblatex-natbib.citeengine:154
+#: lib/citeengines/biblatex.citeengine:146
+#: lib/citeengines/natbib.citeengine:125 lib/layouts/stdciteformats.inc:29
+msgid ", [[separate author names in citation, except for last name]]"
+msgstr ", "
+
+#: lib/citeengines/biblatex-natbib.citeengine:155
+#: lib/citeengines/biblatex.citeengine:147
+#: lib/citeengines/natbib.citeengine:126 lib/layouts/stdciteformats.inc:30
+msgid ", and [[separate name of last author in citation]]"
+msgstr ", a "
+
+#: lib/citeengines/biblatex-natbib.citeengine:156
+#: lib/citeengines/biblatex.citeengine:148
+#: lib/citeengines/natbib.citeengine:127 lib/layouts/stdciteformats.inc:31
+msgid " and [[separate two authors in citation]]"
+msgstr " a "
+
 #: lib/citeengines/biblatex-natbib.citeengine:303
 #: lib/citeengines/biblatex.citeengine:289
 msgid "Super"
@@ -6469,6 +6493,12 @@ msgstr "pred"
 msgid "short title"
 msgstr "krátky titul"
 
+#: lib/citeengines/jurabib.citeengine:131
+#: lib/citeengines/jurabib.citeengine:132
+#: lib/citeengines/jurabib.citeengine:133
+msgid "/"
+msgstr "/"
+
 #: lib/citeengines/natbib.citeengine:2
 msgid "Natbib (BibTeX)"
 msgstr "Natbib (BibTeX)"
@@ -17002,6 +17032,30 @@ msgstr "POĎAKOVANIA"
 msgid "UNDEFINED"
 msgstr "NEDEFINOVANÉ"
 
+#: lib/layouts/stdciteformats.inc:22
+msgid "pp."
+msgstr "str."
+
+#: lib/layouts/stdciteformats.inc:23
+msgid "ed."
+msgstr "vyd."
+
+#: lib/layouts/stdciteformats.inc:24
+msgid "eds."
+msgstr "vyd."
+
+#: lib/layouts/stdciteformats.inc:25
+msgid "vol."
+msgstr "diel"
+
+#: lib/layouts/stdciteformats.inc:26
+msgid "no."
+msgstr "č."
+
+#: lib/layouts/stdciteformats.inc:27
+msgid "in"
+msgstr "v"
+
 #: lib/layouts/stdcounters.inc:10
 msgid "\\Roman{part}"
 msgstr "\\Roman{part}"
@@ -38880,33 +38934,6 @@ msgstr "Neznámy používateľ"
 #~ msgid "for this version of LyX."
 #~ msgstr "pre túto verziu LyXu."
 
-#~ msgid " et al."
-#~ msgstr " a kol."
-
-#~ msgid ", [[separate author names in citation, except for last name]]"
-#~ msgstr ", "
-
-#~ msgid ", and [[separate name of last author in citation]]"
-#~ msgstr ", a "
-
-#~ msgid " and [[separate two authors in citation]]"
-#~ msgstr " a "
-
-#~ msgid "pp."
-#~ msgstr "str."
-
-#~ msgid "ed."
-#~ msgstr "vyd."
-
-#~ msgid "vol."
-#~ msgstr "diel"
-
-#~ msgid "no."
-#~ msgstr "č."
-
-#~ msgid "in"
-#~ msgstr "v"
-
 #~ msgid "Use the minted package instead of the listings one"
 #~ msgstr "Použiť minted balík namiesto balíka listings"
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fix completion in math when inline completion was not yet shown

2023-02-22 Thread Jean-Marc Lasgouttes
commit b4211ef206827f85378b9392472fdc14e1e9f6c4
Author: Jean-Marc Lasgouttes 
Date:   Wed Feb 22 12:02:10 2023 +0100

Fix completion in math when inline completion was not yet shown

It is necessary to set finish=true when the completion is unique.
Otherwise, one gets \upsilon instead of the proper glyph.

Fixes bug #12674.
---
 src/frontends/qt/GuiCompleter.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/frontends/qt/GuiCompleter.cpp 
b/src/frontends/qt/GuiCompleter.cpp
index 2aee436..6611785 100644
--- a/src/frontends/qt/GuiCompleter.cpp
+++ b/src/frontends/qt/GuiCompleter.cpp
@@ -710,7 +710,7 @@ void GuiCompleter::tab()
docstring longestCompletion = longestUniqueCompletion();
prefix = cur.inset().completionPrefix(cur);
docstring postfix = 
longestCompletion.substr(min(longestCompletion.size(), prefix.size()));
-   cur.inset().insertCompletion(cur, postfix, false);
+   cur.inset().insertCompletion(cur, postfix, uniqueCompletionAvailable());
old_cursor_ = bv.cursor();
updatePrefix(cur);
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Revert "Fixup 0cbe0d7a: avoid double redraw when completion is finished"

2023-02-22 Thread Jean-Marc Lasgouttes
commit ab8ea2543dc23593081fc4e9db01828e245a4e9e
Author: Jean-Marc Lasgouttes 
Date:   Wed Feb 22 12:00:14 2023 +0100

Revert "Fixup 0cbe0d7a: avoid double redraw when completion is finished"

This is my 635th lesson that trying to be too clever is not that good.
This change interferes with the yet-to-come fix to #12674.

This reverts commit cc6dae1363a818e975b2b8b5d9d1409068a04b39.
---
 src/mathed/InsetMathNest.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 9fe6bf0..a780a95 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -2143,8 +2143,8 @@ bool InsetMathNest::insertCompletion(Cursor & cur, 
docstring const & s, bool fin
MathCompletionList::addToFavorites(inset->name());
 #endif
lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, " "));
-   } else
-   cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
+   }
+   cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
 
return true;
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fixup 0cbe0d7a: avoid double redraw when completion is finished

2023-02-22 Thread Jean-Marc Lasgouttes
commit cc6dae1363a818e975b2b8b5d9d1409068a04b39
Author: Jean-Marc Lasgouttes 
Date:   Wed Feb 22 11:32:11 2023 +0100

Fixup 0cbe0d7a: avoid double redraw when completion is finished
---
 src/mathed/InsetMathNest.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index a780a95..9fe6bf0 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -2143,8 +2143,8 @@ bool InsetMathNest::insertCompletion(Cursor & cur, 
docstring const & s, bool fin
MathCompletionList::addToFavorites(inset->name());
 #endif
lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, " "));
-   }
-   cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
+   } else
+   cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
 
return true;
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Make sure that screen is updated when completing math

2023-02-22 Thread Jean-Marc Lasgouttes
commit 0cbe0d7a3e91b97fdc5f622a9ca38b15490c0b88
Author: Jean-Marc Lasgouttes 
Date:   Wed Feb 22 11:20:38 2023 +0100

Make sure that screen is updated when completing math

There was a missing update there.

Fixes part of bug #12674.
---
 src/mathed/InsetMathNest.cpp |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 0ef3e8f..a780a95 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -2144,6 +2144,7 @@ bool InsetMathNest::insertCompletion(Cursor & cur, 
docstring const & s, bool fin
 #endif
lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, " "));
}
+   cur.screenUpdateFlags(Update::SinglePar | Update::FitCursor);
 
return true;
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Disable zoom in/out buttons when threshold is reached (#12676)

2023-02-22 Thread Juergen Spitzmueller
commit 1e99920b355a1aad71f79f314f9e2d063b5abc5e
Author: Juergen Spitzmueller 
Date:   Wed Feb 22 11:16:46 2023 +0100

Disable zoom in/out buttons when threshold is reached (#12676)
---
 src/frontends/qt/GuiView.cpp |   18 ++
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 461b09c..f7222e4 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -692,10 +692,12 @@ GuiView::GuiView(int id)
zoom_out_->setAlignment(Qt::AlignCenter);
 
statusBar()->addPermanentWidget(zoom_out_);
-   zoom_out_->setEnabled(currentBufferView());
+   zoom_out_->setEnabled(currentBufferView()
+ && zoom_slider_->value() > 
zoom_slider_->minimum());
statusBar()->addPermanentWidget(zoom_slider_);
zoom_slider_->setEnabled(currentBufferView());
-   zoom_in_->setEnabled(currentBufferView());
+   zoom_in_->setEnabled(currentBufferView()
+&& zoom_slider_->value() < 
zoom_slider_->maximum());
statusBar()->addPermanentWidget(zoom_in_);
 
connect(zoom_slider_, SIGNAL(sliderMoved(int)), this, 
SLOT(zoomSliderMoved(int)));
@@ -829,6 +831,10 @@ void GuiView::zoomSliderMoved(int value)
dispatch(FuncRequest(LFUN_BUFFER_ZOOM, convert(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());
 }
 
 
@@ -1011,6 +1017,8 @@ void GuiView::setCurrentZoom(const int v)
 {
lyxrc.currentZoom = v;
zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), v)));
+   zoom_in_->setEnabled(currentBufferView() && v < 
zoom_slider_->maximum());
+   zoom_out_->setEnabled(currentBufferView() && v > 
zoom_slider_->minimum());
Q_EMIT currentZoomChanged(v);
 }
 
@@ -1560,8 +1568,10 @@ void GuiView::onBufferViewChanged()
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());
 }
 
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fixup 04ece4f0: handle case where openinlined_ is not set

2023-02-22 Thread Jean-Marc Lasgouttes
commit e181474e6c4f8007a56d62e269c61d2d4a8dbd75
Author: Jean-Marc Lasgouttes 
Date:   Wed Feb 22 10:58:22 2023 +0100

Fixup 04ece4f0: handle case where openinlined_ is not set

When computing the width of the button, some code has been added in
04ece4f0 to shorten the space in LeftButton geometry. It turns out
that the Left/Top-button-ness is not always known at this point (since
it depends on the width itself!).

Therefore, it is better to make the button narrower also in the
TopButton case.
---
 src/insets/InsetCollapsible.cpp |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/insets/InsetCollapsible.cpp b/src/insets/InsetCollapsible.cpp
index f76dc99..a0a789c 100644
--- a/src/insets/InsetCollapsible.cpp
+++ b/src/insets/InsetCollapsible.cpp
@@ -191,8 +191,11 @@ Dimension InsetCollapsible::dimensionCollapsed(BufferView 
const & bv) const
int const offset = Inset::textOffset();
theFontMetrics(labelfont).buttonText(
buttonLabel(bv), offset, dim.wid, dim.asc, dim.des);
-   // remove spacing on the right for left buttons
-   if (geometry(bv) == LeftButton)
+   // remove spacing on the right for left buttons; we also do it for
+   // TopButton (although it is not useful per se), because
+   // openinlined_ is not always set properly at this point.
+   Geometry const geom = geometry(bv);
+   if (geom == LeftButton || geom == TopButton)
// this form makes a difference if offset is even
dim.wid -= offset - offset / 2;
return dim;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs


[LyX/master] Fixup 04ece4f0d6a: fix cursor position

2023-02-22 Thread Jean-Marc Lasgouttes
commit a3d58d2884976eaf6c7ea22c2caace51f8e5c566
Author: Jean-Marc Lasgouttes 
Date:   Mon Feb 20 17:14:03 2023 +0100

Fixup 04ece4f0d6a: fix cursor position
---
 src/insets/InsetCollapsible.cpp |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/insets/InsetCollapsible.cpp b/src/insets/InsetCollapsible.cpp
index d629aaa..f76dc99 100644
--- a/src/insets/InsetCollapsible.cpp
+++ b/src/insets/InsetCollapsible.cpp
@@ -424,7 +424,7 @@ void InsetCollapsible::cursorPos(BufferView const & bv,
 
switch (geometry(bv)) {
case LeftButton:
-   x += dimensionCollapsed(bv).wid;
+   x += dimensionCollapsed(bv).wid - leftOffset() / 2;
break;
case TopButton: {
y += dimensionCollapsed(bv).des + textdim.asc;
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs