themes::themePtr HistoryControlPageItem::theme() const
 {
     return get_qt_theme_settings()->themeForContact(aimId_);
 }
Esempio n. 2
0
    MainWindow::MainWindow(QApplication* app)
		: main_page_(nullptr)
		, login_page_(nullptr)
#ifdef __APPLE__
        , accounts_page_(nullptr)
#endif //_APPLE__
		, app_(app)
		, event_filter_(new TitleWidgetEventFilter(this))
		, tray_icon_(new TrayIcon(this))
                , backgroundPixmap_(QPixmap())
        , Shadow_(0)
        , SkipRead_(false)
        , TaskBarIconHidden_(false)
        , liveChats_(new LiveChats(this))
	{
        Utils::InterConnector::instance().setMainWindow(this);

#ifdef _WIN32
        Utils::init_crash_handlers_in_core();
        core::dump::crash_handler chandler;
        chandler.set_process_exception_handlers();
        chandler.set_thread_exception_handlers();
#endif //_WIN32

		setStyleSheet(Utils::LoadStyle(":/main_window/main_window.qss", Utils::get_scale_coefficient(), true));
#ifdef __APPLE__
        mac_support_ = new MacSupport(this);
        mac_support_->enableMacCrashReport();
#endif

        app_->installNativeEventFilter(this);

        if (this->objectName().isEmpty())
            this->setObjectName(QStringLiteral("main_window"));
        this->resize(329, 331);
        QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
        this->setSizePolicy(sizePolicy);
        this->setLayoutDirection(Qt::LeftToRight);
        this->setAutoFillBackground(false);
        main_widget_ = new QWidget(this);
        main_widget_->setObjectName(QStringLiteral("main_widget"));
        sizePolicy.setHeightForWidth(main_widget_->sizePolicy().hasHeightForWidth());
        main_widget_->setSizePolicy(sizePolicy);
        vertical_layout_ = new QVBoxLayout(main_widget_);
        vertical_layout_->setSpacing(0);
        vertical_layout_->setObjectName(QStringLiteral("verticalLayout_9"));
        vertical_layout_->setSizeConstraint(QLayout::SetDefaultConstraint);
        vertical_layout_->setContentsMargins(0, 0, 0, 0);
        title_widget_ = new QWidget(main_widget_);
        title_widget_->setObjectName(QStringLiteral("title_widget"));
        QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Fixed);
        sizePolicy1.setHorizontalStretch(0);
        sizePolicy1.setVerticalStretch(0);
        sizePolicy1.setHeightForWidth(title_widget_->sizePolicy().hasHeightForWidth());
        title_widget_->setSizePolicy(sizePolicy1);
        title_widget_->setProperty("TitleWidget", QVariant(true));
        horizontal_layout_ = new QHBoxLayout(title_widget_);
        horizontal_layout_->setSpacing(0);
        horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout"));
        horizontal_layout_->setContentsMargins(0, 0, 0, 0);
        logo_ = new QPushButton(title_widget_);
        logo_->setObjectName(QStringLiteral("logo"));
        QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Fixed);
        sizePolicy2.setHorizontalStretch(0);
        sizePolicy2.setVerticalStretch(0);
        sizePolicy2.setHeightForWidth(logo_->sizePolicy().hasHeightForWidth());
        logo_->setSizePolicy(sizePolicy2);
        logo_->setProperty("WindowIcon", QVariant(true));
        horizontal_layout_->addWidget(logo_);
        title_ = new QLabel(title_widget_);
        title_->setObjectName(QStringLiteral("title"));
        title_->setProperty("Title", QVariant(true));
        horizontal_layout_->addWidget(title_);
        horizontal_spacer_ = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
        horizontal_layout_->addItem(horizontal_spacer_);
        hide_button_ = new QPushButton(title_widget_);
        hide_button_->setObjectName(QStringLiteral("hide_button"));
        hide_button_->setProperty("HideButton", QVariant(true));
        horizontal_layout_->addWidget(hide_button_);
        maximize_button_ = new QPushButton(title_widget_);
        maximize_button_->setObjectName(QStringLiteral("maximize_button"));
        sizePolicy2.setHeightForWidth(maximize_button_->sizePolicy().hasHeightForWidth());
        maximize_button_->setSizePolicy(sizePolicy2);
        maximize_button_->setProperty("MaximizeButton", QVariant(true));
        horizontal_layout_->addWidget(maximize_button_);
        close_button_ = new QPushButton(title_widget_);
        close_button_->setObjectName(QStringLiteral("close_button"));
        sizePolicy2.setHeightForWidth(close_button_->sizePolicy().hasHeightForWidth());
        close_button_->setSizePolicy(sizePolicy2);
        close_button_->setProperty("CloseButton", QVariant(true));
        horizontal_layout_->addWidget(close_button_);
        vertical_layout_->addWidget(title_widget_);
        stacked_widget_ = new BackgroundWidget(main_widget_, "");
        stacked_widget_->setObjectName(QStringLiteral("stacked_widget"));

        QPixmap p(":/resources/main_window/pat_100.png");
        setBackgroundPixmap(p, true);

        //Utils::InterConnector::instance().setMainWindow(this);
        get_qt_theme_settings()->setOrLoadDefaultTheme();
        vertical_layout_->addWidget(stacked_widget_);
        this->setCentralWidget(main_widget_);

        logo_->setText(QString());
        hide_button_->setText(QString());
        maximize_button_->setText(QString());
        close_button_->setText(QString());

        stacked_widget_->setCurrentIndex(-1);
        QMetaObject::connectSlotsByName(this);

        if (!get_gui_settings()->get_value(settings_keep_logged_in, true))// || !get_gui_settings()->contains_value(settings_keep_logged_in))
        {
            showLoginPage();
        }
        else
        {
            showMainPage();
        }

		title_widget_->installEventFilter(event_filter_);
		title_->setText("ICQ");
		title_->setAttribute(Qt::WA_TransparentForMouseEvents);
		logo_->setAttribute(Qt::WA_TransparentForMouseEvents);

		setWindowTitle("ICQ");
