33 #include <QVBoxLayout>
34 #include <QHBoxLayout>
36 #include <KNotifyConfigWidget>
39 #include <KStandardDirs>
42 using namespace KMail;
45 :
KDialog( parent ), m_changed( false )
47 setCaption( i18n(
"Notification") );
48 setButtons( Ok|Cancel );
51 setMainWidget( page );
53 QVBoxLayout *layout =
new QVBoxLayout( page );
54 layout->setMargin( 0 );
56 m_comboNotify->setSizeAdjustPolicy( QComboBox::AdjustToContents );
58 QHBoxLayout *hbox =
new QHBoxLayout();
59 layout->addLayout( hbox );
60 hbox->addWidget( m_comboNotify, 10 );
62 m_notifyWidget =
new KNotifyConfigWidget( page );
63 layout->addWidget( m_notifyWidget );
64 m_comboNotify->setFocus();
66 layout->addWidget(
new KSeparator);
68 connect( m_comboNotify, SIGNAL(activated(
int)),
69 SLOT(slotComboChanged(
int)) );
70 connect(
this, SIGNAL(okClicked()), SLOT(slotOk()) );
71 connect( m_notifyWidget ,SIGNAL(changed(
bool)) ,
this , SLOT(slotConfigChanged(
bool)));
81 void KMKnotify::slotConfigChanged(
bool changed )
86 void KMKnotify::slotComboChanged(
int index )
88 QString
text( m_comboNotify->itemData(index).toString() );
90 m_notifyWidget->save();
94 m_notifyWidget->setApplication(
text );
99 const int index = m_comboNotify->findData(name);
101 m_comboNotify->setCurrentIndex(index);
102 slotComboChanged(index);
106 void KMKnotify::initCombobox()
109 QStringList lstNotify;
110 lstNotify<< QLatin1String(
"kmail2/kmail2.notifyrc" );
111 lstNotify<< QLatin1String(
"akonadi_maildispatcher_agent/akonadi_maildispatcher_agent.notifyrc" );
112 lstNotify<< QLatin1String(
"akonadi_mailfilter_agent/akonadi_mailfilter_agent.notifyrc" );
113 lstNotify<< QLatin1String(
"akonadi_archivemail_agent/akonadi_archivemail_agent.notifyrc" );
114 lstNotify<< QLatin1String(
"akonadi_sendlater_agent/akonadi_sendlater_agent.notifyrc" );
115 lstNotify<< QLatin1String(
"akonadi_newmailnotifier_agent/akonadi_newmailnotifier_agent.notifyrc" );
116 lstNotify<< QLatin1String(
"akonadi_folderarchive_agent/akonadi_folderarchive_agent.notifyrc" );
117 lstNotify<< QLatin1String(
"messageviewer/messageviewer.notifyrc" );
120 Q_FOREACH (
const QString& notify, lstNotify ) {
121 const QString fullPath = KStandardDirs::locate(
"data", notify );
123 if ( !fullPath.isEmpty() ) {
124 const int slash = fullPath.lastIndexOf( QLatin1Char(
'/') ) - 1;
125 const int slash2 = fullPath.lastIndexOf( QLatin1Char(
'/'), slash );
126 const QString appname= ( slash2 < 0 ) ? QString() : fullPath.mid( slash2+1 , slash-slash2 );
127 if ( !appname.isEmpty() ) {
128 KConfig config(fullPath, KConfig::NoGlobals,
"data" );
129 KConfigGroup globalConfig( &config, QString::fromLatin1(
"Global") );
130 const QString icon = globalConfig.readEntry(QString::fromLatin1(
"IconName"), QString::fromLatin1(
"misc"));
131 const QString description = globalConfig.readEntry( QString::fromLatin1(
"Comment"), appname );
132 m_comboNotify->addItem( SmallIcon( icon ), description, appname );
137 m_comboNotify->model()->sort(0);
138 if ( m_comboNotify->count() > 0 ) {
139 m_comboNotify->setCurrentIndex(0);
140 m_notifyWidget->setApplication( m_comboNotify->itemData( 0 ).toString() );
144 void KMKnotify::slotOk()
147 m_notifyWidget->save();
150 void KMKnotify::readConfig()
152 KConfigGroup notifyDialog(
KMKernel::self()->config(),
"KMKnotifyDialog" );
153 const QSize size = notifyDialog.readEntry(
"Size", QSize(600, 400) );
154 if ( size.isValid() ) {
159 void KMKnotify::writeConfig()
161 KConfigGroup notifyDialog(
KMKernel::self()->config(),
"KMKnotifyDialog" );
162 notifyDialog.writeEntry(
"Size", size() );
167 #include "kmknotify.moc"
KMKnotify(QWidget *parent)
virtual QByteArray text(quint32 serialNumber) const =0
static KMKernel * self()
normal control stuff
void setCurrentNotification(const QString &name)