summaryrefslogtreecommitdiffstats
path: root/kopete/plugins/motionautoaway/motionawaypreferences.cpp
blob: d7a381b46784f424581fe7935bf04e33d13f7234 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
    Kopete Motion Detector Auto-Away plugin

    Copyright (c) 2002-2004 by Duncan Mac-Vicar Prett <[email protected]>
    
    Kopete    (c) 2002 by the Kopete developers  <[email protected]>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include <tqlayout.h>
#include <tqobject.h>
#include <tqcheckbox.h>

#include <kgenericfactory.h>
#include <klineedit.h>
#include <knuminput.h>

#include "motionawayprefs.h"
#include "motionawaypreferences.h"
#include "motionawayconfig.h"

typedef KGenericFactory<MotionAwayPreferences> MotionAwayPreferencesFactory;
K_EXPORT_COMPONENT_FACTORY( kcm_kopete_motionaway, MotionAwayPreferencesFactory("kcm_kopete_motionaway"))

MotionAwayPreferences::MotionAwayPreferences(TQWidget *parent, const char* /*name*/, const TQStringList &args)
							: TDECModule(MotionAwayPreferencesFactory::instance(), parent, args)
{
	// Add actuall widget generated from ui file.
	( new TQVBoxLayout( this ) )->setAutoAdd( true );
	preferencesDialog = new motionawayPrefsUI(this);
	connect(preferencesDialog->BecomeAvailableWithActivity, TQ_SIGNAL(toggled(bool)), this, TQ_SLOT(slotWidgetModified()));
	connect(preferencesDialog->AwayTimeout, TQ_SIGNAL(valueChanged(int)), this, TQ_SLOT(slotWidgetModified()));
	connect(preferencesDialog->VideoDevice, TQ_SIGNAL(textChanged(const TQString &)), this, TQ_SLOT(slotWidgetModified()));
	load();
}

void MotionAwayPreferences::load()
{
	MotionAwayConfig::self()->readConfig();
	preferencesDialog->AwayTimeout->setValue(MotionAwayConfig::self()->awayTimeout());
	preferencesDialog->BecomeAvailableWithActivity->setChecked(MotionAwayConfig::self()->becomeAvailableWithActivity());
	preferencesDialog->VideoDevice->setText(MotionAwayConfig::self()->videoDevice());
	emit TDECModule::changed(false);
}

void MotionAwayPreferences::slotWidgetModified()
{
	emit TDECModule::changed(true);
}

void MotionAwayPreferences::save()
{
	MotionAwayConfig::self()->setAwayTimeout(preferencesDialog->AwayTimeout->value());
	MotionAwayConfig::self()->setBecomeAvailableWithActivity(preferencesDialog->BecomeAvailableWithActivity->isChecked());
	MotionAwayConfig::self()->setVideoDevice(preferencesDialog->VideoDevice->text());
	MotionAwayConfig::self()->writeConfig();
	emit TDECModule::changed(false);
}

#include "motionawaypreferences.moc"