#ifdef _WIN32
        setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint | Qt::WindowMinimizeButtonHint);
        fake_parent_window_ = Utils::create_fake_parent_window();
#else
        title_widget_->hide();
#endif

		title_->setMouseTracking(true);

		connect(hide_button_, SIGNAL(clicked()), this, SLOT(minimize()), Qt::QueuedConnection);
		connect(maximize_button_, SIGNAL(clicked()), this, SLOT(maximize()), Qt::QueuedConnection);
		connect(close_button_, SIGNAL(clicked()), this, SLOT(hideWindow()), Qt::QueuedConnection);

		hide_button_->setCursor(Qt::PointingHandCursor);
		maximize_button_->setCursor(Qt::PointingHandCursor);
		close_button_->setCursor(Qt::PointingHandCursor);

		connect(event_filter_, SIGNAL(doubleClick()), this, SLOT(maximize()), Qt::QueuedConnection);
		connect(event_filter_, SIGNAL(moveRequest(QPoint)), this, SLOT(moveRequest(QPoint)), Qt::QueuedConnection);

        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipResetComplete()), this, SLOT(onVoipResetComplete()), Qt::QueuedConnection);

		connect(Ui::GetDispatcher(), SIGNAL(needLogin()), this, SLOT(showLoginPage()), Qt::DirectConnection);
		connect(&Utils::InterConnector::instance(), SIGNAL(showIconInTaskbar(bool)), this, SLOT(showIconInTaskbar(bool)), Qt::QueuedConnection);

        connect(this, SIGNAL(needActivate()), this, SLOT(activate()), Qt::QueuedConnection);

        connect(get_gui_settings(), SIGNAL(changed(QString)), this, SLOT(guiSettingsChanged(QString)), Qt::QueuedConnection);

		QFont f = QApplication::font();
		f.setStyleStrategy(QFont::PreferAntialias);
		QApplication::setFont(f);

        if (platform::is_windows())
        {
            int shadowWidth = get_gui_settings()->get_shadow_width();
            QBrush b = stacked_widget_->palette().background();
            QMatrix m;
            m.translate(shadowWidth, title_widget_->height() + shadowWidth);
            b.setMatrix(m);
            Shadow_ = new ShadowWindow(b, shadowWidth);
            QPoint pos = mapToGlobal(QPoint(rect().x(), rect().y()));
            Shadow_->move(pos.x(), pos.y());
            Shadow_->resize(rect().width(), rect().height());
            Shadow_->setActive(true);
            Shadow_->show();
        }

        initSettings();
