summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-11-28 22:05:58 -0600
committerAndrew <forkk@forkk.net>2013-11-28 22:05:58 -0600
commit0395474a0c3b40d4ef688e5d726a6519b3b2a620 (patch)
treee1e9cb5c96f23ce3e430a3e8316fd81cd3278f2b /gui
parentf3a9dde52e99385eba01c9356ed8ef9548833e34 (diff)
downloadMultiMC-0395474a0c3b40d4ef688e5d726a6519b3b2a620.tar
MultiMC-0395474a0c3b40d4ef688e5d726a6519b3b2a620.tar.gz
MultiMC-0395474a0c3b40d4ef688e5d726a6519b3b2a620.tar.lz
MultiMC-0395474a0c3b40d4ef688e5d726a6519b3b2a620.tar.xz
MultiMC-0395474a0c3b40d4ef688e5d726a6519b3b2a620.zip
Nuke dead code
Diffstat (limited to 'gui')
-rw-r--r--gui/dialogs/LoginDialog.cpp216
-rw-r--r--gui/dialogs/LoginDialog.h61
-rw-r--r--gui/dialogs/LoginDialog.ui186
3 files changed, 0 insertions, 463 deletions
diff --git a/gui/dialogs/LoginDialog.cpp b/gui/dialogs/LoginDialog.cpp
deleted file mode 100644
index 28bbb1ee..00000000
--- a/gui/dialogs/LoginDialog.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "LoginDialog.h"
-#include "ui_LoginDialog.h"
-#include "keyring.h"
-#include "gui/Platform.h"
-#include "MultiMC.h"
-#include "logic/SkinUtils.h"
-
-#include <QFile>
-#include <QJsonObject>
-#include <QJsonArray>
-#include <QJsonParseError>
-#include "logic/net/HttpMetaCache.h"
-#include "logger/QsLog.h"
-
-LoginDialog::LoginDialog(QWidget *parent, const QString &loginErrMsg)
- : QDialog(parent), ui(new Ui::LoginDialog)
-{
- MultiMCPlatform::fixWM_CLASS(this);
- ui->setupUi(this);
-
- //: Use offline mode one time
- offlineButton = new QPushButton(tr("Offline Once"));
-
- ui->loginButtonBox->addButton(offlineButton, QDialogButtonBox::ActionRole);
-
- blockToggles = false;
- isOnline_ = true;
- onlineForced = false;
-
- //: The username during login (placeholder)
- ui->usernameTextBox->lineEdit()->setPlaceholderText(tr("Name"));
-
- connect(ui->usernameTextBox, SIGNAL(currentTextChanged(QString)), this,
- SLOT(userTextChanged(QString)));
- connect(ui->forgetButton, SIGNAL(clicked(bool)), this, SLOT(forgetCurrentUser()));
- connect(offlineButton, SIGNAL(clicked(bool)), this, SLOT(launchOffline()));
-
- if (loginErrMsg.isEmpty())
- ui->loginErrorLabel->setVisible(false);
- else
- {
- ui->loginErrorLabel->setVisible(true);
- ui->loginErrorLabel->setText(
- QString("<span style=\" color:#ff0000;\">%1</span>").arg(loginErrMsg));
- }
-
- ui->lblFace->setVisible(false);
-
- resize(minimumSizeHint());
- layout()->setSizeConstraint(QLayout::SetFixedSize);
- Keyring *k = Keyring::instance();
- QStringList accounts = k->getStoredAccounts("minecraft");
- ui->usernameTextBox->addItems(accounts);
-
- // TODO: restore last selected account here, if applicable
-
- int index = ui->usernameTextBox->currentIndex();
- if (index != -1)
- {
- ui->passwordTextBox->setFocus(Qt::OtherFocusReason);
- }
-
- connect(ui->rememberUsernameCheckbox, SIGNAL(toggled(bool)), SLOT(usernameToggled(bool)));
- connect(ui->rememberPasswordCheckbox, SIGNAL(toggled(bool)), SLOT(passwordToggled(bool)));
-}
-
-LoginDialog::~LoginDialog()
-{
- delete offlineButton;
- delete ui;
-}
-
-QString LoginDialog::getUsername() const
-{
- return ui->usernameTextBox->currentText();
-}
-
-QString LoginDialog::getPassword() const
-{
- return ui->passwordTextBox->text();
-}
-
-void LoginDialog::forgetCurrentUser()
-{
- Keyring *k = Keyring::instance();
- QString acct = ui->usernameTextBox->currentText();
- k->removeStoredAccount("minecraft", acct);
- ui->passwordTextBox->clear();
- int index = ui->usernameTextBox->findText(acct);
- if (index != -1)
- ui->usernameTextBox->removeItem(index);
- if (!ui->usernameTextBox->count())
- {
- blockToggles = true;
- ui->rememberUsernameCheckbox->setChecked(false);
- ui->rememberPasswordCheckbox->setChecked(false);
- blockToggles = false;
- }
-}
-
-void LoginDialog::passwordToggled(bool state)
-{
- // if toggled off
- if (blockToggles)
- return;
- blockToggles = true;
- if (!state)
- {
- QLOG_DEBUG() << "password disabled";
- }
- else
- {
- if (!ui->rememberUsernameCheckbox->isChecked())
- {
- ui->rememberUsernameCheckbox->setChecked(true);
- }
- QLOG_DEBUG() << "password enabled";
- }
- blockToggles = false;
-}
-
-void LoginDialog::usernameToggled(bool state)
-{
- // if toggled off
- if (blockToggles)
- return;
- blockToggles = true;
- if (!state)
- {
- if (ui->rememberPasswordCheckbox->isChecked())
- {
- ui->rememberPasswordCheckbox->setChecked(false);
- }
- QLOG_DEBUG() << "username disabled";
- }
- else
- {
- QLOG_DEBUG() << "username enabled";
- }
- blockToggles = false;
-}
-
-void LoginDialog::userTextChanged(const QString &user)
-{
- blockToggles = true;
- Keyring *k = Keyring::instance();
- QStringList sl = k->getStoredAccounts("minecraft");
- bool gotFace = false;
-
- if (sl.contains(user))
- {
- ui->rememberUsernameCheckbox->setChecked(true);
- QString passwd = k->getPassword("minecraft", user);
- ui->rememberPasswordCheckbox->setChecked(!passwd.isEmpty());
- ui->passwordTextBox->setText(passwd);
-
- QPixmap face = SkinUtils::getFaceFromCache(user);
- gotFace = !face.isNull();
-
- if(gotFace) ui->lblFace->setPixmap(face);
- }
-
- ui->lblFace->setVisible(gotFace);
- blockToggles = false;
-}
-
-void LoginDialog::accept()
-{
- bool saveName = ui->rememberUsernameCheckbox->isChecked();
- bool savePass = ui->rememberPasswordCheckbox->isChecked();
- Keyring *k = Keyring::instance();
- if (saveName)
- {
- if (savePass)
- {
- k->storePassword("minecraft", getUsername(), getPassword());
- }
- else
- {
- k->storePassword("minecraft", getUsername(), QString());
- }
- }
- else
- {
- QString acct = ui->usernameTextBox->currentText();
- k->removeStoredAccount("minecraft", acct);
- }
- QDialog::accept();
-}
-
-void LoginDialog::launchOffline()
-{
- isOnline_ = false;
- QDialog::accept();
-}
-
-void LoginDialog::forceOnline()
-{
- onlineForced = true;
- offlineButton->setEnabled(false);
-}
diff --git a/gui/dialogs/LoginDialog.h b/gui/dialogs/LoginDialog.h
deleted file mode 100644
index 73a92aab..00000000
--- a/gui/dialogs/LoginDialog.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright 2013 MultiMC Contributors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <QDialog>
-#include <QPushButton>
-
-namespace Ui
-{
-class LoginDialog;
-}
-
-class LoginDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit LoginDialog(QWidget *parent = 0, const QString &loginErrMsg = "");
- ~LoginDialog();
-
- QString getUsername() const;
- QString getPassword() const;
-
- inline bool isOnline()
- {
- return isOnline_;
- }
-
- void forceOnline();
-
-public
-slots:
- virtual void accept();
- virtual void userTextChanged(const QString &user);
- virtual void forgetCurrentUser();
-private
-slots:
- void usernameToggled(bool);
- void passwordToggled(bool);
- void launchOffline();
-
-private:
- Ui::LoginDialog *ui;
- bool blockToggles;
- QPushButton *offlineButton;
- bool isOnline_;
- bool onlineForced;
-};
diff --git a/gui/dialogs/LoginDialog.ui b/gui/dialogs/LoginDialog.ui
deleted file mode 100644
index 45f319ed..00000000
--- a/gui/dialogs/LoginDialog.ui
+++ /dev/null
@@ -1,186 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>LoginDialog</class>
- <widget class="QDialog" name="LoginDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>496</width>
- <height>168</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Login</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="loginErrorLabel">
- <property name="text">
- <string>&lt;span style=&quot; color:#ff0000;&quot;&gt;Error&lt;/span&gt;</string>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="4" rowspan="2">
- <widget class="QLabel" name="lblFace">
- <property name="minimumSize">
- <size>
- <width>48</width>
- <height>48</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>48</width>
- <height>48</height>
- </size>
- </property>
- <property name="sizeIncrement">
- <size>
- <width>1</width>
- <height>1</height>
- </size>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="pixmap">
- <pixmap resource="../../graphics.qrc">:/icons/instances/steve</pixmap>
- </property>
- <property name="scaledContents">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="usernameTextBox">
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="usernameLabel">
- <property name="text">
- <string>Username:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="passwordLabel">
- <property name="text">
- <string>Password:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="passwordTextBox">
- <property name="echoMode">
- <enum>QLineEdit::Password</enum>
- </property>
- <property name="placeholderText">
- <string>Password</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="checkboxLayout">
- <item>
- <widget class="QCheckBox" name="rememberUsernameCheckbox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>&amp;Remember Username?</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="rememberPasswordCheckbox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
- <horstretch>1</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>R&amp;emember Password?</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="forgetButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Forget</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="loginButtonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="../../graphics.qrc"/>
- <include location="../multimc.qrc"/>
- </resources>
- <connections>
- <connection>
- <sender>loginButtonBox</sender>
- <signal>accepted()</signal>
- <receiver>LoginDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>248</x>
- <y>254</y>
- </hint>
- <hint type="destinationlabel">
- <x>157</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>loginButtonBox</sender>
- <signal>rejected()</signal>
- <receiver>LoginDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>316</x>
- <y>260</y>
- </hint>
- <hint type="destinationlabel">
- <x>286</x>
- <y>274</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>