D14000: qqc2-desktop-style: basic support for QGuiApplication-based apps (WIP/PoC)

2018-10-22 Thread René J . V . Bertin
rjvbb updated this revision to Diff 44083.
rjvbb added a comment.


  updated for the current git/head.
  
  David: did you perhaps forget to accept the revision (aka, should I have 
committed this)?

CHANGES SINCE LAST UPDATE
  https://phabricator.kde.org/D14000?vs=37897=44083

REVISION DETAIL
  https://phabricator.kde.org/D14000

AFFECTED FILES
  plugin/kquickstyleitem.cpp
  plugin/kquickstyleitem_p.h

To: rjvbb, #frameworks
Cc: alexeymin, davidedmundson, mart, broulik, plasma-devel, ragreen, Pitel, 
ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol


D14000: qqc2-desktop-style: basic support for QGuiApplication-based apps (WIP/PoC)

2018-07-16 Thread René J . V . Bertin
rjvbb updated this revision to Diff 37897.
rjvbb added a comment.


  Using QApplication::style()

CHANGES SINCE LAST UPDATE
  https://phabricator.kde.org/D14000?vs=37568=37897

REVISION DETAIL
  https://phabricator.kde.org/D14000

AFFECTED FILES
  plugin/kquickstyleitem.cpp
  plugin/kquickstyleitem_p.h

To: rjvbb, #frameworks
Cc: alexeymin, davidedmundson, mart, broulik, plasma-devel, ragreen, Pitel, 
ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol


D14000: qqc2-desktop-style: basic support for QGuiApplication-based apps (WIP/PoC)

2018-07-16 Thread Alexey Min
alexeymin added a comment.


  Don't know how much offtopic will be what I'm going to say, but I recently 
ran into an issue while packaging QQC2 application in flatpak with 
org.kde.Platform//5.9 runtime. My app was functioning perfectly fine in system, 
but under flatpak it failed to start with the following message: `QWidget: 
Cannot create a QWidget without QApplication`. Of course, I had only 
QGuiApplication. But I wasn't using widgets! The only class from QtWidgets was 
QSystemTrayIcon for a nice integration with desktop. My guess was that was 
caused by platform style used in flatpak's KDE runtime may use widgets. But 
this was unexpected, without flatpak all was working. In the end I was forced 
to use QApplication, and visually saw the style used was ogr.kde.desktop.
  
  I wrote a small test QML QQC2 program with QGuiApplication and packaged it 
with flatpak with the same runtime, surprisingly, it started OK, without any 
error message. Basically, QQC2 ApplicationWindow with a button inside, not 
linked to widgets. ( https://github.com/minlexx/test_qqc2hello - repo with test 
scripts )
  
  So, if the program is linked to Qt5Widgets in any way, it has to use 
QApplication in flatpak's org.kde.Platform even if it does not use widgets? Is 
it related to this patch? Will it solve my problem? (if included in flatpak's 
kde runtime) 

REPOSITORY
  R858 Qt Quick Controls 2: Desktop Style

REVISION DETAIL
  https://phabricator.kde.org/D14000

To: rjvbb, #frameworks
Cc: alexeymin, davidedmundson, mart, broulik, plasma-devel, ragreen, Pitel, 
ZrenBot, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol


D14000: qqc2-desktop-style: basic support for QGuiApplication-based apps (WIP/PoC)

2018-07-16 Thread David Edmundson
davidedmundson added a comment.


  Please swap qApp->style for QApplication::style as it's static.
  
  Solution is quite clever. 
  It's risky as any qstyle will always be written assuming it's a QApplication; 
but by definition the QQC2 code shields from a lot of the QWidget casting that 
would cause an issue.
  
  Worst case we crash, which is the current state.
  
  I don't think we should remove the plasma-integration guard, but this is 
surprisingly un-invasive. Meh, +1

REPOSITORY
  R858 Qt Quick Controls 2: Desktop Style

REVISION DETAIL
  https://phabricator.kde.org/D14000

To: rjvbb, #frameworks
Cc: davidedmundson, mart, broulik, plasma-devel, ragreen, Pitel, ZrenBot, 
lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol


D14000: qqc2-desktop-style: basic support for QGuiApplication-based apps (WIP/PoC)

2018-07-11 Thread René J . V . Bertin
rjvbb updated this revision to Diff 37568.
rjvbb added a comment.


  build on Mac too

CHANGES SINCE LAST UPDATE
  https://phabricator.kde.org/D14000?vs=37439=37568

REVISION DETAIL
  https://phabricator.kde.org/D14000

AFFECTED FILES
  plugin/kquickstyleitem.cpp
  plugin/kquickstyleitem_p.h