#ifdef _WIN32
        DragAcceptFiles((HWND)winId(), TRUE);
#endif //_WIN32

        if (!get_gui_settings()->get_value<bool>(settings_show_in_taskbar, true))
            hide_taskbar_icon();

#ifdef __APPLE__
        mac_support_->enableMacUpdater();
        mac_support_->enableMacPreview(this->winId());
#endif

	}
Esempio n. 3
0
QBrush getBodyBrush(
    const bool isOutgoing, 
    const bool isSelected, 
    const int _theme_id)
{
    auto _theme = get_qt_theme_settings()->themeForId(_theme_id);

    QLinearGradient grad(0, 0, 1, 0);

    grad.setCoordinateMode(QGradient::ObjectBoundingMode);

    QColor outgoingSelectedBackgroundColor0 = !isSelected ? _theme->outgoing_bubble_.bg1_color_ : QColor(0x57, 0x9e, 0x1c, (int32_t)(0.9 * 255));
    QColor incomingSelectedBackgroundColor0 = !isSelected ? _theme->incoming_bubble_.bg1_color_ : QColor(0x57, 0x9e, 0x1c, (int32_t)(1.0 * 255));

    QColor outgoingSelectedBackgroundColor1 = !isSelected ? _theme->outgoing_bubble_.bg2_color_ : QColor(0x57, 0x9e, 0x1c, (int32_t)(0.72 * 255));
    QColor incomingSelectedBackgroundColor1 = !isSelected ? _theme->incoming_bubble_.bg2_color_ : QColor(0x57, 0x9e, 0x1c, (int32_t)(0.72 * 255));

    QColor outgoingBackgroundColor0 = !isSelected ? _theme->outgoing_bubble_.bg1_color_ : QColor(0xd8, 0xd4, 0xce, (int32_t)(0.9 * 255));
    QColor incomingBackgroundColor0 = !isSelected ? _theme->incoming_bubble_.bg1_color_ : QColor(0xff, 0xff, 0xff, (int32_t)(1.0 * 255));

    QColor outgoingBackgroundColor1 = !isSelected ? _theme->outgoing_bubble_.bg2_color_ : QColor(0xd5, 0xd2, 0xce, (int32_t)(0.72 * 255));
    QColor incomingBackgroundColor1 = !isSelected ? _theme->incoming_bubble_.bg2_color_ : QColor(0xff, 0xff, 0xff, (int32_t)(0.72 * 255));

    if (isSelected)
    {
        const auto color0 = (
            isOutgoing ?
                outgoingSelectedBackgroundColor0 :
                incomingSelectedBackgroundColor0
        );


        grad.setColorAt(0, color0);

        const auto color1 = (
            isOutgoing ?
                outgoingSelectedBackgroundColor1 :
                incomingSelectedBackgroundColor1
        );
        grad.setColorAt(1, color1);
    }
    else
    {
        const auto color0 = (
            isOutgoing ?
                outgoingBackgroundColor0 :
                incomingBackgroundColor0
        );
        grad.setColorAt(0, color0);

        const auto color1 = (
            isOutgoing ?
                outgoingBackgroundColor1 :
                incomingBackgroundColor1
        );
        grad.setColorAt(1, color1);
    }

    QBrush result(grad);
    result.setColor(QColor(0, 0, 0, 0));

    return result;
}