// Child windows functions void MainWindow::createChildWindows() { currentRecipient = ALL_FRIENDS_ID; // Creating drawing window drawingWindow = new DrawingWindow(this); connect(drawingWindow, SIGNAL(clipartWindowRequest()), this, SLOT(onShowClipart())); connect(drawingWindow, SIGNAL(messageSent()), this, SLOT(onMessageSent())); connect(drawingWindow, SIGNAL(replyChanged()), tvWidget, SLOT(replyChanged())); drawingWindow->updatePosition(this); historyWindow = new HistoryWindow(this); historyWindow->setTvWidget(tvWidget); connect(historyWindow, SIGNAL(beginOfPreview(const MessageKey &)), tvWidget, SLOT(showHistoryMessage(const MessageKey &))); connect(historyWindow, SIGNAL(endOfPreview()), tvWidget, SLOT(stopShowingHistory())); connect(historyWindow, SIGNAL(clicked(const MessageKey &)), tvWidget, SLOT(scrollToMessage(const MessageKey &))); connect(historyWindow, SIGNAL(deleteMessages(const QList<MessageKey> &)), tvWidget, SLOT(deleteMessages(const QList<MessageKey> &))); connect(historyWindow, SIGNAL(saveMessage()), tvWidget, SLOT(saveMessage())); connect(historyWindow, SIGNAL(copyMessage()), tvWidget, SLOT(copyMessage())); connect(tvWidget, SIGNAL(publishRequest(const MessageKey &)), historyWindow, SLOT(publishMessage(const MessageKey &))); historyWindow->updatePosition(this); contactList = new NewContactListWindow(this); contactList->updatePosition(this); contactList->initAutoUpdater(&autoUpdater); // Connect menu signals connect(contactList, SIGNAL(goOnline()), this, SLOT(relogon())); connect(contactList, SIGNAL(goOffline()), this, SLOT(offline())); connect(contactList, SIGNAL(goLogout()), this, SLOT(logout())); connect(contactList, SIGNAL(goExit()), this, SLOT(shutDown())); connect(contactList, SIGNAL(contactSelected(qint32)), this, SLOT(onContactSelected(qint32))); connect(contactList, SIGNAL(contactImageDrop(qint32, const QImage &)), this, SLOT(onContactImageDrop(qint32, const QImage &))); connect(contactList, SIGNAL(soundStateChanged(const bool)), this, SLOT(onSoundStateChanged(const bool))); connect(contactList, SIGNAL(unreadContacts(int)), contactListButton, SLOT(update(int))); #ifdef Q_WS_MAC connect(contactList, SIGNAL(unreadContacts(int)), DockIconHandler::instance(), SLOT(unreadCountChanged(int))); #endif connect(contactList, SIGNAL(historyCleared()), tvWidget, SLOT(reload())); connect(welcomeWidget, SIGNAL(showProfileDialog()), contactList, SLOT(onShowProfileDialog())); connect(welcomeWidget, SIGNAL(showFindFriendsDialog()), contactList, SLOT(onShowFindDialog())); }
MainPage::MainPage(QWidget* parent) : QWidget(parent) , search_widget_(new SearchWidget(8, false, this)) , contact_dialog_(new ContactDialog(this)) , video_window_(new VideoWindow()) , video_panel_(new CallPanelMain(this)) , pages_(new WidgetsNavigator(this)) , search_contacts_(nullptr) , profile_settings_(new ProfileSettingsWidget(this)) , general_settings_(new GeneralSettingsWidget(this)) , noContactsYetSuggestions_(nullptr) , contact_list_widget_(new ContactList(this, Logic::MembersWidgetRegim::CONTACT_LIST, NULL)) , add_contact_menu_(0) { connect(&Utils::InterConnector::instance(), SIGNAL(showNoContactsYetSuggestions()), this, SLOT(showNoContactsYetSuggestions())); connect(&Utils::InterConnector::instance(), SIGNAL(hideNoContactsYetSuggestions()), this, SLOT(hideNoContactsYetSuggestions())); if (this->objectName().isEmpty()) this->setObjectName(QStringLiteral("main_page")); this->resize(400, 300); this->setProperty("Invisible", QVariant(true)); horizontal_layout_ = new QHBoxLayout(this); horizontal_layout_->setSpacing(0); horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout")); horizontal_layout_->setContentsMargins(0, 0, 0, 0); QMetaObject::connectSlotsByName(this); QHBoxLayout* originalLayout = qobject_cast<QHBoxLayout*>(layout()); QVBoxLayout* contactsLayout = new QVBoxLayout(); contactsLayout->setContentsMargins(0, 0, 0, 0); contactsLayout->setSpacing(0); assert(video_panel_); if (video_panel_) { contactsLayout->addWidget(video_panel_); video_panel_->hide(); } contactsLayout->addWidget(search_widget_); contactsLayout->addWidget(contact_list_widget_); QSpacerItem* contactsLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum); contactsLayout->addSpacerItem(contactsLayoutSpacer); pages_layout_ = new QVBoxLayout(); pages_layout_->setContentsMargins(0, 0, 0, 0); pages_layout_->setSpacing(0); pages_layout_->addWidget(pages_); { auto pc = pages_->count(); pages_->addWidget(contact_dialog_); pages_->addWidget(profile_settings_); pages_->addWidget(general_settings_); if (!pc) pages_->push(contact_dialog_); } originalLayout->addLayout(contactsLayout); originalLayout->addLayout(pages_layout_); QSpacerItem* originalLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum); originalLayout->addSpacerItem(originalLayoutSpacer); originalLayout->setAlignment(Qt::AlignLeft); setFocus(); connect(contact_list_widget_, SIGNAL(itemSelected(QString)), contact_dialog_, SLOT(onContactSelected(QString)), Qt::QueuedConnection); connect(contact_dialog_, SIGNAL(sendMessage(QString)), contact_list_widget_, SLOT(onSendMessage(QString)), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(itemSelected(QString)), this, SLOT(onContactSelected(QString)), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(addContactClicked()), this, SLOT(onAddContactClicked()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsShow(QString)), this, SLOT(onProfileSettingsShow(QString)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsShow(int)), this, SLOT(onGeneralSettingsShow(int)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(makeSearchWidgetVisible(bool)), search_widget_, SLOT(setVisible(bool)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(popPagesToRoot()), pages_, SLOT(poproot()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsDoMessage(QString)), contact_list_widget_, SLOT(select(QString)), Qt::QueuedConnection); connect(search_widget_, SIGNAL(searchBegin()), this, SLOT(searchBegin()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(searchEnd()), this, SLOT(searchEnd()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(search(QString)), Logic::GetSearchModel(), SLOT(searchPatternChanged(QString)), Qt::QueuedConnection); connect(search_widget_, SIGNAL(enterPressed()), contact_list_widget_, SLOT(searchResult()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(upPressed()), contact_list_widget_, SLOT(searchUpPressed()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(downPressed()), contact_list_widget_, SLOT(searchDownPressed()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(nonActiveButtonPressed()), this, SLOT(addButtonClicked()), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(searchEnd()), search_widget_, SLOT(searchCompleted()), Qt::QueuedConnection); connect(Logic::GetContactListModel(), SIGNAL(selectedContactChanged(QString)), Logic::GetMessagesModel(), SLOT(contactChanged(QString)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipShowVideoWindow(bool)), this, SLOT(onVoipShowVideoWindow(bool)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncoming(const std::string&, const std::string&)), this, SLOT(onVoipCallIncoming(const std::string&, const std::string&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), this, SLOT(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallDestroyed(const voip_manager::ContactEx&)), this, SLOT(onVoipCallDestroyed(const voip_manager::ContactEx&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallCreated(const voip_manager::ContactEx&)), this, SLOT(onVoipCallCreated(const voip_manager::ContactEx&)), Qt::DirectConnection); search_widget_->setVisible(!contact_list_widget_->shouldHideSearch()); }
int MoodBox::MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: onUserAccountUpdated(); break; case 1: onUserStatusChanged((*reinterpret_cast< UserStatus::UserStatusEnum(*)>(_a[1]))); break; case 2: onServerError((*reinterpret_cast< ServerResponseHandler::ServerError(*)>(_a[1]))); break; case 3: onShowExceptionDialogSendingMessage((*reinterpret_cast< ContactResultCode::ContactResultCodeEnum(*)>(_a[1])),(*reinterpret_cast< qint32(*)>(_a[2]))); break; case 4: onLogonStarted(); break; case 5: onLogonStopped(); break; case 6: onLogonSuccess(); break; case 7: showWindow(); break; case 8: shutDown(); break; case 9: onLogoutCompleted(); break; case 10: relogon(); break; case 11: offline((*reinterpret_cast< bool(*)>(_a[1]))); break; case 12: offline(); break; case 13: { bool _r = logout((*reinterpret_cast< bool(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 14: { bool _r = logout(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 15: showSettings(); break; case 16: ipcMessage((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 17: addFriendByLogin(); break; case 18: forceQuit(); break; case 19: onTrayIconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break; case 20: on_contactListButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break; case 21: on_drawButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break; case 22: on_historyButton_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break; case 23: onDownloadNewVersion(); break; case 24: onInviteCodeAccepted(); break; case 25: onRegistrationSuccess(); break; case 26: onResetPassword(); break; case 27: onShowClipart(); break; case 28: onReply((*reinterpret_cast< const QImage(*)>(_a[1]))); break; case 29: showTvWidget(); break; case 30: showLogonWidget((*reinterpret_cast< bool(*)>(_a[1]))); break; case 31: showLogonWidget(); break; case 32: showInviteCodeWidget(); break; case 33: showRegistrationWidget(); break; case 34: showForgotPasswordWidget(); break; case 35: showInfoWidget(); break; case 36: showWaitingWidget(); break; case 37: stopWaitingWidget(); break; case 38: hideWaitingWidget(); break; case 39: cancelWaitingWidget(); break; case 40: onRegistrationBack(); break; case 41: onInviteCodeNeeded(); break; case 42: onContactSelected((*reinterpret_cast< qint32(*)>(_a[1]))); break; case 43: onContactImageDrop((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const QImage(*)>(_a[2]))); break; case 44: onSoundStateChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 45: onPrivateMessageReceived((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const MessageKey(*)>(_a[2]))); break; case 46: onChannelMessageReceived((*reinterpret_cast< qint32(*)>(_a[1])),(*reinterpret_cast< const MessageKey(*)>(_a[2]))); break; case 47: onFriendsMessageReceived((*reinterpret_cast< const MessageKey(*)>(_a[1]))); break; case 48: onMessageSent(); break; case 49: showHelp(); break; case 50: requestFinished((*reinterpret_cast< QNetworkReply*(*)>(_a[1]))); break; case 51: dataProcessedProgress((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break; case 52: cancelHttpRequest(); break; default: ; } _id -= 53; } return _id; }
void MainWindow::onContactImageDrop(qint32 id, const QImage &image) { onContactSelected(id); drawButton->setChecked(true); drawingWindow->addImage(image); }
MainPage::MainPage(QWidget* parent) : QWidget(parent) , search_widget_(new SearchWidget(false, this)) , contact_dialog_(new ContactDialog(this)) #ifndef STRIP_VOIP , video_window_(nullptr) #else , video_window_(nullptr) #endif //STRIP_VOIP , pages_(new WidgetsNavigator(this)) , search_contacts_(nullptr) , profile_settings_(new ProfileSettingsWidget(this)) , general_settings_(new GeneralSettingsWidget(this)) , live_chats_page_(new LiveChatHome(this)) , themes_settings_(new ThemesSettingsWidget(this)) , noContactsYetSuggestions_(nullptr) , contact_list_widget_(new ContactList(this, Logic::MembersWidgetRegim::CONTACT_LIST, nullptr)) , add_contact_menu_(nullptr) , settings_timer_(new QTimer(this)) , introduceYourselfSuggestions_(nullptr) , needShowIntroduceYourself_(false) , liveChats_(new LiveChats(this)) , login_new_user_(false) , recv_my_info_(false) { connect(&Utils::InterConnector::instance(), &Utils::InterConnector::showPlaceholder, this, &MainPage::showPlaceholder); if (this->objectName().isEmpty()) this->setObjectName(QStringLiteral("main_page")); setStyleSheet(Utils::LoadStyle(":/main_window/main_window.qss", Utils::get_scale_coefficient(), true)); this->resize(400, 300); this->setProperty("Invisible", QVariant(true)); horizontal_layout_ = new QHBoxLayout(this); horizontal_layout_->setSpacing(0); horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout")); horizontal_layout_->setContentsMargins(0, 0, 0, 0); QMetaObject::connectSlotsByName(this); QHBoxLayout* originalLayout = qobject_cast<QHBoxLayout*>(layout()); QVBoxLayout* contactsLayout = new QVBoxLayout(); contactsLayout->setContentsMargins(0, 0, 0, 0); contactsLayout->setSpacing(0); contactsLayout->addWidget(search_widget_); contactsLayout->addWidget(contact_list_widget_); QSpacerItem* contactsLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum); contactsLayout->addSpacerItem(contactsLayoutSpacer); pages_layout_ = new QVBoxLayout(); pages_layout_->setContentsMargins(0, 0, 0, 0); pages_layout_->setSpacing(0); pages_layout_->addWidget(pages_); { auto pc = pages_->count(); pages_->addWidget(contact_dialog_); pages_->addWidget(profile_settings_); pages_->addWidget(general_settings_); pages_->addWidget(live_chats_page_); pages_->addWidget(themes_settings_); if (!pc) pages_->push(contact_dialog_); } originalLayout->addLayout(contactsLayout); originalLayout->addLayout(pages_layout_); QSpacerItem* originalLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum); originalLayout->addSpacerItem(originalLayoutSpacer); originalLayout->setAlignment(Qt::AlignLeft); setFocus(); connect(contact_list_widget_, SIGNAL(itemSelected(QString)), contact_dialog_, SLOT(onContactSelected(QString)), Qt::QueuedConnection); connect(contact_dialog_, SIGNAL(sendMessage(QString)), contact_list_widget_, SLOT(onSendMessage(QString)), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(itemSelected(QString)), this, SLOT(onContactSelected(QString)), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(addContactClicked()), this, SLOT(onAddContactClicked()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsShow(QString)), this, SLOT(onProfileSettingsShow(QString)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(themesSettingsShow(bool,QString)), this, SLOT(onThemesSettingsShow(bool,QString)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsShow(int)), this, SLOT(onGeneralSettingsShow(int)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(liveChatsShow()), this, SLOT(onLiveChatsShow()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(themesSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(attachPhoneBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(attachUinBack()), pages_, SLOT(pop()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(makeSearchWidgetVisible(bool)), search_widget_, SLOT(setVisible(bool)), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(popPagesToRoot()), this, SLOT(popPagesToRoot()), Qt::QueuedConnection); connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsDoMessage(QString)), contact_list_widget_, SLOT(select(QString)), Qt::QueuedConnection); connect(search_widget_, SIGNAL(searchBegin()), this, SLOT(searchBegin()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(searchEnd()), this, SLOT(searchEnd()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(search(QString)), Logic::GetSearchModel(), SLOT(searchPatternChanged(QString)), Qt::QueuedConnection); connect(search_widget_, SIGNAL(enterPressed()), contact_list_widget_, SLOT(searchResult()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(upPressed()), contact_list_widget_, SLOT(searchUpPressed()), Qt::QueuedConnection); connect(search_widget_, SIGNAL(downPressed()), contact_list_widget_, SLOT(searchDownPressed()), Qt::QueuedConnection); connect(contact_list_widget_, SIGNAL(searchEnd()), search_widget_, SLOT(searchCompleted()), Qt::QueuedConnection); connect(Logic::GetContactListModel(), SIGNAL(selectedContactChanged(QString)), Logic::GetMessagesModel(), SLOT(contactChanged(QString)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipShowVideoWindow(bool)), this, SLOT(onVoipShowVideoWindow(bool)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncoming(const std::string&, const std::string&)), this, SLOT(onVoipCallIncoming(const std::string&, const std::string&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), this, SLOT(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallDestroyed(const voip_manager::ContactEx&)), this, SLOT(onVoipCallDestroyed(const voip_manager::ContactEx&)), Qt::DirectConnection); connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallCreated(const voip_manager::ContactEx&)), this, SLOT(onVoipCallCreated(const voip_manager::ContactEx&)), Qt::DirectConnection); search_widget_->setVisible(!contact_list_widget_->shouldHideSearch()); post_stats_with_settings(); QObject::connect(settings_timer_, SIGNAL(timeout()), this, SLOT(post_stats_with_settings())); settings_timer_->start(Ui::period_for_stats_settings_ms); connect(Ui::GetDispatcher(), &core_dispatcher::myInfo, this, &MainPage::myInfo, Qt::UniqueConnection); connect(Ui::GetDispatcher(), &core_dispatcher::login_new_user, this, &MainPage::loginNewUser, Qt::DirectConnection); add_contact_menu_ = new FlatMenu(search_widget_->searchEditIcon()); Utils::ApplyStyle(add_contact_menu_, "QMenu { background-color: #f2f2f2; border:1px solid #cccccc; } " "QMenu::item { padding-left:40dip; background-color:transparent; color:black; padding-top:6dip; padding-bottom:6dip; padding-right:12dip; } " "QMenu::item:selected { background-color:#e2e2e2; } " "QMenu::icon { padding-left:22dip; }" ); add_contact_menu_->addAction(QIcon(Utils::parse_image_name(":/resources/dialog_newchat_100.png")), QT_TRANSLATE_NOOP("contact_list", "New chat"), contact_list_widget_, SLOT(allClicked())); add_contact_menu_->addAction(QIcon(Utils::parse_image_name(":/resources/dialog_newgroup_100.png")), QT_TRANSLATE_NOOP("contact_list", "Create Groupchat"), this, SLOT(createGroupChat())); add_contact_menu_->setExpandDirection(Qt::AlignLeft); add_contact_menu_->stickToIcon(); Utils::ApplyStyle(search_widget_->searchEditIcon(), "QPushButton::menu-indicator { image:none; } QPushButton:pressed { background-color:transparent; }"); search_widget_->searchEditIcon()->setMenu(add_contact_menu_); }