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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8; -*-
/***************************************************************************
norsswidget.cpp
Copyright: Marcus Camen <mcamen@mcamen.de>
***************************************************************************/
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <layout.h>
#include <tqsizepolicy.h>
#include <dcopref.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kpushbutton.h>
#include <kdebug.h>
#include <kconfigdialog.h>
#include "sidebarsettings.h"
#include "configfeeds.h"
#include "norsswidget.h"
namespace KSB_News {
NoRSSWidget::NoRSSWidget(TQWidget *parent, const char *name)
: TQWidget(parent, name) {
TQVBoxLayout *topLayout = new TQVBoxLayout(this);
topLayout->addStretch();
KPushButton *btn = new KPushButton(i18n("&Configure"), this);
btn->setSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Minimum);
connect(btn, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotBtnClicked()));
topLayout->addWidget(btn, 0, TQt::AlignHCenter);
topLayout->addStretch();
}
void NoRSSWidget::slotBtnClicked() {
// An instance of your dialog could be already created and could be
// cached, in which case you want to display the cached dialog
// instead of creating another one
if (KConfigDialog::showDialog("settings"))
return;
// KConfigDialog didn't find an instance of this dialog, so lets create it
m_confdlg = new KConfigDialog(this, "settings", SidebarSettings::self(),
KDialogBase::Plain,
KDialogBase::Ok|KDialogBase::Cancel|KDialogBase::Default,
KDialogBase::Ok,
true);
ConfigFeeds *conf_widget = new ConfigFeeds(0, "feedcfgdlg");
m_confdlg->addPage(conf_widget, i18n("RSS Settings"), "pixmap_name");
// User edited the configuration - update your local copies of the
// configuration data
connect(m_confdlg, TQT_SIGNAL(settingsChanged()), this,
TQT_SLOT(slotConfigure_okClicked()));
m_confdlg->show();
}
void NoRSSWidget::slotConfigure_okClicked() {
DCOPRef rss_document("rssservice", "RSSService");
// read list of sources
TQStringList m_our_rsssources = SidebarSettings::sources();
// add new sources
TQStringList::iterator it;
for (it = m_our_rsssources.begin(); it != m_our_rsssources.end(); ++it) {
rss_document.call("add", ( *it ));
}
// save configuration to disk
SidebarSettings::setSources(m_our_rsssources);
SidebarSettings::writeConfig();
}
} // namespace KSB_News
#include "norsswidget.moc"
|