Make window caption presentation configurable and turned off by default.

svn path=/trunk/KDE/kdebase/workspace/; revision=791193
This commit is contained in:
Louai Al-Khanji 2008-03-28 17:26:04 +00:00
parent 334a64dedb
commit 32bc8c8d07
4 changed files with 43 additions and 24 deletions

View file

@ -64,6 +64,7 @@ PresentWindowsEffect::PresentWindowsEffect()
borderActivate = (ElectricBorder)conf.readEntry("BorderActivate", (int)ElectricNone); borderActivate = (ElectricBorder)conf.readEntry("BorderActivate", (int)ElectricNone);
borderActivateAll = (ElectricBorder)conf.readEntry("BorderActivateAll", (int)ElectricTopLeft); borderActivateAll = (ElectricBorder)conf.readEntry("BorderActivateAll", (int)ElectricTopLeft);
drawWindowCaptions = conf.readEntry("DrawWindowCaptions", false);
effects->reserveElectricBorder( borderActivate ); effects->reserveElectricBorder( borderActivate );
effects->reserveElectricBorder( borderActivateAll ); effects->reserveElectricBorder( borderActivateAll );
@ -84,7 +85,7 @@ PresentWindowsEffect::~PresentWindowsEffect()
void PresentWindowsEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void PresentWindowsEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{ {
// How long does it take for the effect to get it's full strength (in ms) // How long does it take for the effect to get it's full strength (in ms)
const double changeTime = 300; const double changeTime = 125;
if(mActivated) if(mActivated)
{ {
mActiveness = qMin(1.0, mActiveness + time/changeTime); mActiveness = qMin(1.0, mActiveness + time/changeTime);
@ -122,7 +123,7 @@ void PresentWindowsEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData&
data.setTranslucent(); data.setTranslucent();
// Change window's highlight // Change window's highlight
WindowData& windata = mWindowData[w]; WindowData& windata = mWindowData[w];
const double highlightchangetime = 200; const double highlightchangetime = 100;
if( w == mHighlightedWindow ) if( w == mHighlightedWindow )
windata.highlight = qMin(1.0, windata.highlight + time / highlightchangetime); windata.highlight = qMin(1.0, windata.highlight + time / highlightchangetime);
else else
@ -205,18 +206,21 @@ void PresentWindowsEffect::paintWindow( EffectWindow* w, int mask, QRegion regio
const WindowData& windata = mWindowData[w]; const WindowData& windata = mWindowData[w];
paintWindowIcon( w, data ); paintWindowIcon( w, data );
QString text = w->caption(); if (drawWindowCaptions)
double centerx = w->x() + data.xTranslate + w->width() * data.xScale * 0.5f; {
double centery = w->y() + data.yTranslate + w->height() * data.yScale * 0.5f; QString text = w->caption();
int maxwidth = (int)(w->width() * data.xScale - 20); double centerx = w->x() + data.xTranslate + w->width() * data.xScale * 0.5f;
double opacity = (0.7 + 0.2*windata.highlight) * data.opacity * mActiveness; double centery = w->y() + data.yTranslate + w->height() * data.yScale * 0.5f;
QColor textcolor( 255, 255, 255, (int)(255*opacity) ); int maxwidth = (int)(w->width() * data.xScale - 20);
QColor bgcolor( 0, 0, 0, (int)(255*opacity) ); double opacity = (0.7 + 0.2*windata.highlight) * data.opacity * mActiveness;
QFont f; QColor textcolor( 255, 255, 255, (int)(255*opacity) );
f.setBold( true ); QColor bgcolor( 0, 0, 0, (int)(255*opacity) );
f.setPointSize( 12 ); QFont f;
effects->paintTextWithBackground( text, QPoint( (int)centerx, (int)centery ), maxwidth, f.setBold( true );
textcolor, bgcolor, f); f.setPointSize( 12 );
effects->paintTextWithBackground( text, QPoint( (int)centerx, (int)centery ), maxwidth,
textcolor, bgcolor, f);
}
} }
} }

View file

@ -137,6 +137,7 @@ class PresentWindowsEffect
ElectricBorder borderActivate; ElectricBorder borderActivate;
ElectricBorder borderActivateAll; ElectricBorder borderActivateAll;
bool drawWindowCaptions;
#ifdef KWIN_HAVE_XRENDER_COMPOSITING #ifdef KWIN_HAVE_XRENDER_COMPOSITING
XRenderPictFormat* alphaFormat; XRenderPictFormat* alphaFormat;

View file

@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QGridLayout> #include <QGridLayout>
#include <QLabel> #include <QLabel>
#include <QComboBox> #include <QComboBox>
#include <QCheckBox>
KWIN_EFFECT_CONFIG_FACTORY KWIN_EFFECT_CONFIG_FACTORY
@ -47,23 +48,27 @@ PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QV
QGridLayout* layout = new QGridLayout(this); QGridLayout* layout = new QGridLayout(this);
layout->addWidget(new QLabel(i18n("Activate when cursor is at a specific edge " mDrawWindowText = new QCheckBox(i18n("Draw window caption on top of window."), this);
"or corner of the screen:"), this), 0, 0, 1, 3); connect(mDrawWindowText, SIGNAL(stateChanged(int)), this, SLOT(changed()));
layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed), 1, 0, 2, 1); layout->addWidget(mDrawWindowText, 0, 0);
layout->addWidget(new QLabel(i18n("for windows on current desktop: "), this), 1, 1); layout->addWidget(new QLabel(i18n("Activate when cursor is at a specific edge "
"or corner of the screen:"), this), 1, 0, 1, 3);
layout->addItem(new QSpacerItem(20, 20, QSizePolicy::Fixed), 2, 0, 2, 1);
layout->addWidget(new QLabel(i18n("for windows on current desktop: "), this), 2, 1);
mActivateCombo = new QComboBox; mActivateCombo = new QComboBox;
addItems(mActivateCombo); addItems(mActivateCombo);
connect(mActivateCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); connect(mActivateCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
layout->addWidget(mActivateCombo, 1, 2); layout->addWidget(mActivateCombo, 2, 2);
layout->addWidget(new QLabel(i18n("for windows on all desktops: "), this), 2, 1); layout->addWidget(new QLabel(i18n("for windows on all desktops: "), this), 3, 1);
mActivateAllCombo = new QComboBox; mActivateAllCombo = new QComboBox;
addItems(mActivateAllCombo); addItems(mActivateAllCombo);
connect(mActivateAllCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); connect(mActivateAllCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
layout->addWidget(mActivateAllCombo, 2, 2); layout->addWidget(mActivateAllCombo, 3, 2);
layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Expanding), 3, 0, 1, 3); layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Fixed, QSizePolicy::Expanding), 4, 0, 1, 3);
// Shortcut config // Shortcut config
KGlobalAccel::self()->overrideMainComponentData(componentData()); KGlobalAccel::self()->overrideMainComponentData(componentData());
@ -77,9 +82,9 @@ PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QV
mShortcutEditor = new KShortcutsEditor(actionCollection, this, mShortcutEditor = new KShortcutsEditor(actionCollection, this,
KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed); KShortcutsEditor::GlobalAction, KShortcutsEditor::LetterShortcutsDisallowed);
connect(mShortcutEditor, SIGNAL(keyChange()), this, SLOT(changed())); connect(mShortcutEditor, SIGNAL(keyChange()), this, SLOT(changed()));
layout->addWidget(mShortcutEditor, 4, 0, 1, 3); layout->addWidget(mShortcutEditor, 5, 0, 1, 3);
layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 5, 0, 1, 3); layout->addItem(new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding), 6, 0, 1, 3);
load(); load();
@ -119,6 +124,9 @@ void PresentWindowsEffectConfig::load()
activateAllBorder--; activateAllBorder--;
mActivateAllCombo->setCurrentIndex(activateAllBorder); mActivateAllCombo->setCurrentIndex(activateAllBorder);
bool drawWindowCaptions = conf.readEntry("DrawWindowCaptions", false);
mDrawWindowText->setChecked(drawWindowCaptions);
emit changed(false); emit changed(false);
} }
@ -139,6 +147,9 @@ void PresentWindowsEffectConfig::save()
activateAllBorder = (int)ElectricNone; activateAllBorder = (int)ElectricNone;
conf.writeEntry("BorderActivateAll", activateAllBorder); conf.writeEntry("BorderActivateAll", activateAllBorder);
bool drawWindowCaptions = mDrawWindowText->isChecked();
conf.writeEntry("DrawWindowCaptions", drawWindowCaptions);
conf.sync(); conf.sync();
emit changed(false); emit changed(false);
@ -150,6 +161,7 @@ void PresentWindowsEffectConfig::defaults()
kDebug() ; kDebug() ;
mActivateCombo->setCurrentIndex( (int)ElectricNone - 1 ); mActivateCombo->setCurrentIndex( (int)ElectricNone - 1 );
mActivateAllCombo->setCurrentIndex( (int)ElectricTopLeft ); mActivateAllCombo->setCurrentIndex( (int)ElectricTopLeft );
mDrawWindowText->setChecked(false);
mShortcutEditor->allDefault(); mShortcutEditor->allDefault();
emit changed(true); emit changed(true);
} }

View file

@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kcmodule.h> #include <kcmodule.h>
#undef KDE3_SUPPORT #undef KDE3_SUPPORT
class QCheckBox;
class QComboBox; class QComboBox;
class KShortcutsEditor; class KShortcutsEditor;
@ -46,6 +47,7 @@ class PresentWindowsEffectConfig : public KCModule
void addItems(QComboBox* combo); void addItems(QComboBox* combo);
private: private:
QCheckBox* mDrawWindowText;
QComboBox* mActivateCombo; QComboBox* mActivateCombo;
QComboBox* mActivateAllCombo; QComboBox* mActivateAllCombo;
KShortcutsEditor* mShortcutEditor; KShortcutsEditor* mShortcutEditor;