Esempio n. 1
0
TabBar::TabBar(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::TabBar)
{
    enter
    ui->setupUi(this);
    ui->cmdScrollLeft->hide();
    ui->cmdScrollRight->hide();

    QHBoxLayout *layout = new QHBoxLayout();
    layout->addItem(new QSpacerItem(1,1, QSizePolicy::Expanding, QSizePolicy::Expanding));
    layout->setContentsMargins(0, 0, 0, 0);
    layout->setSpacing(2);
    ui->scrollContent->setLayout(layout);

    ui->cmdScrollLeft->hide();
    ui->cmdScrollRight->hide();
    ui->scroll->adjustSize();
    ui->scrollContent->adjustSize();
    updateScrollButtonsVisibility();

    connect(Core::ui(), SIGNAL(createTab(QString, bool)), SLOT(createTab(QString, bool)));
    connect(Core::ui(), SIGNAL(activateTab(QString)), SLOT(activateTab(QString)));
    connect(Core::ui(), SIGNAL(setTabName(QString,QString)), SLOT(setTabName(QString,QString)));
    connect(Core::ui(), SIGNAL(setTabIcon(QString,QString)), SLOT(setTabIcon(QString,QString)));
    connect(Core::ui(), SIGNAL(highlight(QString)), SLOT(highlight(QString)));
    connect(Core::ui(), SIGNAL(closeTab(QString)), SLOT(closeTab(QString)));
    connect(ui->cmdScrollLeft, SIGNAL(clicked()), SLOT(scrollLeft()));
    connect(ui->cmdScrollRight, SIGNAL(clicked()), SLOT(scrollRight()));
    leave
}
Esempio n. 2
0
int TabWidget::addTab(Tab *widget, const QString &name, quint32 tabId)
{
    if(!widget->isHometab())
        emit closeHomeTab();

    int idx = QTabWidget::addTab(widget, name);

    installEventFilterToChildren(widget);

    std::vector<quint32>::iterator itr = m_tab_ids.begin() + idx;
    m_tab_ids.insert(itr, tabId);

    setCurrentIndex(idx);
    changeMenu(idx);

    if(count() >= 2)
        m_tab_bar->enableSplit(true);

    if(widget->isWorkTab())
    {
        connect(widget, SIGNAL(statusBarMsg(QString,int)),     SIGNAL(statusBarMsg(QString,int)));
        connect(widget, SIGNAL(setConnId(QString,bool)),       SLOT(setConnString(QString,bool)));
    }
    else if(widget->isChild())
        connect((ChildTab*)widget, SIGNAL(tabText(QString)), SLOT(setTabNameAndTooltip(QString)));
    connect(widget, SIGNAL(activateMe()), SLOT(activateTab()));
    connect(widget, SIGNAL(destroyed()), SLOT(checkEmpty()), Qt::QueuedConnection);

    setTabNameAndTooltip(idx, name);
    setTabsClosable(true);
    return idx;
}
Esempio n. 3
0
void MainWindow::playDvb()
{
	if (isMinimized())
		showNormal();

	activateTab(DvbTabId);
	dvbTab->playLastChannel();
}
Esempio n. 4
0
void MainWindow::openDvd(const QString &device)
{
	if (isMinimized())
		showNormal();

	activateTab(PlayerTabId);
	mediaWidget->playDvd(device);
}
bool DeclarativeTabModel::activateTabById(int tabId)
{
    int index = findTabIndex(tabId);
    if (index >= 0) {
        return activateTab(index);
    }
    return false;
}
bool DeclarativeTabModel::activateTab(const QString& url)
{
    for (int i = 0; i < m_tabs.size(); i++) {
        if (m_tabs.at(i).url() == url) {
            return activateTab(i);
        }
    }
    return false;
}
void DeclarativeTabModel::remove(int index) {
    if (!m_tabs.isEmpty() && index >= 0 && index < m_tabs.count()) {
        bool removingActiveTab = activeTabIndex() == index;
        removeTab(m_tabs.at(index).tabId(), m_tabs.at(index).thumbnailPath(), index);
        if (removingActiveTab) {
            if (index >= m_tabs.count()) {
                --index;
            }

            activateTab(index, false);
        }
    }
}
/**
 * @brief DeclarativeTabModel::closeActiveTab
 * Closes the active tab and activates a tab next to the current tab. If possible
 * tab that is after the current tab is activated, then falling back to previous tabs, or
 * finally none (if all closed).
 */
