1
/***************************************************************************
2
* Copyright (C) 2006 by Ivan Vasić *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
20
#include "scanfolderprefpagewidget.h"
21
#include "scanfolderpluginsettings.h"
25
#include <qcheckbox.h>
30
#include <kmessagebox.h>
31
#include <kurlrequester.h>
35
ScanFolderPrefPageWidget::ScanFolderPrefPageWidget(QWidget *parent, const char *name)
36
:SfPrefPageWidgetBase(parent, name)
38
use1->setChecked(ScanFolderPluginSettings::useFolder1());
39
use2->setChecked(ScanFolderPluginSettings::useFolder2());
40
use3->setChecked(ScanFolderPluginSettings::useFolder3());
42
url1->setURL(ScanFolderPluginSettings::folder1());
43
url2->setURL(ScanFolderPluginSettings::folder2());
44
url3->setURL(ScanFolderPluginSettings::folder3());
46
openSilently->setChecked(ScanFolderPluginSettings::openSilently());
47
deleteCheck->setChecked(ScanFolderPluginSettings::actionDelete());
48
moveCheck->setChecked(ScanFolderPluginSettings::actionMove());
50
url1->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
51
url2->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
52
url3->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly);
55
void ScanFolderPrefPageWidget::apply()
57
bool usesf1 = use1->isChecked();
58
bool usesf2 = use2->isChecked();
59
bool usesf3 = use3->isChecked();
61
QString sfPath1 = url1->url();
62
QString sfPath2 = url2->url();
63
QString sfPath3 = url3->url();
65
bool silently = openSilently->isChecked();
66
bool deleteChecked = deleteCheck->isChecked();
67
bool moveChecked = moveCheck->isChecked();
69
ScanFolderPluginSettings::setOpenSilently(silently);
70
ScanFolderPluginSettings::setActionDelete(deleteChecked);
71
ScanFolderPluginSettings::setActionMove(moveChecked);
73
QString message = i18n( "ScanFolder - Folder %1: Invalid URL or folder does not exist. Please, choose a valid directory." );
74
if(!QFile::exists(sfPath1) && usesf1)
76
KMessageBox::sorry(0, message.arg( 1 ) );
80
ScanFolderPluginSettings::setFolder1(sfPath1);
82
if(!QFile::exists(sfPath2) && usesf2)
84
KMessageBox::sorry(0, message.arg( 2 ) );
88
ScanFolderPluginSettings::setFolder2(sfPath2);
90
if(!QFile::exists(sfPath3) && usesf3)
92
KMessageBox::sorry(0, message.arg( 3 ) );
96
ScanFolderPluginSettings::setFolder3(sfPath3);
99
ScanFolderPluginSettings::setUseFolder1(usesf1);
100
ScanFolderPluginSettings::setUseFolder2(usesf2);
101
ScanFolderPluginSettings::setUseFolder3(usesf3);
103
ScanFolderPluginSettings::writeConfig();
107
#include "scanfolderprefpagewidget.moc"