Example #1
0
void CMenuBeginGame::update ()
{
	if ( event.keyboard->isPressed () == true && event.keyboard->pressed == false )
	{
		event.keyboard->pressed = true;

		switch ( event.keyboard->getEvent ()->key.keysym.sym )
		{
		case SDLK_UP:
			selectkUp ();
			break;
		case SDLK_DOWN:
			selectDown ();
			break;
		case SDLK_SPACE:
			doIt ();
			break;
		default:
			break;
		}
	}
	else
		event.keyboard->pressed = event.keyboard->isPressed ();
}
Example #2
0
void Menu::parseMenuInput(){
    sf::Event evt;
    //Loop through all window events
    while(menuWindow->pollEvent(evt)){
        //request closing window
        if(evt.type == sf::Event::Closed){
            menuWindow->close();
        }
    }
    //restrict key selections to 0.5 per second
    if((sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) && (inputClock.getElapsedTime().asSeconds() > inputRate)){
        selectUp();
        inputClock.restart();
    }
    if((sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) && (inputClock.getElapsedTime().asSeconds() > inputRate)){
        selectDown();
        inputClock.restart();
    }

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::Return)){
        selectOption();
    }

}
Example #3
0
void MVListBase::handleEvent(MVEvent& event,phaseType phase)
/****************************************************************************
*
* Function:     MVListBase::handleEvent
* Parameters:   event   - Event to handle
*               phase   - Current phase for the event (pre,focus,post)
*
* Description:  Event handling mechanism for the MVListBase class.
*
****************************************************************************/
{
    MVView::handleEvent(event,phase);

    switch (event.what) {
        case evMouseDown:
            if (range.isEmpty())
                return;

            if (event.mouse.buttons & mbLeftButton) {
                while (event.what != evMouseUp) {
                    switch (event.what) {
                        case evMouseDown:
                            if (!(event.mouse.modifiers & mdShift)
                                    && !(flags & lsDisjointSelect)) {
                                clearSelection();
                                selectCell(cursor);
                                refresh();
                                }
                            if (event.mouse.doubleClick) {
                                MV_message(owner,evBroadcast,cmListItemSelected,this);
                                goto doneMouse;
                                }
                        case evMouseAuto:
                        case evMouseMove:
                            MVPoint loc;
                            uint    modifiers = mdShift;

                            if (event.what == evMouseDown)
                                modifiers = event.mouse.modifiers;
                            if (flags & lsDisjointSelect)
                                modifiers = 0;

                            uint pos = findCellHit(event.where,loc);
                            if (pos == lsInside && event.what != evMouseAuto) {
                                // Selection within the list
                                if (loc == cursor && event.what == evMouseDown) {
                                    // Post a message to ensure updates
                                    // occur for the first mouse down event
                                    // in the list box.
                                    MV_message(owner,evBroadcast,
                                        cmListCursorChanged,this);
                                    }

                                if (loc.x < cursor.x)
                                    selectLeft(cursor.x - loc.x,modifiers);
                                else if (loc.x > cursor.x)
                                    selectRight(loc.x - cursor.x,modifiers);

                                if (loc.y < cursor.y)
                                    selectUp(cursor.y - loc.y,modifiers);
                                else if (loc.y > cursor.y)
                                    selectDown(loc.y - cursor.y,modifiers);
                                }
                            else if (event.what == evMouseAuto) {
                                // Auto selection outside window to scroll
                                if (pos & lsAbove)
                                    selectUp(1,modifiers);
                                if (pos & lsBelow)
                                    selectDown(1,modifiers);
                                if (pos & lsLeft)
                                    selectLeft(1,modifiers);
                                if (pos & lsRight)
                                    selectRight(1,modifiers);
                                }
                            if (event.what == evMouseDown
                                    && flags & lsDisjointSelect) {
                                toggleCell(cursor);
                                refresh();
                                }
                            break;
                        }
                    getEvent(event);
                    }

doneMouse:
                clearEvent(event);
                }
            break;
        case evKeyDown:
        case evKeyAuto:
            if (range.isEmpty())
                return;

            switch (event.key.charScan.scanCode) {
                case kbSpace:
                    if (event.what == evKeyAuto)
                        break;
                    if (flags & lsDisjointSelect) {
                        toggleCell(cursor);
                        refresh();
                        }
                    break;
                case kbLeft:
                    selectLeft(1,event.key.modifiers);
                    break;
                case kbRight:
                    selectRight(1,event.key.modifiers);
                    break;
                case kbUp:
                    selectUp(1,event.key.modifiers);
                    break;
                case kbDown:
                    selectDown(1,event.key.modifiers);
                    break;
                case kbHome:
                    selectNext(lsLeft | lsAbove,range.bottom(),
                        event.key.modifiers);
                    break;
                case kbEnd:
                    selectNext(lsRight | lsBelow,range.bottom(),
                        event.key.modifiers);
                    break;
                case kbPgUp:
                    selectUp(visible.bottom()-visible.top(),
                        event.key.modifiers,true);
                    break;
                case kbPgDn:
                    selectDown(visible.bottom()-visible.top(),
                        event.key.modifiers,true);
                default:
                    // Key press is not handled by us, so simply return.
                    return;
                }
            clearEvent(event);
            break;
        case evBroadcast:
            if (options & ofSelectable) {
                if (event.message.command == cmScrollBarClicked &&
                        (event.message.infoPtr == hScroll ||
                         event.message.infoPtr == vScroll))
                    select();
                else if (event.message.command == cmScrollBarChanged) {
                    if (range.isEmpty())
                        return;
                    if (event.message.infoPtr == hScroll)
                        hScrollTo(hScroll->getValue());
                    else if (event.message.infoPtr == vScroll)
                        vScrollTo(vScroll->getValue());
                    }
                }
            break;
        }
}
Example #4
0
TagsEditDialog::TagsEditDialog(QWidget *parent, State *stateToEdit, bool addNewTag)
        : KDialog(parent)
        ,  m_loading(false)
{
    // KDialog options
    setCaption(i18n("Customize Tags"));
    setButtons(Ok | Cancel);
    setDefaultButton(Ok);
    setObjectName("CustomizeTags");
    setModal(true);
    showButtonSeparator(true);
    connect(this, SIGNAL(okClicked()), SLOT(slotOk()));
    connect(this, SIGNAL(cancelClicked()), SLOT(slotCancel()));

    setMainWidget(new QWidget(this));

    QHBoxLayout *layout = new QHBoxLayout(mainWidget());

    /* Left part: */

    QPushButton *newTag     = new QPushButton(i18n("Ne&w Tag"),   mainWidget());
    QPushButton *newState   = new QPushButton(i18n("New St&ate"), mainWidget());

    connect(newTag,   SIGNAL(clicked()), this, SLOT(newTag()));
    connect(newState, SIGNAL(clicked()), this, SLOT(newState()));

    m_tags = new TagListView(mainWidget());
    m_tags->header()->hide();
    m_tags->setRootIsDecorated(false);
    //m_tags->addColumn("");
    //m_tags->setSorting(-1); // Sort column -1, so disabled sorting
    //m_tags->setResizeMode(QTreeWidget::LastColumn);

    m_moveUp    = new KPushButton(KGuiItem("", "arrow-up"),   mainWidget());
    m_moveDown  = new KPushButton(KGuiItem("", "arrow-down"), mainWidget());
    m_deleteTag = new KPushButton(KGuiItem("", "edit-delete"), mainWidget());

    m_moveUp->setToolTip(i18n("Move Up (Ctrl+Shift+Up)"));
    m_moveDown->setToolTip(i18n("Move Down (Ctrl+Shift+Down)"));
    m_deleteTag->setToolTip(i18n("Delete"));

    connect(m_moveUp,    SIGNAL(clicked()), this, SLOT(moveUp()));
    connect(m_moveDown,  SIGNAL(clicked()), this, SLOT(moveDown()));
    connect(m_deleteTag, SIGNAL(clicked()), this, SLOT(deleteTag()));

    QHBoxLayout *topLeftLayout = new QHBoxLayout;
    topLeftLayout->addWidget(m_moveUp);
    topLeftLayout->addWidget(m_moveDown);
    topLeftLayout->addWidget(m_deleteTag);

    QVBoxLayout *leftLayout = new QVBoxLayout;
    leftLayout->addWidget(newTag);
    leftLayout->addWidget(newState);
    leftLayout->addWidget(m_tags);
    leftLayout->addLayout(topLeftLayout);

    layout->addLayout(leftLayout);

    /* Right part: */

    QWidget *rightWidget = new QWidget(mainWidget());

    m_tagBox             = new QGroupBox(i18n("Tag"), rightWidget);
    m_tagBoxLayout       = new QHBoxLayout;
    m_tagBox->setLayout(m_tagBoxLayout);

    QWidget   *tagWidget = new QWidget;
    m_tagBoxLayout->addWidget(tagWidget);

    m_tagName = new QLineEdit(tagWidget);
    QLabel *tagNameLabel = new QLabel(i18n("&Name:"), tagWidget);
    tagNameLabel->setBuddy(m_tagName);

    m_shortcut = new KShortcutWidget(tagWidget);
    m_removeShortcut = new QPushButton(i18nc("Remove tag shortcut", "&Remove"), tagWidget);
    QLabel *shortcutLabel = new QLabel(i18n("S&hortcut:"), tagWidget);
    shortcutLabel->setBuddy(m_shortcut);
    //connect( m_shortcut,       SIGNAL(shortcutChanged(const KShortcut&)), this, SLOT(capturedShortcut(const KShortcut&)) );
    connect(m_removeShortcut, SIGNAL(clicked()),                          this, SLOT(removeShortcut()));

    m_inherit = new QCheckBox(i18n("&Inherited by new sibling notes"), tagWidget);

    QGridLayout *tagGrid = new QGridLayout(tagWidget);
    tagGrid->addWidget(tagNameLabel, 0, 0);
    tagGrid->addWidget(m_tagName, 0, 1, 1, 3);
    tagGrid->addWidget(shortcutLabel, 1, 0);
    tagGrid->addWidget(m_shortcut, 1, 1);
    tagGrid->addWidget(m_removeShortcut, 1, 2);
    tagGrid->addWidget(m_inherit, 2, 0, 1, 4);
    tagGrid->setColumnStretch(/*col=*/3, /*stretch=*/255);

    m_stateBox           = new QGroupBox(i18n("State"), rightWidget);
    m_stateBoxLayout = new QHBoxLayout;
    m_stateBox->setLayout(m_stateBoxLayout);

    QWidget *stateWidget = new QWidget;
    m_stateBoxLayout->addWidget(stateWidget);

    m_stateName = new QLineEdit(stateWidget);
    m_stateNameLabel = new QLabel(i18n("Na&me:"), stateWidget);
    m_stateNameLabel->setBuddy(m_stateName);

    QWidget *emblemWidget = new QWidget(stateWidget);
    m_emblem = new KIconButton(emblemWidget);
    m_emblem->setIconType(KIconLoader::NoGroup, KIconLoader::Action);
    m_emblem->setIconSize(16);
    m_emblem->setIcon("edit-delete");
    m_removeEmblem = new QPushButton(i18nc("Remove tag emblem", "Remo&ve"), emblemWidget);
    QLabel *emblemLabel = new QLabel(i18n("&Emblem:"), stateWidget);
    emblemLabel->setBuddy(m_emblem);
    connect(m_removeEmblem, SIGNAL(clicked()), this, SLOT(removeEmblem()));   // m_emblem.resetIcon() is not a slot!

    // Make the icon button and the remove button the same height:
    int height = qMax(m_emblem->sizeHint().width(), m_emblem->sizeHint().height());
    height = qMax(height, m_removeEmblem->sizeHint().height());
    m_emblem->setFixedSize(height, height); // Make it square
    m_removeEmblem->setFixedHeight(height);
    m_emblem->resetIcon();

    QHBoxLayout *emblemLayout = new QHBoxLayout(emblemWidget);
    emblemLayout->addWidget(m_emblem);
    emblemLayout->addWidget(m_removeEmblem);
    emblemLayout->addStretch();

    m_backgroundColor = new KColorCombo2(QColor(), palette().color(QPalette::Base), stateWidget);
    QLabel *backgroundColorLabel = new QLabel(i18n("&Background:"), stateWidget);
    backgroundColorLabel->setBuddy(m_backgroundColor);

    QHBoxLayout *backgroundColorLayout = new QHBoxLayout(0);
    backgroundColorLayout->addWidget(m_backgroundColor);
    backgroundColorLayout->addStretch();

    //QIcon boldIconSet = KIconLoader::global()->loadIconSet("format-text-bold", KIconLoader::Small);
    KIcon boldIconSet("format-text-bold", KIconLoader::global());
    m_bold = new QPushButton(boldIconSet, "", stateWidget);
    m_bold->setCheckable(true);
    int size = qMax(m_bold->sizeHint().width(), m_bold->sizeHint().height());
    m_bold->setFixedSize(size, size); // Make it square!
    m_bold->setToolTip(i18n("Bold"));

    //QIcon underlineIconSet = KIconLoader::global()->loadIconSet("format-text-underline", KIconLoader::Small);
    KIcon underlineIconSet("format-text-underline", KIconLoader::global());
    m_underline = new QPushButton(underlineIconSet, "", stateWidget);
    m_underline->setCheckable(true);
    m_underline->setFixedSize(size, size); // Make it square!
    m_underline->setToolTip(i18n("Underline"));

    //QIcon italicIconSet = KIconLoader::global()->loadIconSet("format-text-italic", KIconLoader::Small);
    KIcon italicIconSet("format-text-italic", KIconLoader::global());
    m_italic = new QPushButton(italicIconSet, "", stateWidget);
    m_italic->setCheckable(true);
    m_italic->setFixedSize(size, size); // Make it square!
    m_italic->setToolTip(i18n("Italic"));

    KIcon strikeIconSet("format-text-strikethrough", KIconLoader::global());
    m_strike = new QPushButton(strikeIconSet, "", stateWidget);
    m_strike->setCheckable(true);
    m_strike->setFixedSize(size, size); // Make it square!
    m_strike->setToolTip(i18n("Strike Through"));

    QLabel *textLabel = new QLabel(i18n("&Text:"), stateWidget);
    textLabel->setBuddy(m_bold);

    QHBoxLayout *textLayout = new QHBoxLayout;
    textLayout->addWidget(m_bold);
    textLayout->addWidget(m_underline);
    textLayout->addWidget(m_italic);
    textLayout->addWidget(m_strike);
    textLayout->addStretch();

    m_textColor = new KColorCombo2(QColor(), palette().color(QPalette::Text), stateWidget);
    QLabel *textColorLabel = new QLabel(i18n("Co&lor:"), stateWidget);
    textColorLabel->setBuddy(m_textColor);

    m_font = new QFontComboBox(stateWidget);
    m_font->addItem(i18n("(Default)"), 0);
    QLabel *fontLabel = new QLabel(i18n("&Font:"), stateWidget);
    fontLabel->setBuddy(m_font);

    m_fontSize = new FontSizeCombo(/*rw=*/true, /*withDefault=*/true, stateWidget);
    QLabel *fontSizeLabel = new QLabel(i18n("&Size:"), stateWidget);
    fontSizeLabel->setBuddy(m_fontSize);

    m_textEquivalent = new QLineEdit(stateWidget);
    QLabel *textEquivalentLabel = new QLabel(i18n("Te&xt equivalent:"), stateWidget);
    textEquivalentLabel->setBuddy(m_textEquivalent);
    QFont font = m_textEquivalent->font();
    font.setFamily("monospace");
    m_textEquivalent->setFont(font);

    HelpLabel *textEquivalentHelp = new HelpLabel(
        i18n("What is this for?"),
        "<p>" + i18n("When you copy and paste or drag and drop notes to a text editor, this text will be inserted as a textual equivalent of the tag.") + "</p>" +
//      "<p>" + i18n("If filled, this property lets you paste this tag or this state as textual equivalent.") + "<br>" +
        i18n("For instance, a list of notes with the <b>To Do</b> and <b>Done</b> tags are exported as lines preceded by <b>[ ]</b> or <b>[x]</b>, "
             "representing an empty checkbox and a checked box.") + "</p>" +
        "<p align='center'><img src=\":images/tag_export_help.png\"></p>",
        stateWidget);
    QHBoxLayout *textEquivalentHelpLayout = new QHBoxLayout;
    textEquivalentHelpLayout->addWidget(textEquivalentHelp);
    textEquivalentHelpLayout->addStretch(255);

    m_onEveryLines = new QCheckBox(i18n("On ever&y line"), stateWidget);

    HelpLabel *onEveryLinesHelp = new HelpLabel(
        i18n("What does this mean?"),
        "<p>" + i18n("When a note has several lines, you can choose to export the tag or the state on the first line or on every line of the note.") + "</p>" +
        "<p align='center'><img src=\":images/tag_export_on_every_lines_help.png\"></p>" +
        "<p>" + i18n("In the example above, the tag of the top note is only exported on the first line, while the tag of the bottom note is exported on every line of the note."),
        stateWidget);
    QHBoxLayout *onEveryLinesHelpLayout = new QHBoxLayout;
    onEveryLinesHelpLayout->addWidget(onEveryLinesHelp);
    onEveryLinesHelpLayout->addStretch(255);

    QGridLayout *textEquivalentGrid = new QGridLayout;
    textEquivalentGrid->addWidget(textEquivalentLabel,      0, 0);
    textEquivalentGrid->addWidget(m_textEquivalent,         0, 1);
    textEquivalentGrid->addLayout(textEquivalentHelpLayout, 0, 2);
    textEquivalentGrid->addWidget(m_onEveryLines,           1, 1);
    textEquivalentGrid->addLayout(onEveryLinesHelpLayout,   1, 2);
    textEquivalentGrid->setColumnStretch(/*col=*/3, /*stretch=*/255);

    KSeparator *separator = new KSeparator(Qt::Horizontal, stateWidget);

    QGridLayout *stateGrid = new QGridLayout(stateWidget);
    stateGrid->addWidget(m_stateNameLabel, 0, 0);
    stateGrid->addWidget(m_stateName, 0, 1, 1, 6);
    stateGrid->addWidget(emblemLabel, 1, 0);
    stateGrid->addWidget(emblemWidget, 1, 1, 1, 6);
    stateGrid->addWidget(backgroundColorLabel, 1, 5);
    stateGrid->addLayout(backgroundColorLayout, 1, 6, 1, 1);
    stateGrid->addWidget(textLabel, 2, 0);
    stateGrid->addLayout(textLayout, 2, 1, 1, 4);
    stateGrid->addWidget(textColorLabel, 2, 5);
    stateGrid->addWidget(m_textColor, 2, 6);
    stateGrid->addWidget(fontLabel, 3, 0);
    stateGrid->addWidget(m_font, 3, 1, 1, 4);
    stateGrid->addWidget(fontSizeLabel, 3, 5);
    stateGrid->addWidget(m_fontSize, 3, 6);
    stateGrid->addWidget(separator, 4, 0, 1, 7);
    stateGrid->addLayout(textEquivalentGrid, 5, 0, 1, 7);

    QVBoxLayout *rightLayout = new QVBoxLayout(rightWidget);
    rightLayout->addWidget(m_tagBox);
    rightLayout->addWidget(m_stateBox);
    rightLayout->addStretch();

    layout->addWidget(rightWidget);
    rightWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);

    // Equalize the width of the first column of the two grids:
    int maxWidth = tagNameLabel->sizeHint().width();
    maxWidth = qMax(maxWidth, shortcutLabel->sizeHint().width());
    maxWidth = qMax(maxWidth, m_stateNameLabel->sizeHint().width());
    maxWidth = qMax(maxWidth, emblemLabel->sizeHint().width());
    maxWidth = qMax(maxWidth, textLabel->sizeHint().width());
    maxWidth = qMax(maxWidth, fontLabel->sizeHint().width());
    maxWidth = qMax(maxWidth, backgroundColorLabel->sizeHint().width());
    maxWidth = qMax(maxWidth, textEquivalentLabel->sizeHint().width());

    tagNameLabel->setFixedWidth(maxWidth);
    m_stateNameLabel->setFixedWidth(maxWidth);
    textEquivalentLabel->setFixedWidth(maxWidth);

    // Load Tags:
    for (Tag::List::iterator tagIt = Tag::all.begin(); tagIt != Tag::all.end(); ++tagIt)
        m_tagCopies.append(new TagCopy(*tagIt));

    TagListViewItem *lastInsertedItem = 0;
    TagListViewItem *lastInsertedSubItem;
    TagListViewItem *item;
    TagListViewItem *subItem;
    for (TagCopy::List::iterator tagCopyIt = m_tagCopies.begin(); tagCopyIt != m_tagCopies.end(); ++tagCopyIt) {
        // New List View Item:
        if (lastInsertedItem)
            item = new TagListViewItem(m_tags, lastInsertedItem, *tagCopyIt);
        else
            item = new TagListViewItem(m_tags, *tagCopyIt);
        item->setExpanded(true);
        lastInsertedItem = item;
        // Load
        if ((*tagCopyIt)->isMultiState()) {
            lastInsertedSubItem = 0;
            StateCopy::List stateCopies = item->tagCopy()->stateCopies;
            for (StateCopy::List::iterator stateCopyIt = stateCopies.begin(); stateCopyIt != stateCopies.end(); ++stateCopyIt) {
                if (lastInsertedSubItem)
                    subItem = new TagListViewItem(item, lastInsertedSubItem, *stateCopyIt);
                else
                    subItem = new TagListViewItem(item, *stateCopyIt);
                lastInsertedSubItem = subItem;
            }
        }
    }

    // Connect Signals:
    connect(m_tagName,         SIGNAL(textChanged(const QString&)),        this, SLOT(modified()));
    connect(m_shortcut,        SIGNAL(shortcutChanged(const KShortcut&)), this, SLOT(modified()));
    connect(m_inherit,         SIGNAL(stateChanged(int)),                  this, SLOT(modified()));
    connect(m_stateName,       SIGNAL(textChanged(const QString&)),        this, SLOT(modified()));
    connect(m_emblem,          SIGNAL(iconChanged(QString)),               this, SLOT(modified()));
    connect(m_backgroundColor, SIGNAL(activated(const QColor&)),             this, SLOT(modified()));
    connect(m_bold,            SIGNAL(toggled(bool)),                      this, SLOT(modified()));
    connect(m_underline,       SIGNAL(toggled(bool)),                      this, SLOT(modified()));
    connect(m_italic,          SIGNAL(toggled(bool)),                      this, SLOT(modified()));
    connect(m_strike,          SIGNAL(toggled(bool)),                      this, SLOT(modified()));
    connect(m_textColor,       SIGNAL(activated(const QColor&)),             this, SLOT(modified()));
    connect(m_font,            SIGNAL(textChanged(const QString&)),        this, SLOT(modified()));
    connect(m_fontSize,        SIGNAL(textChanged(const QString&)),        this, SLOT(modified()));
    connect(m_textEquivalent,  SIGNAL(textChanged(const QString&)),        this, SLOT(modified()));
    connect(m_onEveryLines,    SIGNAL(stateChanged(int)),                  this, SLOT(modified()));

    connect(m_tags,            SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),     this,
            SLOT(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
    connect(m_tags,            SIGNAL(deletePressed()),                    this, SLOT(deleteTag()));
    connect(m_tags,            SIGNAL(doubleClickedItem()),                this, SLOT(renameIt()));

    QTreeWidgetItem *firstItem = m_tags->firstChild();
    if (stateToEdit != 0) {
        TagListViewItem *item = itemForState(stateToEdit);
        if (item)
            firstItem = item;
    }
    // Select the first tag unless the first tag is a multi-state tag.
    // In this case, select the first state, as it let customize the state AND the associated tag.
    if (firstItem) {
        if (firstItem->childCount() > 0)
            firstItem = firstItem->child(0);
        firstItem->setSelected(true);
        m_tags->setCurrentItem(firstItem);
        currentItemChanged(firstItem);
        if (stateToEdit == 0)
            m_tags->scrollToItem(firstItem);
        m_tags->setFocus();
    } else {
        m_moveUp->setEnabled(false);
        m_moveDown->setEnabled(false);
        m_deleteTag->setEnabled(false);
        m_tagBox->setEnabled(false);
        m_stateBox->setEnabled(false);
    }
    // TODO: Disabled both boxes if no tag!!!

    // Some keyboard shortcuts:       // Ctrl+arrows instead of Alt+arrows (same as Go menu in the main window) because Alt+Down is for combo boxes
    QAction *selectAbove = new QAction(this);
    selectAbove->setShortcut(Qt::CTRL + Qt::Key_Up);
    connect(selectAbove, SIGNAL(activated()), this, SLOT(selectUp()));

    QAction *selectBelow = new QAction(this);
    selectBelow->setShortcut(Qt::CTRL + Qt::Key_Down);
    connect(selectBelow, SIGNAL(activated()), this, SLOT(selectDown()));

    QAction *selectLeft = new QAction(this);
    selectLeft->setShortcut(Qt::CTRL + Qt::Key_Left);
    connect(selectLeft, SIGNAL(activated()), this, SLOT(selectLeft()));

    QAction *selectRight = new QAction(this);
    selectRight->setShortcut(Qt::CTRL + Qt::Key_Right);
    connect(selectRight, SIGNAL(activated()), this, SLOT(selectRight()));

    QAction *moveAbove = new QAction(this);
    moveAbove->setShortcut(Qt::CTRL + Qt::Key_Up);
    connect(moveAbove, SIGNAL(activated()), this, SLOT(moveUp()));

    QAction *moveBelow = new QAction(this);
    moveBelow->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Down);
    connect(moveBelow, SIGNAL(activated()), this, SLOT(moveDown()));

    QAction *rename = new QAction(this);
    rename->setShortcut(Qt::Key_F2);
    connect(rename, SIGNAL(activated()), this, SLOT(renameIt()));

    m_tags->setMinimumSize(
        m_tags->sizeHint().width() * 2,
        m_tagBox->sizeHint().height() + m_stateBox->sizeHint().height()
    );

    if (addNewTag)
        QTimer::singleShot(0, this, SLOT(newTag()));
    else
        // Once the window initial size is computed and the window show, allow the user to resize it down:
        QTimer::singleShot(0, this, SLOT(resetTreeSizeHint()));
}