To: rjvbb, #frameworks
Cc: mart, broulik, plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, 
ali-mohamed, jensreuterberg, abetts, sebas, apol


D14000: qqc2-desktop-style: basic support for QGuiApplication-based apps (WIP/PoC)

2018-07-10 Thread Marco Martin
mart added a comment.


  in principle i agree, I would love to be able to use this in 
qguiapplications, but are we sure qstyles won't access qapplication? doesn't 
this risk to just move the crash?

REPOSITORY
  R858 Qt Quick Controls 2: Desktop Style

REVISION DETAIL
  https://phabricator.kde.org/D14000

To: rjvbb, #frameworks
Cc: mart, broulik, plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, 
ali-mohamed, jensreuterberg, abetts, sebas, apol


D14000: qqc2-desktop-style: basic support for QGuiApplication-based apps (WIP/PoC)

2018-07-09 Thread Kai Uwe Broulik
broulik added a comment.


  Why, or who, is setting this environment variable? Plasma-integration sets 
`QQuickStyle` depending on whether there is a `QApplication` or not, so this 
makes no sense.

REPOSITORY
  R858 Qt Quick Controls 2: Desktop Style

REVISION DETAIL
  https://phabricator.kde.org/D14000

To: rjvbb, #frameworks
Cc: broulik, plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, 
jensreuterberg, abetts, sebas, apol, mart


D14000: qqc2-desktop-style: basic support for QGuiApplication-based apps (WIP/PoC)

2018-07-09 Thread René J . V . Bertin
rjvbb updated this revision to Diff 37439.
rjvbb edited the summary of this revision.
rjvbb edited the test plan for this revision.
rjvbb added a comment.


  Getting the user's desktop style was easier than I thought.

CHANGES SINCE LAST UPDATE
  https://phabricator.kde.org/D14000?vs=37437=37439

REVISION DETAIL
  https://phabricator.kde.org/D14000

AFFECTED FILES
  plugin/kquickstyleitem.cpp
  plugin/kquickstyleitem_p.h

To: rjvbb, #framework_syntax_highlighting
Cc: plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, 
jensreuterberg, abetts, sebas, apol, mart


D14000: qqc2-desktop-style: basic support for QGuiApplication-based apps (WIP/PoC)

2018-07-09 Thread René J . V . Bertin
rjvbb created this revision.
rjvbb added a reviewer: Framework: Syntax Highlighting.
Restricted Application added a project: Plasma.
Restricted Application added a subscriber: plasma-devel.
rjvbb requested review of this revision.

REVISION SUMMARY
  See https://bugs.kde.org/show_bug.cgi?id=396287
  
  Setting `QT_QUICK_CONTROLS_STYLE=org.kde.desktop` used to be safe but has 
started the cause applications to crash. Or I just never ran into what seem to 
be random (from a Joe User experience) but in fact are QGuiApplication-based 
applications.
  
  This patch presents a proof-of-concept fix that makes it safe to set 
`QT_QUICK_CONTROLS_STYLE` or whatever other options there are to use the QQC2 
desktop style in all applications that use QuickControls2.
  The current implementation creates a local instance of Qt's built-in Fusion 
style, and probably doesn't need to create a new instance for each new 
KQuickStyleItem instance. Being a Tier3 framework it should be possible to 
fetch the current desktop style through KConfig, in which case creating a new 
QStyle instance would be (more) justified. There's probably some optimisation 
to be done here though I'm not convinced it will make any difference in 
practice, in the general context of using QtQuick.
  
  An alternative approach would be to do the programmatic equivalent of the 
command-line override (e.g. `quickcontrols2/gallery/gallery -style Default`) 
but I have not yet been able to figure out if it is possible to change the 
QQuickStyle at this point.

TEST PLAN
  Tested with
  
> env QT_QUICK_CONTROLS_STYLE=org.kde.desktop 
/path/to/qt5-examples/quickcontrols2/gallery/gallery
  
  before: immediate crash because the plugin dereferences a NULL qApp->style() 
without flinching
  after: practically normal behaviour that is certainly preferable to crashing 
due to a potential security exploit.

REPOSITORY
  R858 Qt Quick Controls 2: Desktop Style

REVISION DETAIL
  https://phabricator.kde.org/D14000

AFFECTED FILES
  plugin/kquickstyleitem.cpp
  plugin/kquickstyleitem_p.h

To: rjvbb, #framework_syntax_highlighting
Cc: plasma-devel, ragreen, Pitel, ZrenBot, lesliezhai, ali-mohamed, 
jensreuterberg, abetts, sebas, apol, mart