Beispiel #1
0
MsgEdit::MsgEdit(QWidget *parent, UserWnd *userWnd)
        : QMainWindow(parent, NULL, 0)
{
    m_userWnd	= userWnd;
    m_msg		= NULL;
    m_bTyping	= false;
    m_type		= NO_TYPE;
    m_flags		= 0;
    m_retry.msg = NULL;
    m_bReceived = false;
    m_processor = NULL;
    m_recvProcessor = NULL;
    m_cmd.param = NULL;

    connect(CorePlugin::m_plugin, SIGNAL(modeChanged()), this, SLOT(modeChanged()));

    m_frame = new QFrame(this);
    setCentralWidget(m_frame);
    m_layout = new QVBoxLayout(m_frame);

    m_edit = new MsgTextEdit(this, m_frame);
    m_edit->setBackground(QColor(CorePlugin::m_plugin->getEditBackground() & 0xFFFFFF));
    m_edit->setForeground(QColor(CorePlugin::m_plugin->getEditForeground() & 0xFFFFFF), true);
    m_edit->setFont(CorePlugin::m_plugin->editFont);
    m_edit->setCtrlMode(!CorePlugin::m_plugin->getSendOnEnter());
	setFocusProxy(m_edit);

    QStyleSheet *style = new QStyleSheet(m_edit);
    QStyleSheetItem *style_p = style->item("p");
    // Disable top and bottom margins for P tags. This will make sure
    // paragraphs have no more spacing than regular lines, thus matching
    // RTFs defaut look for paragraphs.
    style_p->setMargin(QStyleSheetItem::MarginTop, 0);
    style_p->setMargin(QStyleSheetItem::MarginBottom, 0);
    m_edit->setStyleSheet(style);

    connect(m_edit, SIGNAL(lostFocus()), this, SLOT(editLostFocus()));
    connect(m_edit, SIGNAL(textChanged()), this, SLOT(editTextChanged()));
    connect(m_edit, SIGNAL(ctrlEnterPressed()), this, SLOT(editEnterPressed()));
    connect(m_edit, SIGNAL(colorsChanged()), this, SLOT(colorsChanged()));
    connect(m_edit, SIGNAL(finished()), this, SLOT(editFinished()));
    connect(m_edit, SIGNAL(fontSelected(const QFont&)), this, SLOT(editFontChanged(const QFont&)));

    QFontMetrics fm(m_edit->font());
    m_edit->setMinimumSize(QSize(fm.maxWidth(), fm.height() + 10));
    m_layout->addWidget(m_edit);

    BarShow b;
    b.bar_id = ToolBarMsgEdit;
    b.parent = this;
    Event e(EventShowBar, &b);
    m_bar = (CToolBar*)(e.process());
    m_bar->setParam(this);

    if (CorePlugin::m_plugin->getContainerMode() == 0)
        showCloseSend(false);

    setDockEnabled(m_bar, Left, false);
    setDockEnabled(m_bar, Right, false);
}
Beispiel #2
0
	SearchWidget::SearchWidget(int _offset, bool _isWithButton, QWidget* _parent)
        : QWidget(_parent)
	{
        if (this->objectName().isEmpty())
            this->setObjectName(QStringLiteral("search_widget"));
        active_ = false;
        parent_search_vertical_layout_ = new QVBoxLayout(this);
        parent_search_vertical_layout_->setContentsMargins(0, 0, 0, 0);
        parent_search_vertical_layout_->setSpacing(0);
        horizontal_search_layout_ = new QHBoxLayout();
        horizontal_search_layout_->setContentsMargins(0, 0, 0, Utils::scale_value(0));
        parent_search_vertical_layout_->addLayout(horizontal_search_layout_);

        horizontal_search_layout_->addSpacing(Utils::scale_value(_offset - 8));

        search_icon_ = new Ui::CustomButton(this, ":/resources/contr_search_100.png");
        search_icon_->setOffsets(Utils::scale_value(8), Utils::scale_value(0));
        search_icon_->setActiveImage(":/resources/contr_search_100_active.png");
        search_icon_->setFixedWidth(Utils::scale_value(34));
        search_icon_->setFixedHeight(Utils::scale_value(53));
        search_icon_->setStyleSheet("border: none;");
        horizontal_search_layout_->addWidget(search_icon_);

        parent_widget_ = new QWidget(this);
        search_vertical_layout_ = new QVBoxLayout(parent_widget_);
        search_vertical_layout_->setContentsMargins(0, Utils::scale_value(5), 0, 0);
        search_edit_ = new LineEditEx(this);
        search_edit_->setProperty("SearchEdit", true);
        search_edit_->setPlaceholderText(QT_TRANSLATE_NOOP("search_widget", "Search"));
        search_edit_->setContentsMargins(Utils::scale_value(6), 0, Utils::scale_value(22), 0);
        search_edit_->setAttribute(Qt::WA_MacShowFocusRect, false);
        search_edit_->setStyleSheet(QString("background-color: transparent"));
        Testing::setAccessibleName(search_edit_, "search_edit");
        search_vertical_layout_->addSpacing(Utils::scale_value(0));
        search_vertical_layout_->addWidget(search_edit_);
        horizontal_search_layout_->addWidget(parent_widget_);

        search_edit_icon_ = new CustomButton(this, ":/resources/contr_compose_100.png");
        search_edit_icon_->setOffsets(Utils::scale_value(0), Utils::scale_value(0));
		search_edit_icon_->setOffsetsForActive(Utils::scale_value(2), Utils::scale_value(0));
        search_edit_icon_->setHoverImage(":/resources/contr_compose_100_hover.png");
        search_edit_icon_->setActiveImage(":/resources/contr_clear_100.png");
        search_edit_icon_->setFixedWidth(Utils::scale_value(50));
        search_edit_icon_->setFixedHeight(Utils::scale_value(53));
		search_edit_icon_->setCursor(Qt::PointingHandCursor);
		search_edit_icon_->setFocusPolicy(Qt::NoFocus);
        search_edit_icon_->setStyleSheet("background-color: transparent;");
        Testing::setAccessibleName(search_edit_icon_, "CreateGroupChat");
		horizontal_search_layout_->addWidget(search_edit_icon_);

        horizontal_line_widget_ = new QWidget(this);
        horizontal_line_widget_->setFixedHeight(Utils::scale_value(1));
        horizontal_line_widget_->setStyleSheet(QString("background-color: #dadada;"));
        parent_search_vertical_layout_->addSpacing(0);
        widget_2_ = new QWidget(this);
        horizontal_layout_2_ = new QHBoxLayout(widget_2_);
        horizontal_layout_2_->setContentsMargins(Utils::scale_value(_isWithButton ? 24 : 16), 0, Utils::scale_value(_isWithButton ? 24 : 60), Utils::scale_value(10));
        horizontal_layout_2_->addWidget(horizontal_line_widget_);
        parent_search_vertical_layout_->addWidget(widget_2_);

        QMetaObject::connectSlotsByName(this);
        connect(search_edit_, SIGNAL(textEdited(QString)), this, SLOT(searchChanged(QString)), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(clicked()), this, SLOT(searchStarted()), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(escapePressed()), this, SLOT(searchCompleted()), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(enter()), this, SLOT(editEnterPressed()), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(upArrow()), this, SLOT(editUpPressed()), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(downArrow()), this, SLOT(editDownPressed()), Qt::QueuedConnection);
        connect(search_edit_, SIGNAL(focusOut()), this, SLOT(focusedOut()), Qt::QueuedConnection);
        connect(search_edit_icon_, SIGNAL(clicked()), this, SLOT(clearPressed()), Qt::QueuedConnection);

		setActive(false);
	}