void DeclarativeTabModel::closeActiveTab()
{
    if (!m_tabs.isEmpty()) {
        int index = activeTabIndex();
        removeTab(m_activeTab.tabId(), m_activeTab.thumbnailPath(), index);

        if (index >= m_tabs.count()) {
            --index;
        }

        activateTab(index, true);
    }
}
bool DeclarativeTabModel::activateTab(const QString& url)
{
    if (m_activeTab.currentLink().url() == url && m_currentTab) {
        m_currentTab->tabChanged(m_activeTab);
        return true;
    }
    for (int i = 0; i < m_tabs.size(); i++) {
        if (m_tabs.at(i).currentLink().url() == url) {
            return activateTab(i);
        }
    }
    return false;
}
Esempio n. 10
0
    bool TabsModel::activateSystemTab(int systemTabID) {
        bool activated = false;

        const int index = findSystemTabIndexByID(systemTabID);
        const int mostRecentIndex = getMostRecentIndex();

        if ((index >= 0) && (mostRecentIndex != index)) {
            activateTab(index);
            activated = true;
        }

        return activated;
    }
Esempio n. 11
0
void ChatClient::slotWriteToFriend(User* us) {
    User *fr = pSocket->addUserById(myId, us->id(), ServerFlags::InUserlist);
    connect(fr, SIGNAL(readMessages()), this, SLOT(slotReadMessageNotify()));
    Dialog *dg = userlist->userById(us->id());

    if (dg == NULL) {
        userlist->add(fr);
        dg = fr;
        connect(fr, SIGNAL(readMessages()), this, SLOT(slotReadMessageNotify()));
    }

    createDialog(dg);
    activateTab(dg);
    dialogFindFriends->close();
}
Esempio n. 12
0
void MainWindow::open()
{
	if (isMinimized())
		showNormal();

	QList<QUrl> urls = QFileDialog::getOpenFileUrls(this, i18nc("@title:window", "Open files"), QUrl(), MediaWidget::extensionFilter());

//	trayIcon->showMessage("Open", "Opening file(s)");
	if (urls.size() >= 2) {
		activateTab(PlaylistTabId);
		playlistTab->appendToVisiblePlaylist(urls, true);
	} else if (!urls.isEmpty()) {
		openUrl(urls.at(0));
	}
}
Esempio n. 13
0
void MainWindow::openUrl(const QUrl &url)
{
	if (!url.isValid()) {
		return;
	}

	// we need to copy "url" because addUrl() may invalidate it
	QUrl copy(url);
	actionOpenRecent->addUrl(copy); // moves the url to the top of the list

	if (currentTabIndex != PlaylistTabId) {
		activateTab(PlayerTabId);
	}

	playlistTab->appendToVisiblePlaylist(QList<QUrl>() << copy, true);
}
void DeclarativeTabModel::closeActiveTab()
{
    if (m_activeTab.isValid()) {
#ifdef DEBUG_LOGS
        qDebug() << &m_activeTab;
#endif
        // Clear active tab data and try to active a tab from the first model index.
        int activeTabId = m_activeTab.tabId();
        // Invalidate
        m_activeTab.setTabId(0);
        removeTab(activeTabId, m_activeTab.thumbnailPath());
        if (!activateTab(0)) {
            // Last active tab got closed.
            emit activeTabChanged(activeTabId, 0);
        }
    }
}
void DeclarativeTabModel::closeActiveTab()
{
#ifdef DEBUG_LOGS
    qDebug() << m_activeTab.isValid() << m_activeTab.tabId() << m_activeTab.currentLink().thumbPath() << m_activeTab.currentLink().url();
#endif
    if (m_activeTab.isValid()) {
        // Invalidate active tab
        removeTab(m_activeTab);
        m_activeTab.setTabId(0);
        emit countChanged();
        m_activeTabClosed = true;
        if (!activateTab(0) && m_currentTab) {
            // Last active tab got closed.
            Link emptyLink;
            m_activeTab.setCurrentLink(emptyLink);
            m_currentTab->invalidate();
        }
    }
}
Esempio n. 16
0
CentralWidget::CentralWidget(MainWindow *parent)
    : QWidget(parent)
    , lastTabPage(0)
    , tabWidget(0)
    , findWidget(0)
    , printer(0)
    , usesDefaultCollection(parent->usesDefaultCollection())
    , m_searchWidget(0)
{
    TRACE_OBJ
    globalActionList.clear();
    staticCentralWidget = this;
    QVBoxLayout *vboxLayout = new QVBoxLayout(this);
    QString resourcePath = QLatin1String(":/trolltech/assistant/images/");

    vboxLayout->setMargin(0);
    tabWidget = new QTabWidget(this);
#ifndef Q_OS_MAC
    resourcePath.append(QLatin1String("win"));
#else
    resourcePath.append(QLatin1String("mac"));
    tabWidget->setDocumentMode(true);
#endif

    connect(tabWidget, SIGNAL(currentChanged(int)), this,
        SLOT(currentPageChanged(int)));

    QToolButton *newTabButton = new QToolButton(this);
    newTabButton->setAutoRaise(true);
    newTabButton->setToolTip(tr("Add new page"));
    newTabButton->setIcon(QIcon(resourcePath + QLatin1String("/addtab.png")));

    tabWidget->setCornerWidget(newTabButton, Qt::TopLeftCorner);
    connect(newTabButton, SIGNAL(clicked()), this, SLOT(newTab()));

    QToolButton *closeTabButton = new QToolButton(this);
    closeTabButton->setEnabled(false);
    closeTabButton->setAutoRaise(true);
    closeTabButton->setToolTip(tr("Close current page"));
    closeTabButton->setIcon(QIcon(resourcePath + QLatin1String("/closetab.png")));

    tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner);
    connect(closeTabButton, SIGNAL(clicked()), this, SLOT(closeTab()));

    vboxLayout->addWidget(tabWidget);

    findWidget = new FindWidget(this);
    vboxLayout->addWidget(findWidget);
    findWidget->hide();

    connect(findWidget, SIGNAL(findNext()), this, SLOT(findNext()));
    connect(findWidget, SIGNAL(findPrevious()), this, SLOT(findPrevious()));
    connect(findWidget, SIGNAL(find(QString, bool)), this,
        SLOT(find(QString, bool)));
    connect(findWidget, SIGNAL(escapePressed()), this, SLOT(activateTab()));

    QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
    if (tabBar) {
        tabBar->installEventFilter(this);
        tabBar->setContextMenuPolicy(Qt::CustomContextMenu);
        connect(tabBar, SIGNAL(customContextMenuRequested(QPoint)), this,
            SLOT(showTabBarContextMenu(QPoint)));
    }

