summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2011-10-29 10:59:11 (GMT)
committerKevin Smith <git@kismith.co.uk>2011-10-29 10:59:11 (GMT)
commit06e40dd580e43e11e519acbb2d30156c18081f79 (patch)
tree83503e4acac19c40c745c44504e3675894cb2dea /Swift/QtUI
parent7cb49cb679156151f19a556de76274c5a25e6de2 (diff)
downloadswift-contrib-06e40dd580e43e11e519acbb2d30156c18081f79.zip
swift-contrib-06e40dd580e43e11e519acbb2d30156c18081f79.tar.bz2
Make the --eagle-mode banner per-login, not per-run
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp42
-rw-r--r--Swift/QtUI/QtLoginWindow.h5
-rw-r--r--Swift/QtUI/QtSwift.cpp24
-rw-r--r--Swift/QtUI/QtUIFactory.cpp2
4 files changed, 35 insertions, 38 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) {
diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h
index 414bb20..acf327f 100644
--- a/Swift/QtUI/QtLoginWindow.h
+++ b/Swift/QtUI/QtLoginWindow.h
@@ -21,28 +21,27 @@
class QLabel;
class QToolButton;
class QComboBox;
namespace Swift {
class QtLoginWindow : public QMainWindow, public LoginWindow {
Q_OBJECT
public:
- QtLoginWindow(UIEventStream* uiEventStream);
+ QtLoginWindow(UIEventStream* uiEventStream, bool eagleMode);
void morphInto(MainWindow *mainWindow);
virtual void loggedOut();
virtual void setMessage(const std::string& message);
virtual void addAvailableAccount(const std::string& defaultJID, const std::string& defaultPassword, const std::string& defaultCertificate);
virtual void removeAvailableAccount(const std::string& jid);
virtual void setLoginAutomatically(bool loginAutomatically);
virtual void setIsLoggingIn(bool loggingIn);
- virtual void setRememberingAllowed(bool allowed);
void selectUser(const std::string& user);
bool askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref certificate);
void hide();
virtual void quit();
signals:
void geometryChanged();
@@ -81,14 +80,14 @@ namespace Swift {
QString certificateFile_;
QToolButton* certificateButton_;
QMenuBar* menuBar_;
QMenu* swiftMenu_;
QMenu* generalMenu_;
QAction* toggleSoundsAction_;
QAction* toggleNotificationsAction_;
UIEventStream* uiEventStream_;
QPointer<QtAboutWidget> aboutDialog_;
- bool forgetful_;
+ bool eagleMode_;
QAction* xmlConsoleAction_;
QAction* fileTransferOverviewAction_;
};
}
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index 7c0a2bd..7f11b5c 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -27,19 +27,18 @@
#include <string>
#include "Swiften/Base/Platform.h"
#include "Swiften/Elements/Presence.h"
#include "Swiften/Client/Client.h"
#include "Swift/Controllers/MainController.h"
#include "Swift/Controllers/ApplicationInfo.h"
#include "Swift/Controllers/BuildVersion.h"
#include "SwifTools/AutoUpdater/AutoUpdater.h"
#include "SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h"
-#include "Swiften/Base/Paths.h"
#if defined(SWIFTEN_PLATFORM_WINDOWS)
#include "WindowsNotifier.h"
#elif defined(HAVE_GROWL)
#include "SwifTools/Notifier/GrowlNotifier.h"
#elif defined(SWIFTEN_PLATFORM_LINUX)
#include "FreeDesktopNotifier.h"
#else
#include "SwifTools/Notifier/NullNotifier.h"
@@ -169,41 +168,18 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa
dock_,
notifier_,
uriHandler_,
&idleDetector_,
options.count("latency-debug") > 0,
eagleMode);
mainControllers_.push_back(mainController);
}
- 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(tr("Do you agree to the terms of use?"));
- msgBox.setInformativeText(banner);
- msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
- msgBox.setDefaultButton(QMessageBox::No);
- if (msgBox.exec() != QMessageBox::Yes) {
- exit(0);
- }
- }
- }
- }
-
// PlatformAutoUpdaterFactory autoUpdaterFactory;
// if (autoUpdaterFactory.isSupported()) {
// autoUpdater_ = autoUpdaterFactory.createAutoUpdater(SWIFT_APPCAST_URL);
// autoUpdater_->checkForUpdates();
// }
}
QtSwift::~QtSwift() {
diff --git a/Swift/QtUI/QtUIFactory.cpp b/Swift/QtUI/QtUIFactory.cpp
index faeebdc..5f55795 100644
--- a/Swift/QtUI/QtUIFactory.cpp
+++ b/Swift/QtUI/QtUIFactory.cpp
@@ -54,19 +54,19 @@ FileTransferListWidget* QtUIFactory::createFileTransferListWidget() {
return widget;
}
MainWindow* QtUIFactory::createMainWindow(UIEventStream* eventStream) {
lastMainWindow = new QtMainWindow(settings, eventStream);
return lastMainWindow;
}
LoginWindow* QtUIFactory::createLoginWindow(UIEventStream* eventStream) {
- loginWindow = new QtLoginWindow(eventStream);
+ loginWindow = new QtLoginWindow(eventStream, eagleMode);
if (netbookSplitter) {
netbookSplitter->insertWidget(0, loginWindow);
}
connect(systemTray, SIGNAL(clicked()), loginWindow, SLOT(bringToFront()));
#ifndef SWIFT_MOBILE
QVariant loginWindowGeometryVariant = settings->getQSettings()->value("loginWindowGeometry");
if (loginWindowGeometryVariant.isValid()) {
loginWindow->restoreGeometry(loginWindowGeometryVariant.toByteArray());