Exemplo n.º 1
0
	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());
	}
Exemplo n.º 2
0
    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_);
    }