enable read and write settings
diff --git a/chatdialog.cpp b/chatdialog.cpp
index 2519089..d8010a0 100644
--- a/chatdialog.cpp
+++ b/chatdialog.cpp
@@ -86,9 +86,9 @@
SyncDemo::ChatMessage msg;
formControlMessage(msg, SyncDemo::ChatMessage::LEAVE);
sendMsg(msg);
- sleep(1);
+ usleep(500000);
m_sock->remove(m_user.getPrefix().toStdString());
- sleep(1);
+ usleep(5000);
#ifdef __DEBUG
std::cout << "Sync REMOVE signal sent" << std::endl;
#endif
@@ -133,7 +133,7 @@
void
ChatDialog::closeEvent(QCloseEvent *e)
{
- if (trayIcon->isVisible())
+ if (trayIcon->isVisible() && !m_minimaniho)
{
QMessageBox::information(this, tr("Chronos"),
tr("The program will keep running in the "
@@ -142,6 +142,8 @@
"of the system tray entry."));
hide();
e->ignore();
+ m_minimaniho = true;
+ writeSettings();
}
}
@@ -453,12 +455,12 @@
bool
ChatDialog::readSettings()
{
-#ifndef __DEBUG
QSettings s(ORGANIZATION, APPLICATION);
QString nick = s.value("nick", "").toString();
QString chatroom = s.value("chatroom", "").toString();
QString originPrefix = s.value("originPrefix", "").toString();
- if (nick == "" || chatroom == "" || prefix == "") {
+ m_minimaniho = s.value("minimaniho", false).toBool();
+ if (nick == "" || chatroom == "" || originPrefix == "") {
QTimer::singleShot(500, this, SLOT(buttonPressed()));
return false;
}
@@ -466,24 +468,22 @@
m_user.setNick(nick);
m_user.setChatroom(chatroom);
m_user.setOriginPrefix(originPrefix);
- m_user.setPrefix(origin_prefix + "/" + chatroom + "/" + getRandomString());
+ m_user.setPrefix(originPrefix + "/" + chatroom + "/" + getRandomString());
return true;
}
-#else
- QTimer::singleShot(500, this, SLOT(buttonPressed()));
- return false;
-#endif
+
+// QTimer::singleShot(500, this, SLOT(buttonPressed()));
+ // return false;
}
void
ChatDialog::writeSettings()
{
-#ifndef __DEBUG
QSettings s(ORGANIZATION, APPLICATION);
s.setValue("nick", m_user.getNick());
s.setValue("chatroom", m_user.getChatroom());
s.setValue("originPrefix", m_user.getOriginPrefix());
-#endif
+ s.setValue("minimaniho", m_minimaniho);
}
void
diff --git a/chatdialog.h b/chatdialog.h
index 1ee4216..a8e385d 100644
--- a/chatdialog.h
+++ b/chatdialog.h
@@ -91,6 +91,7 @@
int m_randomizedInterval;
QTimer *m_timer;
QStringListModel *m_rosterModel;
+ bool m_minimaniho;
// icon related
QAction *minimizeAction;