forked from qt-creator/qt-creator
Add an combo box to switch between the opened tabs.
Follow the text editor and provide a combo box for opened documents. We might consider removing the tabs all together to look more consistent. Task-number: QTCREATORBUG-584 Reviewed-by: ck
This commit is contained in:
@@ -209,7 +209,9 @@ void CentralWidget::closeTab(int index)
|
|||||||
if (!viewer || tabWidget->count() == 1)
|
if (!viewer || tabWidget->count() == 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
emit viewerAboutToBeRemoved(index);
|
||||||
tabWidget->removeTab(index);
|
tabWidget->removeTab(index);
|
||||||
|
emit viewerRemoved(index);
|
||||||
QTimer::singleShot(0, viewer, SLOT(deleteLater()));
|
QTimer::singleShot(0, viewer, SLOT(deleteLater()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,6 +486,13 @@ HelpViewer *CentralWidget::helpViewerAtIndex(int index) const
|
|||||||
return qobject_cast<HelpViewer*>(tabWidget->widget(index));
|
return qobject_cast<HelpViewer*>(tabWidget->widget(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CentralWidget::indexOf(HelpViewer *viewer) const
|
||||||
|
{
|
||||||
|
if (!viewer)
|
||||||
|
return -1;
|
||||||
|
return tabWidget->indexOf(viewer);
|
||||||
|
}
|
||||||
|
|
||||||
HelpViewer *CentralWidget::currentHelpViewer() const
|
HelpViewer *CentralWidget::currentHelpViewer() const
|
||||||
{
|
{
|
||||||
return qobject_cast<HelpViewer*>(tabWidget->currentWidget());
|
return qobject_cast<HelpViewer*>(tabWidget->currentWidget());
|
||||||
@@ -529,7 +538,7 @@ void CentralWidget::currentPageChanged(int index)
|
|||||||
tabWidget->setTabsClosable(tabWidget->count() > 1);
|
tabWidget->setTabsClosable(tabWidget->count() > 1);
|
||||||
tabWidget->cornerWidget(Qt::TopLeftCorner)->setEnabled(true);
|
tabWidget->cornerWidget(Qt::TopLeftCorner)->setEnabled(true);
|
||||||
|
|
||||||
emit currentViewerChanged();
|
emit currentViewerChanged(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CentralWidget::showTabBarContextMenu(const QPoint &point)
|
void CentralWidget::showTabBarContextMenu(const QPoint &point)
|
||||||
@@ -711,6 +720,11 @@ void CentralWidget::copy()
|
|||||||
viewer->copy();
|
viewer->copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CentralWidget::activateTab(int index)
|
||||||
|
{
|
||||||
|
tabWidget->setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
QString CentralWidget::quoteTabTitle(const QString &title) const
|
QString CentralWidget::quoteTabTitle(const QString &title) const
|
||||||
{
|
{
|
||||||
QString s = title;
|
QString s = title;
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ public:
|
|||||||
bool find(const QString &txt, QTextDocument::FindFlags findFlags, bool incremental);
|
bool find(const QString &txt, QTextDocument::FindFlags findFlags, bool incremental);
|
||||||
void setLastShownPages();
|
void setLastShownPages();
|
||||||
HelpViewer *helpViewerAtIndex(int index) const;
|
HelpViewer *helpViewerAtIndex(int index) const;
|
||||||
|
int indexOf(HelpViewer *viewer) const;
|
||||||
|
|
||||||
static CentralWidget *instance();
|
static CentralWidget *instance();
|
||||||
|
|
||||||
@@ -99,12 +100,13 @@ public slots:
|
|||||||
void showTopicChooser(const QMap<QString, QUrl> &links,
|
void showTopicChooser(const QMap<QString, QUrl> &links,
|
||||||
const QString &keyword);
|
const QString &keyword);
|
||||||
void copy();
|
void copy();
|
||||||
|
void activateTab(int index);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void focusInEvent(QFocusEvent *event);
|
void focusInEvent(QFocusEvent *event);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentViewerChanged();
|
void currentViewerChanged(int index);
|
||||||
void copyAvailable(bool yes);
|
void copyAvailable(bool yes);
|
||||||
void sourceChanged(const QUrl &url);
|
void sourceChanged(const QUrl &url);
|
||||||
void highlighted(const QString &link);
|
void highlighted(const QString &link);
|
||||||
@@ -112,6 +114,9 @@ signals:
|
|||||||
void backwardAvailable(bool available);
|
void backwardAvailable(bool available);
|
||||||
void addNewBookmark(const QString &title, const QString &url);
|
void addNewBookmark(const QString &title, const QString &url);
|
||||||
|
|
||||||
|
void viewerAboutToBeRemoved(int index);
|
||||||
|
void viewerRemoved(int index);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void newTab();
|
void newTab();
|
||||||
void closeTab();
|
void closeTab();
|
||||||
|
|||||||
@@ -522,7 +522,7 @@ void HelpPlugin::createRightPaneSideBar()
|
|||||||
this));
|
this));
|
||||||
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
|
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
|
||||||
SLOT(updateSideBarSource(QUrl)));
|
SLOT(updateSideBarSource(QUrl)));
|
||||||
connect(m_centralWidget, SIGNAL(currentViewerChanged()), this,
|
connect(m_centralWidget, SIGNAL(currentViewerChanged(int)), this,
|
||||||
SLOT(updateSideBarSource()));
|
SLOT(updateSideBarSource()));
|
||||||
|
|
||||||
QAction *copyActionSideBar = new QAction(this);
|
QAction *copyActionSideBar = new QAction(this);
|
||||||
@@ -693,6 +693,13 @@ void HelpPlugin::extensionsInitialized()
|
|||||||
"index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR));
|
"index.html").arg(IDE_VERSION_MAJOR).arg(IDE_VERSION_MINOR));
|
||||||
}
|
}
|
||||||
m_helpEngine->setCustomValue(QLatin1String("DefaultHomePage"), url.toString());
|
m_helpEngine->setCustomValue(QLatin1String("DefaultHomePage"), url.toString());
|
||||||
|
|
||||||
|
connect(m_centralWidget, SIGNAL(sourceChanged(QUrl)), this,
|
||||||
|
SLOT(rebuildViewerComboBox()));
|
||||||
|
connect(m_centralWidget, SIGNAL(currentViewerChanged(int)), this,
|
||||||
|
SLOT(updateViewerComboBoxIndex(int)));
|
||||||
|
connect(m_centralWidget, SIGNAL(viewerAboutToBeRemoved(int)), this,
|
||||||
|
SLOT(removeViewerFromComboBox(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::shutdown()
|
void HelpPlugin::shutdown()
|
||||||
@@ -756,6 +763,31 @@ void HelpPlugin::fontChanged()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HelpPlugin::rebuildViewerComboBox()
|
||||||
|
{
|
||||||
|
m_documentsCombo->clear();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (HelpViewer *viewer = m_centralWidget->helpViewerAtIndex(i++))
|
||||||
|
m_documentsCombo->addItem(viewer->documentTitle());
|
||||||
|
|
||||||
|
int index = m_centralWidget->indexOf(m_centralWidget->currentHelpViewer());
|
||||||
|
if (index >= 0)
|
||||||
|
m_documentsCombo->setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpPlugin::removeViewerFromComboBox(int index)
|
||||||
|
{
|
||||||
|
if (index >= 0)
|
||||||
|
m_documentsCombo->removeItem(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HelpPlugin::updateViewerComboBoxIndex(int index)
|
||||||
|
{
|
||||||
|
if (index >= 0)
|
||||||
|
m_documentsCombo->setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
HelpViewer* HelpPlugin::viewerForContextMode()
|
HelpViewer* HelpPlugin::viewerForContextMode()
|
||||||
{
|
{
|
||||||
HelpViewer *viewer = 0;
|
HelpViewer *viewer = 0;
|
||||||
@@ -873,16 +905,25 @@ QToolBar *HelpPlugin::createToolBar()
|
|||||||
toolWidget->addSeparator();
|
toolWidget->addSeparator();
|
||||||
|
|
||||||
QWidget *w = new QWidget;
|
QWidget *w = new QWidget;
|
||||||
|
toolWidget->addWidget(w);
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout(w);
|
QHBoxLayout *layout = new QHBoxLayout(w);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->addSpacing(10);
|
layout->addSpacing(10);
|
||||||
|
m_documentsCombo = new QComboBox;
|
||||||
|
m_documentsCombo->setMinimumContentsLength(40);
|
||||||
|
layout->addWidget(m_documentsCombo);
|
||||||
|
|
||||||
|
connect(m_documentsCombo, SIGNAL(activated(int)), m_centralWidget,
|
||||||
|
SLOT(activateTab(int)));
|
||||||
|
|
||||||
layout->addWidget(new QLabel(tr("Filtered by:")));
|
layout->addWidget(new QLabel(tr("Filtered by:")));
|
||||||
m_filterComboBox = new QComboBox;
|
m_filterComboBox = new QComboBox;
|
||||||
m_filterComboBox->setMinimumContentsLength(20);
|
m_filterComboBox->setMinimumContentsLength(20);
|
||||||
|
layout->addWidget(m_filterComboBox);
|
||||||
|
|
||||||
connect(m_filterComboBox, SIGNAL(activated(QString)), this,
|
connect(m_filterComboBox, SIGNAL(activated(QString)), this,
|
||||||
SLOT(filterDocumentation(QString)));
|
SLOT(filterDocumentation(QString)));
|
||||||
layout->addWidget(m_filterComboBox);
|
|
||||||
toolWidget->addWidget(w);
|
|
||||||
|
|
||||||
return toolWidget;
|
return toolWidget;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,6 +143,10 @@ private slots:
|
|||||||
|
|
||||||
void fontChanged();
|
void fontChanged();
|
||||||
|
|
||||||
|
void rebuildViewerComboBox();
|
||||||
|
void removeViewerFromComboBox(int index);
|
||||||
|
void updateViewerComboBoxIndex(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QToolBar *createToolBar();
|
QToolBar *createToolBar();
|
||||||
void createRightPaneSideBar();
|
void createRightPaneSideBar();
|
||||||
@@ -170,6 +174,7 @@ private:
|
|||||||
DocSettingsPage *m_docSettingsPage;
|
DocSettingsPage *m_docSettingsPage;
|
||||||
FilterSettingsPage *m_filterSettingsPage;
|
FilterSettingsPage *m_filterSettingsPage;
|
||||||
|
|
||||||
|
QComboBox *m_documentsCombo;
|
||||||
QComboBox *m_filterComboBox;
|
QComboBox *m_filterComboBox;
|
||||||
Core::SideBar *m_sideBar;
|
Core::SideBar *m_sideBar;
|
||||||
QWidget *m_rightPaneSideBar;
|
QWidget *m_rightPaneSideBar;
|
||||||
|
|||||||
Reference in New Issue
Block a user