#if defined(QT_NO_WEBKIT)
    QPalette p = palette();
    p.setColor(QPalette::Inactive, QPalette::Highlight,
        p.color(QPalette::Active, QPalette::Highlight));
    p.setColor(QPalette::Inactive, QPalette::HighlightedText,
        p.color(QPalette::Active, QPalette::HighlightedText));
    setPalette(p);
#endif
}
Esempio n. 17
0
void MainWindow::parseArgs()
{
	if (parser->isSet("fullscreen")) {
		mediaWidget->setDisplayMode(MediaWidget::FullScreenMode);
	}

	if (parser->isSet("audiocd")) {
		if (parser->positionalArguments().count() > 0) {
			openAudioCd(parser->positionalArguments().first());
		} else {
			openAudioCd();
		}
		return;
	}

	if (parser->isSet("videocd")) {
		if (parser->positionalArguments().count() > 0) {
			openVideoCd(parser->positionalArguments().first());
		} else {
			openVideoCd();
		}
		return;
	}

	if (parser->isSet("dvd")) {
		if (parser->positionalArguments().count() > 0) {
			openDvd(parser->positionalArguments().first());
		} else {
			openDvd();
		}
		return;
	}

#if HAVE_DVB == 1
	QString channel;

	if (parser->isSet("dumpdvb")) {
		dvbTab->enableDvbDump();
	}

	channel = parser->value("channel");

	if (!channel.isEmpty()) {
		activateTab(DvbTabId);
		dvbTab->playChannel(channel);

		return;
	}

	channel = parser->value("tv");
	if (!channel.isEmpty()) {
		activateTab(DvbTabId);
		dvbTab->playChannel(channel);

		return;
	}

	if (parser->isSet("lastchannel")) {
		activateTab(DvbTabId);
		dvbTab->playLastChannel();


		return;
	}
#endif /* HAVE_DVB == 1 */

	if (parser->positionalArguments().count() > 0) {
		QList<QUrl> urls;

		for (int i = 0; i < parser->positionalArguments().count(); ++i) {
			QUrl url = QUrl::fromUserInput(parser->positionalArguments().at(i));

			if (url.isValid()) {
				urls.append(url);
			}
		}

		if (parser->isSet("tempfile")) {
			temporaryUrls.append(urls);
		}

		if (urls.size() >= 2) {
			activateTab(PlaylistTabId);
			playlistTab->appendToVisiblePlaylist(urls, true);
		} else if (!urls.isEmpty()) {
			openUrl(urls.at(0));
		}
	}
}
Esempio n. 18
0
 void TabsModel::escalateTab(int index) {
     activateTab(index);
 }
Esempio n. 19
0
void ChatClient::slotDoubleClickDialog(Dialog *dg) {
    createDialog(dg);
    activateTab(dg);
    //pSocket->talker()->readMessageNotify(myId, dg->dialog());
}
Esempio n. 20
0
void TabSwitcher::closeEvent(QCloseEvent *)
{
    m_timer->stop();
    activateTab(model()->data(model()->index(currentIndex().row(), 0), static_cast<int>(AppRole::Index)).value<int>());
}