Exemplo n.º 1
0
LRESULT toolbarNotify(NMHDR* hdr, HWND toolbar)
{
  if(hdr->code == TTN_NEEDTEXT)
  {
    TOOLTIPTEXT* ttt = (TOOLTIPTEXT*)hdr;
    ttt->lpszText = tools[hdr->idFrom - TOOLBAR_FIRST_ICON].tip;
    return 1;
  }

  else if(hdr->code == TBN_GETBUTTONINFO)
  {
    NMTOOLBAR* nmt = (NMTOOLBAR*)hdr;
    if(nmt->iItem < numButtons)
    {
      nmt->tbButton = toolToWin32(nmt->iItem);
      nmt->pszText = tools[nmt->iItem].tip;
      return 1;
    }
    else
      return 0;
  }

  else if(hdr->code == TBN_RESET)
  {
    int n = SendMessage(toolbar, TB_BUTTONCOUNT, 0, 0);
    for(int i = 0; i < n; ++i)
      SendMessage(toolbar, TB_DELETEBUTTON, 0, 0);
    addTools(toolbar);
    updateToolbar(toolbar);
    return 1;
  }


  else if(hdr->code == TBN_QUERYDELETE || hdr->code == TBN_QUERYINSERT)
    return 1;

  else if(hdr->code == TBN_CUSTHELP)
  {
    return 1;
  }

  else
    return 0;
}
WidgetChatInput::WidgetChatInput(QWidget *parent, bool isIRC) :
	QMainWindow(parent),
	ui(new Ui::WidgetChatInput)
{
	ui->setupUi(this);
	bIsIRC = isIRC;
	textEditInput = new WidgetReturnEmitTextEdit(this);
	connect(textEditInput, SIGNAL(cursorPositionChanged()), this, SLOT(updateToolbar()));
	ui->horizontalLayoutInput->addWidget(textEditInput);
	checkBoxSendOnEnter = new QCheckBox(tr("Send On Enter"), this);
	checkBoxSendOnEnter->setChecked(true);
	connect(checkBoxSendOnEnter, SIGNAL(toggled(bool)), textEditInput, SLOT(setEmitsReturn(bool)));
	connect(textEditInput, SIGNAL(returnPressed()), ui->toolButtonSend, SLOT(click()));
	connect(textEditInput, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(onTextFormatChange(QTextCharFormat)));
	toolButtonSmilies = new QToolButton();
	toolButtonSmilies->setPopupMode(QToolButton::InstantPopup);
	toolButtonSmilies->setToolTip(tr("Smilies"));
	toolButtonSmilies->setIcon(QIcon(":/Resource/Smileys/0.png"));
	widgetSmileyList = new WidgetSmileyList(this);
	toolButtonSmilies->setMenu(widgetSmileyList);
	toolButtonPickColor = new QToolButton(this);
	toolButtonPickColor->setStyleSheet(QString("QToolButton { background-color: %1; border-style: outset; border-width: 2px;	border-radius: 6px; border-color: lightgrey; }").arg(textEditInput->textColor().name()));
	toolButtonPickColor->setToolTip(tr("Font Color"));
	connect(toolButtonPickColor, SIGNAL(clicked()), this, SLOT(pickColor()));
	toolButtonPrivateMessage = new QToolButton(this);
	toolButtonPrivateMessage->setText(tr("New Private Message"));
	toolButtonPrivateMessage->setToolTip(tr("New Private Message"));
	toolButtonPrivateMessage->setIcon(QIcon(":/Resource/Chat/Chat.png"));
	ui->toolBarTextTools->insertWidget(ui->actionBold, toolButtonPickColor);
	ui->toolBarTextTools->addSeparator();
	ui->toolBarTextTools->addWidget(toolButtonSmilies);
	ui->toolBarTextTools->addWidget(checkBoxSendOnEnter);
	ui->actionBold->setChecked(textEditInput->fontWeight() == QFont::Bold);
	ui->actionItalic->setChecked(textEditInput->fontItalic());
	ui->actionUnderline->setChecked(textEditInput->fontUnderline());
	ui->toolBarTextTools->addWidget(toolButtonPrivateMessage);
	toolButtonPrivateMessage->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
	connect(ui->actionItalic, SIGNAL(toggled(bool)), textEditInput, SLOT(setFontItalic(bool)));
	connect(ui->actionUnderline, SIGNAL(toggled(bool)), textEditInput, SLOT(setFontUnderline(bool)));
	connect(toolButtonPrivateMessage, SIGNAL(clicked()), this, SLOT(addPrivateMessage()));
}