CContactModel::CContactModel(CTelegramCore *backend, QObject *parent) : CPeerModel(parent) { setBackend(backend); connect(m_backend, SIGNAL(contactProfileChanged(quint32)), SLOT(onContactProfileChanged(quint32))); connect(m_backend, SIGNAL(contactStatusChanged(quint32,TelegramNamespace::ContactStatus)), SLOT(onContactStatusChanged(quint32))); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_contactsModel(new CContactsModel(this)), m_messagingModel(new CMessagingModel(this)), m_chatContactsModel(new CContactsModel(this)), m_chatMessagingModel(new CMessagingModel(this)), m_chatInfoModel(new CChatInfoModel(this)), m_activeChatId(0), m_chatCreationMode(false), m_core(new CTelegramCore(this)), m_registered(false), m_appState(AppStateNone) { ui->setupUi(this); ui->contactListTable->setModel(m_contactsModel); ui->messagingView->setModel(m_messagingModel); ui->groupChatContacts->setModel(m_chatContactsModel); ui->groupChatChatsList->setModel(m_chatInfoModel); ui->groupChatMessagingView->setModel(m_chatMessagingModel); QCompleter *comp = new QCompleter(m_contactsModel, this); ui->messagingContactPhone->setCompleter(comp); ui->groupChatContactPhone->setCompleter(comp); connect(ui->secretOpenFile, SIGNAL(clicked()), SLOT(loadSecretFromBrowsedFile())); // Telepathy Morse app info CAppInformation appInfo; appInfo.setAppId(14617); appInfo.setAppHash(QLatin1String("e17ac360fd072f83d5d08db45ce9a121")); appInfo.setAppVersion(QLatin1String("0.1")); appInfo.setDeviceInfo(QLatin1String("pc")); appInfo.setOsInfo(QLatin1String("GNU/Linux")); appInfo.setLanguageCode(QLatin1String("en")); m_core->setAppInformation(&appInfo); m_core->setAutoReconnection(true); connect(m_core, SIGNAL(connectionStateChanged(TelegramNamespace::ConnectionState)), SLOT(whenConnectionStateChanged(TelegramNamespace::ConnectionState))); connect(m_core, SIGNAL(phoneStatusReceived(QString,bool,bool)), SLOT(whenPhoneStatusReceived(QString,bool,bool))); connect(m_core, SIGNAL(phoneCodeRequired()), SLOT(whenPhoneCodeRequested())); connect(m_core, SIGNAL(authSignErrorReceived(TelegramNamespace::AuthSignError,QString)), SLOT(whenAuthSignErrorReceived(TelegramNamespace::AuthSignError,QString))); connect(m_core, SIGNAL(contactListChanged()), SLOT(whenContactListChanged())); connect(m_core, SIGNAL(contactProfileChanged(QString)), SLOT(whenContactProfileChanged(QString))); connect(m_core, SIGNAL(avatarReceived(QString,QByteArray,QString,QString)), SLOT(whenAvatarReceived(QString,QByteArray,QString))); connect(m_core, SIGNAL(messageMediaDataReceived(QString,quint32,QByteArray,QString,TelegramNamespace::MessageType,quint32,quint32)), SLOT(whenMessageMediaDataReceived(QString,quint32,QByteArray,QString,TelegramNamespace::MessageType,quint32,quint32))); connect(m_core, SIGNAL(messageReceived(TelegramNamespace::Message)), SLOT(whenMessageReceived(TelegramNamespace::Message))); connect(m_core, SIGNAL(contactChatTypingStatusChanged(quint32,QString,bool)), SLOT(whenContactChatTypingStatusChanged(quint32,QString,bool))); connect(m_core, SIGNAL(contactTypingStatusChanged(QString,bool)), SLOT(whenContactTypingStatusChanged(QString,bool))); connect(m_core, SIGNAL(contactStatusChanged(QString,TelegramNamespace::ContactStatus)), SLOT(whenContactStatusChanged(QString))); connect(m_core, SIGNAL(sentMessageStatusChanged(QString,quint64,TelegramNamespace::MessageDeliveryStatus)), m_messagingModel, SLOT(setMessageDeliveryStatus(QString,quint64,TelegramNamespace::MessageDeliveryStatus))); connect(m_core, SIGNAL(uploadingStatusUpdated(quint32,quint32,quint32)), SLOT(whenUploadingStatusUpdated(quint32,quint32,quint32))); connect(m_core, SIGNAL(chatAdded(quint32)), SLOT(whenChatAdded(quint32))); connect(m_core, SIGNAL(chatChanged(quint32)), SLOT(whenChatChanged(quint32))); ui->groupChatContacts->hideColumn(CContactsModel::Blocked); ui->mainSplitter->setSizes(QList<int>() << 0 << 100); ui->groupChatSplitter->setSizes(QList<int>() << 550 << 450 << 300); ui->groupChatChatsList->setColumnWidth(CChatInfoModel::Id, 30); ui->blockContact->hide(); ui->unblockContact->hide(); ui->groupChatLeaveChat->hide(); QFile helpFile(QLatin1String(":/USAGE")); helpFile.open(QIODevice::ReadOnly); ui->helpView->setPlainText(helpFile.readAll()); setAppState(AppStateNone); updateGroupChatAddContactButtonText(); connect(ui->groupChatContactPhone, SIGNAL(textChanged(QString)), SLOT(updateGroupChatAddContactButtonText())); #if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) connect(ui->messagingView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(whenCustomMenuRequested(QPoint))); #endif ui->groupChatAddContactForwardMessages->hide(); ui->messagingAttachButton->hide(); }