Added 'lock on screen' functionality.

Signed-off-by: Ray-V <ray-v@inbox.lv>
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/10/head
Ray-V 4 years ago committed by Michele Calgaro
parent d1fca948cf
commit 0da79dd6ef
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -4,33 +4,47 @@ DragWidget::DragWidget(TQWidget *parent, const char *name, WFlags f) : TQWidget(
{
dragP=TQPoint(0,0);
drag=false;
locked=false;
}
DragWidget::~DragWidget()
{
}
void DragWidget::mousePressEvent(TQMouseEvent *e)
{
dragP=e->pos();
gpress=e->globalPos();
if (locked)
{
return;
}
drag=true;
}
void DragWidget::mouseReleaseEvent(TQMouseEvent *)
{
drag=false;
}
void DragWidget::mouseMoveEvent(TQMouseEvent *e)
{
if (!drag) {
if (!drag)
{
return;
}
TQPoint curr(e->globalPos().x()-dragP.x(),e->globalPos().y()-dragP.y());
TQWidget::move(curr);
}
void DragWidget::setLocked(bool mode)
{
locked=mode;
}
const bool DragWidget::isLocked() const
{
return locked;
}
#include "DragWidget.moc"

@ -12,6 +12,9 @@ public:
DragWidget(TQWidget *parent=0, const char *name="", WFlags f=0);
virtual ~DragWidget();
void setLocked(bool mode);
const bool isLocked() const;
private:
bool drag;
@ -22,6 +25,7 @@ protected:
void mouseReleaseEvent ( TQMouseEvent * e );
TQPoint dragP;
TQPoint gpress;
bool locked;
};

@ -516,12 +516,14 @@ MainWidget::MainWidget ( TDEAboutData *about, bool tren, TQWidget *parent, const
bool fnt_autores = cfg->readBoolEntry("autoresfont",true);
m->setItemChecked(mnu_autores, fnt_autores);
mnu_dock = m->insertItem ( "Dock widget", this, TQT_SLOT ( showDock() ) );
bool show_dock = cfg->readBoolEntry("showdock",false);
m->setItemChecked(mnu_dock, show_dock);
mnu_lock = m->insertItem(i18n("Lock on screen"), this, TQT_SLOT(toggleLock()));
bool is_locked = cfg->readBoolEntry("locked", false);
m->setItemChecked(mnu_lock, is_locked);
//m->insertItem("Configure", this, TQT_SLOT(config()));
m->insertSeparator();
m->insertItem ( "Help", h->menu() );
@ -728,6 +730,7 @@ void MainWidget::chooseFont()
if (c)show();
updateFont();
}
void MainWidget::quitClicked()
{
if (stand_alone)
@ -735,6 +738,19 @@ void MainWidget::quitClicked()
else
hide();
}
void MainWidget::toggleLock()
{
bool c = isLocked();
tray->contextMenu()->setItemChecked(mnu_lock, !c);
setLocked(!c);
TDEConfig *cfg = TDEApplication::kApplication()->config();
cfg->writeEntry("locked", !c);
cfg->sync();
}
void MainWidget::showDock()
{
bool c = dock->isShown();

@ -63,6 +63,7 @@ public slots:
void chooseFont();
void toggleNumericPad();
void toggleFontAutoRes();
void toggleLock();
void restorePosition();
void showConfigMenu();
// void shutDown();
@ -128,7 +129,7 @@ private:
double sdxb;
int mnu_dock;
int mnu_autores;
int mnu_lock;
};

@ -36,6 +36,10 @@ ResizableDragWidget::~ResizableDragWidget()
void ResizableDragWidget::mousePressEvent(TQMouseEvent * e)
{
if (locked)
{
return;
}
TQPoint pos = e->pos();
if (pos.x()>width()-20 && pos.x()<width() && pos.y()>height()-20 && pos.y()<height() ) {

Loading…
Cancel
Save