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");
62 setButtons(
Yes|User1|
No|Details);
63 #ifndef Q_WS_QWS //FIXME(E): Implement for Qt Embedded
64 setCaption(
i18n(
"Cookie Alert") );
65 setWindowIcon(
KIcon(
"preferences-web-browser-cookies") );
67 if( cookieList.first().windowIds().count() > 0 )
81 kapp->updateUserTimestamp();
85 const int count = cookieList.count();
88 int pos = host.indexOf(
':');
90 QString portNum = host.left(pos);
91 host.remove(0, pos+1);
96 QString txt = QLatin1String(
"<html><body style=\"p {line-height: 150%}; text-align: center;\">");
97 txt +=
i18ncp(
"%2 hostname, %3 optional cross domain suffix (translated below)",
98 "<p>You received a cookie from<br/>"
100 "Do you want to accept or reject this cookie?</p>",
101 "<p>You received %1 cookies from<br/>"
103 "Do you want to accept or reject these cookies?</p>",
105 QUrl::fromAce(host.toLatin1()),
107 txt += QLatin1String(
"</body></html>");
111 setMainWidget(vBox1);
116 icon->setAlignment( Qt::AlignCenter );
117 icon->setFixedSize( 2*icon->sizeHint() );
121 lbl->setAlignment(Qt::AlignCenter);
124 m_detailView =
new KCookieDetail( cookieList, count, vBox1 );
125 setDetailsWidget(m_detailView);
129 QVBoxLayout *vbox =
new QVBoxLayout;
130 txt = (count == 1)?
i18n(
"&Only this cookie") :
i18n(
"&Only these cookies");
131 m_onlyCookies =
new QRadioButton( txt, m_btnGrp );
132 vbox->addWidget(m_onlyCookies);
133 #ifndef QT_NO_WHATSTHIS
134 m_onlyCookies->setWhatsThis(
i18n(
"Select this option to only accept or reject this cookie. "
135 "You will be prompted again if you receive another cookie."));
137 m_allCookiesDomain =
new QRadioButton(
i18n(
"All cookies from this do&main"), m_btnGrp );
138 vbox->addWidget(m_allCookiesDomain);
139 #ifndef QT_NO_WHATSTHIS
140 m_allCookiesDomain->setWhatsThis(
i18n(
"Select this option to accept or reject all cookies from "
141 "this site. Choosing this option will add a new policy for "
142 "the site this cookie originated from. This policy will be "
143 "permanent until you manually change it from the System Settings."));
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 for all cookies until you manually change "
151 "it from the System Settings."));
153 m_btnGrp->setLayout(vbox);
155 switch (defaultButton) {
157 m_onlyCookies->setChecked(
true);
160 m_allCookiesDomain->setChecked(
true);
163 m_allCookies->setChecked(
true);
166 m_onlyCookies->setChecked(
true);
170 setButtonText(KDialog::Yes,
i18n(
"&Accept"));
171 setButtonText(KDialog::User1,
i18n(
"Accept for this &session"));
172 setButtonIcon(KDialog::User1,
KIcon(
"chronometer"));
173 setButtonToolTip(KDialog::User1,
i18n(
"Accept cookie(s) until the end of the current session"));
174 setButtonText(KDialog::No,
i18n(
"&Reject"));
176 setButtonToolTip(Details,
i18n(
"See or modify the cookie information") );
177 setDefaultButton(
Yes);
179 setDetailsWidgetVisible(showDetails);
188 const int result = exec();
207 if (m_allCookiesDomain->isChecked()) {
210 }
else if (m_allCookies->isChecked()) {
223 setTitle(
i18n(
"Cookie Details") );
224 QGridLayout* grid =
new QGridLayout(
this );
225 grid->addItem(
new QSpacerItem(0, fontMetrics().lineSpacing()), 0, 0 );
226 grid->setColumnStretch( 1, 3 );
229 grid->addWidget( label, 1, 0 );
232 m_name->setMaximumWidth( fontMetrics().maxWidth() * 25 );
233 grid->addWidget( m_name, 1 ,1 );
237 grid->addWidget( label, 2, 0 );
240 m_value->setMaximumWidth( fontMetrics().maxWidth() * 25 );
241 grid->addWidget( m_value, 2, 1);
244 grid->addWidget( label, 3, 0 );
247 m_expires->setMaximumWidth(fontMetrics().maxWidth() * 25 );
248 grid->addWidget( m_expires, 3, 1);
251 grid->addWidget( label, 4, 0 );
254 m_path->setMaximumWidth( fontMetrics().maxWidth() * 25 );
255 grid->addWidget( m_path, 4, 1);
258 grid->addWidget( label, 5, 0 );
261 m_domain->setMaximumWidth( fontMetrics().maxWidth() * 25 );
262 grid->addWidget( m_domain, 5, 1);
264 label =
new QLabel(
i18n(
"Exposure:"),
this );
265 grid->addWidget( label, 6, 0 );
268 m_secure->setMaximumWidth( fontMetrics().maxWidth() * 25 );
269 grid->addWidget( m_secure, 6, 1 );
271 if ( cookieCount > 1 )
274 btnNext->setFixedSize( btnNext->sizeHint() );
275 grid->addWidget( btnNext, 8, 0, 1, 2 );
276 connect( btnNext, SIGNAL(clicked()), SLOT(slotNextCookie()) );
277 #ifndef QT_NO_TOOLTIP
278 btnNext->setToolTip(
i18n(
"Show details of the next cookie") );
281 m_cookieList = cookieList;
290 void KCookieDetail::slotNextCookie()
292 if (m_cookieNumber == m_cookieList.count() - 1)
296 displayCookieDetails();
299 void KCookieDetail::displayCookieDetails()
301 const KHttpCookie& cookie = m_cookieList.at(m_cookieNumber);
304 if (cookie.
domain().isEmpty())
319 sec =
i18n(
"Secure servers only");
321 sec =
i18n(
"Secure servers, page scripts");
326 sec =
i18n(
"Servers");
328 sec =
i18n(
"Servers, page scripts");
335 if (button == KDialog::User1) {
336 done (KDialog::User1);
340 KDialog::slotButtonClicked(button);
344 #include "kcookiewin.moc"
qint64 expireDate() const
QString i18n(const char *text)
int IconSize(KIconLoader::Group group)
void setDomainAdvice(const QString &_domain, KCookieAdvice _advice)
This function sets the advice for all cookies originating from _domain.
void setShowCookieDetails(bool value)
Sets the user's preference of level of detail displayed by the cookie dialog.
KCookieAdvice advice(KCookieJar *cookiejar, const KHttpCookie &cookie)
QString label(StandardShortcut id)
KCookieDetail(KHttpCookieList cookieList, int cookieCount, QWidget *parent=0)
QString i18nc(const char *ctxt, const char *text)
void setTime_t(qint64 seconds)
QString i18ncp(const char *ctxt, const char *sing, const char *plur, const A1 &a1)
void setGlobalAdvice(KCookieAdvice _advice)
This function sets the global advice for cookies.
KCookieWin(QWidget *parent, KHttpCookieList cookieList, int defaultButton=0, bool showDetails=false)
static void setState(WId win, unsigned long state)
QString formatDateTime(const QDateTime &dateTime, DateFormat format=ShortDate, bool includeSecs=false) const
static void setMainWindow(QWidget *subwindow, WId mainwindow)
virtual void slotButtonClicked(int button)
void setPreferredDefaultPolicy(KCookieDefaultPolicy value)
Sets the user's default preference cookie policy.
void setSpacing(int space)
bool isCrossDomain() const
virtual void setReadOnly(bool)
virtual void setText(const QString &)