summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtLoginWindow.cpp')
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp42
1 files changed, 32 insertions, 10 deletions
diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp
index 0db6071..87dd849 100644
--- a/Swift/QtUI/QtLoginWindow.cpp
+++ b/Swift/QtUI/QtLoginWindow.cpp
@@ -27,27 +27,28 @@
#include <QMessageBox>
#include <QKeyEvent>
#include "Swift/Controllers/UIEvents/UIEventStream.h"
#include "Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h"
#include "Swift/Controllers/UIEvents/RequestFileTransferListUIEvent.h"
#include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h"
#include "Swift/Controllers/UIEvents/ToggleNotificationsUIEvent.h"
#include "Swiften/Base/Platform.h"
+#include "Swiften/Base/Paths.h"
#include "QtAboutWidget.h"
#include "QtSwiftUtil.h"
#include "QtMainWindow.h"
#include "QtUtilities.h"
namespace Swift{
-QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow(), forgetful_(false) {
+QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream, bool eagleMode) : QMainWindow(), eagleMode_(eagleMode) {
uiEventStream_ = uiEventStream;
setWindowTitle("Swift");
#ifndef Q_WS_MAC
setWindowIcon(QIcon(":/logo-icon-16.png"));
#endif
QtUtilities::setX11Resource(this, "Main");
resize(200, 500);
@@ -196,30 +197,29 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow(), forg
QAction* quitAction = new QAction("&Quit", this);
#else
QAction* quitAction = new QAction(tr("&Quit"), this);
#endif
connect(quitAction, SIGNAL(triggered()), SLOT(handleQuit()));
swiftMenu_->addAction(quitAction);
setInitialMenus();
uiEventStream_->onUIEvent.connect(boost::bind(&QtLoginWindow::handleUIEvent, this, _1));
- this->show();
-}
-void QtLoginWindow::setRememberingAllowed(bool allowed) {
- forgetful_ = true;
- remember_->setEnabled(allowed);
- loginAutomatically_->setEnabled(allowed);
- xmlConsoleAction_->setEnabled(allowed);
- if (!allowed) {
+
+ remember_->setEnabled(!eagleMode_);
+ loginAutomatically_->setEnabled(!eagleMode_);
+ xmlConsoleAction_->setEnabled(!eagleMode_);
+ if (eagleMode_) {
remember_->setChecked(false);
loginAutomatically_->setChecked(false);
}
+
+ this->show();
}
bool QtLoginWindow::eventFilter(QObject *obj, QEvent *event) {
if (obj == username_->view() && event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Delete || keyEvent->key() == Qt::Key_Backspace) {
QString jid(username_->view()->currentIndex().data().toString());
int result = QMessageBox::question(this, tr("Remove profile"), tr("Remove the profile '%1'?").arg(jid), QMessageBox::Yes | QMessageBox::No);
if (result == QMessageBox::Yes) {
@@ -316,20 +316,42 @@ void QtLoginWindow::setIsLoggingIn(bool loggingIn) {
loginButton_->setText(loggingIn ? tr("Cancel") : tr("Connect"));
for (int i = 0; i < 5; i++) {
widgets[i]->setEnabled(!loggingIn);
}
}
void QtLoginWindow::loginClicked() {
if (username_->isEnabled()) {
+ if (eagleMode_) {
+ QString clickThroughPath(P2QSTRING((Paths::getExecutablePath() / "eagle-banner.txt").string()));
+ QFile clickThroughFile(clickThroughPath);
+ if (clickThroughFile.exists() && clickThroughFile.open(QIODevice::ReadOnly)) {
+ QString banner;
+ while (!clickThroughFile.atEnd()) {
+ QByteArray line = clickThroughFile.readLine();
+ banner += line + "\n";
+ }
+ if (!banner.isEmpty()) {
+ QMessageBox msgBox;
+ msgBox.setWindowTitle(tr("Confirm terms of use"));
+ msgBox.setText("");
+ msgBox.setInformativeText(banner);
+ msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+ msgBox.setDefaultButton(QMessageBox::No);
+ if (msgBox.exec() != QMessageBox::Yes) {
+ return;
+ }
+ }
+ }
+ }
onLoginRequest(Q2PSTRING(username_->currentText()), Q2PSTRING(password_->text()), Q2PSTRING(certificateFile_), remember_->isChecked(), loginAutomatically_->isChecked());
- if (forgetful_) { /* Mustn't remember logins */
+ if (eagleMode_) { /* Mustn't remember logins */
username_->clearEditText();
password_->setText("");
}
} else {
onCancelLoginRequest();
}
}
void QtLoginWindow::setLoginAutomatically(bool loginAutomatically) {