- 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:
parent
b9275d2b1a
commit
eb02256303
3 changed files with 14 additions and 13 deletions
|
@ -18,6 +18,7 @@ License. See the file "COPYING" for the exact licensing terms.
|
||||||
#include <kglobal.h>
|
#include <kglobal.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
|
#include <kconfiggroup.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
@ -36,9 +37,12 @@ MouseMarkEffect::MouseMarkEffect()
|
||||||
{
|
{
|
||||||
KActionCollection* actionCollection = new KActionCollection( this );
|
KActionCollection* actionCollection = new KActionCollection( this );
|
||||||
KAction* a = static_cast< KAction* >( actionCollection->addAction( "ClearMouseMarks" ));
|
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 ));
|
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F11 ));
|
||||||
connect( a, SIGNAL( triggered( bool )), this, SLOT( clear()));
|
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 )
|
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 );
|
glPushAttrib( GL_ENABLE_BIT | GL_CURRENT_BIT | GL_LINE_BIT );
|
||||||
glColor4f( 1, 0, 0, 1 ); // red
|
glColor4f( 1, 0, 0, 1 ); // red
|
||||||
glEnable( GL_LINE_SMOOTH );
|
glEnable( GL_LINE_SMOOTH );
|
||||||
glLineWidth( 3 );
|
glLineWidth( width );
|
||||||
foreach( const Mark& mark, marks )
|
foreach( const Mark& mark, marks )
|
||||||
{
|
{
|
||||||
glBegin( GL_LINE_STRIP );
|
glBegin( GL_LINE_STRIP );
|
||||||
|
@ -78,8 +82,10 @@ void MouseMarkEffect::mouseChanged( const QPoint& pos, const QPoint&,
|
||||||
return;
|
return;
|
||||||
QPoint pos2 = drawing.last();
|
QPoint pos2 = drawing.last();
|
||||||
drawing.append( pos );
|
drawing.append( pos );
|
||||||
effects->addRepaint( QRect( qMin( pos.x(), pos2.x()), qMin( 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())));
|
qMax( pos.x(), pos2.x()), qMax( pos.y(), pos2.y()));
|
||||||
|
repaint.adjust( -width, -width, width, width );
|
||||||
|
effects->addRepaint( repaint );
|
||||||
}
|
}
|
||||||
else if( !drawing.isEmpty())
|
else if( !drawing.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,7 @@ class MouseMarkEffect
|
||||||
typedef QVector< QPoint > Mark;
|
typedef QVector< QPoint > Mark;
|
||||||
QVector< Mark > marks;
|
QVector< Mark > marks;
|
||||||
Mark drawing;
|
Mark drawing;
|
||||||
|
int width;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -52,12 +52,11 @@ MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList
|
||||||
// Shortcut config
|
// Shortcut config
|
||||||
KGlobalAccel::self()->overrideMainComponentData(componentData());
|
KGlobalAccel::self()->overrideMainComponentData(componentData());
|
||||||
m_actionCollection = new KActionCollection( this, componentData() );
|
m_actionCollection = new KActionCollection( this, componentData() );
|
||||||
m_actionCollection->setConfigGroup("MouseMark");
|
|
||||||
m_actionCollection->setConfigGlobal(true);
|
|
||||||
|
|
||||||
KAction* a = static_cast< KAction* >( m_actionCollection->addAction( "ClearMouseMarks" ));
|
KAction* a = static_cast< KAction* >( m_actionCollection->addAction( "ClearMouseMarks" ));
|
||||||
a->setText( i18n( "Clear Mouse Marks" ));
|
a->setText( i18n( "Clear Mouse Marks" ));
|
||||||
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F11 ));
|
a->setGlobalShortcut( KShortcut( Qt::SHIFT + Qt::META + Qt::Key_F11 ));
|
||||||
|
m_ui->editor->addCollection(m_actionCollection);
|
||||||
|
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
@ -69,14 +68,11 @@ void MouseMarkEffectConfig::load()
|
||||||
|
|
||||||
KConfigGroup conf = EffectsHandler::effectConfig("MouseMark");
|
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));
|
QColor color = conf.readEntry("Color", QColor(255, 0, 0));
|
||||||
m_ui->spinWidth->setValue(width);
|
m_ui->spinWidth->setValue(width);
|
||||||
//m_ui->spinHeight->setValue(height);
|
//m_ui->spinHeight->setValue(height);
|
||||||
|
|
||||||
m_actionCollection->readSettings();
|
|
||||||
m_ui->editor->addCollection(m_actionCollection);
|
|
||||||
|
|
||||||
emit changed(false);
|
emit changed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,12 +86,10 @@ void MouseMarkEffectConfig::save()
|
||||||
conf.writeEntry("LineWidth", m_ui->spinWidth->value());
|
conf.writeEntry("LineWidth", m_ui->spinWidth->value());
|
||||||
//conf.writeEntry("Color", m_ui->spinHeight->value());
|
//conf.writeEntry("Color", m_ui->spinHeight->value());
|
||||||
|
|
||||||
m_actionCollection->writeSettings();
|
|
||||||
|
|
||||||
conf.sync();
|
conf.sync();
|
||||||
|
|
||||||
emit changed(false);
|
emit changed(false);
|
||||||
EffectsHandler::sendReloadMessage( "magnifier" );
|
EffectsHandler::sendReloadMessage( "mousemark" );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MouseMarkEffectConfig::defaults()
|
void MouseMarkEffectConfig::defaults()
|
||||||
|
|
Loading…
Reference in a new issue