- Load & use line width from config file.

- Correct some mistakes in config module.
- Sync i18n string to the one in config module.
- Use correct repaint area.

svn path=/trunk/KDE/kdebase/workspace/; revision=740973
This commit is contained in:
Rivo Laks 2007-11-24 14:23:04 +00:00
parent b9275d2b1a
commit eb02256303
3 changed files with 14 additions and 13 deletions

View file

@ -18,6 +18,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include <kglobal.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kconfiggroup.h>
#include <math.h>
@ -36,9 +37,12 @@ MouseMarkEffect::MouseMarkEffect()
{
KActionCollection* actionCollection = new KActionCollection( this );
KAction* a = static_cast< KAction* >( actionCollection->addAction( "ClearMouseMarks" ));
a->setText( i18n( "ClearMouseMarks" ));
a->setText( i18n( "Clear Mouse Marks" ));
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F11 ));
connect( a, SIGNAL( triggered( bool )), this, SLOT( clear()));
KConfigGroup conf = EffectsHandler::effectConfig("MouseMark");
width = conf.readEntry( "LineWidth", 3 );
}
void MouseMarkEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
@ -49,7 +53,7 @@ void MouseMarkEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da
glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_LINE_BIT );
glColor4f( 1, 0, 0, 1 ); // red
glEnable( GL_LINE_SMOOTH );
glLineWidth( 3 );
glLineWidth( width );
foreach( const Mark& mark, marks )
{
glBegin( GL_LINE_STRIP );
@ -78,8 +82,10 @@ void MouseMarkEffect::mouseChanged( const QPoint& pos, const QPoint&,
return;
QPoint pos2 = drawing.last();
drawing.append( pos );
effects->addRepaint( QRect( qMin( pos.x(), pos2.x()), qMin( pos.y(), pos2.y()),
qMax( pos.x(), pos2.x()), qMax( pos.y(), pos2.y())));
QRect repaint = QRect( qMin( pos.x(), pos2.x()), qMin( pos.y(), pos2.y()),
qMax( pos.x(), pos2.x()), qMax( pos.y(), pos2.y()));
repaint.adjust( -width, -width, width, width );
effects->addRepaint( repaint );
}
else if( !drawing.isEmpty())
{

View file

@ -32,6 +32,7 @@ class MouseMarkEffect
typedef QVector< QPoint > Mark;
QVector< Mark > marks;
Mark drawing;
int width;
};
} // namespace

View file

@ -52,12 +52,11 @@ MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList
// Shortcut config
KGlobalAccel::self()->overrideMainComponentData(componentData());
m_actionCollection = new KActionCollection( this, componentData() );
m_actionCollection->setConfigGroup("MouseMark");
m_actionCollection->setConfigGlobal(true);
KAction* a = static_cast< KAction* >( m_actionCollection->addAction( "ClearMouseMarks" ));
a->setText( i18n( "Clear Mouse Marks" ));
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F11 ));
m_ui->editor->addCollection(m_actionCollection);
load();
}
@ -69,14 +68,11 @@ void MouseMarkEffectConfig::load()
KConfigGroup conf = EffectsHandler::effectConfig("MouseMark");
int width = conf.readEntry("LineWidth", 200);
int width = conf.readEntry("LineWidth", 3);
QColor color = conf.readEntry("Color", QColor(255, 0, 0));
m_ui->spinWidth->setValue(width);
//m_ui->spinHeight->setValue(height);
m_actionCollection->readSettings();
m_ui->editor->addCollection(m_actionCollection);
emit changed(false);
}
@ -90,12 +86,10 @@ void MouseMarkEffectConfig::save()
conf.writeEntry("LineWidth", m_ui->spinWidth->value());
//conf.writeEntry("Color", m_ui->spinHeight->value());
m_actionCollection->writeSettings();
conf.sync();
emit changed(false);
EffectsHandler::sendReloadMessage( "magnifier" );
EffectsHandler::sendReloadMessage( "mousemark" );
}
void MouseMarkEffectConfig::defaults()