qtchatmx.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "qtchatmx.h"
  2. #include <QtCore>
  3. #include <QtGui>
  4. #include <QPropertyAnimation>
  5. QtChatMX::QtChatMX(QWidget *parent, Qt::WFlags flags)
  6. : QMainWindow(parent, flags)
  7. {
  8. homeView = new LoginView(this);
  9. chatView = new ChatView(this);
  10. networkApi = new NetworkApi(this);
  11. homeView->resize(640, 360);
  12. chatView->resize(640, 360);
  13. chatView->hide();
  14. connect(homeView, SIGNAL(loginComplete(QString*)), this, SLOT(showChatView(QString*)));
  15. connect(chatView, SIGNAL(logoutEvent(QString*)), this, SLOT(showHomeView(QString*)));
  16. chatView->init(networkApi);
  17. homeView->init(networkApi);
  18. homeView->show();
  19. }
  20. // switch to main chat view once the login in done
  21. void QtChatMX::showChatView(QString *nick)
  22. {
  23. chatView->setNick(nick);
  24. homeView->hide();
  25. chatView->show();
  26. }
  27. // switch to home view if the logout is pressed
  28. void QtChatMX::showHomeView(QString *nick)
  29. {
  30. //
  31. chatView->resetUI();
  32. chatView->hide();
  33. homeView->resetUI();
  34. homeView->show();
  35. }
  36. QtChatMX::~QtChatMX()
  37. {
  38. }