Electric Border handling for desktopgrid effect
FEATURE: 155954 svn path=/trunk/KDE/kdebase/workspace/; revision=768124
This commit is contained in:
parent
90f7989cec
commit
414d59ea16
4 changed files with 57 additions and 1 deletions
|
@ -51,6 +51,14 @@ DesktopGridEffect::DesktopGridEffect()
|
|||
connect( a, SIGNAL( triggered( bool )), this, SLOT( toggle()));
|
||||
KConfigGroup conf = effects->effectConfig("DesktopGrid");
|
||||
slideEnabled = conf.readEntry( "Slide", true );
|
||||
|
||||
borderActivate = (ElectricBorder)conf.readEntry("BorderActivate", (int)ElectricNone);
|
||||
effects->reserveElectricBorder( borderActivate );
|
||||
}
|
||||
|
||||
DesktopGridEffect::~DesktopGridEffect()
|
||||
{
|
||||
effects->unreserveElectricBorder( borderActivate );
|
||||
}
|
||||
|
||||
void DesktopGridEffect::prePaintScreen( ScreenPrePaintData& data, int time )
|
||||
|
@ -615,6 +623,18 @@ void DesktopGridEffect::setHighlightedDesktop( int d )
|
|||
effects->addRepaint( desktopRect( highlighted_desktop, true ));
|
||||
}
|
||||
|
||||
bool DesktopGridEffect::borderActivated( ElectricBorder border )
|
||||
{
|
||||
if( effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this )
|
||||
return false;
|
||||
if( border == borderActivate && !activated )
|
||||
{
|
||||
toggle();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "desktopgrid.moc"
|
||||
|
|
|
@ -33,6 +33,7 @@ class DesktopGridEffect
|
|||
Q_OBJECT
|
||||
public:
|
||||
DesktopGridEffect();
|
||||
~DesktopGridEffect();
|
||||
virtual void prePaintScreen( ScreenPrePaintData& data, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
|
@ -42,6 +43,7 @@ class DesktopGridEffect
|
|||
virtual void desktopChanged( int old );
|
||||
virtual void windowInputMouseEvent( Window w, QEvent* e );
|
||||
virtual void grabbedKeyboardEvent( QKeyEvent* e );
|
||||
virtual bool borderActivated( ElectricBorder border );
|
||||
private slots:
|
||||
void toggle();
|
||||
private:
|
||||
|
@ -71,6 +73,7 @@ class DesktopGridEffect
|
|||
QPoint slide_start_pos;
|
||||
bool slide_painting_sticky;
|
||||
QPoint slide_painting_diff;
|
||||
ElectricBorder borderActivate;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -31,7 +31,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <kconfiggroup.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QLabel>
|
||||
#ifndef KDE_USE_FINAL
|
||||
KWIN_EFFECT_CONFIG_FACTORY
|
||||
#endif
|
||||
|
@ -49,6 +52,25 @@ DesktopGridEffectConfig::DesktopGridEffectConfig(QWidget* parent, const QVariant
|
|||
connect(mSlide, SIGNAL(toggled(bool)), this, SLOT(changed()));
|
||||
layout->addWidget(mSlide);
|
||||
|
||||
QHBoxLayout* comboLayout = new QHBoxLayout();
|
||||
QLabel* label = new QLabel(i18n("Activate when cursor is at a specific edge "
|
||||
"or corner of the screen:"), this);
|
||||
|
||||
mActivateCombo = new QComboBox;
|
||||
mActivateCombo->addItem(i18n("Top"));
|
||||
mActivateCombo->addItem(i18n("Top-right"));
|
||||
mActivateCombo->addItem(i18n("Right"));
|
||||
mActivateCombo->addItem(i18n("Bottom-right"));
|
||||
mActivateCombo->addItem(i18n("Bottom"));
|
||||
mActivateCombo->addItem(i18n("Bottom-left"));
|
||||
mActivateCombo->addItem(i18n("Left"));
|
||||
mActivateCombo->addItem(i18n("Top-left"));
|
||||
mActivateCombo->addItem(i18n("None"));
|
||||
connect(mActivateCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
||||
comboLayout->addWidget(label);
|
||||
comboLayout->addWidget(mActivateCombo);
|
||||
layout->addLayout(comboLayout);
|
||||
|
||||
KGlobalAccel::self()->overrideMainComponentData(componentData());
|
||||
KActionCollection* actionCollection = new KActionCollection( this, KComponentData("kwin") );
|
||||
KAction* show = static_cast<KAction*>(actionCollection->addAction( "ShowDesktopGrid" ));
|
||||
|
@ -78,6 +100,11 @@ void DesktopGridEffectConfig::load()
|
|||
KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
|
||||
mSlide->setChecked(conf.readEntry("Slide", true));
|
||||
|
||||
int activateBorder = conf.readEntry("BorderActivate", (int)ElectricNone);
|
||||
if(activateBorder == (int)ElectricNone)
|
||||
activateBorder--;
|
||||
mActivateCombo->setCurrentIndex(activateBorder);
|
||||
|
||||
emit changed(false);
|
||||
}
|
||||
|
||||
|
@ -89,6 +116,10 @@ void DesktopGridEffectConfig::save()
|
|||
KConfigGroup conf = EffectsHandler::effectConfig("DesktopGrid");
|
||||
conf.writeEntry("Slide", mSlide->isChecked());
|
||||
|
||||
int activateBorder = mActivateCombo->currentIndex();
|
||||
if(activateBorder == (int)ELECTRIC_COUNT)
|
||||
activateBorder = (int)ElectricNone;
|
||||
conf.writeEntry("BorderActivate", activateBorder);
|
||||
conf.sync();
|
||||
|
||||
emit changed(false);
|
||||
|
@ -99,10 +130,10 @@ void DesktopGridEffectConfig::defaults()
|
|||
{
|
||||
kDebug() ;
|
||||
mSlide->setChecked(true);
|
||||
mActivateCombo->setCurrentIndex( (int)ElectricNone );
|
||||
emit changed(true);
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "desktopgrid_config.moc"
|
||||
|
|
|
@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <kcmodule.h>
|
||||
#undef KDE3_SUPPORT
|
||||
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
|
||||
namespace KWin
|
||||
|
@ -44,6 +45,7 @@ class DesktopGridEffectConfig : public KCModule
|
|||
|
||||
private:
|
||||
QCheckBox* mSlide;
|
||||
QComboBox* mActivateCombo;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in a new issue