Commiter: gramakri
Author: gramakri
Parent: e327bd3fa4
(2008/10/21 00:21) Over 3 years ago
Show stats
25
Q_OBJECT
26
public:
27
KeepAlive(const QString &username, const QString &domain, const QString &password, QWidget *parent = 0)
28
: QWebView(parent)
: QWebView(parent), m_autoLogCount(0)
29
{
30
setAttribute(Qt::WA_QuitOnClose, false);
31
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
...
51
QMenu *menu = new QMenu(this);
52
QAction *showAction = menu->addAction("Show browser");
53
connect(showAction, SIGNAL(triggered()), this, SLOT(show()));
54
QAction *statsAction = menu->addAction("Show statistics");
55
connect(statsAction, SIGNAL(triggered()), this, SLOT(showStatistics()));
menu->addSeparator();
56
QAction *exitAction = menu->addAction("Exit");
57
connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
58
77
79
78
qDebug() << "login() " << url();
80
QVariant result = page()->mainFrame()->evaluateJavaScript(m_loginScript);
81
82
qDebug() << result;
if (result.toBool()) { // script's return value seems to be always false
83
qDebug() << "login successful";
84
85
++m_autoLogCount;
}
86
m_watchDogTimer->start();
87
88
117
m_loginTimer->start();
121
118
122
119
123
124
void showStatistics()
125
126
QMessageBox::information(this, tr("Statistics"), tr("Auto logged in %1 times").arg(m_autoLogCount));
127
128
120
private:
129
QTimer *m_loginTimer, *m_watchDogTimer;
130
QString m_loginScript;
131
QSystemTrayIcon *m_trayIcon;
132
133
int m_autoLogCount;
};
134
135
int main(int argc, char *argv[])
136
: QWebView(parent), m_autoLogCount(0){{QAction *showAction = menu->addAction("Show browser");QAction *showAction = menu->addAction("Show browser");QAction *statsAction = menu->addAction("Show statistics");QAction *exitAction = menu->addAction("Exit");QAction *exitAction = menu->addAction("Exit");{{if (result.toBool()) { // script's return value seems to be always falseif (result.toBool()) { // script's return value seems to be always false{QMessageBox::information(this, tr("Statistics"), tr("Auto logged in %1 times").arg(m_autoLogCount));