40 #include <QtGui/QLabel>
41 #include <QtGui/QLayout>
42 #include <QtGui/QGroupBox>
43 #include <QtGui/QPushButton>
44 #include <QtGui/QRadioButton>
45 #include <QtGui/QShortcut>
57 int defaultButton,
bool showDetails )
61 setObjectName(
"cookiealert");
63 #ifndef Q_WS_QWS //FIXME(E): Implement for Qt Embedded
65 setWindowIcon(
KIcon(
"preferences-web-browser-cookies") );
67 if( cookieList.first().windowIds().count() > 0 )
81 kapp->updateUserTimestamp();
91 icon->setAlignment( Qt::AlignCenter );
92 icon->setFixedSize( 2*icon->sizeHint() );
94 int count = cookieList.count();
98 "You received %1 cookies from", count);
100 lbl->setAlignment( Qt::AlignCenter );
104 int pos = host.indexOf(
':');
107 QString portNum = host.left(pos);
108 host.remove(0, pos+1);
113 txt =
QString(
"<b>%1</b>").arg( QUrl::fromAce(host.toLatin1()) );
115 txt +=
i18n(
" <b>[Cross Domain]</b>");
116 lbl =
new QLabel( txt, vBox );
117 lbl->setAlignment( Qt::AlignCenter );
118 lbl =
new QLabel(
i18n(
"Do you want to accept or reject?"), vBox );
119 lbl->setAlignment( Qt::AlignCenter );
122 m_detailView =
new KCookieDetail( cookieList, count, vBox1 );
127 QVBoxLayout *vbox =
new QVBoxLayout;
128 txt = (count == 1)?
i18n(
"&Only this cookie") :
i18n(
"&Only these cookies");
129 m_onlyCookies =
new QRadioButton( txt, m_btnGrp );
130 vbox->addWidget(m_onlyCookies);
131 #ifndef QT_NO_WHATSTHIS
132 m_onlyCookies->setWhatsThis(
i18n(
"Select this option to accept/reject only this cookie. "
133 "You will be prompted if another cookie is received. "
134 "<em>(see WebBrowsing/Cookies in the System Settings)</em>." ) );
136 m_allCookiesDomain =
new QRadioButton(
i18n(
"All cookies from this do&main"), m_btnGrp );
137 vbox->addWidget(m_allCookiesDomain);
138 #ifndef QT_NO_WHATSTHIS
139 m_allCookiesDomain->setWhatsThis(
i18n(
"Select this option to accept/reject all cookies from "
140 "this site. Choosing this option will add a new policy for "
141 "the site this cookie originated from. This policy will be "
142 "permanent until you manually change it from the System Settings "
143 "<em>(see WebBrowsing/Cookies in the System Settings)</em>.") );
145 m_allCookies =
new QRadioButton(
i18n(
"All &cookies"), m_btnGrp);
146 vbox->addWidget(m_allCookies);
147 #ifndef QT_NO_WHATSTHIS
148 m_allCookies->setWhatsThis(
i18n(
"Select this option to accept/reject all cookies from "
149 "anywhere. Choosing this option will change the global "
150 "cookie policy set in the System Settings for all cookies "
151 "<em>(see WebBrowsing/Cookies in the System Settings)</em>.") );
153 m_btnGrp->setLayout(vbox);
155 m_onlyCookies->setChecked(
true);
157 m_allCookiesDomain->setChecked(
true);
159 m_allCookies->setChecked(
true);
161 m_onlyCookies->setChecked(
true);
184 if (m_allCookiesDomain->isChecked()) {
187 }
else if (m_allCookies->isChecked()) {
200 setTitle(
i18n(
"Cookie Details") );
201 QGridLayout* grid =
new QGridLayout(
this );
202 grid->addItem(
new QSpacerItem(0, fontMetrics().lineSpacing()), 0, 0 );
203 grid->setColumnStretch( 1, 3 );
206 grid->addWidget( label, 1, 0 );
209 m_name->setMaximumWidth( fontMetrics().maxWidth() * 25 );
210 grid->addWidget( m_name, 1 ,1 );
214 grid->addWidget( label, 2, 0 );
217 m_value->setMaximumWidth( fontMetrics().maxWidth() * 25 );
218 grid->addWidget( m_value, 2, 1);
221 grid->addWidget( label, 3, 0 );
224 m_expires->setMaximumWidth(fontMetrics().maxWidth() * 25 );
225 grid->addWidget( m_expires, 3, 1);
228 grid->addWidget( label, 4, 0 );
231 m_path->setMaximumWidth( fontMetrics().maxWidth() * 25 );
232 grid->addWidget( m_path, 4, 1);
235 grid->addWidget( label, 5, 0 );
238 m_domain->setMaximumWidth( fontMetrics().maxWidth() * 25 );
239 grid->addWidget( m_domain, 5, 1);
241 label =
new QLabel(
i18n(
"Exposure:"),
this );
242 grid->addWidget( label, 6, 0 );
245 m_secure->setMaximumWidth( fontMetrics().maxWidth() * 25 );
246 grid->addWidget( m_secure, 6, 1 );
248 if ( cookieCount > 1 )
251 btnNext->setFixedSize( btnNext->sizeHint() );
252 grid->addWidget( btnNext, 8, 0, 1, 2 );
253 connect( btnNext, SIGNAL(clicked()), SLOT(slotNextCookie()) );
254 #ifndef QT_NO_TOOLTIP
255 btnNext->setToolTip(
i18n(
"Show details of the next cookie") );
258 m_cookieList = cookieList;
267 void KCookieDetail::slotNextCookie()
269 if (m_cookieNumber == m_cookieList.count() - 1)
273 displayCookieDetails();
276 void KCookieDetail::displayCookieDetails()
278 const KHttpCookie& cookie = m_cookieList.at(m_cookieNumber);
281 if (cookie.
domain().isEmpty())
296 sec =
i18n(
"Secure servers only");
298 sec =
i18n(
"Secure servers, page scripts");
303 sec =
i18n(
"Servers");
305 sec =
i18n(
"Servers, page scripts");
310 #include "kcookiewin.moc"