예제 #1
0
MsgFile::MsgFile(CToolCustom *parent, Message *msg)
        : QLineEdit(parent)
{
    m_client = msg->client();
    for (QWidget *p = parent->parentWidget(); p; p = p->parentWidget()){
        if (p->inherits("MsgEdit")){
            m_edit = static_cast<MsgEdit*>(p);
            break;
        }
    }
    m_edit->m_edit->setTextFormat(PlainText);
    QString t = msg->getPlainText();
    if (!t.isEmpty())
        m_edit->m_edit->setText(t);
    setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
    parent->addWidget(this);
    QToolButton *btn = new QToolButton(parent);
    btn->setAutoRaise(true);
    btn->setIconSet(*Icon("fileopen"));
    btn->setTextLabel(i18n("Select file"));
    parent->addWidget(btn);
    btn->show();
    connect(btn, SIGNAL(clicked()), this, SLOT(selectFile()));
    parent->setText(i18n("File:"));
    connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(changed(const QString&)));
    Command cmd;
    cmd->id    = CmdSend;
    cmd->param = m_edit;
    Event e(EventCommandWidget, cmd);
    btnSend = (QToolButton*)(e.process());
    setText(static_cast<FileMessage*>(msg)->getFile());
    changed(text());
    show();
}
예제 #2
0
void PresetWidget::populateButtonLayout()
{
	//delete old stuff
	if(mButtonLayout)
	{
		QLayoutItem *child;
		while ((child = mButtonLayout->takeAt(0)) != 0)
		{
			// delete both the layoutitem AND the widget. Not auto done because layoutitem is no QObject.
			QWidget* widget = child->widget();
			delete child;
			delete widget;
		}
		delete mButtonLayout;
	}

	//make the new buttons
	mButtonLayout = new QHBoxLayout;
	mLayout->addLayout(mButtonLayout);

	QList<QAction*> actions = mActionGroup->actions();
	for (int i=0; i<actions.size(); ++i)
	{
		QToolButton* button = new QToolButton(this);
		button->setDefaultAction(actions[i]);
		button->show();
		mButtonLayout->addWidget(button);
	}
	mButtonLayout->addStretch();
}
예제 #3
0
MsgGen::MsgGen(CToolCustom *parent, Message *msg)
        : QObject(parent)
{
    m_client = msg->client();
    m_edit = NULL;
    for (QWidget *p = parent->parentWidget(); p; p = p->parentWidget()){
        if (p->inherits("MsgEdit")){
            m_edit = static_cast<MsgEdit*>(p);
            break;
        }
    }
    connect(m_edit->m_userWnd, SIGNAL(multiplyChanged()), this, SLOT(textChanged()));
    parent->setText(i18n(" "));
    m_edit->m_edit->setTextFormat(RichText);
    QString text = msg->getRichText();
    if (!text.isEmpty()){
        m_edit->m_edit->setText(text);
        m_edit->m_edit->moveCursor(QTextEdit::MoveEnd, false);
        if ((msg->getBackground() != msg->getForeground()) && !CorePlugin::m_plugin->getOwnColors()){
            m_edit->m_edit->setBackground(msg->getBackground());
            m_edit->m_edit->setForeground(msg->getForeground());
        }
    }
    Command cmd;
    cmd->id    = CmdSend;
    cmd->param = m_edit;
    Event e(EventCommandWidget, cmd);
    btnSend = (QToolButton*)(e.process());

    QToolButton *btn = new ColorToolButton(parent, QColor(CorePlugin::m_plugin->getEditBackground()));
    set_button(btn, "bgcolor", I18N_NOOP("Bac&kground color"));
    connect(btn, SIGNAL(colorChanged(QColor)), this, SLOT(bgColorChanged(QColor)));
    parent->addWidget(btn);
    btn->show();

    btn = new ColorToolButton(parent, QColor(CorePlugin::m_plugin->getEditForeground()));
    set_button(btn, "fgcolor", I18N_NOOP("&Text color"));
    connect(btn, SIGNAL(colorChanged(QColor)), this, SLOT(fgColorChanged(QColor)));
    parent->addWidget(btn);
    btn->show();

    btnBold = new QToolButton(parent);
    set_button(btnBold, "text_bold", I18N_NOOP("&Bold"));
    btnBold->setToggleButton(true);
    connect(btnBold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool)));
    parent->addWidget(btnBold);
    btnBold->show();

    btnItalic = new QToolButton(parent);
    set_button(btnItalic, "text_italic", I18N_NOOP("&Italic"));
    btnItalic->setToggleButton(true);
    connect(btnItalic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool)));
    parent->addWidget(btnItalic);
    btnItalic->show();

    btnUnderline = new QToolButton(parent);
    set_button(btnUnderline, "text_under", I18N_NOOP("&Underline"));
    btnUnderline->setToggleButton(true);
    connect(btnUnderline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool)));
    parent->addWidget(btnUnderline);
    btnUnderline->show();

    btn = new QToolButton(parent);
    set_button(btn, "text", I18N_NOOP("Text &font"));
    connect(btn, SIGNAL(clicked()), this, SLOT(selectFont()));
    parent->addWidget(btn);
    btn->show();

    connect(m_edit->m_edit, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(fontChanged(const QFont&)));
    connect(m_edit->m_edit, SIGNAL(textChanged()), this, SLOT(textChanged()));
    fontChanged(m_edit->m_edit->font());
    textChanged();
}