From 25a14730ed7710bc057dde5900bb99170b0d48d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 7 Apr 2009 05:01:08 +0000 Subject: [PATCH] * First step towards default view format. The icons could be replaced by something nicer. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29134 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/scons/scons_manifest.py | 6 ++ lib/Makefile.am | 6 ++ lib/images/buffer-update.png | Bin 0 -> 1179 bytes lib/images/buffer-view.png | Bin 0 -> 1345 bytes lib/images/master-buffer-update.png | Bin 0 -> 1427 bytes lib/images/master-buffer-view.png | Bin 0 -> 1319 bytes lib/images/math/update-others.png | Bin 0 -> 1203 bytes lib/images/math/view-others.png | Bin 0 -> 1327 bytes lib/ui/stdmenus.inc | 14 ++++- lib/ui/stdtoolbars.inc | 19 ++++++- src/Buffer.cpp | 15 +++++ src/Buffer.h | 2 + src/LyXFunc.cpp | 48 ++++++++++++---- src/LyXRC.cpp | 19 ++++++- src/LyXRC.h | 3 + src/frontends/qt4/GuiPrefs.cpp | 31 +++++++++-- src/frontends/qt4/Menus.cpp | 4 +- src/frontends/qt4/ui/PrefFileformatsUi.ui | 64 +++++++++++++++++----- 18 files changed, 191 insertions(+), 40 deletions(-) create mode 100644 lib/images/buffer-update.png create mode 100644 lib/images/buffer-view.png create mode 100644 lib/images/master-buffer-update.png create mode 100644 lib/images/master-buffer-view.png create mode 100644 lib/images/math/update-others.png create mode 100644 lib/images/math/view-others.png diff --git a/development/scons/scons_manifest.py b/development/scons/scons_manifest.py index 7df6aa9628..77e29aba92 100644 --- a/development/scons/scons_manifest.py +++ b/development/scons/scons_manifest.py @@ -1358,9 +1358,11 @@ lib_images_files = Split(''' buffer-export_text.png buffer-new.png buffer-reload.png + buffer-update.png buffer-update_dvi.png buffer-update_pdf2.png buffer-update_ps.png + buffer-view.png buffer-view_dvi.png buffer-view_pdf2.png buffer-view_ps.png @@ -1425,6 +1427,8 @@ lib_images_files = Split(''' vc-register.png vc-revert.png marginalnote-insert.png + master-buffer-update.png + master-buffer-view.png math-display.png math-macro-add-greedy-optional-param.png math-macro-add-optional-param.png @@ -1951,6 +1955,7 @@ lib_images_math_files = Split(''' underset.png uparrow.png uparrow2.png + update-others.png updownarrow.png updownarrow2.png upharpoonleft.png @@ -1985,6 +1990,7 @@ lib_images_math_files = Split(''' veebar.png vert.png vert2.png + view-others.png vphantom.png wedge.png widehat.png diff --git a/lib/Makefile.am b/lib/Makefile.am index 4e85b0fd90..afa3f0f9e5 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -282,9 +282,11 @@ dist_images_DATA = \ images/buffer-export_text.png \ images/buffer-new.png \ images/buffer-reload.png \ + images/buffer-update.png \ images/buffer-update_dvi.png \ images/buffer-update_pdf2.png \ images/buffer-update_ps.png \ + images/buffer-view.png \ images/buffer-view_dvi.png \ images/buffer-view_pdf2.png \ images/buffer-view_ps.png \ @@ -349,6 +351,8 @@ dist_images_DATA = \ images/vc-register.png \ images/vc-revert.png \ images/marginalnote-insert.png \ + images/master-buffer-update.png \ + images/master-buffer-view.png \ images/math-display.png \ images/math-macro-add-greedy-optional-param.png \ images/math-macro-add-optional-param.png \ @@ -868,6 +872,7 @@ dist_imagesmath_DATA = \ images/math/underset.png \ images/math/uparrow.png \ images/math/uparrow2.png \ + images/math/update-others.png \ images/math/updownarrow.png \ images/math/updownarrow2.png \ images/math/upharpoonleft.png \ @@ -902,6 +907,7 @@ dist_imagesmath_DATA = \ images/math/veebar.png \ images/math/vert.png \ images/math/vert2.png \ + images/math/view-others.png \ images/math/vphantom.png \ images/math/wedge.png \ images/math/widehat.png \ diff --git a/lib/images/buffer-update.png b/lib/images/buffer-update.png new file mode 100644 index 0000000000000000000000000000000000000000..3f74d0e9471e50b8169e4e73e53c4761ab8466c4 GIT binary patch literal 1179 zcmV;M1Z4Y(P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_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 z2$W!!J$v?YnCD;LX4On&0-pw$REAPYGQyrP=cv_`O2qyQBRW^KK#>OAtz5AQ%uBS53ELb#=I| z`&?aJ-6!QotU1nZU^l=o!^5F`PtT>^ogYc@a8Tsz>zTdrBdQ*LkH(GfGd>t0e^jDr1rz@AHVz4wik1%=lH^}refwIgdf5u zh+kEO;Lba4uSqmDS06iejI(FY hW`Ie+1qy%<@E0M*FL%4)JZS&`002ovPDHLkV1jrMm=6E| literal 0 HcmV?d00001 diff --git a/lib/images/master-buffer-view.png b/lib/images/master-buffer-view.png new file mode 100644 index 0000000000000000000000000000000000000000..b074bd7ce084fc8d0f71aceb4ec593c83add63d4 GIT binary patch literal 1319 zcmV+?1=#wDP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXJ$ z4>vCvgv1K~00gH=L_t(I%e9qVXdG1($NzWkotd5NY+bIUeqv(cU6IS>4qKL`FvcKB5JM01=HwNeJ=W(p=Yt=Xu!u{CV+>jg3A4h^?(HY;SMx z3m_tJ&e7i9j^5s0#9}cJ5f&F0F*`ep)z#Gl!Llr)2DWW`Uw{w-gM)+6bsfI%Bb&{F zF$P6ZkVquZ+1ZK7$;nzJySCdFVOiF`j5STez`y{OmzOa&H-~&a565w!sw!GrTVWUm znwy)EOeS&T#toFq<=R`%^J+7RbDn*=g0zk4X-`(v=4P0MePnxD3nBA#Ur)XecfI2!l z_T3wXK|MV^d%#SV<-4Be^&K=7p->1TBO?ffLdfUy@H`JKEiGthXu$aRI966xz!(D& zp{uJ4xm*smZQpYor=NvFp?zTA_tDweiT3t(Sk|A=^kWEUt?)euTcriK&IXPgHBcxN z@ZiA%RI61G5!%|?U|H6^LZQ$vg25ns-`@i@3fu!KECh? zes|;Od8H9M5(jZY z5ZHx}jg8@h_uoU-X}}5#K@R|%4}XN4{uSHIM_qFmfoKQbPQHxCvyWh!CZf?Os?{nq zP0MDp*)Jts*AWVZ5Dtf-swz0=Fbsn+bRDHta)HLdf%V=!~`v^oW9 z%Mo0@{5ejZJPFIP5DteC2m~qsNUE=|KOc!ih9Z&35a)cfQmO1*xpIXO09^qzK@f5Y z*RM}t>edvVEH1;Xti$y@NV0-pT@aTpT|#$vH_GKQJkPriK=6fyg^f%mV`efLGndO{ zbX}jZEbFXOapXiIL8h&+x+cQo>7S5(m_{Jpjh9BwLjy-V>?0_AsH%$o{(juNc@yPw z`LrZS*Z8yZTPl?@nx@?{O*2`?oJjP=0a~&&CikXLIr=(c$q%9W3L*i4(=85&2t))$ zQIOB)X=Y}IX`1%JKCodJWSZvE+S=OJ=948|l$Lse$NS}y*TA41f?zW00|Kdbhnkcs z{@U4L>+9 zrDaS{|Ay)5>FsnnJyoexzBNtr8WC-?|F|D_;|Ks=JN;^t5kJv*=gu9>&(B)`b^tg4 dTmU`*{0(5IEGkUnOYr~z002ovPDHLkV1n#?ToM2P literal 0 HcmV?d00001 diff --git a/lib/images/math/update-others.png b/lib/images/math/update-others.png new file mode 100644 index 0000000000000000000000000000000000000000..d2d3155dd0bd6a1f484fa2804aaa9d77278d4e3b GIT binary patch literal 1203 zcmV;k1WfyhP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXJ$ z5ETu4EGL2h00c8hL_t(I%e|CaOk716$NzKA9uBjtz?S7^k;=ucii8)0Dm)NEiCt1G zCM-2b8$=_?q31Ebp7$=!zzWKiS&3rT8{DJ?dRa8`voi@4Og~i3iNo8eaCRJ7ScDw!Jz`#IY zzxV^eo*N0EFgCsZmDs#y&z)i{IeGIN zQ7j)G9K03tSu7T_!C*KO4u{jD(I`_C<@dR{x$}K}eM6!o^~#j?0;o5H!>0grZ9ksL zWQxBsG$bvG;^dj5N6(IpjoAR8v9a-RQc{xD=kpaVEiC~I41@#E6Ox&c0XZD*3xz_b z`}_Ol9gl4mC8?JHKtQX#q+#s26+sxu-P|k(fTpIVvl|;5=iTl#D$5GX%0EF;a|*z5 z0@hbnq4-Cc%P~(95)x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ui/stdmenus.inc index 12638f885f..3188b6fd92 100644 --- a/lib/ui/stdmenus.inc +++ b/lib/ui/stdmenus.inc @@ -297,11 +297,15 @@ Menuset Item "Fold Math Macro" "math-macro-fold" Separator Item "View Source|S" "dialog-toggle view-source" - Submenu "Update|U" "view_update" - ViewFormats + Item "View|V" "buffer-view" + Item "Update|U" "buffer-update" + OptItem "View Master Document|M" "master-buffer-view" + OptItem "Update Master Document|a" "master-buffer-update" + Submenu "View (other formats)|f" "view_others" + Submenu "Update (other formats)|p" "view_update" Separator Item "Split View Into Left And Right Half|i" "split-view horizontal" - Item "Split View Into Upper And Lower Half|V" "split-view vertical" + Item "Split View Into Upper And Lower Half|e" "split-view vertical" Item "Close Tab Group|G" "close-tab-group" Item "Fullscreen|l" "ui-toggle fullscreen" Submenu "Toolbars|b" "toolbars" @@ -309,6 +313,10 @@ Menuset Documents End + Menu "view_others" + ViewFormats + End + Menu "view_update" UpdateFormats End diff --git a/lib/ui/stdtoolbars.inc b/lib/ui/stdtoolbars.inc index 77b5df270d..8432b30e22 100644 --- a/lib/ui/stdtoolbars.inc +++ b/lib/ui/stdtoolbars.inc @@ -203,11 +203,24 @@ ToolbarSet End Toolbar "view/update" "View/Update" + Item "View" "buffer-view" + Item "Update" "buffer-update" + Item "View Master Document" "master-buffer-view" + Item "Update Master Document" "master-buffer-update" + Separator + PopupMenu "view-others" "View Other Formats" + PopupMenu "update-others" "Update Other Formats" + End + + Toolbar "view-others" "View Other Formats" Item "View DVI" "buffer-view dvi" - Item "Update DVI" "buffer-update dvi" - Item "View PDF (pdflatex)" "command-alternatives buffer-view pdf2;buffer-view pdf4" - Item "Update PDF (pdflatex)" "command-alternatives buffer-update pdf2;buffer-view pdf4" + Item "View PDF (pdflatex)" "buffer-view pdf2" Item "View PostScript" "buffer-view ps" + End + + Toolbar "update-others" "Update Other Formats" + Item "Update DVI" "buffer-update dvi" + Item "Update PDF (pdflatex)" "buffer-update pdf2" Item "Update PostScript" "buffer-update ps" End diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 43d5c236b2..3b5a45bc02 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2652,6 +2652,21 @@ string Buffer::bufferFormat() const } +string Buffer::getDefaultOutputFormat() const +{ + typedef vector Formats; + Formats formats = exportableFormats(true); + if (isDocBook() + || isLiterate() + || params().useXetex + || params().encoding().package() == Encoding::japanese) + // return the first we find + return formats.front()->name(); + return lyxrc.default_view_format; +} + + + bool Buffer::doExport(string const & format, bool put_in_tempdir, string & result_file) const { diff --git a/src/Buffer.h b/src/Buffer.h index 43d82b6477..dd1a2b4c84 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -471,6 +471,8 @@ public: /// return the format of the buffer on a string std::string bufferFormat() const; + /// return the default output format of the current backend + std::string getDefaultOutputFormat() const; /// bool doExport(std::string const & format, bool put_in_tempdir, diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index d8f5e9cf4c..93a83139f1 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -583,10 +583,17 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const break; } - case LFUN_BUFFER_UPDATE: - case LFUN_BUFFER_VIEW: case LFUN_MASTER_BUFFER_UPDATE: - case LFUN_MASTER_BUFFER_VIEW: { + case LFUN_MASTER_BUFFER_VIEW: + if (!buf->parent()) { + enable = false; + break; + } + case LFUN_BUFFER_UPDATE: + case LFUN_BUFFER_VIEW: { + string format = to_utf8(cmd.argument()); + if (cmd.argument().empty()) + format = buf->getDefaultOutputFormat(); typedef vector Formats; Formats formats; formats = buf->exportableFormats(true); @@ -594,7 +601,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const Formats::const_iterator end = formats.end(); enable = false; for (; fit != end ; ++fit) { - if ((*fit)->name() == to_utf8(cmd.argument())) + if ((*fit)->name() == format) enable = true; } break; @@ -867,25 +874,41 @@ void LyXFunc::dispatch(FuncRequest const & cmd) break; } - case LFUN_BUFFER_UPDATE: + case LFUN_BUFFER_UPDATE: { LASSERT(lyx_view_ && buffer, /**/); - buffer->doExport(argument, true); + string format = argument; + if (argument.empty()) + format = buffer->getDefaultOutputFormat(); + buffer->doExport(format, true); break; + } - case LFUN_BUFFER_VIEW: + case LFUN_BUFFER_VIEW: { LASSERT(lyx_view_ && buffer, /**/); - buffer->preview(argument); + string format = argument; + if (argument.empty()) + format = buffer->getDefaultOutputFormat(); + buffer->preview(format); break; + } - case LFUN_MASTER_BUFFER_UPDATE: + case LFUN_MASTER_BUFFER_UPDATE: { LASSERT(lyx_view_ && buffer && buffer->masterBuffer(), /**/); - buffer->masterBuffer()->doExport(argument, true); + string format = argument; + if (argument.empty()) + format = buffer->masterBuffer()->getDefaultOutputFormat(); + buffer->masterBuffer()->doExport(format, true); break; + } - case LFUN_MASTER_BUFFER_VIEW: + case LFUN_MASTER_BUFFER_VIEW: { LASSERT(lyx_view_ && buffer && buffer->masterBuffer(), /**/); - buffer->masterBuffer()->preview(argument); + string format = argument; + if (argument.empty()) + format = buffer->masterBuffer()->getDefaultOutputFormat(); + buffer->masterBuffer()->preview(format); break; + } case LFUN_BUILD_PROGRAM: LASSERT(lyx_view_ && buffer, /**/); @@ -1874,6 +1897,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_DEFAULT_LANGUAGE: case LyXRC::RC_GUI_LANGUAGE: case LyXRC::RC_DEFAULT_PAPERSIZE: + case LyXRC::RC_DEFAULT_VIEW_FORMAT: case LyXRC::RC_DEFFILE: case LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN: case LyXRC::RC_DISPLAY_GRAPHICS: diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 3e14a07898..8397f70cbb 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -84,6 +84,7 @@ LexerKeyword lyxrcTags[] = { { "\\def_file", LyXRC::RC_DEFFILE }, { "\\default_language", LyXRC::RC_DEFAULT_LANGUAGE }, { "\\default_papersize", LyXRC::RC_DEFAULT_PAPERSIZE }, + { "\\default_view_format", LyXRC::RC_DEFAULT_VIEW_FORMAT }, { "\\dialogs_iconify_with_main", LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN }, { "\\display_graphics", LyXRC::RC_DISPLAY_GRAPHICS }, { "\\document_path", LyXRC::RC_DOCUMENTPATH }, @@ -227,6 +228,7 @@ void LyXRC::setDefaults() view_dvi_paper_option.erase(); default_papersize = PAPER_DEFAULT; custom_export_format = "ps"; + default_view_format = "pdf2"; chktex_command = "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"; bibtex_command = "bibtex"; fontenc = "default"; @@ -1017,6 +1019,10 @@ int LyXRC::read(Lexer & lexrc) } break; } + case RC_DEFAULT_VIEW_FORMAT: + lexrc >> default_view_format; + break; + case RC_DEFAULT_LANGUAGE: lexrc >> default_language; break; @@ -2389,6 +2395,13 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c << "\" \"\" \"\" \"\" \"\" \"\" \"\"\n"; if (tag != RC_LAST) break; + case RC_DEFAULT_VIEW_FORMAT: + if (ignore_system_lyxrc || + default_view_format != system_lyxrc.default_view_format) { + os << "\\default_view_format " << default_view_format << '\n'; + } + if (tag != RC_LAST) + break; case RC_VIEWER: // Ignore it if (tag != RC_LAST) @@ -2422,7 +2435,7 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c << "\" \"" << cit->to << "\" \"\" \"\"\n"; if (tag != RC_LAST) break; - + case RC_COPIER: if (tag == RC_LAST) os << "\n#\n" @@ -2554,6 +2567,10 @@ string const LyXRC::getDescription(LyXRCTags tag) str = _("Command definition file. Can either specify an absolute path, or LyX will look in its global and local commands/ directories."); break; + case RC_DEFAULT_VIEW_FORMAT: + str = _("The default format used with LFUN_BUFFER_[VIEW|UPDATE]."); + break; + case RC_DEFAULT_LANGUAGE: str = _("New documents will be assigned this language."); break; diff --git a/src/LyXRC.h b/src/LyXRC.h index dd84720d1a..329c79201c 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -69,6 +69,7 @@ public: RC_DATE_INSERT_FORMAT, RC_DEFFILE, RC_DEFAULT_LANGUAGE, + RC_DEFAULT_VIEW_FORMAT, RC_GUI_LANGUAGE, RC_DEFAULT_PAPERSIZE, RC_DIALOGS_ICONIFY_WITH_MAIN, @@ -371,6 +372,8 @@ public: /// std::string gui_language; /// + std::string default_view_format; + /// bool mac_like_word_movement; /// bool cursor_follows_scrollbar; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 809d3496b5..567df6a7ae 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1474,6 +1474,8 @@ PrefFileformats::PrefFileformats(GuiPreferences * form) this, SLOT(updatePrettyname())); connect(formatsCB->lineEdit(), SIGNAL(textEdited(QString)), this, SIGNAL(changed())); + connect(defaultFormatCB, SIGNAL(activated(QString)), + this, SIGNAL(changed())); } @@ -1492,36 +1494,55 @@ string const l10n_shortcut(string const prettyname, string const shortcut) }; // namespace anon -void PrefFileformats::apply(LyXRC & /*rc*/) const +void PrefFileformats::apply(LyXRC & rc) const { + QString const default_format = defaultFormatCB->itemData( + defaultFormatCB->currentIndex()).toString(); + rc.default_view_format = fromqstr(default_format); } -void PrefFileformats::update(LyXRC const & /*rc*/) +void PrefFileformats::update(LyXRC const & rc) { + bool const init = defaultFormatCB->currentText().isEmpty(); updateView(); + if (init) { + int const pos = defaultFormatCB->findData(toqstr( + rc.default_view_format)); + defaultFormatCB->setCurrentIndex(pos); + } } void PrefFileformats::updateView() { QString const current = formatsCB->currentText(); + QString const current_def = defaultFormatCB->currentText(); // update combobox with formats formatsCB->blockSignals(true); + defaultFormatCB->blockSignals(true); formatsCB->clear(); form_->formats().sort(); Formats::const_iterator cit = form_->formats().begin(); Formats::const_iterator end = form_->formats().end(); - for (; cit != end; ++cit) + for (; cit != end; ++cit) { formatsCB->addItem(qt_(cit->prettyname()), - QVariant(form_->formats().getNumber(cit->name()))); + QVariant(form_->formats().getNumber(cit->name()))); + if (form_->converters().isReachable("latex", cit->name()) + || form_->converters().isReachable("pdflatex", cit->name())) + defaultFormatCB->addItem(qt_(cit->prettyname()), + QVariant(toqstr(cit->name()))); + } // restore selection - int const item = formatsCB->findText(current, Qt::MatchExactly); + int item = formatsCB->findText(current, Qt::MatchExactly); formatsCB->setCurrentIndex(item < 0 ? 0 : item); on_formatsCB_currentIndexChanged(item < 0 ? 0 : item); + item = defaultFormatCB->findText(current_def, Qt::MatchExactly); + defaultFormatCB->setCurrentIndex(item < 0 ? 0 : item); formatsCB->blockSignals(false); + defaultFormatCB->blockSignals(false); } diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index d323c7b313..5c02c392d5 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -791,8 +791,10 @@ void MenuDefinition::expandFormats(MenuItem::Kind kind, Buffer const * buf) label += "..."; break; case MenuItem::ViewFormats: - case MenuItem::ExportFormats: case MenuItem::UpdateFormats: + if ((*fit)->name() == buf->getDefaultOutputFormat()) + continue; + case MenuItem::ExportFormats: if (!(*fit)->documentFormat()) continue; break; diff --git a/src/frontends/qt4/ui/PrefFileformatsUi.ui b/src/frontends/qt4/ui/PrefFileformatsUi.ui index 695c55daa9..2f8141dd4b 100644 --- a/src/frontends/qt4/ui/PrefFileformatsUi.ui +++ b/src/frontends/qt4/ui/PrefFileformatsUi.ui @@ -5,8 +5,8 @@ 0 0 - 414 - 322 + 427 + 413 @@ -19,6 +19,53 @@ 6 + + + + Specify the default output format when using (PDF)LaTeX + + + Default Format + + + true + + + + 9 + + + 6 + + + + + De&fault Output Format: + + + defaultFormatCB + + + + + + + + + + + + + Qt::Vertical + + + + 124 + 21 + + + + @@ -149,19 +196,6 @@ - - - - Qt::Vertical - - - - 168 - 21 - - - - -- 2.39.2