add GUI config for graphicssystem

REVIEW: 103431
This commit is contained in:
Thomas Lübking 2011-12-16 17:35:50 +01:00
parent d845b60c6c
commit 19fceb5216
3 changed files with 69 additions and 9 deletions

View file

@ -38,6 +38,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <knotification.h>
#include <QtDBus/QtDBus>
#include <QPainter>
#include <QPaintEngine>
#include <QTimer>
#include <QLabel>
#include <KPluginFactory>
@ -99,6 +101,7 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
connect(ui.rearmGlSupportButton, SIGNAL(clicked()), this, SLOT(rearmGlSupport()));
connect(ui.useCompositing, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect(ui.useCompositing, SIGNAL(clicked(bool)), this, SLOT(suggestGraphicsSystem()));
connect(ui.effectWinManagement, SIGNAL(toggled(bool)), this, SLOT(changed()));
connect(ui.effectAnimations, SIGNAL(toggled(bool)), this, SLOT(changed()));
@ -111,6 +114,8 @@ KWinCompositingConfig::KWinCompositingConfig(QWidget *parent, const QVariantList
connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
connect(ui.compositingType, SIGNAL(currentIndexChanged(int)), this, SLOT(toogleSmoothScaleUi(int)));
connect(ui.compositingType, SIGNAL(activated(int)), this, SLOT(suggestGraphicsSystem()));
connect(ui.graphicsSystem, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
connect(ui.windowThumbnails, SIGNAL(activated(int)), this, SLOT(changed()));
connect(ui.unredirectFullscreen , SIGNAL(toggled(bool)), this, SLOT(changed()));
connect(ui.glScaleFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
@ -303,6 +308,12 @@ void KWinCompositingConfig::rearmGlSupport()
load();
}
void KWinCompositingConfig::suggestGraphicsSystem()
{
if (!ui.useCompositing->isChecked() || ui.compositingType->currentIndex() == XRENDER_INDEX)
ui.graphicsSystem->setCurrentIndex(0);
}
void KWinCompositingConfig::toogleSmoothScaleUi(int compositingType)
{
@ -339,6 +350,16 @@ void KWinCompositingConfig::loadAdvancedTab()
KConfigGroup config(mKWinConfig, "Compositing");
QString backend = config.readEntry("Backend", "OpenGL");
ui.compositingType->setCurrentIndex((backend == "XRender") ? XRENDER_INDEX : 0);
originalGraphicsSystem = config.readEntry("GraphicsSystem", QString());
if (originalGraphicsSystem.isEmpty()) { // detect system default
QPixmap pix(1,1);
QPainter p(&pix);
originalGraphicsSystem = (p.paintEngine()->type() == QPaintEngine::X11) ? "native" : "raster";
p.end();
}
ui.graphicsSystem->setCurrentIndex((originalGraphicsSystem == "native") ? 0 : 1);
// 4 - off, 5 - shown, 6 - always, other are old values
int hps = config.readEntry("HiddenPreviews", 5);
if (hps == 6) // always
@ -461,6 +482,7 @@ bool KWinCompositingConfig::saveAdvancedTab()
static const int hps[] = { 6 /*always*/, 5 /*shown*/, 4 /*never*/ };
KConfigGroup config(mKWinConfig, "Compositing");
QString graphicsSystem = (ui.graphicsSystem->currentIndex() == 0) ? "native" : "raster";
if (config.readEntry("Backend", "OpenGL")
!= ((ui.compositingType->currentIndex() == OPENGL_INDEX) ? "OpenGL" : "XRender")
@ -470,10 +492,14 @@ bool KWinCompositingConfig::saveAdvancedTab()
advancedChanged = true;
} else if (config.readEntry("HiddenPreviews", 5) != hps[ ui.windowThumbnails->currentIndex()]
|| (int)config.readEntry("XRenderSmoothScale", false) != ui.xrScaleFilter->currentIndex()
|| config.readEntry("GLTextureFilter", 2) != ui.glScaleFilter->currentIndex())
|| config.readEntry("GLTextureFilter", 2) != ui.glScaleFilter->currentIndex()) {
advancedChanged = true;
} else if (originalGraphicsSystem != graphicsSystem) {
advancedChanged = true;
}
config.writeEntry("Backend", (ui.compositingType->currentIndex() == OPENGL_INDEX) ? "OpenGL" : "XRender");
config.writeEntry("GraphicsSystem", graphicsSystem);
config.writeEntry("HiddenPreviews", hps[ ui.windowThumbnails->currentIndex()]);
config.writeEntry("UnredirectFullscreen", ui.unredirectFullscreen->isChecked());

View file

@ -77,6 +77,7 @@ public slots:
private slots:
void rearmGlSupport();
void suggestGraphicsSystem();
void toogleSmoothScaleUi(int compositingType);
void toggleEffectShortcutChanged(const QKeySequence &seq);
@ -93,6 +94,7 @@ private:
KSharedConfigPtr mTmpConfig;
bool m_showConfirmDialog;
KActionCollection* m_actionCollection;
QString originalGraphicsSystem;
};
} // namespace

View file

@ -7,14 +7,14 @@
<x>0</x>
<y>0</y>
<width>552</width>
<height>523</height>
<height>483</height>
</rect>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@ -517,6 +517,39 @@
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Qt graphics system:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="graphicsSystem">
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;It is &lt;span style=&quot; font-weight:600;&quot;&gt;strongly recommended&lt;/span&gt; to use the &lt;span style=&quot; font-weight:600;&quot;&gt;native&lt;/span&gt; system when using the the &lt;span style=&quot; font-weight:600;&quot;&gt;XRender&lt;/span&gt; backend.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;On the other hand, many decorations perform better with the &lt;span style=&quot; font-weight:600;&quot;&gt;raster&lt;/span&gt; system on the &lt;span style=&quot; font-weight:600;&quot;&gt;default and generally preferred OpenGL&lt;/span&gt; backend (though some don't - also the impact here can be anything between &amp;quot;slight&amp;quot; and &amp;quot;incredible&amp;quot; depending on the GPU and driver)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>Native</string>
</property>
</item>
<item>
<property name="text">
<string>Raster</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="3">
@ -810,16 +843,16 @@ On legacy hardware disabling Shaders can improve the performance.</string>
<extends>QWidget</extends>
<header>kkeysequencewidget.h</header>
</customwidget>
<customwidget>
<class>KTitleWidget</class>
<extends>QWidget</extends>
<header>ktitlewidget.h</header>
</customwidget>
<customwidget>
<class>KComboBox</class>
<extends>QComboBox</extends>
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>KTitleWidget</class>
<extends>QWidget</extends>
<header>ktitlewidget.h</header>
</customwidget>
<customwidget>
<class>KPluginSelector</class>
<extends>QWidget</extends>
@ -832,7 +865,6 @@ On legacy hardware disabling Shaders can improve the performance.</string>
<tabstop>useCompositing</tabstop>
<tabstop>effectWinManagement</tabstop>
<tabstop>effectAnimations</tabstop>
<tabstop>windowSwitchingCombo</tabstop>
<tabstop>desktopSwitchingCombo</tabstop>
<tabstop>animationSpeedCombo</tabstop>
</tabstops>