Ejemplo n.º 1
0
void IrcClient::createLayout()
{
    setWindowTitle(tr("Communi %1 example client").arg(IRC_VERSION_STR));

    // a read-only text editor for showing the messages
    textEdit = new QTextEdit(this);
    textEdit->setReadOnly(true);

    // a line editor for entering commands
    lineEdit = new QLineEdit(this);
    lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
    textEdit->setFocusProxy(lineEdit);
    connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(onTextEntered()));
    connect(lineEdit, SIGNAL(textEdited(QString)), this, SLOT(onTextEdited()));

    // the rest is just setting up the UI layout...
    QSplitter* splitter = new QSplitter(this);
    splitter->setHandleWidth(1);
    splitter->addWidget(textEdit);
    splitter->addWidget(userList);
    splitter->setStretchFactor(0, 5);
    splitter->setStretchFactor(1, 1);

    QWidget* container = new QWidget(this);
    QVBoxLayout* layout = new QVBoxLayout(container);
    layout->setSpacing(0);
    layout->setMargin(0);
    layout->addWidget(splitter);
    layout->addWidget(lineEdit);

    addWidget(container);

    setHandleWidth(1);
}
Ejemplo n.º 2
0
void InputListener::onEvent(const sf::Event& event)
{
	switch (event.type)
	{
		/* Window */
		case sf::Event::LostFocus:               onFocusLost();                                   break;
		case sf::Event::GainedFocus:             onFocusGained();                                 break;
		case sf::Event::Closed:                  onWindowClosed();                                break;
		case sf::Event::Resized:                 onWindowResized(event.size);                     break;
			
		/* Keyboard */
		case sf::Event::TextEntered:             onTextEntered(event.text);                       break;
		case sf::Event::KeyPressed:              onKeyPressed(event.key);                         break;
		case sf::Event::KeyReleased:             onKeyReleased(event.key);                        break;
			
		/* Mouse */
		case sf::Event::MouseEntered:            onMouseEntered();                                break;
		case sf::Event::MouseLeft:               onMouseLeft();                                   break;
		case sf::Event::MouseMoved:              onMouseMoved(event.mouseMove);                   break;
		case sf::Event::MouseWheelMoved:         onMouseWheelMoved(event.mouseWheel);             break;
		case sf::Event::MouseButtonPressed:      onMouseButtonPressed(event.mouseButton);         break;
		case sf::Event::MouseButtonReleased:     onMouseButtonReleased(event.mouseButton);        break;
			
		/* Joystick */
		case sf::Event::JoystickConnected:       onJoystickConnected(event.joystickConnect);      break;
		case sf::Event::JoystickDisconnected:    onJoystickDisconnected(event.joystickConnect);   break;
		case sf::Event::JoystickButtonPressed:   onJoystickButtonPressed(event.joystickButton);   break;
		case sf::Event::JoystickButtonReleased:  onJoystickButtonReleased(event.joystickButton);  break;
		case sf::Event::JoystickMoved:           onJoystickMoved(event.joystickMove);             break;
			
		default:
			Logger::log("Warning", "Unknow event type: %d", event.type);
			break;
	}
}
void SplitDetailDialog::OnButtonCategoryClick( wxCommandEvent& /*event*/ )
{
    mmCategDialog dlg(this, split_.CATEGID, split_.SUBCATEGID, false);
    if (dlg.ShowModal() == wxID_OK)
    {
        split_.CATEGID = dlg.getCategId();
        split_.SUBCATEGID = dlg.getSubCategId();
        bCategory_->SetLabelText(dlg.getFullCategName());
    }
    wxCommandEvent evt(wxID_ANY, wxID_ANY);
    onTextEntered(evt);
    DataToControls();
}
Ejemplo n.º 4
0
InputWidget::InputWidget(QWidget *parent)
    : AbstractItemView(parent),
    _networkId(0)
{
    ui.setupUi(this);
    connect(ui.ownNick, SIGNAL(activated(QString)), this, SLOT(changeNick(QString)));

    layout()->setAlignment(ui.ownNick, Qt::AlignBottom);
    layout()->setAlignment(ui.inputEdit, Qt::AlignBottom);
    layout()->setAlignment(ui.showStyleButton, Qt::AlignBottom);
    layout()->setAlignment(ui.styleFrame, Qt::AlignBottom);

    ui.styleFrame->setVisible(false);

    setFocusProxy(ui.inputEdit);
    ui.ownNick->setFocusProxy(ui.inputEdit);

    ui.ownNick->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    ui.ownNick->installEventFilter(new MouseWheelFilter(this));
    ui.inputEdit->installEventFilter(this);

    ui.inputEdit->setMinHeight(1);
    ui.inputEdit->setMaxHeight(5);
    ui.inputEdit->setMode(MultiLineEdit::MultiLine);
    ui.inputEdit->setPasteProtectionEnabled(true);

    ui.boldButton->setIcon(SmallIcon("format-text-bold"));
    ui.italicButton->setIcon(SmallIcon("format-text-italic"));
    ui.underlineButton->setIcon(SmallIcon("format-text-underline"));
    ui.textcolorButton->setIcon(SmallIcon("format-text-color"));
    ui.highlightcolorButton->setIcon(SmallIcon("format-fill-color"));
    ui.encryptionIconLabel->hide();

    _colorMenu = new QMenu();
    _colorFillMenu = new QMenu();

    QStringList names;
    names << tr("White") << tr("Black") << tr("Dark blue") << tr("Dark green") << tr("Red") << tr("Dark red") << tr("Dark magenta")  << tr("Orange")
          << tr("Yellow") << tr("Green") << tr("Dark cyan") << tr("Cyan") << tr("Blue") << tr("Magenta") << tr("Dark gray") << tr("Light gray");

    QPixmap pix(16, 16);
    for (int i = 0; i < inputLine()->mircColorMap().count(); i++) {
        pix.fill(inputLine()->mircColorMap().values()[i]);
        _colorMenu->addAction(pix, names[i])->setData(inputLine()->mircColorMap().keys()[i]);
        _colorFillMenu->addAction(pix, names[i])->setData(inputLine()->mircColorMap().keys()[i]);
    }

    pix.fill(Qt::transparent);
    _colorMenu->addAction(pix, tr("Clear Color"))->setData("");
    _colorFillMenu->addAction(pix, tr("Clear Color"))->setData("");

    ui.textcolorButton->setMenu(_colorMenu);
    connect(_colorMenu, SIGNAL(triggered(QAction *)), this, SLOT(colorChosen(QAction *)));
    ui.highlightcolorButton->setMenu(_colorFillMenu);
    connect(_colorFillMenu, SIGNAL(triggered(QAction *)), this, SLOT(colorHighlightChosen(QAction *)));

    new TabCompleter(ui.inputEdit);

    UiStyleSettings fs("Fonts");
    fs.notify("UseCustomInputWidgetFont", this, SLOT(setUseCustomFont(QVariant)));
    fs.notify("InputWidget", this, SLOT(setCustomFont(QVariant)));
    if (fs.value("UseCustomInputWidgetFont", false).toBool())
        setCustomFont(fs.value("InputWidget", QFont()));

    UiSettings s("InputWidget");

#ifdef HAVE_KDE
    s.notify("EnableSpellCheck", this, SLOT(setEnableSpellCheck(QVariant)));
    setEnableSpellCheck(s.value("EnableSpellCheck", false));
#endif

    s.notify("EnableEmacsMode", this, SLOT(setEnableEmacsMode(QVariant)));
    setEnableEmacsMode(s.value("EnableEmacsMode", false));

    s.notify("ShowNickSelector", this, SLOT(setShowNickSelector(QVariant)));
    setShowNickSelector(s.value("ShowNickSelector", true));

    s.notify("ShowStyleButtons", this, SLOT(setShowStyleButtons(QVariant)));
    setShowStyleButtons(s.value("ShowStyleButtons", true));

    s.notify("EnablePerChatHistory", this, SLOT(setEnablePerChatHistory(QVariant)));
    setEnablePerChatHistory(s.value("EnablePerChatHistory", false));

    s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant)));
    setMaxLines(s.value("MaxNumLines", 5));

    s.notify("EnableScrollBars", this, SLOT(setScrollBarsEnabled(QVariant)));
    setScrollBarsEnabled(s.value("EnableScrollBars", true));

    s.notify("EnableLineWrap", this, SLOT(setLineWrapEnabled(QVariant)));
    setLineWrapEnabled(s.value("EnableLineWrap", false));

    s.notify("EnableMultiLine", this, SLOT(setMultiLineEnabled(QVariant)));
    setMultiLineEnabled(s.value("EnableMultiLine", true));

    ActionCollection *coll = QtUi::actionCollection();

    Action *activateInputline = coll->add<Action>("FocusInputLine");
    connect(activateInputline, SIGNAL(triggered()), SLOT(setFocus()));
    activateInputline->setText(tr("Focus Input Line"));
    activateInputline->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));

    connect(inputLine(), SIGNAL(textEntered(QString)), SLOT(onTextEntered(QString)), Qt::QueuedConnection); // make sure the line is already reset, bug #984
    connect(inputLine(), SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat)));
}