Am Fr., 7. Juli 2023 um 04:37 Uhr schrieb Thibaut Cuvelier:

> I'm having an issue with your patch: QStyle::name has only been added in
> Qt 6.1 (https://doc.qt.io/qt-6/qstyle.html#name). I believe
> QObject::objectName should do the trick too.
>
> As I understand your problem, in LyX.cpp, LyX::exec first creates a
> GuiApplication (line 358) before initialising LyX (line 366). If I do the
> initialisation in GuiApplication::exec instead, I don't get any crash;
> actually, your patch works :)!
> I have added a similar line in PrefInput::applyRC so that the style change
> applies immediately when clicking Apply in the Preferences window.
>

I think it is actually better to do that in PrefUserInterface::applyRC for
affiliation.

>
> I'm attaching the corresponding patch.
>

I didn't understand this part:
@@ -718,13 +718,13 @@ GuiView::GuiView(int id)
  connect(zoom_value_, SIGNAL(pressed()), this,
SLOT(showZoomContextMenu()));
  // zoom_value_->setPalette(palette);
  zoom_value_->setForegroundRole(statusBar()->foregroundRole());
  zoom_value_->setFixedHeight(fm.height());
 #if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
- zoom_value_->setMinimumWidth(fm.horizontalAdvance("444\%"));
+ zoom_value_->setMinimumWidth(fm.horizontalAdvance("444%"));
 #else
- zoom_value_->setMinimumWidth(fm.width("444\%"));
+ zoom_value_->setMinimumWidth(fm.width("444%"));
 #endif
  zoom_value_->setAlignment(Qt::AlignCenter);
  zoom_value_->setText(toqstr(bformat(_("[[ZOOM]]%1$d%"), zoom)));
  statusBar()->addPermanentWidget(zoom_value_);
  zoom_value_->setEnabled(currentBufferView());


>
> Side question: why is createApplication declared in Application.h but
> defined in GuiApplication.cpp?
>
>
> On Fri, 7 Jul 2023 at 02:23, Thibaut Cuvelier wrote:
>
>> Can't you use setStyle later on, once LyXRC is read?
>>
>
You could, like in your patch, but this creates another problem (see below)


> I suspect it should be enough to apply the style to the whole application,
>> based on the source code (
>> https://github.com/qt/qtbase/blob/dev/src/widgets/kernel/qapplication.cpp#L971),
>> as I understand that GuiApplication is the root widget for the whole LyX.
>>
>> Also, I believe that LyXRC shouldn't take precedence over CLI arguments
>> (-style windows, for instance); does Qt implement this itself or do we have
>> to check in QCoreApplication::arguments if a style is given?
>>
>
I believe the way would be to set the style *before* the QApplication is
created, then if any style is given in CLI arguments, QApplication uses
that over the one previously set.

I don't know, to me it seems we *need* to know style setting from lyxrc
before we create the gui app
frontend::GuiApplication * guiApp = new frontend::GuiApplication(argc,
argv);
which is not given.
otherwise we would need to check cli arguments manually for "-style" and I
don't want to do that, if Qt decides to change those in the future we would
have to put more work into it.
What can be done is calling readRcFile("preferences", true) before
CreateApplication, like I have done here in the attached patch, but I don't
know if that is ok or not, it seems to work, but I can't assess it 100%,
any ideas/objections?
Also note that in the patch I have set "fusion" to default on Windows,
other OSes can do it the same way if they want.
-- 
  Eugene

Attachment: 0001-Implement-style-selection-dialog.patch
Description: Binary data

-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to