Ejemplo n.º 1
0
TabBar::TabBar(quint32 id, QWidget *parent) :
    PlusTabBar(parent)
{
    m_id = id;
    m_menu = new QMenu(this);
    m_drag_idx = -1;
    m_drag_insert = NULL;

    m_newTopBottom = m_menu->addAction(tr("Split view top/bottom"));
    m_newLeftRight = m_menu->addAction(tr("Split view left/right"));
    m_newTopBottom->setEnabled(false);
    m_newLeftRight->setEnabled(false);
    m_newTopBottom->setIcon(QIcon(":/icons/split_top.png"));
    m_newLeftRight->setIcon(QIcon(":/icons/split_left.png"));

    QAction *newWindow = m_menu->addAction(tr("To new window"));

    m_menu->addSeparator();

    QAction *rename = m_menu->addAction(tr("Rename..."));

    setAcceptDrops(true);

    connect(rename,         SIGNAL(triggered()), SLOT(renameTab()));
    connect(m_newTopBottom, SIGNAL(triggered()), SLOT(splitTop()));
    connect(m_newLeftRight, SIGNAL(triggered()), SLOT(splitLeft()));
    connect(newWindow,      SIGNAL(triggered()), SLOT(toNewWindow()));
}
Ejemplo n.º 2
0
/** Redefined to validate new tab name if the focus is lost. */
bool TabBar::eventFilter(QObject *obj, QEvent *event)
{
	// Accept the escape key
	if (obj == lineEdit && event->type() == QEvent::KeyPress) {
		QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
		if (keyEvent->key() == Qt::Key_Escape) {
			lineEdit->releaseMouse();
			lineEdit->setText(lineEdit->text().trimmed());
			lineEdit->close();
		}
	} else if (obj == lineEdit && event->type() == QEvent::FocusOut) {
		lineEdit->releaseMouse();
		lineEdit->setText(lineEdit->text().trimmed());
		renameTab();
	} else if (obj == lineEdit && event->type() == QEvent::MouseButtonPress) {
		QMouseEvent *me = static_cast<QMouseEvent*>(event);
		if (!lineEdit->rect().contains(me->pos())) {
			lineEdit->releaseMouse();
			lineEdit->setText(lineEdit->text().trimmed());
			lineEdit->close();
		}
	} else if (obj == this && event->type() == QEvent::HoverLeave) {
		this->update();
	}
	return false;
}
Ejemplo n.º 3
0
void TabBar::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(event->button() != Qt::LeftButton)
        return PlusTabBar::mouseDoubleClickEvent(event);

    int tab = tabAt(event->pos());
    if(tab == -1 || tabData(tab) == HOME_TAB)
        return PlusTabBar::mouseDoubleClickEvent(event);

    m_cur_menu_tab = tab;
    renameTab();
}
Ejemplo n.º 4
0
QString ScriptableProxyHelper::renameTab(const QString &arg1, const QString &arg2)
{
    INVOKE(renameTab(arg1, arg2));

    if ( arg1.isEmpty() || arg2.isEmpty() )
        return tabNameEmptyError();

    const int i = m_wnd->findTabIndex(arg2);
    if (i == -1)
        return tabNotFoundError();

    if ( m_wnd->findTabIndex(arg1) != -1 )
        return tr("Tab with given name already exists!");

    m_wnd->renameTab(arg1, i);

    return QString();
}
Ejemplo n.º 5
0
bool ControlsTab::renameTab(const TCHAR *internalName, const TCHAR *newName)
{
	bool foundIt = false;
	size_t i = 0;
	for ( ; i < _pWinVector->size() ; i++)
	{
		if ((*_pWinVector)[i]._internalName == internalName)
		{
			foundIt = true;
			break;
		}
	}
	if (!foundIt)
		return false;

	renameTab(i, newName);
	return true;
}
Ejemplo n.º 6
0
void FooTabBar::contextMenuRequested (const QPoint &position)
{
	/*
	 Renane Playlist
	 Remove Playlist
	 Add New Playlist
	 ---
	 Move Left
	 Move Right
	 ---
	 Save All Playlists...
	 Save Playlist...
	 Load Playlist...
	 ---
	 "<playlist-name>" Contents > -- odpuścić na razie
	 */
	QMenu menu;
	menu.addAction(tr("New Playlist..."), this, SIGNAL(newTab()), QKeySequence::New);

	int index = tabAt(position);

	if (-1 != index)
	{
		menu.addAction(tr("&Duplicate Playlist"), this, SLOT(cloneTab()))->setData(index);

		menu.addSeparator();

		menu.addAction(tr("&Close Playlist"), this, SLOT(closeTab()), QKeySequence::Close)->setData(index);

		menu.addSeparator();

		menu.addAction (tr ("Close &Other Playlists"), this, SLOT (closeOtherTabs()))->setData(index);

		menu.addSeparator();

		menu.addAction (tr ("&Rename Playlist"), this, SLOT(renameTab()))->setData(index);
	}

	menu.exec (QCursor::pos());
}