-<?xml version="1.0" encoding="UTF-8"?>\r
-<ui version="4.0">\r
- <class>MainForm</class>\r
- <widget class="QMainWindow" name="MainForm">\r
- <property name="geometry">\r
- <rect>\r
- <x>0</x>\r
- <y>0</y>\r
- <width>800</width>\r
- <height>480</height>\r
- </rect>\r
- </property>\r
- <property name="windowTitle">\r
- <string>EasyList - by Willem Liu</string>\r
- </property>\r
- <widget class="QWidget" name="centralwidget">\r
- <layout class="QGridLayout" name="gridLayout">\r
- <property name="margin">\r
- <number>0</number>\r
- </property>\r
- <property name="spacing">\r
- <number>0</number>\r
- </property>\r
- <item row="0" column="0">\r
- <widget class="QStackedWidget" name="stackedWidget">\r
- <property name="currentIndex">\r
- <number>-1</number>\r
- </property>\r
- </widget>\r
- </item>\r
- </layout>\r
- </widget>\r
- <widget class="QMenuBar" name="menubar">\r
- <property name="geometry">\r
- <rect>\r
- <x>0</x>\r
- <y>0</y>\r
- <width>800</width>\r
- <height>21</height>\r
- </rect>\r
- </property>\r
- <widget class="QMenu" name="menuRotate">\r
- <property name="title">\r
- <string>Rotate</string>\r
- </property>\r
- <addaction name="actionRotate"/>\r
- </widget>\r
- <widget class="QMenu" name="menuAbout">\r
- <property name="title">\r
- <string>About</string>\r
- </property>\r
- <addaction name="actionAbout"/>\r
- </widget>\r
- <widget class="QMenu" name="menuChecked_bottom">\r
- <property name="title">\r
- <string>Checked to bottom</string>\r
- </property>\r
- <addaction name="actionChecked_bottom"/>\r
- </widget>\r
- <widget class="QMenu" name="menuAuto_Orientation">\r
- <property name="title">\r
- <string>Auto Orientation</string>\r
- </property>\r
- <addaction name="actionAuto_Orientation"/>\r
- </widget>\r
- <widget class="QMenu" name="menuSort_A_Z">\r
- <property name="title">\r
- <string>Sort A-Z</string>\r
- </property>\r
- <addaction name="actionSort_A_Z"/>\r
- </widget>\r
- <widget class="QMenu" name="menuList">\r
- <property name="title">\r
- <string>Lists...</string>\r
- </property>\r
- <addaction name="actionLists"/>\r
- </widget>\r
- <widget class="QMenu" name="menuSync">\r
- <property name="title">\r
- <string>Sync</string>\r
- </property>\r
- <addaction name="actionSync"/>\r
- </widget>\r
- <widget class="QMenu" name="menuSettings">\r
- <property name="title">\r
- <string>Settings</string>\r
- </property>\r
- <addaction name="actionSetting"/>\r
- </widget>\r
- <addaction name="menuList"/>\r
- <addaction name="menuAuto_Orientation"/>\r
- <addaction name="menuSort_A_Z"/>\r
- <addaction name="menuChecked_bottom"/>\r
- <addaction name="menuRotate"/>\r
- <addaction name="menuSync"/>\r
- <addaction name="menuSettings"/>\r
- <addaction name="menuAbout"/>\r
- </widget>\r
- <action name="actionRotate">\r
- <property name="text">\r
- <string>Rotate</string>\r
- </property>\r
- </action>\r
- <action name="actionAbout">\r
- <property name="text">\r
- <string>About</string>\r
- </property>\r
- </action>\r
- <action name="actionChecked_bottom">\r
- <property name="checkable">\r
- <bool>true</bool>\r
- </property>\r
- <property name="text">\r
- <string>Checked to bottom</string>\r
- </property>\r
- </action>\r
- <action name="actionAuto_Orientation">\r
- <property name="checkable">\r
- <bool>true</bool>\r
- </property>\r
- <property name="text">\r
- <string>Auto Orientation</string>\r
- </property>\r
- </action>\r
- <action name="actionSort_A_Z">\r
- <property name="checkable">\r
- <bool>true</bool>\r
- </property>\r
- <property name="text">\r
- <string>Sort A-Z</string>\r
- </property>\r
- </action>\r
- <action name="actionLists">\r
- <property name="text">\r
- <string>Lists...</string>\r
- </property>\r
- </action>\r
- <action name="actionSync">\r
- <property name="text">\r
- <string>Sync</string>\r
- </property>\r
- </action>\r
- <action name="actionSetting">\r
- <property name="text">\r
- <string>Settings</string>\r
- </property>\r
- </action>\r
- </widget>\r
- <resources/>\r
- <connections/>\r
-</ui>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainForm</class>
+ <widget class="QMainWindow" name="MainForm">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>480</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>EasyList - by Willem Liu</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QStackedWidget" name="stackedWidget">
+ <property name="currentIndex">
+ <number>-1</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>800</width>
+ <height>25</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuRotate">
+ <property name="title">
+ <string>Rotate</string>
+ </property>
+ <addaction name="actionRotate"/>
+ </widget>
+ <widget class="QMenu" name="menuAbout">
+ <property name="title">
+ <string>About</string>
+ </property>
+ <addaction name="actionAbout"/>
+ </widget>
+ <widget class="QMenu" name="menuChecked_bottom">
+ <property name="title">
+ <string>Checked to bottom</string>
+ </property>
+ <addaction name="actionChecked_bottom"/>
+ </widget>
+ <widget class="QMenu" name="menuAuto_Orientation">
+ <property name="title">
+ <string>Auto Orientation</string>
+ </property>
+ <addaction name="actionAuto_Orientation"/>
+ </widget>
+ <widget class="QMenu" name="menuSort_A_Z">
+ <property name="title">
+ <string>Sort A-Z</string>
+ </property>
+ <addaction name="actionSort_A_Z"/>
+ </widget>
+ <widget class="QMenu" name="menuList">
+ <property name="title">
+ <string>Lists...</string>
+ </property>
+ <addaction name="actionLists"/>
+ </widget>
+ <widget class="QMenu" name="menuSync">
+ <property name="title">
+ <string>Sync</string>
+ </property>
+ <addaction name="actionSync"/>
+ </widget>
+ <widget class="QMenu" name="menuSettings">
+ <property name="title">
+ <string>Settings</string>
+ </property>
+ <addaction name="actionSetting"/>
+ </widget>
+ <addaction name="menuList"/>
+ <addaction name="menuAuto_Orientation"/>
+ <addaction name="menuSort_A_Z"/>
+ <addaction name="menuChecked_bottom"/>
+ <addaction name="menuRotate"/>
+ <addaction name="menuSync"/>
+ <addaction name="menuSettings"/>
+ <addaction name="menuAbout"/>
+ </widget>
+ <action name="actionRotate">
+ <property name="text">
+ <string>Rotate</string>
+ </property>
+ </action>
+ <action name="actionAbout">
+ <property name="text">
+ <string>About</string>
+ </property>
+ </action>
+ <action name="actionChecked_bottom">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Checked to bottom</string>
+ </property>
+ </action>
+ <action name="actionAuto_Orientation">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Auto Orientation</string>
+ </property>
+ </action>
+ <action name="actionSort_A_Z">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Sort A-Z</string>
+ </property>
+ </action>
+ <action name="actionLists">
+ <property name="text">
+ <string>Lists...</string>
+ </property>
+ </action>
+ <action name="actionSync">
+ <property name="text">
+ <string>Sync</string>
+ </property>
+ </action>
+ <action name="actionSetting">
+ <property name="text">
+ <string>Settings</string>
+ </property>
+ </action>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
ui->syncPasswordLineEdit->setInputMethodHints(Qt::ImhNoAutoUppercase);\r
ui->syncUrlLineEdit->setInputMethodHints(Qt::ImhNoAutoUppercase);\r
settings = new QSettings(WILLEM_LIU, EASY_LIST);\r
+ ui->syncPasswordLineEdit->installEventFilter(this);\r
shown();\r
}\r
\r
\r
void SettingsForm::shown()\r
{\r
- ui->syncUsernameLineEdit->clear();\r
- ui->syncPasswordLineEdit->clear();\r
+ ui->syncUsernameLineEdit->setText(settings->value(USERNAME,"").toString());\r
+ ui->syncPasswordLineEdit->setText(settings->value(PASSWORD,"").toString());\r
+ if(settings->contains(PASSWORD))\r
+ ui->syncPasswordLineEdit->setReadOnly(true);\r
+\r
ui->syncUrlLineEdit->setText(settings->value(SYNC_URL, DEFAULT_SYNC_URL).toString());\r
ui->syncUsernameLineEdit->setFocus(Qt::ActiveWindowFocusReason);\r
}\r
-\r
+bool SettingsForm::eventFilter(QObject *obj, QEvent *e)\r
+{\r
+ if(obj == ui->syncPasswordLineEdit && ui->syncPasswordLineEdit->isReadOnly() && e->type() == QEvent::MouseButtonRelease)\r
+ {\r
+ int res = QMessageBox::warning(this, "Clear Password",\r
+ "Are you sure you would like to change the password?",\r
+ QMessageBox::Yes, QMessageBox::Cancel);\r
+ if(res==QMessageBox::Yes)\r
+ {\r
+ ui->syncPasswordLineEdit->setReadOnly(false);\r
+ ui->syncPasswordLineEdit->clear();\r
+ }\r
+ }\r
+ else\r
+ return QWidget::eventFilter(obj,e);\r
+ return true;\r
+}\r
void SettingsForm::on_restoreSyncPushButton_clicked()\r
{\r
ui->syncUrlLineEdit->setText(DEFAULT_SYNC_URL);\r
void SettingsForm::on_applyPushButton_clicked()\r
{\r
saveSync();\r
+ shown();\r
}\r
\r
void SettingsForm::on_savePushButton_clicked()\r
{\r
settings->setValue(USERNAME, ui->syncUsernameLineEdit->text());\r
QVariant passString = ui->syncPasswordLineEdit->text();\r
- QString passMd5 = QCryptographicHash::hash(passString.toByteArray(), QCryptographicHash::Md5).toHex().constData();\r
- // We save the md5 hash of the password instead of the real password so it won't be retrievable.\r
- settings->setValue(PASSWORD, passMd5);\r
+\r
+ if(ui->syncPasswordLineEdit->isReadOnly()) //Password is already a hash\r
+ {\r
+ settings->setValue(PASSWORD,passString);\r
+ }\r
+ else\r
+ {\r
+ QString passMd5 = QCryptographicHash::hash(passString.toByteArray(), QCryptographicHash::Md5).toHex().constData();\r
+ // We save the md5 hash of the password instead of the real password so it won't be retrievable.\r
+ settings->setValue(PASSWORD, passMd5);\r
+ }\r
settings->setValue(SYNC_URL, ui->syncUrlLineEdit->text());\r
+ settings->sync();\r
}\r
\r
void SettingsForm::on_cancelPushButton_clicked()\r