forked from qt-creator/qt-creator
Header cleanup in coreplugin, part 1
This commit is contained in:
@@ -104,7 +104,10 @@ SOURCES += mainwindow.cpp \
|
|||||||
ssh/sftpoperation.cpp \
|
ssh/sftpoperation.cpp \
|
||||||
ssh/sftpincomingpacket.cpp \
|
ssh/sftpincomingpacket.cpp \
|
||||||
ssh/sftpdefs.cpp \
|
ssh/sftpdefs.cpp \
|
||||||
ssh/sftpchannel.cpp
|
ssh/sftpchannel.cpp \
|
||||||
|
outputpanemanager.cpp \
|
||||||
|
navigationsubwidget.cpp \
|
||||||
|
sidebarwidget.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
editmode.h \
|
editmode.h \
|
||||||
@@ -212,7 +215,10 @@ HEADERS += mainwindow.h \
|
|||||||
ssh/sftpincomingpacket_p.h \
|
ssh/sftpincomingpacket_p.h \
|
||||||
ssh/sftpdefs.h \
|
ssh/sftpdefs.h \
|
||||||
ssh/sftpchannel.h \
|
ssh/sftpchannel.h \
|
||||||
ssh/sftpchannel_p.h
|
ssh/sftpchannel_p.h \
|
||||||
|
outputpanemanager.h \
|
||||||
|
navigationsubwidget.h \
|
||||||
|
sidebarwidget.h
|
||||||
|
|
||||||
FORMS += dialogs/newdialog.ui \
|
FORMS += dialogs/newdialog.ui \
|
||||||
actionmanager/commandmappings.ui \
|
actionmanager/commandmappings.ui \
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <QtGui/QHBoxLayout>
|
#include <QtGui/QHBoxLayout>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtGui/QSplitter>
|
#include <QtGui/QSplitter>
|
||||||
|
#include <QtGui/QIcon>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
|||||||
@@ -50,7 +50,9 @@
|
|||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtCore/QEvent>
|
#include <QtCore/QEvent>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
|
#include <QtCore/QPointer>
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
|
#include <QtGui/QComboBox>
|
||||||
#include <QtGui/QPlainTextEdit>
|
#include <QtGui/QPlainTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QtGui/QVBoxLayout>
|
||||||
#include <QtGui/QScrollArea>
|
#include <QtGui/QScrollArea>
|
||||||
@@ -69,79 +71,100 @@ enum {
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
struct EditorToolBarPrivate {
|
||||||
|
explicit EditorToolBarPrivate(QWidget *parent, EditorToolBar *q);
|
||||||
|
|
||||||
|
Core::OpenEditorsModel *m_editorsListModel;
|
||||||
|
QComboBox *m_editorList;
|
||||||
|
QToolButton *m_closeButton;
|
||||||
|
QToolButton *m_lockButton;
|
||||||
|
QAction *m_goBackAction;
|
||||||
|
QAction *m_goForwardAction;
|
||||||
|
QToolButton *m_backButton;
|
||||||
|
QToolButton *m_forwardButton;
|
||||||
|
|
||||||
|
QWidget *m_activeToolBar;
|
||||||
|
QWidget *m_toolBarPlaceholder;
|
||||||
|
QWidget *m_defaultToolBar;
|
||||||
|
|
||||||
|
bool m_isStandalone;
|
||||||
|
};
|
||||||
|
|
||||||
|
EditorToolBarPrivate::EditorToolBarPrivate(QWidget *parent, EditorToolBar *q) :
|
||||||
|
m_editorList(new QComboBox(q)),
|
||||||
|
m_closeButton(new QToolButton),
|
||||||
|
m_lockButton(new QToolButton),
|
||||||
|
m_goBackAction(new QAction(QIcon(QLatin1String(Constants::ICON_PREV)), EditorManager::tr("Go Back"), parent)),
|
||||||
|
m_goForwardAction(new QAction(QIcon(QLatin1String(Constants::ICON_NEXT)), EditorManager::tr("Go Forward"), parent)),
|
||||||
|
m_activeToolBar(0),
|
||||||
|
m_toolBarPlaceholder(new QWidget),
|
||||||
|
m_defaultToolBar(new QWidget(q)),
|
||||||
|
m_isStandalone(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Mimic the look of the text editor toolbar as defined in e.g. EditorView::EditorView
|
Mimic the look of the text editor toolbar as defined in e.g. EditorView::EditorView
|
||||||
*/
|
*/
|
||||||
EditorToolBar::EditorToolBar(QWidget *parent) :
|
EditorToolBar::EditorToolBar(QWidget *parent) :
|
||||||
Utils::StyledBar(parent),
|
Utils::StyledBar(parent), d(new EditorToolBarPrivate(parent, this))
|
||||||
m_editorList(new QComboBox(this)),
|
|
||||||
m_closeButton(new QToolButton),
|
|
||||||
m_lockButton(new QToolButton),
|
|
||||||
|
|
||||||
m_goBackAction(new QAction(QIcon(QLatin1String(Constants::ICON_PREV)), EditorManager::tr("Go Back"), parent)),
|
|
||||||
m_goForwardAction(new QAction(QIcon(QLatin1String(Constants::ICON_NEXT)), EditorManager::tr("Go Forward"), parent)),
|
|
||||||
|
|
||||||
m_activeToolBar(0),
|
|
||||||
m_toolBarPlaceholder(new QWidget),
|
|
||||||
m_defaultToolBar(new QWidget(this)),
|
|
||||||
m_isStandalone(false)
|
|
||||||
{
|
{
|
||||||
QHBoxLayout *toolBarLayout = new QHBoxLayout(this);
|
QHBoxLayout *toolBarLayout = new QHBoxLayout(this);
|
||||||
toolBarLayout->setMargin(0);
|
toolBarLayout->setMargin(0);
|
||||||
toolBarLayout->setSpacing(0);
|
toolBarLayout->setSpacing(0);
|
||||||
toolBarLayout->addWidget(m_defaultToolBar);
|
toolBarLayout->addWidget(d->m_defaultToolBar);
|
||||||
m_toolBarPlaceholder->setLayout(toolBarLayout);
|
d->m_toolBarPlaceholder->setLayout(toolBarLayout);
|
||||||
m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
d->m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
|
|
||||||
m_defaultToolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
d->m_defaultToolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
m_activeToolBar = m_defaultToolBar;
|
d->m_activeToolBar = d->m_defaultToolBar;
|
||||||
|
|
||||||
m_editorsListModel = EditorManager::instance()->openedEditorsModel();
|
d->m_editorsListModel = EditorManager::instance()->openedEditorsModel();
|
||||||
connect(m_goBackAction, SIGNAL(triggered()), this, SIGNAL(goBackClicked()));
|
connect(d->m_goBackAction, SIGNAL(triggered()), this, SIGNAL(goBackClicked()));
|
||||||
connect(m_goForwardAction, SIGNAL(triggered()), this, SIGNAL(goForwardClicked()));
|
connect(d->m_goForwardAction, SIGNAL(triggered()), this, SIGNAL(goForwardClicked()));
|
||||||
|
|
||||||
m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
d->m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
m_editorList->setMinimumContentsLength(20);
|
d->m_editorList->setMinimumContentsLength(20);
|
||||||
m_editorList->setModel(m_editorsListModel);
|
d->m_editorList->setModel(d->m_editorsListModel);
|
||||||
m_editorList->setMaxVisibleItems(40);
|
d->m_editorList->setMaxVisibleItems(40);
|
||||||
m_editorList->setContextMenuPolicy(Qt::CustomContextMenu);
|
d->m_editorList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
m_lockButton->setAutoRaise(true);
|
d->m_lockButton->setAutoRaise(true);
|
||||||
m_lockButton->setProperty("type", QLatin1String("dockbutton"));
|
d->m_lockButton->setProperty("type", QLatin1String("dockbutton"));
|
||||||
m_lockButton->setVisible(false);
|
d->m_lockButton->setVisible(false);
|
||||||
|
|
||||||
m_closeButton->setAutoRaise(true);
|
d->m_closeButton->setAutoRaise(true);
|
||||||
m_closeButton->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE)));
|
d->m_closeButton->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE)));
|
||||||
m_closeButton->setProperty("type", QLatin1String("dockbutton"));
|
d->m_closeButton->setProperty("type", QLatin1String("dockbutton"));
|
||||||
m_closeButton->setEnabled(false);
|
d->m_closeButton->setEnabled(false);
|
||||||
|
|
||||||
m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
d->m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
|
|
||||||
m_backButton = new QToolButton(this);
|
d->m_backButton = new QToolButton(this);
|
||||||
m_backButton->setDefaultAction(m_goBackAction);
|
d->m_backButton->setDefaultAction(d->m_goBackAction);
|
||||||
|
|
||||||
m_forwardButton= new QToolButton(this);
|
d->m_forwardButton= new QToolButton(this);
|
||||||
m_forwardButton->setDefaultAction(m_goForwardAction);
|
d->m_forwardButton->setDefaultAction(d->m_goForwardAction);
|
||||||
|
|
||||||
QHBoxLayout *toplayout = new QHBoxLayout(this);
|
QHBoxLayout *toplayout = new QHBoxLayout(this);
|
||||||
toplayout->setSpacing(0);
|
toplayout->setSpacing(0);
|
||||||
toplayout->setMargin(0);
|
toplayout->setMargin(0);
|
||||||
toplayout->addWidget(m_backButton);
|
toplayout->addWidget(d->m_backButton);
|
||||||
toplayout->addWidget(m_forwardButton);
|
toplayout->addWidget(d->m_forwardButton);
|
||||||
toplayout->addWidget(m_editorList);
|
toplayout->addWidget(d->m_editorList);
|
||||||
toplayout->addWidget(m_toolBarPlaceholder, 1); // Custom toolbar stretches
|
toplayout->addWidget(d->m_toolBarPlaceholder, 1); // Custom toolbar stretches
|
||||||
toplayout->addWidget(m_lockButton);
|
toplayout->addWidget(d->m_lockButton);
|
||||||
toplayout->addWidget(m_closeButton);
|
toplayout->addWidget(d->m_closeButton);
|
||||||
|
|
||||||
setLayout(toplayout);
|
setLayout(toplayout);
|
||||||
|
|
||||||
// this signal is disconnected for standalone toolbars and replaced with
|
// this signal is disconnected for standalone toolbars and replaced with
|
||||||
// a private slot connection
|
// a private slot connection
|
||||||
connect(m_editorList, SIGNAL(activated(int)), this, SIGNAL(listSelectionActivated(int)));
|
connect(d->m_editorList, SIGNAL(activated(int)), this, SIGNAL(listSelectionActivated(int)));
|
||||||
|
|
||||||
connect(m_editorList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(listContextMenu(QPoint)));
|
connect(d->m_editorList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(listContextMenu(QPoint)));
|
||||||
connect(m_lockButton, SIGNAL(clicked()), this, SLOT(makeEditorWritable()));
|
connect(d->m_lockButton, SIGNAL(clicked()), this, SLOT(makeEditorWritable()));
|
||||||
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeView()), Qt::QueuedConnection);
|
connect(d->m_closeButton, SIGNAL(clicked()), this, SLOT(closeView()), Qt::QueuedConnection);
|
||||||
|
|
||||||
ActionManager *am = ICore::instance()->actionManager();
|
ActionManager *am = ICore::instance()->actionManager();
|
||||||
connect(am->command(Constants::CLOSE), SIGNAL(keySequenceChanged()),
|
connect(am->command(Constants::CLOSE), SIGNAL(keySequenceChanged()),
|
||||||
@@ -153,6 +176,10 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditorToolBar::~EditorToolBar()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void EditorToolBar::removeToolbarForEditor(IEditor *editor)
|
void EditorToolBar::removeToolbarForEditor(IEditor *editor)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(editor, return)
|
QTC_ASSERT(editor, return)
|
||||||
@@ -160,11 +187,11 @@ void EditorToolBar::removeToolbarForEditor(IEditor *editor)
|
|||||||
|
|
||||||
QWidget *toolBar = editor->toolBar();
|
QWidget *toolBar = editor->toolBar();
|
||||||
if (toolBar != 0) {
|
if (toolBar != 0) {
|
||||||
if (m_activeToolBar == toolBar) {
|
if (d->m_activeToolBar == toolBar) {
|
||||||
m_activeToolBar = m_defaultToolBar;
|
d->m_activeToolBar = d->m_defaultToolBar;
|
||||||
m_activeToolBar->setVisible(true);
|
d->m_activeToolBar->setVisible(true);
|
||||||
}
|
}
|
||||||
m_toolBarPlaceholder->layout()->removeWidget(toolBar);
|
d->m_toolBarPlaceholder->layout()->removeWidget(toolBar);
|
||||||
toolBar->setVisible(false);
|
toolBar->setVisible(false);
|
||||||
toolBar->setParent(0);
|
toolBar->setParent(0);
|
||||||
}
|
}
|
||||||
@@ -175,7 +202,7 @@ void EditorToolBar::closeView()
|
|||||||
if (!currentEditor())
|
if (!currentEditor())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_isStandalone) {
|
if (d->m_isStandalone) {
|
||||||
EditorManager *em = ICore::instance()->editorManager();
|
EditorManager *em = ICore::instance()->editorManager();
|
||||||
if (IEditor *editor = currentEditor()) {
|
if (IEditor *editor = currentEditor()) {
|
||||||
em->closeEditor(editor);
|
em->closeEditor(editor);
|
||||||
@@ -190,7 +217,7 @@ void EditorToolBar::addEditor(IEditor *editor)
|
|||||||
connect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus()));
|
connect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus()));
|
||||||
QWidget *toolBar = editor->toolBar();
|
QWidget *toolBar = editor->toolBar();
|
||||||
|
|
||||||
if (toolBar && !m_isStandalone)
|
if (toolBar && !d->m_isStandalone)
|
||||||
addCenterToolBar(toolBar);
|
addCenterToolBar(toolBar);
|
||||||
|
|
||||||
updateEditorStatus(editor);
|
updateEditorStatus(editor);
|
||||||
@@ -200,7 +227,7 @@ void EditorToolBar::addCenterToolBar(QWidget *toolBar)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(toolBar, return)
|
QTC_ASSERT(toolBar, return)
|
||||||
toolBar->setVisible(false); // will be made visible in setCurrentEditor
|
toolBar->setVisible(false); // will be made visible in setCurrentEditor
|
||||||
m_toolBarPlaceholder->layout()->addWidget(toolBar);
|
d->m_toolBarPlaceholder->layout()->addWidget(toolBar);
|
||||||
|
|
||||||
updateToolBar(toolBar);
|
updateToolBar(toolBar);
|
||||||
}
|
}
|
||||||
@@ -208,34 +235,34 @@ void EditorToolBar::addCenterToolBar(QWidget *toolBar)
|
|||||||
void EditorToolBar::updateToolBar(QWidget *toolBar)
|
void EditorToolBar::updateToolBar(QWidget *toolBar)
|
||||||
{
|
{
|
||||||
if (!toolBar)
|
if (!toolBar)
|
||||||
toolBar = m_defaultToolBar;
|
toolBar = d->m_defaultToolBar;
|
||||||
if (m_activeToolBar == toolBar)
|
if (d->m_activeToolBar == toolBar)
|
||||||
return;
|
return;
|
||||||
toolBar->setVisible(true);
|
toolBar->setVisible(true);
|
||||||
m_activeToolBar->setVisible(false);
|
d->m_activeToolBar->setVisible(false);
|
||||||
m_activeToolBar = toolBar;
|
d->m_activeToolBar = toolBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorToolBar::setToolbarCreationFlags(ToolbarCreationFlags flags)
|
void EditorToolBar::setToolbarCreationFlags(ToolbarCreationFlags flags)
|
||||||
{
|
{
|
||||||
m_isStandalone = flags & FlagsStandalone;
|
d->m_isStandalone = flags & FlagsStandalone;
|
||||||
if (m_isStandalone) {
|
if (d->m_isStandalone) {
|
||||||
EditorManager *em = EditorManager::instance();
|
EditorManager *em = EditorManager::instance();
|
||||||
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(updateEditorListSelection(Core::IEditor*)));
|
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(updateEditorListSelection(Core::IEditor*)));
|
||||||
|
|
||||||
disconnect(m_editorList, SIGNAL(activated(int)), this, SIGNAL(listSelectionActivated(int)));
|
disconnect(d->m_editorList, SIGNAL(activated(int)), this, SIGNAL(listSelectionActivated(int)));
|
||||||
connect(m_editorList, SIGNAL(activated(int)), this, SLOT(changeActiveEditor(int)));
|
connect(d->m_editorList, SIGNAL(activated(int)), this, SLOT(changeActiveEditor(int)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorToolBar::setCurrentEditor(IEditor *editor)
|
void EditorToolBar::setCurrentEditor(IEditor *editor)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(editor, return)
|
QTC_ASSERT(editor, return)
|
||||||
m_editorList->setCurrentIndex(m_editorsListModel->indexOf(editor).row());
|
d->m_editorList->setCurrentIndex(d->m_editorsListModel->indexOf(editor).row());
|
||||||
|
|
||||||
// If we never added the toolbar from the editor, we will never change
|
// If we never added the toolbar from the editor, we will never change
|
||||||
// the editor, so there's no need to update the toolbar either.
|
// the editor, so there's no need to update the toolbar either.
|
||||||
if (!m_isStandalone)
|
if (!d->m_isStandalone)
|
||||||
updateToolBar(editor->toolBar());
|
updateToolBar(editor->toolBar());
|
||||||
|
|
||||||
updateEditorStatus(editor);
|
updateEditorStatus(editor);
|
||||||
@@ -244,13 +271,13 @@ void EditorToolBar::setCurrentEditor(IEditor *editor)
|
|||||||
void EditorToolBar::updateEditorListSelection(IEditor *newSelection)
|
void EditorToolBar::updateEditorListSelection(IEditor *newSelection)
|
||||||
{
|
{
|
||||||
if (newSelection)
|
if (newSelection)
|
||||||
m_editorList->setCurrentIndex(m_editorsListModel->indexOf(newSelection).row());
|
d->m_editorList->setCurrentIndex(d->m_editorsListModel->indexOf(newSelection).row());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorToolBar::changeActiveEditor(int row)
|
void EditorToolBar::changeActiveEditor(int row)
|
||||||
{
|
{
|
||||||
EditorManager *em = ICore::instance()->editorManager();
|
EditorManager *em = ICore::instance()->editorManager();
|
||||||
QAbstractItemModel *model = m_editorList->model();
|
QAbstractItemModel *model = d->m_editorList->model();
|
||||||
const QModelIndex modelIndex = model->index(row, 0);
|
const QModelIndex modelIndex = model->index(row, 0);
|
||||||
IEditor *editor = model->data(modelIndex, Qt::UserRole).value<IEditor*>();
|
IEditor *editor = model->data(modelIndex, Qt::UserRole).value<IEditor*>();
|
||||||
|
|
||||||
@@ -264,19 +291,19 @@ void EditorToolBar::changeActiveEditor(int row)
|
|||||||
editor = em->openEditor(fileName, kind);
|
editor = em->openEditor(fileName, kind);
|
||||||
}
|
}
|
||||||
if (editor) {
|
if (editor) {
|
||||||
m_editorList->setCurrentIndex(m_editorsListModel->indexOf(editor).row());
|
d->m_editorList->setCurrentIndex(d->m_editorsListModel->indexOf(editor).row());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorToolBar::listContextMenu(QPoint pos)
|
void EditorToolBar::listContextMenu(QPoint pos)
|
||||||
{
|
{
|
||||||
QModelIndex index = m_editorsListModel->index(m_editorList->currentIndex(), 0);
|
QModelIndex index = d->m_editorsListModel->index(d->m_editorList->currentIndex(), 0);
|
||||||
QString fileName = m_editorsListModel->data(index, Qt::UserRole + 1).toString();
|
QString fileName = d->m_editorsListModel->data(index, Qt::UserRole + 1).toString();
|
||||||
if (fileName.isEmpty())
|
if (fileName.isEmpty())
|
||||||
return;
|
return;
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
menu.addAction(tr("Copy Full Path to Clipboard"));
|
menu.addAction(tr("Copy Full Path to Clipboard"));
|
||||||
if (menu.exec(m_editorList->mapToGlobal(pos))) {
|
if (menu.exec(d->m_editorList->mapToGlobal(pos))) {
|
||||||
QApplication::clipboard()->setText(QDir::toNativeSeparators(fileName));
|
QApplication::clipboard()->setText(QDir::toNativeSeparators(fileName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -289,20 +316,20 @@ void EditorToolBar::makeEditorWritable()
|
|||||||
|
|
||||||
void EditorToolBar::setCanGoBack(bool canGoBack)
|
void EditorToolBar::setCanGoBack(bool canGoBack)
|
||||||
{
|
{
|
||||||
m_goBackAction->setEnabled(canGoBack);
|
d->m_goBackAction->setEnabled(canGoBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorToolBar::setCanGoForward(bool canGoForward)
|
void EditorToolBar::setCanGoForward(bool canGoForward)
|
||||||
{
|
{
|
||||||
m_goForwardAction->setEnabled(canGoForward);
|
d->m_goForwardAction->setEnabled(canGoForward);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorToolBar::updateActionShortcuts()
|
void EditorToolBar::updateActionShortcuts()
|
||||||
{
|
{
|
||||||
ActionManager *am = ICore::instance()->actionManager();
|
ActionManager *am = ICore::instance()->actionManager();
|
||||||
m_closeButton->setToolTip(am->command(Constants::CLOSE)->stringWithAppendedShortcut(EditorManager::tr("Close")));
|
d->m_closeButton->setToolTip(am->command(Constants::CLOSE)->stringWithAppendedShortcut(EditorManager::tr("Close")));
|
||||||
m_goBackAction->setToolTip(am->command(Constants::GO_BACK)->action()->toolTip());
|
d->m_goBackAction->setToolTip(am->command(Constants::GO_BACK)->action()->toolTip());
|
||||||
m_goForwardAction->setToolTip(am->command(Constants::GO_FORWARD)->action()->toolTip());
|
d->m_goForwardAction->setToolTip(am->command(Constants::GO_FORWARD)->action()->toolTip());
|
||||||
}
|
}
|
||||||
|
|
||||||
IEditor *EditorToolBar::currentEditor() const
|
IEditor *EditorToolBar::currentEditor() const
|
||||||
@@ -321,27 +348,27 @@ void EditorToolBar::checkEditorStatus()
|
|||||||
|
|
||||||
void EditorToolBar::updateEditorStatus(IEditor *editor)
|
void EditorToolBar::updateEditorStatus(IEditor *editor)
|
||||||
{
|
{
|
||||||
m_lockButton->setVisible(editor != 0);
|
d->m_lockButton->setVisible(editor != 0);
|
||||||
m_closeButton->setEnabled(editor != 0);
|
d->m_closeButton->setEnabled(editor != 0);
|
||||||
|
|
||||||
if (!editor || !editor->file()) {
|
if (!editor || !editor->file()) {
|
||||||
m_editorList->setToolTip(QString());
|
d->m_editorList->setToolTip(QString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_editorList->setCurrentIndex(m_editorsListModel->indexOf(editor).row());
|
d->m_editorList->setCurrentIndex(d->m_editorsListModel->indexOf(editor).row());
|
||||||
|
|
||||||
if (editor->file()->isReadOnly()) {
|
if (editor->file()->isReadOnly()) {
|
||||||
m_lockButton->setIcon(QIcon(m_editorsListModel->lockedIcon()));
|
d->m_lockButton->setIcon(QIcon(d->m_editorsListModel->lockedIcon()));
|
||||||
m_lockButton->setEnabled(!editor->file()->fileName().isEmpty());
|
d->m_lockButton->setEnabled(!editor->file()->fileName().isEmpty());
|
||||||
m_lockButton->setToolTip(tr("Make writable"));
|
d->m_lockButton->setToolTip(tr("Make writable"));
|
||||||
} else {
|
} else {
|
||||||
m_lockButton->setIcon(QIcon(m_editorsListModel->unlockedIcon()));
|
d->m_lockButton->setIcon(QIcon(d->m_editorsListModel->unlockedIcon()));
|
||||||
m_lockButton->setEnabled(false);
|
d->m_lockButton->setEnabled(false);
|
||||||
m_lockButton->setToolTip(tr("File is writable"));
|
d->m_lockButton->setToolTip(tr("File is writable"));
|
||||||
}
|
}
|
||||||
if (editor == currentEditor())
|
if (editor == currentEditor())
|
||||||
m_editorList->setToolTip(
|
d->m_editorList->setToolTip(
|
||||||
currentEditor()->file()->fileName().isEmpty()
|
currentEditor()->file()->fileName().isEmpty()
|
||||||
? currentEditor()->displayName()
|
? currentEditor()->displayName()
|
||||||
: QDir::toNativeSeparators(editor->file()->fileName())
|
: QDir::toNativeSeparators(editor->file()->fileName())
|
||||||
@@ -351,10 +378,10 @@ void EditorToolBar::updateEditorStatus(IEditor *editor)
|
|||||||
|
|
||||||
void EditorToolBar::setNavigationVisible(bool isVisible)
|
void EditorToolBar::setNavigationVisible(bool isVisible)
|
||||||
{
|
{
|
||||||
m_goBackAction->setVisible(isVisible);
|
d->m_goBackAction->setVisible(isVisible);
|
||||||
m_goForwardAction->setVisible(isVisible);
|
d->m_goForwardAction->setVisible(isVisible);
|
||||||
m_backButton->setVisible(isVisible);
|
d->m_backButton->setVisible(isVisible);
|
||||||
m_forwardButton->setVisible(isVisible);
|
d->m_forwardButton->setVisible(isVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Core
|
} // Core
|
||||||
|
|||||||
@@ -31,25 +31,15 @@
|
|||||||
#define FAKETOOLBAR_H
|
#define FAKETOOLBAR_H
|
||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
#include <QWidget>
|
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QScopedPointer>
|
||||||
|
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QComboBox;
|
|
||||||
class QToolButton;
|
|
||||||
class QToolBar;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IEditor;
|
class IEditor;
|
||||||
class OpenEditorsModel;
|
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
class EditorView;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
struct EditorToolBarPrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fakes an IEditor-like toolbar for design mode widgets such as Qt Designer and Bauhaus.
|
* Fakes an IEditor-like toolbar for design mode widgets such as Qt Designer and Bauhaus.
|
||||||
@@ -61,6 +51,7 @@ class CORE_EXPORT EditorToolBar : public Utils::StyledBar
|
|||||||
Q_DISABLE_COPY(EditorToolBar)
|
Q_DISABLE_COPY(EditorToolBar)
|
||||||
public:
|
public:
|
||||||
explicit EditorToolBar(QWidget *parent = 0);
|
explicit EditorToolBar(QWidget *parent = 0);
|
||||||
|
virtual ~EditorToolBar();
|
||||||
|
|
||||||
enum ToolbarCreationFlags { FlagsNone = 0, FlagsStandalone = 1 };
|
enum ToolbarCreationFlags { FlagsNone = 0, FlagsStandalone = 1 };
|
||||||
|
|
||||||
@@ -109,23 +100,10 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void updateToolBar(QWidget *toolBar);
|
void updateToolBar(QWidget *toolBar);
|
||||||
IEditor *currentEditor() const;
|
IEditor *currentEditor() const;
|
||||||
Core::OpenEditorsModel *m_editorsListModel;
|
|
||||||
QComboBox *m_editorList;
|
|
||||||
QToolButton *m_closeButton;
|
|
||||||
QToolButton *m_lockButton;
|
|
||||||
QAction *m_goBackAction;
|
|
||||||
QAction *m_goForwardAction;
|
|
||||||
QToolButton *m_backButton;
|
|
||||||
QToolButton *m_forwardButton;
|
|
||||||
|
|
||||||
QWidget *m_activeToolBar;
|
QScopedPointer<EditorToolBarPrivate> d;
|
||||||
QWidget *m_toolBarPlaceholder;
|
|
||||||
QWidget *m_defaultToolBar;
|
|
||||||
|
|
||||||
bool m_isStandalone;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace Core
|
||||||
|
|
||||||
|
|
||||||
#endif // FAKETOOLBAR_H
|
#endif // FAKETOOLBAR_H
|
||||||
|
|||||||
@@ -47,7 +47,22 @@
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
HelpManager *HelpManager::m_instance = 0;
|
struct HelpManagerPrivate {
|
||||||
|
HelpManagerPrivate() :
|
||||||
|
m_needsSetup(true), m_helpEngine(0), m_collectionWatcher(0) {}
|
||||||
|
|
||||||
|
static HelpManager *m_instance;
|
||||||
|
|
||||||
|
bool m_needsSetup;
|
||||||
|
QHelpEngineCore *m_helpEngine;
|
||||||
|
QFileSystemWatcher *m_collectionWatcher;
|
||||||
|
|
||||||
|
QStringList m_filesToRegister;
|
||||||
|
QStringList m_nameSpacesToUnregister;
|
||||||
|
QHash<QString, QVariant> m_customValues;
|
||||||
|
};
|
||||||
|
|
||||||
|
HelpManager *HelpManagerPrivate::m_instance = 0;
|
||||||
|
|
||||||
static const char linksForKeyQuery[] = "SELECT d.Title, f.Name, e.Name, "
|
static const char linksForKeyQuery[] = "SELECT d.Title, f.Name, e.Name, "
|
||||||
"d.Name, a.Anchor FROM IndexTable a, FileNameTable d, FolderTable e, "
|
"d.Name, a.Anchor FROM IndexTable a, FileNameTable d, FolderTable e, "
|
||||||
@@ -67,13 +82,11 @@ struct DbCleaner {
|
|||||||
|
|
||||||
// -- HelpManager
|
// -- HelpManager
|
||||||
|
|
||||||
HelpManager::HelpManager(QObject *parent)
|
HelpManager::HelpManager(QObject *parent) :
|
||||||
: QObject(parent)
|
QObject(parent), d(new HelpManagerPrivate)
|
||||||
, m_needsSetup(true)
|
|
||||||
, m_helpEngine(0)
|
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_instance);
|
Q_ASSERT(!HelpManagerPrivate::m_instance);
|
||||||
m_instance = this;
|
HelpManagerPrivate::m_instance = this;
|
||||||
|
|
||||||
connect(Core::ICore::instance(), SIGNAL(coreOpened()), this,
|
connect(Core::ICore::instance(), SIGNAL(coreOpened()), this,
|
||||||
SLOT(setupHelpManager()));
|
SLOT(setupHelpManager()));
|
||||||
@@ -81,16 +94,16 @@ HelpManager::HelpManager(QObject *parent)
|
|||||||
|
|
||||||
HelpManager::~HelpManager()
|
HelpManager::~HelpManager()
|
||||||
{
|
{
|
||||||
delete m_helpEngine;
|
delete d->m_helpEngine;
|
||||||
m_helpEngine = 0;
|
d->m_helpEngine = 0;
|
||||||
|
|
||||||
m_instance = 0;
|
HelpManagerPrivate::m_instance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpManager* HelpManager::instance()
|
HelpManager* HelpManager::instance()
|
||||||
{
|
{
|
||||||
Q_ASSERT(m_instance);
|
Q_ASSERT(HelpManagerPrivate::m_instance);
|
||||||
return m_instance;
|
return HelpManagerPrivate::m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HelpManager::collectionFilePath()
|
QString HelpManager::collectionFilePath()
|
||||||
@@ -101,33 +114,33 @@ QString HelpManager::collectionFilePath()
|
|||||||
|
|
||||||
void HelpManager::registerDocumentation(const QStringList &files)
|
void HelpManager::registerDocumentation(const QStringList &files)
|
||||||
{
|
{
|
||||||
if (m_needsSetup) {
|
if (d->m_needsSetup) {
|
||||||
m_filesToRegister.append(files);
|
d->m_filesToRegister.append(files);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool docsChanged = false;
|
bool docsChanged = false;
|
||||||
foreach (const QString &file, files) {
|
foreach (const QString &file, files) {
|
||||||
const QString &nameSpace = m_helpEngine->namespaceName(file);
|
const QString &nameSpace = d->m_helpEngine->namespaceName(file);
|
||||||
if (nameSpace.isEmpty())
|
if (nameSpace.isEmpty())
|
||||||
continue;
|
continue;
|
||||||
if (!m_helpEngine->registeredDocumentations().contains(nameSpace)) {
|
if (!d->m_helpEngine->registeredDocumentations().contains(nameSpace)) {
|
||||||
if (m_helpEngine->registerDocumentation(file)) {
|
if (d->m_helpEngine->registerDocumentation(file)) {
|
||||||
docsChanged = true;
|
docsChanged = true;
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Error registering namespace '" << nameSpace
|
qWarning() << "Error registering namespace '" << nameSpace
|
||||||
<< "' from file '" << file << "':" << m_helpEngine->error();
|
<< "' from file '" << file << "':" << d->m_helpEngine->error();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const QLatin1String key("CreationDate");
|
const QLatin1String key("CreationDate");
|
||||||
const QString &newDate = m_helpEngine->metaData(file, key).toString();
|
const QString &newDate = d->m_helpEngine->metaData(file, key).toString();
|
||||||
const QString &oldDate = m_helpEngine->metaData(
|
const QString &oldDate = d->m_helpEngine->metaData(
|
||||||
m_helpEngine->documentationFileName(nameSpace), key).toString();
|
d->m_helpEngine->documentationFileName(nameSpace), key).toString();
|
||||||
if (QDateTime::fromString(newDate, Qt::ISODate)
|
if (QDateTime::fromString(newDate, Qt::ISODate)
|
||||||
> QDateTime::fromString(oldDate, Qt::ISODate)) {
|
> QDateTime::fromString(oldDate, Qt::ISODate)) {
|
||||||
if (m_helpEngine->unregisterDocumentation(nameSpace)) {
|
if (d->m_helpEngine->unregisterDocumentation(nameSpace)) {
|
||||||
docsChanged = true;
|
docsChanged = true;
|
||||||
m_helpEngine->registerDocumentation(file);
|
d->m_helpEngine->registerDocumentation(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,19 +151,19 @@ void HelpManager::registerDocumentation(const QStringList &files)
|
|||||||
|
|
||||||
void HelpManager::unregisterDocumentation(const QStringList &nameSpaces)
|
void HelpManager::unregisterDocumentation(const QStringList &nameSpaces)
|
||||||
{
|
{
|
||||||
if (m_needsSetup) {
|
if (d->m_needsSetup) {
|
||||||
m_nameSpacesToUnregister.append(nameSpaces);
|
d->m_nameSpacesToUnregister.append(nameSpaces);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool docsChanged = false;
|
bool docsChanged = false;
|
||||||
foreach (const QString &nameSpace, nameSpaces) {
|
foreach (const QString &nameSpace, nameSpaces) {
|
||||||
if (m_helpEngine->unregisterDocumentation(nameSpace)) {
|
if (d->m_helpEngine->unregisterDocumentation(nameSpace)) {
|
||||||
docsChanged = true;
|
docsChanged = true;
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Error unregistering namespace '" << nameSpace
|
qWarning() << "Error unregistering namespace '" << nameSpace
|
||||||
<< "' from file '" << m_helpEngine->documentationFileName(nameSpace)
|
<< "' from file '" << d->m_helpEngine->documentationFileName(nameSpace)
|
||||||
<< "': " << m_helpEngine->error();
|
<< "': " << d->m_helpEngine->error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (docsChanged)
|
if (docsChanged)
|
||||||
@@ -172,7 +185,7 @@ QUrl buildQUrl(const QString &nameSpace, const QString &folder,
|
|||||||
QMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key) const
|
QMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key) const
|
||||||
{
|
{
|
||||||
QMap<QString, QUrl> links;
|
QMap<QString, QUrl> links;
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return links;
|
return links;
|
||||||
|
|
||||||
const QLatin1String sqlite("QSQLITE");
|
const QLatin1String sqlite("QSQLITE");
|
||||||
@@ -181,9 +194,9 @@ QMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key) const
|
|||||||
DbCleaner cleaner(name);
|
DbCleaner cleaner(name);
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
|
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
|
||||||
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
|
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
|
||||||
const QStringList ®isteredDocs = m_helpEngine->registeredDocumentations();
|
const QStringList ®isteredDocs = d->m_helpEngine->registeredDocumentations();
|
||||||
foreach (const QString &nameSpace, registeredDocs) {
|
foreach (const QString &nameSpace, registeredDocs) {
|
||||||
db.setDatabaseName(m_helpEngine->documentationFileName(nameSpace));
|
db.setDatabaseName(d->m_helpEngine->documentationFileName(nameSpace));
|
||||||
if (db.open()) {
|
if (db.open()) {
|
||||||
QSqlQuery query = QSqlQuery(db);
|
QSqlQuery query = QSqlQuery(db);
|
||||||
query.setForwardOnly(true);
|
query.setForwardOnly(true);
|
||||||
@@ -204,16 +217,16 @@ QMap<QString, QUrl> HelpManager::linksForKeyword(const QString &key) const
|
|||||||
|
|
||||||
QMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id) const
|
QMap<QString, QUrl> HelpManager::linksForIdentifier(const QString &id) const
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return QMap<QString, QUrl>();
|
return QMap<QString, QUrl>();
|
||||||
return m_helpEngine->linksForIdentifier(id);
|
return d->m_helpEngine->linksForIdentifier(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should go into Qt 4.8 once we start using it for Qt Creator
|
// This should go into Qt 4.8 once we start using it for Qt Creator
|
||||||
QStringList HelpManager::findKeywords(const QString &key, int maxHits) const
|
QStringList HelpManager::findKeywords(const QString &key, int maxHits) const
|
||||||
{
|
{
|
||||||
QStringList keywords;
|
QStringList keywords;
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return keywords;
|
return keywords;
|
||||||
|
|
||||||
const QLatin1String sqlite("QSQLITE");
|
const QLatin1String sqlite("QSQLITE");
|
||||||
@@ -222,9 +235,9 @@ QStringList HelpManager::findKeywords(const QString &key, int maxHits) const
|
|||||||
DbCleaner cleaner(name);
|
DbCleaner cleaner(name);
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
|
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
|
||||||
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
|
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
|
||||||
const QStringList ®isteredDocs = m_helpEngine->registeredDocumentations();
|
const QStringList ®isteredDocs = d->m_helpEngine->registeredDocumentations();
|
||||||
foreach (const QString &nameSpace, registeredDocs) {
|
foreach (const QString &nameSpace, registeredDocs) {
|
||||||
db.setDatabaseName(m_helpEngine->documentationFileName(nameSpace));
|
db.setDatabaseName(d->m_helpEngine->documentationFileName(nameSpace));
|
||||||
if (db.open()) {
|
if (db.open()) {
|
||||||
QSqlQuery query = QSqlQuery(db);
|
QSqlQuery query = QSqlQuery(db);
|
||||||
query.setForwardOnly(true);
|
query.setForwardOnly(true);
|
||||||
@@ -246,16 +259,16 @@ QStringList HelpManager::findKeywords(const QString &key, int maxHits) const
|
|||||||
|
|
||||||
QUrl HelpManager::findFile(const QUrl &url) const
|
QUrl HelpManager::findFile(const QUrl &url) const
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return QUrl();
|
return QUrl();
|
||||||
return m_helpEngine->findFile(url);
|
return d->m_helpEngine->findFile(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray HelpManager::fileData(const QUrl &url) const
|
QByteArray HelpManager::fileData(const QUrl &url) const
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
return m_helpEngine->fileData(url);
|
return d->m_helpEngine->fileData(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpManager::handleHelpRequest(const QString &url)
|
void HelpManager::handleHelpRequest(const QString &url)
|
||||||
@@ -265,58 +278,58 @@ void HelpManager::handleHelpRequest(const QString &url)
|
|||||||
|
|
||||||
QStringList HelpManager::registeredNamespaces() const
|
QStringList HelpManager::registeredNamespaces() const
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return QStringList();
|
return QStringList();
|
||||||
return m_helpEngine->registeredDocumentations();
|
return d->m_helpEngine->registeredDocumentations();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HelpManager::namespaceFromFile(const QString &file) const
|
QString HelpManager::namespaceFromFile(const QString &file) const
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return QString();
|
return QString();
|
||||||
return m_helpEngine->namespaceName(file);
|
return d->m_helpEngine->namespaceName(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HelpManager::fileFromNamespace(const QString &nameSpace) const
|
QString HelpManager::fileFromNamespace(const QString &nameSpace) const
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return QString();
|
return QString();
|
||||||
return m_helpEngine->documentationFileName(nameSpace);
|
return d->m_helpEngine->documentationFileName(nameSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpManager::setCustomValue(const QString &key, const QVariant &value)
|
void HelpManager::setCustomValue(const QString &key, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (m_needsSetup) {
|
if (d->m_needsSetup) {
|
||||||
m_customValues.insert(key, value);
|
d->m_customValues.insert(key, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_helpEngine->setCustomValue(key, value))
|
if (d->m_helpEngine->setCustomValue(key, value))
|
||||||
emit collectionFileChanged();
|
emit collectionFileChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant HelpManager::customValue(const QString &key, const QVariant &value) const
|
QVariant HelpManager::customValue(const QString &key, const QVariant &value) const
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
return m_helpEngine->customValue(key, value);
|
return d->m_helpEngine->customValue(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpManager::Filters HelpManager::filters() const
|
HelpManager::Filters HelpManager::filters() const
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return Filters();
|
return Filters();
|
||||||
|
|
||||||
Filters filters;
|
Filters filters;
|
||||||
const QStringList &customFilters = m_helpEngine->customFilters();
|
const QStringList &customFilters = d->m_helpEngine->customFilters();
|
||||||
foreach (const QString &filter, customFilters)
|
foreach (const QString &filter, customFilters)
|
||||||
filters.insert(filter, m_helpEngine->filterAttributes(filter));
|
filters.insert(filter, d->m_helpEngine->filterAttributes(filter));
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpManager::Filters HelpManager::fixedFilters() const
|
HelpManager::Filters HelpManager::fixedFilters() const
|
||||||
{
|
{
|
||||||
Filters fixedFilters;
|
Filters fixedFilters;
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return fixedFilters;
|
return fixedFilters;
|
||||||
|
|
||||||
const QLatin1String sqlite("QSQLITE");
|
const QLatin1String sqlite("QSQLITE");
|
||||||
@@ -325,16 +338,16 @@ HelpManager::Filters HelpManager::fixedFilters() const
|
|||||||
DbCleaner cleaner(name);
|
DbCleaner cleaner(name);
|
||||||
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
|
QSqlDatabase db = QSqlDatabase::addDatabase(sqlite, name);
|
||||||
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
|
if (db.driver() && db.driver()->lastError().type() == QSqlError::NoError) {
|
||||||
const QStringList ®isteredDocs = m_helpEngine->registeredDocumentations();
|
const QStringList ®isteredDocs = d->m_helpEngine->registeredDocumentations();
|
||||||
foreach (const QString &nameSpace, registeredDocs) {
|
foreach (const QString &nameSpace, registeredDocs) {
|
||||||
db.setDatabaseName(m_helpEngine->documentationFileName(nameSpace));
|
db.setDatabaseName(d->m_helpEngine->documentationFileName(nameSpace));
|
||||||
if (db.open()) {
|
if (db.open()) {
|
||||||
QSqlQuery query = QSqlQuery(db);
|
QSqlQuery query = QSqlQuery(db);
|
||||||
query.setForwardOnly(true);
|
query.setForwardOnly(true);
|
||||||
query.exec(QLatin1String("SELECT Name FROM FilterNameTable"));
|
query.exec(QLatin1String("SELECT Name FROM FilterNameTable"));
|
||||||
while (query.next()) {
|
while (query.next()) {
|
||||||
const QString &filter = query.value(0).toString();
|
const QString &filter = query.value(0).toString();
|
||||||
fixedFilters.insert(filter, m_helpEngine->filterAttributes(filter));
|
fixedFilters.insert(filter, d->m_helpEngine->filterAttributes(filter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -344,7 +357,7 @@ HelpManager::Filters HelpManager::fixedFilters() const
|
|||||||
|
|
||||||
HelpManager::Filters HelpManager::userDefinedFilters() const
|
HelpManager::Filters HelpManager::userDefinedFilters() const
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return Filters();
|
return Filters();
|
||||||
|
|
||||||
Filters all = filters();
|
Filters all = filters();
|
||||||
@@ -356,19 +369,19 @@ HelpManager::Filters HelpManager::userDefinedFilters() const
|
|||||||
|
|
||||||
void HelpManager::removeUserDefinedFilter(const QString &filter)
|
void HelpManager::removeUserDefinedFilter(const QString &filter)
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_helpEngine->removeCustomFilter(filter))
|
if (d->m_helpEngine->removeCustomFilter(filter))
|
||||||
emit collectionFileChanged();
|
emit collectionFileChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpManager::addUserDefinedFilter(const QString &filter, const QStringList &attr)
|
void HelpManager::addUserDefinedFilter(const QString &filter, const QStringList &attr)
|
||||||
{
|
{
|
||||||
if (m_needsSetup)
|
if (d->m_needsSetup)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_helpEngine->addCustomFilter(filter, attr))
|
if (d->m_helpEngine->addCustomFilter(filter, attr))
|
||||||
emit collectionFileChanged();
|
emit collectionFileChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,42 +389,42 @@ void HelpManager::addUserDefinedFilter(const QString &filter, const QStringList
|
|||||||
|
|
||||||
void HelpManager::setupHelpManager()
|
void HelpManager::setupHelpManager()
|
||||||
{
|
{
|
||||||
if (!m_needsSetup)
|
if (!d->m_needsSetup)
|
||||||
return;
|
return;
|
||||||
m_needsSetup = false;
|
d->m_needsSetup = false;
|
||||||
|
|
||||||
m_helpEngine = new QHelpEngineCore(collectionFilePath(), this);
|
d->m_helpEngine = new QHelpEngineCore(collectionFilePath(), this);
|
||||||
m_helpEngine->setAutoSaveFilter(false);
|
d->m_helpEngine->setAutoSaveFilter(false);
|
||||||
m_helpEngine->setCurrentFilter(tr("Unfiltered"));
|
d->m_helpEngine->setCurrentFilter(tr("Unfiltered"));
|
||||||
m_helpEngine->setupData();
|
d->m_helpEngine->setupData();
|
||||||
|
|
||||||
verifyDocumenation();
|
verifyDocumenation();
|
||||||
|
|
||||||
if (!m_nameSpacesToUnregister.isEmpty()) {
|
if (!d->m_nameSpacesToUnregister.isEmpty()) {
|
||||||
unregisterDocumentation(m_nameSpacesToUnregister);
|
unregisterDocumentation(d->m_nameSpacesToUnregister);
|
||||||
m_nameSpacesToUnregister.clear();
|
d->m_nameSpacesToUnregister.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this might come from the installer
|
// this might come from the installer
|
||||||
const QLatin1String key("AddedDocs");
|
const QLatin1String key("AddedDocs");
|
||||||
const QString addedDocs = m_helpEngine->customValue(key).toString();
|
const QString addedDocs = d->m_helpEngine->customValue(key).toString();
|
||||||
if (!addedDocs.isEmpty()) {
|
if (!addedDocs.isEmpty()) {
|
||||||
m_helpEngine->removeCustomValue(key);
|
d->m_helpEngine->removeCustomValue(key);
|
||||||
m_filesToRegister += addedDocs.split(QLatin1Char(';'));
|
d->m_filesToRegister += addedDocs.split(QLatin1Char(';'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_filesToRegister.isEmpty()) {
|
if (!d->m_filesToRegister.isEmpty()) {
|
||||||
registerDocumentation(m_filesToRegister);
|
registerDocumentation(d->m_filesToRegister);
|
||||||
m_filesToRegister.clear();
|
d->m_filesToRegister.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, QVariant>::const_iterator it;
|
QHash<QString, QVariant>::const_iterator it;
|
||||||
for (it = m_customValues.constBegin(); it != m_customValues.constEnd(); ++it)
|
for (it = d->m_customValues.constBegin(); it != d->m_customValues.constEnd(); ++it)
|
||||||
setCustomValue(it.key(), it.value());
|
setCustomValue(it.key(), it.value());
|
||||||
|
|
||||||
m_collectionWatcher = new QFileSystemWatcher(QStringList() << collectionFilePath(),
|
d->m_collectionWatcher = new QFileSystemWatcher(QStringList() << collectionFilePath(),
|
||||||
this);
|
this);
|
||||||
connect(m_collectionWatcher, SIGNAL(fileChanged(QString)), this,
|
connect(d->m_collectionWatcher, SIGNAL(fileChanged(QString)), this,
|
||||||
SLOT(collectionFileModified()));
|
SLOT(collectionFileModified()));
|
||||||
|
|
||||||
emit setupFinished();
|
emit setupFinished();
|
||||||
@@ -420,9 +433,9 @@ void HelpManager::setupHelpManager()
|
|||||||
void HelpManager::collectionFileModified()
|
void HelpManager::collectionFileModified()
|
||||||
{
|
{
|
||||||
const QLatin1String key("AddedDocs");
|
const QLatin1String key("AddedDocs");
|
||||||
const QString addedDocs = m_helpEngine->customValue(key).toString();
|
const QString addedDocs = d->m_helpEngine->customValue(key).toString();
|
||||||
if (!addedDocs.isEmpty()) {
|
if (!addedDocs.isEmpty()) {
|
||||||
m_helpEngine->removeCustomValue(key);
|
d->m_helpEngine->removeCustomValue(key);
|
||||||
registerDocumentation(addedDocs.split(QLatin1Char(';')));
|
registerDocumentation(addedDocs.split(QLatin1Char(';')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -431,10 +444,10 @@ void HelpManager::collectionFileModified()
|
|||||||
|
|
||||||
void HelpManager::verifyDocumenation()
|
void HelpManager::verifyDocumenation()
|
||||||
{
|
{
|
||||||
const QStringList ®isteredDocs = m_helpEngine->registeredDocumentations();
|
const QStringList ®isteredDocs = d->m_helpEngine->registeredDocumentations();
|
||||||
foreach (const QString &nameSpace, registeredDocs) {
|
foreach (const QString &nameSpace, registeredDocs) {
|
||||||
if (!QFileInfo(m_helpEngine->documentationFileName(nameSpace)).exists())
|
if (!QFileInfo(d->m_helpEngine->documentationFileName(nameSpace)).exists())
|
||||||
m_nameSpacesToUnregister.append(nameSpace);
|
d->m_nameSpacesToUnregister.append(nameSpace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,20 +32,18 @@
|
|||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QtCore/QHash>
|
#include <QtCore/QScopedPointer>
|
||||||
#include <QtCore/QMap>
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QtCore/QString>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
#include <QtCore/QUrl>
|
|
||||||
#include <QtCore/QVariant>
|
|
||||||
#include <QtCore/QByteArray>
|
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QFileSystemWatcher)
|
#include <QtCore/QObject>
|
||||||
QT_FORWARD_DECLARE_CLASS(QHelpEngineCore)
|
#include <QtCore/QStringList>
|
||||||
QT_FORWARD_DECLARE_CLASS(QSqlQuery)
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QHash>
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QUrl)
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
struct HelpManagerPrivate;
|
||||||
|
|
||||||
class CORE_EXPORT HelpManager : public QObject
|
class CORE_EXPORT HelpManager : public QObject
|
||||||
{
|
{
|
||||||
@@ -54,7 +52,6 @@ class CORE_EXPORT HelpManager : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
typedef QHash<QString, QStringList> Filters;
|
typedef QHash<QString, QStringList> Filters;
|
||||||
|
|
||||||
explicit HelpManager(QObject *parent = 0);
|
explicit HelpManager(QObject *parent = 0);
|
||||||
virtual ~HelpManager();
|
virtual ~HelpManager();
|
||||||
|
|
||||||
@@ -99,16 +96,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void verifyDocumenation();
|
void verifyDocumenation();
|
||||||
|
|
||||||
private:
|
QScopedPointer<HelpManagerPrivate> d;
|
||||||
bool m_needsSetup;
|
|
||||||
QHelpEngineCore *m_helpEngine;
|
|
||||||
QFileSystemWatcher *m_collectionWatcher;
|
|
||||||
|
|
||||||
QStringList m_filesToRegister;
|
|
||||||
QStringList m_nameSpacesToUnregister;
|
|
||||||
QHash<QString, QVariant> m_customValues;
|
|
||||||
|
|
||||||
static HelpManager *m_instance;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Core
|
} // Core
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include "modemanager.h"
|
#include "modemanager.h"
|
||||||
#include "mimedatabase.h"
|
#include "mimedatabase.h"
|
||||||
#include "newdialog.h"
|
#include "newdialog.h"
|
||||||
|
#include "outputpanemanager.h"
|
||||||
#include "outputpane.h"
|
#include "outputpane.h"
|
||||||
#include "plugindialog.h"
|
#include "plugindialog.h"
|
||||||
#include "progressmanager_p.h"
|
#include "progressmanager_p.h"
|
||||||
|
|||||||
222
src/plugins/coreplugin/navigationsubwidget.cpp
Normal file
222
src/plugins/coreplugin/navigationsubwidget.cpp
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "navigationsubwidget.h"
|
||||||
|
#include "navigationwidget.h"
|
||||||
|
|
||||||
|
#include "icore.h"
|
||||||
|
#include "icontext.h"
|
||||||
|
#include "coreconstants.h"
|
||||||
|
#include "inavigationwidgetfactory.h"
|
||||||
|
#include "modemanager.h"
|
||||||
|
#include "actionmanager/actionmanager.h"
|
||||||
|
#include "actionmanager/command.h"
|
||||||
|
#include "uniqueidmanager.h"
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
|
#include <utils/styledbar.h>
|
||||||
|
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
#include <QtCore/QSettings>
|
||||||
|
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
#include <QtGui/QHBoxLayout>
|
||||||
|
#include <QtGui/QResizeEvent>
|
||||||
|
#include <QtGui/QToolButton>
|
||||||
|
#include <QtGui/QShortcut>
|
||||||
|
#include <QtGui/QStandardItemModel>
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(Core::INavigationWidgetFactory *)
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
////
|
||||||
|
// NavigationSubWidget
|
||||||
|
////
|
||||||
|
|
||||||
|
NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int position, int factoryIndex)
|
||||||
|
: m_parentWidget(parentWidget),
|
||||||
|
m_position(position)
|
||||||
|
{
|
||||||
|
m_navigationComboBox = new NavComboBox(this);
|
||||||
|
m_navigationComboBox->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||||
|
m_navigationComboBox->setFocusPolicy(Qt::TabFocus);
|
||||||
|
m_navigationComboBox->setMinimumContentsLength(0);
|
||||||
|
m_navigationComboBox->setModel(parentWidget->factoryModel());
|
||||||
|
m_navigationWidget = 0;
|
||||||
|
m_navigationWidgetFactory = 0;
|
||||||
|
|
||||||
|
m_toolBar = new Utils::StyledBar(this);
|
||||||
|
QHBoxLayout *toolBarLayout = new QHBoxLayout;
|
||||||
|
toolBarLayout->setMargin(0);
|
||||||
|
toolBarLayout->setSpacing(0);
|
||||||
|
m_toolBar->setLayout(toolBarLayout);
|
||||||
|
toolBarLayout->addWidget(m_navigationComboBox);
|
||||||
|
|
||||||
|
QToolButton *splitAction = new QToolButton();
|
||||||
|
splitAction->setIcon(QIcon(QLatin1String(Constants::ICON_SPLIT_HORIZONTAL)));
|
||||||
|
splitAction->setToolTip(tr("Split"));
|
||||||
|
QToolButton *close = new QToolButton();
|
||||||
|
close->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE)));
|
||||||
|
close->setToolTip(tr("Close"));
|
||||||
|
|
||||||
|
toolBarLayout->addWidget(splitAction);
|
||||||
|
toolBarLayout->addWidget(close);
|
||||||
|
|
||||||
|
QVBoxLayout *lay = new QVBoxLayout();
|
||||||
|
lay->setMargin(0);
|
||||||
|
lay->setSpacing(0);
|
||||||
|
setLayout(lay);
|
||||||
|
lay->addWidget(m_toolBar);
|
||||||
|
|
||||||
|
connect(splitAction, SIGNAL(clicked()), this, SIGNAL(splitMe()));
|
||||||
|
connect(close, SIGNAL(clicked()), this, SIGNAL(closeMe()));
|
||||||
|
|
||||||
|
setFactoryIndex(factoryIndex);
|
||||||
|
|
||||||
|
connect(m_navigationComboBox, SIGNAL(currentIndexChanged(int)),
|
||||||
|
this, SLOT(comboBoxIndexChanged(int)));
|
||||||
|
|
||||||
|
comboBoxIndexChanged(factoryIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
NavigationSubWidget::~NavigationSubWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationSubWidget::comboBoxIndexChanged(int factoryIndex)
|
||||||
|
{
|
||||||
|
saveSettings();
|
||||||
|
|
||||||
|
// Remove toolbutton
|
||||||
|
foreach (QWidget *w, m_additionalToolBarWidgets)
|
||||||
|
delete w;
|
||||||
|
m_additionalToolBarWidgets.clear();
|
||||||
|
|
||||||
|
// Remove old Widget
|
||||||
|
delete m_navigationWidget;
|
||||||
|
m_navigationWidget = 0;
|
||||||
|
m_navigationWidgetFactory = 0;
|
||||||
|
if (factoryIndex == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Get new stuff
|
||||||
|
m_navigationWidgetFactory = m_navigationComboBox->itemData(factoryIndex,
|
||||||
|
NavigationWidget::FactoryObjectRole).value<INavigationWidgetFactory *>();
|
||||||
|
NavigationView n = m_navigationWidgetFactory->createWidget();
|
||||||
|
m_navigationWidget = n.widget;
|
||||||
|
layout()->addWidget(m_navigationWidget);
|
||||||
|
|
||||||
|
// Add Toolbutton
|
||||||
|
m_additionalToolBarWidgets = n.dockToolBarWidgets;
|
||||||
|
QHBoxLayout *layout = qobject_cast<QHBoxLayout *>(m_toolBar->layout());
|
||||||
|
foreach (QToolButton *w, m_additionalToolBarWidgets) {
|
||||||
|
layout->insertWidget(layout->count()-2, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
restoreSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationSubWidget::setFocusWidget()
|
||||||
|
{
|
||||||
|
if (m_navigationWidget)
|
||||||
|
m_navigationWidget->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
INavigationWidgetFactory *NavigationSubWidget::factory()
|
||||||
|
{
|
||||||
|
return m_navigationWidgetFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NavigationSubWidget::saveSettings()
|
||||||
|
{
|
||||||
|
if (!m_navigationWidget || !factory())
|
||||||
|
return;
|
||||||
|
factory()->saveSettings(position(), m_navigationWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationSubWidget::restoreSettings()
|
||||||
|
{
|
||||||
|
if (!m_navigationWidget || !factory())
|
||||||
|
return;
|
||||||
|
factory()->restoreSettings(position(), m_navigationWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Command *NavigationSubWidget::command(const QString &title) const
|
||||||
|
{
|
||||||
|
const QHash<QString, Core::Command*> commandMap = m_parentWidget->commandMap();
|
||||||
|
QHash<QString, Core::Command*>::const_iterator r = commandMap.find(title);
|
||||||
|
if (r != commandMap.end())
|
||||||
|
return r.value();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NavigationSubWidget::factoryIndex() const
|
||||||
|
{
|
||||||
|
return m_navigationComboBox->currentIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationSubWidget::setFactoryIndex(int i)
|
||||||
|
{
|
||||||
|
m_navigationComboBox->setCurrentIndex(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
int NavigationSubWidget::position() const
|
||||||
|
{
|
||||||
|
return m_position;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationSubWidget::setPosition(int position)
|
||||||
|
{
|
||||||
|
m_position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandComboBox::CommandComboBox(QWidget *parent) : QComboBox(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CommandComboBox::event(QEvent *e)
|
||||||
|
{
|
||||||
|
if (e->type() == QEvent::ToolTip) {
|
||||||
|
const QString text = currentText();
|
||||||
|
if (const Core::Command *cmd = command(text)) {
|
||||||
|
const QString tooltip = tr("Activate %1").arg(text);
|
||||||
|
setToolTip(cmd->stringWithAppendedShortcut(tooltip));
|
||||||
|
} else {
|
||||||
|
setToolTip(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QComboBox::event(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Core
|
||||||
127
src/plugins/coreplugin/navigationsubwidget.h
Normal file
127
src/plugins/coreplugin/navigationsubwidget.h
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef NAVIGATIONSSUBWIDGET_H
|
||||||
|
#define NAVIGATIONSSUBWIDGET_H
|
||||||
|
|
||||||
|
#include <QtGui/QComboBox>
|
||||||
|
|
||||||
|
#include <QtCore/QList>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QToolButton;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
class StyledBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class INavigationWidgetFactory;
|
||||||
|
class IMode;
|
||||||
|
class Command;
|
||||||
|
class NavigationWidget;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class NavigationSubWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
NavigationSubWidget(NavigationWidget *parentWidget, int position, int index);
|
||||||
|
virtual ~NavigationSubWidget();
|
||||||
|
|
||||||
|
INavigationWidgetFactory *factory();
|
||||||
|
|
||||||
|
int factoryIndex() const;
|
||||||
|
void setFactoryIndex(int i);
|
||||||
|
|
||||||
|
void setFocusWidget();
|
||||||
|
|
||||||
|
int position() const;
|
||||||
|
void setPosition(int i);
|
||||||
|
|
||||||
|
void saveSettings();
|
||||||
|
void restoreSettings();
|
||||||
|
|
||||||
|
Core::Command *command(const QString &title) const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void splitMe();
|
||||||
|
void closeMe();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void comboBoxIndexChanged(int);
|
||||||
|
|
||||||
|
private:
|
||||||
|
NavigationWidget *m_parentWidget;
|
||||||
|
QComboBox *m_navigationComboBox;
|
||||||
|
QWidget *m_navigationWidget;
|
||||||
|
INavigationWidgetFactory *m_navigationWidgetFactory;
|
||||||
|
Utils::StyledBar *m_toolBar;
|
||||||
|
QList<QToolButton *> m_additionalToolBarWidgets;
|
||||||
|
int m_position;
|
||||||
|
};
|
||||||
|
|
||||||
|
// A combo associated with a command. Shows the command text
|
||||||
|
// and shortcut in the tooltip.
|
||||||
|
class CommandComboBox : public QComboBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit CommandComboBox(QWidget *parent = 0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool event(QEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual const Core::Command *command(const QString &text) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class NavComboBox : public CommandComboBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit NavComboBox(NavigationSubWidget *navSubWidget) :
|
||||||
|
m_navSubWidget(navSubWidget) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual const Core::Command *command(const QString &text) const
|
||||||
|
{ return m_navSubWidget->command(text); }
|
||||||
|
|
||||||
|
NavigationSubWidget *m_navSubWidget;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
#endif // NAVIGATIONSSUBWIDGET_H
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "navigationwidget.h"
|
#include "navigationwidget.h"
|
||||||
|
#include "navigationsubwidget.h"
|
||||||
#include "icore.h"
|
#include "icore.h"
|
||||||
#include "icontext.h"
|
#include "icontext.h"
|
||||||
#include "coreconstants.h"
|
#include "coreconstants.h"
|
||||||
@@ -54,8 +54,7 @@
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(Core::INavigationWidgetFactory *)
|
Q_DECLARE_METATYPE(Core::INavigationWidgetFactory *)
|
||||||
|
|
||||||
using namespace Core;
|
namespace Core {
|
||||||
using namespace Core::Internal;
|
|
||||||
|
|
||||||
NavigationWidgetPlaceHolder *NavigationWidgetPlaceHolder::m_current = 0;
|
NavigationWidgetPlaceHolder *NavigationWidgetPlaceHolder::m_current = 0;
|
||||||
|
|
||||||
@@ -135,29 +134,49 @@ void NavigationWidgetPlaceHolder::currentModeAboutToChange(Core::IMode *mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationWidget *NavigationWidget::m_instance = 0;
|
struct NavigationWidgetPrivate {
|
||||||
|
explicit NavigationWidgetPrivate(QAction *toggleSideBarAction);
|
||||||
|
|
||||||
NavigationWidget::NavigationWidget(QAction *toggleSideBarAction) :
|
QList<Internal::NavigationSubWidget *> m_subWidgets;
|
||||||
|
QHash<QShortcut *, QString> m_shortcutMap;
|
||||||
|
QHash<QString, Core::Command*> m_commandMap;
|
||||||
|
QStandardItemModel *m_factoryModel;
|
||||||
|
|
||||||
|
bool m_shown;
|
||||||
|
bool m_suppressed;
|
||||||
|
int m_width;
|
||||||
|
static NavigationWidget* m_instance;
|
||||||
|
QAction *m_toggleSideBarAction;
|
||||||
|
};
|
||||||
|
|
||||||
|
NavigationWidgetPrivate::NavigationWidgetPrivate(QAction *toggleSideBarAction) :
|
||||||
m_factoryModel(new QStandardItemModel),
|
m_factoryModel(new QStandardItemModel),
|
||||||
m_shown(true),
|
m_shown(true),
|
||||||
m_suppressed(false),
|
m_suppressed(false),
|
||||||
m_width(0),
|
m_width(0),
|
||||||
m_toggleSideBarAction(toggleSideBarAction)
|
m_toggleSideBarAction(toggleSideBarAction)
|
||||||
{
|
{
|
||||||
m_factoryModel->setSortRole(FactoryPriorityRole);
|
}
|
||||||
|
|
||||||
|
NavigationWidget *NavigationWidgetPrivate::m_instance = 0;
|
||||||
|
|
||||||
|
NavigationWidget::NavigationWidget(QAction *toggleSideBarAction) :
|
||||||
|
d(new NavigationWidgetPrivate(toggleSideBarAction))
|
||||||
|
{
|
||||||
|
d->m_factoryModel->setSortRole(FactoryPriorityRole);
|
||||||
setOrientation(Qt::Vertical);
|
setOrientation(Qt::Vertical);
|
||||||
insertSubItem(0, -1); // we don't have any entry to show yet
|
insertSubItem(0, -1); // we don't have any entry to show yet
|
||||||
m_instance = this;
|
d->m_instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationWidget::~NavigationWidget()
|
NavigationWidget::~NavigationWidget()
|
||||||
{
|
{
|
||||||
m_instance = 0;
|
NavigationWidgetPrivate::m_instance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationWidget *NavigationWidget::instance()
|
NavigationWidget *NavigationWidget::instance()
|
||||||
{
|
{
|
||||||
return m_instance;
|
return NavigationWidgetPrivate::m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> factories)
|
void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> factories)
|
||||||
@@ -172,65 +191,65 @@ void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> fact
|
|||||||
QShortcut *shortcut = new QShortcut(this);
|
QShortcut *shortcut = new QShortcut(this);
|
||||||
shortcut->setWhatsThis(tr("Activate %1 Pane").arg(factory->displayName()));
|
shortcut->setWhatsThis(tr("Activate %1 Pane").arg(factory->displayName()));
|
||||||
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSubWidget()));
|
connect(shortcut, SIGNAL(activated()), this, SLOT(activateSubWidget()));
|
||||||
m_shortcutMap.insert(shortcut, id);
|
d->m_shortcutMap.insert(shortcut, id);
|
||||||
|
|
||||||
Command *cmd = am->registerShortcut(shortcut,
|
Command *cmd = am->registerShortcut(shortcut,
|
||||||
Id(QLatin1String("QtCreator.Sidebar.") + id), navicontext);
|
Id(QLatin1String("QtCreator.Sidebar.") + id), navicontext);
|
||||||
cmd->setDefaultKeySequence(factory->activationSequence());
|
cmd->setDefaultKeySequence(factory->activationSequence());
|
||||||
m_commandMap.insert(id, cmd);
|
d->m_commandMap.insert(id, cmd);
|
||||||
|
|
||||||
QStandardItem *newRow = new QStandardItem(factory->displayName());
|
QStandardItem *newRow = new QStandardItem(factory->displayName());
|
||||||
newRow->setData(qVariantFromValue(factory), FactoryObjectRole);
|
newRow->setData(qVariantFromValue(factory), FactoryObjectRole);
|
||||||
newRow->setData(factory->id(), FactoryIdRole);
|
newRow->setData(factory->id(), FactoryIdRole);
|
||||||
newRow->setData(factory->priority(), FactoryPriorityRole);
|
newRow->setData(factory->priority(), FactoryPriorityRole);
|
||||||
m_factoryModel->appendRow(newRow);
|
d->m_factoryModel->appendRow(newRow);
|
||||||
}
|
}
|
||||||
m_factoryModel->sort(0);
|
d->m_factoryModel->sort(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int NavigationWidget::storedWidth()
|
int NavigationWidget::storedWidth()
|
||||||
{
|
{
|
||||||
return m_width;
|
return d->m_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractItemModel *NavigationWidget::factoryModel() const
|
QAbstractItemModel *NavigationWidget::factoryModel() const
|
||||||
{
|
{
|
||||||
return m_factoryModel;
|
return d->m_factoryModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::updateToggleText()
|
void NavigationWidget::updateToggleText()
|
||||||
{
|
{
|
||||||
if (isShown())
|
if (isShown())
|
||||||
m_toggleSideBarAction->setText(tr("Hide Sidebar"));
|
d->m_toggleSideBarAction->setText(tr("Hide Sidebar"));
|
||||||
else
|
else
|
||||||
m_toggleSideBarAction->setText(tr("Show Sidebar"));
|
d->m_toggleSideBarAction->setText(tr("Show Sidebar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::placeHolderChanged(NavigationWidgetPlaceHolder *holder)
|
void NavigationWidget::placeHolderChanged(NavigationWidgetPlaceHolder *holder)
|
||||||
{
|
{
|
||||||
m_toggleSideBarAction->setEnabled(holder);
|
d->m_toggleSideBarAction->setEnabled(holder);
|
||||||
m_toggleSideBarAction->setChecked(holder && isShown());
|
d->m_toggleSideBarAction->setChecked(holder && isShown());
|
||||||
updateToggleText();
|
updateToggleText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::resizeEvent(QResizeEvent *re)
|
void NavigationWidget::resizeEvent(QResizeEvent *re)
|
||||||
{
|
{
|
||||||
if (m_width && re->size().width())
|
if (d->m_width && re->size().width())
|
||||||
m_width = re->size().width();
|
d->m_width = re->size().width();
|
||||||
MiniSplitter::resizeEvent(re);
|
MiniSplitter::resizeEvent(re);
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationSubWidget *NavigationWidget::insertSubItem(int position,int index)
|
Internal::NavigationSubWidget *NavigationWidget::insertSubItem(int position,int index)
|
||||||
{
|
{
|
||||||
for (int pos = position + 1; pos < m_subWidgets.size(); ++pos) {
|
for (int pos = position + 1; pos < d->m_subWidgets.size(); ++pos) {
|
||||||
m_subWidgets.at(pos)->setPosition(pos + 1);
|
d->m_subWidgets.at(pos)->setPosition(pos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationSubWidget *nsw = new NavigationSubWidget(this, position, index);
|
Internal::NavigationSubWidget *nsw = new Internal::NavigationSubWidget(this, position, index);
|
||||||
connect(nsw, SIGNAL(splitMe()), this, SLOT(splitSubWidget()));
|
connect(nsw, SIGNAL(splitMe()), this, SLOT(splitSubWidget()));
|
||||||
connect(nsw, SIGNAL(closeMe()), this, SLOT(closeSubWidget()));
|
connect(nsw, SIGNAL(closeMe()), this, SLOT(closeSubWidget()));
|
||||||
insertWidget(position, nsw);
|
insertWidget(position, nsw);
|
||||||
m_subWidgets.insert(position, nsw);
|
d->m_subWidgets.insert(position, nsw);
|
||||||
|
|
||||||
return nsw;
|
return nsw;
|
||||||
}
|
}
|
||||||
@@ -238,14 +257,14 @@ NavigationSubWidget *NavigationWidget::insertSubItem(int position,int index)
|
|||||||
void NavigationWidget::activateSubWidget()
|
void NavigationWidget::activateSubWidget()
|
||||||
{
|
{
|
||||||
QShortcut *original = qobject_cast<QShortcut *>(sender());
|
QShortcut *original = qobject_cast<QShortcut *>(sender());
|
||||||
QString id = m_shortcutMap[original];
|
QString id = d->m_shortcutMap[original];
|
||||||
activateSubWidget(id);
|
activateSubWidget(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::activateSubWidget(const QString &factoryId)
|
void NavigationWidget::activateSubWidget(const QString &factoryId)
|
||||||
{
|
{
|
||||||
setShown(true);
|
setShown(true);
|
||||||
foreach (NavigationSubWidget *subWidget, m_subWidgets) {
|
foreach (Internal::NavigationSubWidget *subWidget, d->m_subWidgets) {
|
||||||
if (subWidget->factory()->id() == factoryId) {
|
if (subWidget->factory()->id() == factoryId) {
|
||||||
subWidget->setFocusWidget();
|
subWidget->setFocusWidget();
|
||||||
return;
|
return;
|
||||||
@@ -254,24 +273,24 @@ void NavigationWidget::activateSubWidget(const QString &factoryId)
|
|||||||
|
|
||||||
int index = factoryIndex(factoryId);
|
int index = factoryIndex(factoryId);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
m_subWidgets.first()->setFactoryIndex(index);
|
d->m_subWidgets.first()->setFactoryIndex(index);
|
||||||
m_subWidgets.first()->setFocusWidget();
|
d->m_subWidgets.first()->setFocusWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::splitSubWidget()
|
void NavigationWidget::splitSubWidget()
|
||||||
{
|
{
|
||||||
NavigationSubWidget *original = qobject_cast<NavigationSubWidget *>(sender());
|
Internal::NavigationSubWidget *original = qobject_cast<Internal::NavigationSubWidget *>(sender());
|
||||||
int pos = indexOf(original) + 1;
|
int pos = indexOf(original) + 1;
|
||||||
insertSubItem(pos, original->factoryIndex());
|
insertSubItem(pos, original->factoryIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::closeSubWidget()
|
void NavigationWidget::closeSubWidget()
|
||||||
{
|
{
|
||||||
if (m_subWidgets.count() != 1) {
|
if (d->m_subWidgets.count() != 1) {
|
||||||
NavigationSubWidget *subWidget = qobject_cast<NavigationSubWidget *>(sender());
|
Internal::NavigationSubWidget *subWidget = qobject_cast<Internal::NavigationSubWidget *>(sender());
|
||||||
subWidget->saveSettings();
|
subWidget->saveSettings();
|
||||||
m_subWidgets.removeOne(subWidget);
|
d->m_subWidgets.removeOne(subWidget);
|
||||||
subWidget->hide();
|
subWidget->hide();
|
||||||
subWidget->deleteLater();
|
subWidget->deleteLater();
|
||||||
} else {
|
} else {
|
||||||
@@ -282,14 +301,14 @@ void NavigationWidget::closeSubWidget()
|
|||||||
void NavigationWidget::saveSettings(QSettings *settings)
|
void NavigationWidget::saveSettings(QSettings *settings)
|
||||||
{
|
{
|
||||||
QStringList viewIds;
|
QStringList viewIds;
|
||||||
for (int i=0; i<m_subWidgets.count(); ++i) {
|
for (int i=0; i<d->m_subWidgets.count(); ++i) {
|
||||||
m_subWidgets.at(i)->saveSettings();
|
d->m_subWidgets.at(i)->saveSettings();
|
||||||
viewIds.append(m_subWidgets.at(i)->factory()->id());
|
viewIds.append(d->m_subWidgets.at(i)->factory()->id());
|
||||||
}
|
}
|
||||||
settings->setValue("Navigation/Views", viewIds);
|
settings->setValue("Navigation/Views", viewIds);
|
||||||
settings->setValue("Navigation/Visible", isShown());
|
settings->setValue("Navigation/Visible", isShown());
|
||||||
settings->setValue("Navigation/VerticalPosition", saveState());
|
settings->setValue("Navigation/VerticalPosition", saveState());
|
||||||
settings->setValue("Navigation/Width", m_width);
|
settings->setValue("Navigation/Width", d->m_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::restoreSettings(QSettings *settings)
|
void NavigationWidget::restoreSettings(QSettings *settings)
|
||||||
@@ -312,10 +331,10 @@ void NavigationWidget::restoreSettings(QSettings *settings)
|
|||||||
const QString &view = viewIds.at(i);
|
const QString &view = viewIds.at(i);
|
||||||
int index = factoryIndex(view);
|
int index = factoryIndex(view);
|
||||||
|
|
||||||
if (i >= m_subWidgets.size()) {
|
if (i >= d->m_subWidgets.size()) {
|
||||||
insertSubItem(i, index);
|
insertSubItem(i, index);
|
||||||
} else {
|
} else {
|
||||||
m_subWidgets.at(i)->setFactoryIndex(index);
|
d->m_subWidgets.at(i)->setFactoryIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,229 +355,74 @@ void NavigationWidget::restoreSettings(QSettings *settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (settings->contains("Navigation/Width")) {
|
if (settings->contains("Navigation/Width")) {
|
||||||
m_width = settings->value("Navigation/Width").toInt();
|
d->m_width = settings->value("Navigation/Width").toInt();
|
||||||
if (!m_width)
|
if (!d->m_width)
|
||||||
m_width = 240;
|
d->m_width = 240;
|
||||||
} else {
|
} else {
|
||||||
m_width = 240; //pixel
|
d->m_width = 240; //pixel
|
||||||
}
|
}
|
||||||
// Apply
|
// Apply
|
||||||
if (NavigationWidgetPlaceHolder::m_current) {
|
if (NavigationWidgetPlaceHolder::m_current) {
|
||||||
NavigationWidgetPlaceHolder::m_current->applyStoredSize(m_width);
|
NavigationWidgetPlaceHolder::m_current->applyStoredSize(d->m_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::closeSubWidgets()
|
void NavigationWidget::closeSubWidgets()
|
||||||
{
|
{
|
||||||
foreach (NavigationSubWidget *subWidget, m_subWidgets) {
|
foreach (Internal::NavigationSubWidget *subWidget, d->m_subWidgets) {
|
||||||
subWidget->saveSettings();
|
subWidget->saveSettings();
|
||||||
delete subWidget;
|
delete subWidget;
|
||||||
}
|
}
|
||||||
m_subWidgets.clear();
|
d->m_subWidgets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::setShown(bool b)
|
void NavigationWidget::setShown(bool b)
|
||||||
{
|
{
|
||||||
if (m_shown == b)
|
if (d->m_shown == b)
|
||||||
return;
|
return;
|
||||||
m_shown = b;
|
d->m_shown = b;
|
||||||
if (NavigationWidgetPlaceHolder::m_current) {
|
if (NavigationWidgetPlaceHolder::m_current) {
|
||||||
NavigationWidgetPlaceHolder::m_current->setVisible(m_shown && !m_suppressed);
|
NavigationWidgetPlaceHolder::m_current->setVisible(d->m_shown && !d->m_suppressed);
|
||||||
m_toggleSideBarAction->setChecked(m_shown);
|
d->m_toggleSideBarAction->setChecked(d->m_shown);
|
||||||
} else {
|
} else {
|
||||||
m_toggleSideBarAction->setChecked(false);
|
d->m_toggleSideBarAction->setChecked(false);
|
||||||
}
|
}
|
||||||
updateToggleText();
|
updateToggleText();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavigationWidget::isShown() const
|
bool NavigationWidget::isShown() const
|
||||||
{
|
{
|
||||||
return m_shown;
|
return d->m_shown;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NavigationWidget::isSuppressed() const
|
bool NavigationWidget::isSuppressed() const
|
||||||
{
|
{
|
||||||
return m_suppressed;
|
return d->m_suppressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::setSuppressed(bool b)
|
void NavigationWidget::setSuppressed(bool b)
|
||||||
{
|
{
|
||||||
if (m_suppressed == b)
|
if (d->m_suppressed == b)
|
||||||
return;
|
return;
|
||||||
m_suppressed = b;
|
d->m_suppressed = b;
|
||||||
if (NavigationWidgetPlaceHolder::m_current)
|
if (NavigationWidgetPlaceHolder::m_current)
|
||||||
NavigationWidgetPlaceHolder::m_current->setVisible(m_shown && !m_suppressed);
|
NavigationWidgetPlaceHolder::m_current->setVisible(d->m_shown && !d->m_suppressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
int NavigationWidget::factoryIndex(const QString &id)
|
int NavigationWidget::factoryIndex(const QString &id)
|
||||||
{
|
{
|
||||||
for (int row = 0; row < m_factoryModel->rowCount(); ++row) {
|
for (int row = 0; row < d->m_factoryModel->rowCount(); ++row) {
|
||||||
if (m_factoryModel->data(m_factoryModel->index(row, 0), FactoryIdRole).toString() == id) {
|
if (d->m_factoryModel->data(d->m_factoryModel->index(row, 0), FactoryIdRole).toString() == id) {
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
////
|
QHash<QString, Core::Command*> NavigationWidget::commandMap() const
|
||||||
// NavigationSubWidget
|
|
||||||
////
|
|
||||||
|
|
||||||
|
|
||||||
NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget, int position, int factoryIndex)
|
|
||||||
: m_parentWidget(parentWidget),
|
|
||||||
m_position(position)
|
|
||||||
{
|
{
|
||||||
m_navigationComboBox = new NavComboBox(this);
|
return d->m_commandMap;
|
||||||
m_navigationComboBox->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
|
||||||
m_navigationComboBox->setFocusPolicy(Qt::TabFocus);
|
|
||||||
m_navigationComboBox->setMinimumContentsLength(0);
|
|
||||||
m_navigationComboBox->setModel(parentWidget->factoryModel());
|
|
||||||
m_navigationWidget = 0;
|
|
||||||
m_navigationWidgetFactory = 0;
|
|
||||||
|
|
||||||
m_toolBar = new Utils::StyledBar(this);
|
|
||||||
QHBoxLayout *toolBarLayout = new QHBoxLayout;
|
|
||||||
toolBarLayout->setMargin(0);
|
|
||||||
toolBarLayout->setSpacing(0);
|
|
||||||
m_toolBar->setLayout(toolBarLayout);
|
|
||||||
toolBarLayout->addWidget(m_navigationComboBox);
|
|
||||||
|
|
||||||
QToolButton *splitAction = new QToolButton();
|
|
||||||
splitAction->setIcon(QIcon(QLatin1String(Constants::ICON_SPLIT_HORIZONTAL)));
|
|
||||||
splitAction->setToolTip(tr("Split"));
|
|
||||||
QToolButton *close = new QToolButton();
|
|
||||||
close->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE)));
|
|
||||||
close->setToolTip(tr("Close"));
|
|
||||||
|
|
||||||
toolBarLayout->addWidget(splitAction);
|
|
||||||
toolBarLayout->addWidget(close);
|
|
||||||
|
|
||||||
QVBoxLayout *lay = new QVBoxLayout();
|
|
||||||
lay->setMargin(0);
|
|
||||||
lay->setSpacing(0);
|
|
||||||
setLayout(lay);
|
|
||||||
lay->addWidget(m_toolBar);
|
|
||||||
|
|
||||||
connect(splitAction, SIGNAL(clicked()), this, SIGNAL(splitMe()));
|
|
||||||
connect(close, SIGNAL(clicked()), this, SIGNAL(closeMe()));
|
|
||||||
|
|
||||||
setFactoryIndex(factoryIndex);
|
|
||||||
|
|
||||||
connect(m_navigationComboBox, SIGNAL(currentIndexChanged(int)),
|
|
||||||
this, SLOT(comboBoxIndexChanged(int)));
|
|
||||||
|
|
||||||
comboBoxIndexChanged(factoryIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationSubWidget::~NavigationSubWidget()
|
} // namespace Core
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void NavigationSubWidget::comboBoxIndexChanged(int factoryIndex)
|
|
||||||
{
|
|
||||||
saveSettings();
|
|
||||||
|
|
||||||
// Remove toolbutton
|
|
||||||
foreach (QWidget *w, m_additionalToolBarWidgets)
|
|
||||||
delete w;
|
|
||||||
m_additionalToolBarWidgets.clear();
|
|
||||||
|
|
||||||
// Remove old Widget
|
|
||||||
delete m_navigationWidget;
|
|
||||||
m_navigationWidget = 0;
|
|
||||||
m_navigationWidgetFactory = 0;
|
|
||||||
if (factoryIndex == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Get new stuff
|
|
||||||
m_navigationWidgetFactory = m_navigationComboBox->itemData(factoryIndex,
|
|
||||||
NavigationWidget::FactoryObjectRole).value<INavigationWidgetFactory *>();
|
|
||||||
NavigationView n = m_navigationWidgetFactory->createWidget();
|
|
||||||
m_navigationWidget = n.widget;
|
|
||||||
layout()->addWidget(m_navigationWidget);
|
|
||||||
|
|
||||||
// Add Toolbutton
|
|
||||||
m_additionalToolBarWidgets = n.dockToolBarWidgets;
|
|
||||||
QHBoxLayout *layout = qobject_cast<QHBoxLayout *>(m_toolBar->layout());
|
|
||||||
foreach (QToolButton *w, m_additionalToolBarWidgets) {
|
|
||||||
layout->insertWidget(layout->count()-2, w);
|
|
||||||
}
|
|
||||||
|
|
||||||
restoreSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NavigationSubWidget::setFocusWidget()
|
|
||||||
{
|
|
||||||
if (m_navigationWidget)
|
|
||||||
m_navigationWidget->setFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
INavigationWidgetFactory *NavigationSubWidget::factory()
|
|
||||||
{
|
|
||||||
return m_navigationWidgetFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NavigationSubWidget::saveSettings()
|
|
||||||
{
|
|
||||||
if (!m_navigationWidget || !factory())
|
|
||||||
return;
|
|
||||||
factory()->saveSettings(position(), m_navigationWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NavigationSubWidget::restoreSettings()
|
|
||||||
{
|
|
||||||
if (!m_navigationWidget || !factory())
|
|
||||||
return;
|
|
||||||
factory()->restoreSettings(position(), m_navigationWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::Command *NavigationSubWidget::command(const QString &title) const
|
|
||||||
{
|
|
||||||
const QHash<QString, Core::Command*> commandMap = m_parentWidget->commandMap();
|
|
||||||
QHash<QString, Core::Command*>::const_iterator r = commandMap.find(title);
|
|
||||||
if (r != commandMap.end())
|
|
||||||
return r.value();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int NavigationSubWidget::factoryIndex() const
|
|
||||||
{
|
|
||||||
return m_navigationComboBox->currentIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NavigationSubWidget::setFactoryIndex(int i)
|
|
||||||
{
|
|
||||||
m_navigationComboBox->setCurrentIndex(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
int NavigationSubWidget::position() const
|
|
||||||
{
|
|
||||||
return m_position;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NavigationSubWidget::setPosition(int position)
|
|
||||||
{
|
|
||||||
m_position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
NavComboBox::NavComboBox(NavigationSubWidget *navSubWidget)
|
|
||||||
: m_navSubWidget(navSubWidget)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NavComboBox::event(QEvent *e)
|
|
||||||
{
|
|
||||||
if (e->type() == QEvent::ToolTip) {
|
|
||||||
QString txt = currentText();
|
|
||||||
Core::Command *cmd = m_navSubWidget->command(txt);
|
|
||||||
if (cmd) {
|
|
||||||
txt = tr("Activate %1").arg(txt);
|
|
||||||
setToolTip(cmd->stringWithAppendedShortcut(txt));
|
|
||||||
} else {
|
|
||||||
setToolTip(txt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QComboBox::event(e);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -32,24 +32,25 @@
|
|||||||
|
|
||||||
#include <coreplugin/minisplitter.h>
|
#include <coreplugin/minisplitter.h>
|
||||||
|
|
||||||
#include <QtGui/QComboBox>
|
#include <QtCore/QHash>
|
||||||
|
#include <QtCore/QScopedPointer>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSettings;
|
class QSettings;
|
||||||
class QShortcut;
|
class QShortcut;
|
||||||
class QToolButton;
|
class QAbstractItemModel;
|
||||||
class QStandardItemModel;
|
class QStandardItemModel;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils {
|
|
||||||
class StyledBar;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class INavigationWidgetFactory;
|
class INavigationWidgetFactory;
|
||||||
class IMode;
|
class IMode;
|
||||||
class Command;
|
class Command;
|
||||||
class NavigationWidget;
|
class NavigationWidget;
|
||||||
|
struct NavigationWidgetPrivate;
|
||||||
|
namespace Internal {
|
||||||
|
class NavigationSubWidget;
|
||||||
|
}
|
||||||
|
|
||||||
class CORE_EXPORT NavigationWidgetPlaceHolder : public QWidget
|
class CORE_EXPORT NavigationWidgetPlaceHolder : public QWidget
|
||||||
{
|
{
|
||||||
@@ -57,20 +58,18 @@ class CORE_EXPORT NavigationWidgetPlaceHolder : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit NavigationWidgetPlaceHolder(Core::IMode *mode, QWidget *parent = 0);
|
explicit NavigationWidgetPlaceHolder(Core::IMode *mode, QWidget *parent = 0);
|
||||||
~NavigationWidgetPlaceHolder();
|
virtual ~NavigationWidgetPlaceHolder();
|
||||||
static NavigationWidgetPlaceHolder* current();
|
static NavigationWidgetPlaceHolder* current();
|
||||||
void applyStoredSize(int width);
|
void applyStoredSize(int width);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void currentModeAboutToChange(Core::IMode *);
|
void currentModeAboutToChange(Core::IMode *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::IMode *m_mode;
|
Core::IMode *m_mode;
|
||||||
static NavigationWidgetPlaceHolder* m_current;
|
static NavigationWidgetPlaceHolder* m_current;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
class NavigationSubWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CORE_EXPORT NavigationWidget : public MiniSplitter
|
class CORE_EXPORT NavigationWidget : public MiniSplitter
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -81,9 +80,8 @@ public:
|
|||||||
FactoryPriorityRole
|
FactoryPriorityRole
|
||||||
};
|
};
|
||||||
|
|
||||||
|
explicit NavigationWidget(QAction *toggleSideBarAction);
|
||||||
NavigationWidget(QAction *toggleSideBarAction);
|
virtual ~NavigationWidget();
|
||||||
~NavigationWidget();
|
|
||||||
|
|
||||||
void setFactories(const QList<INavigationWidgetFactory*> factories);
|
void setFactories(const QList<INavigationWidgetFactory*> factories);
|
||||||
|
|
||||||
@@ -106,7 +104,7 @@ public:
|
|||||||
// Called from the place holders
|
// Called from the place holders
|
||||||
void placeHolderChanged(NavigationWidgetPlaceHolder *holder);
|
void placeHolderChanged(NavigationWidgetPlaceHolder *holder);
|
||||||
|
|
||||||
QHash<QString, Core::Command*> commandMap() const { return m_commandMap; }
|
QHash<QString, Core::Command*> commandMap() const;
|
||||||
QAbstractItemModel *factoryModel() const;
|
QAbstractItemModel *factoryModel() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -122,74 +120,9 @@ private:
|
|||||||
Internal::NavigationSubWidget *insertSubItem(int position, int index);
|
Internal::NavigationSubWidget *insertSubItem(int position, int index);
|
||||||
int factoryIndex(const QString &id);
|
int factoryIndex(const QString &id);
|
||||||
|
|
||||||
QList<Internal::NavigationSubWidget *> m_subWidgets;
|
QScopedPointer<NavigationWidgetPrivate> d;
|
||||||
QHash<QShortcut *, QString> m_shortcutMap;
|
|
||||||
QHash<QString, Core::Command*> m_commandMap;
|
|
||||||
QStandardItemModel *m_factoryModel;
|
|
||||||
|
|
||||||
bool m_shown;
|
|
||||||
bool m_suppressed;
|
|
||||||
int m_width;
|
|
||||||
static NavigationWidget* m_instance;
|
|
||||||
QAction *m_toggleSideBarAction;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class NavigationSubWidget : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
NavigationSubWidget(NavigationWidget *parentWidget, int position, int index);
|
|
||||||
virtual ~NavigationSubWidget();
|
|
||||||
|
|
||||||
INavigationWidgetFactory *factory();
|
|
||||||
|
|
||||||
int factoryIndex() const;
|
|
||||||
void setFactoryIndex(int i);
|
|
||||||
|
|
||||||
void setFocusWidget();
|
|
||||||
|
|
||||||
int position() const;
|
|
||||||
void setPosition(int i);
|
|
||||||
|
|
||||||
void saveSettings();
|
|
||||||
void restoreSettings();
|
|
||||||
|
|
||||||
Core::Command *command(const QString &title) const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void splitMe();
|
|
||||||
void closeMe();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void comboBoxIndexChanged(int);
|
|
||||||
|
|
||||||
private:
|
|
||||||
NavigationWidget *m_parentWidget;
|
|
||||||
QComboBox *m_navigationComboBox;
|
|
||||||
QWidget *m_navigationWidget;
|
|
||||||
INavigationWidgetFactory *m_navigationWidgetFactory;
|
|
||||||
Utils::StyledBar *m_toolBar;
|
|
||||||
QList<QToolButton *> m_additionalToolBarWidgets;
|
|
||||||
int m_position;
|
|
||||||
};
|
|
||||||
|
|
||||||
class NavComboBox : public QComboBox
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
NavComboBox(NavigationSubWidget *navSubWidget);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool event(QEvent *event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
NavigationSubWidget *m_navSubWidget;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
#endif // NAVIGATIONWIDGET_H
|
#endif // NAVIGATIONWIDGET_H
|
||||||
|
|||||||
@@ -28,47 +28,37 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "outputpane.h"
|
#include "outputpane.h"
|
||||||
|
#include "outputpanemanager.h"
|
||||||
|
|
||||||
#include "coreconstants.h"
|
#include "coreconstants.h"
|
||||||
#include "icore.h"
|
#include "icore.h"
|
||||||
#include "ioutputpane.h"
|
#include "ioutputpane.h"
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "modemanager.h"
|
#include "modemanager.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
||||||
#include <coreplugin/actionmanager/command.h>
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
|
||||||
#include <coreplugin/findplaceholder.h>
|
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
|
|
||||||
#include <utils/styledbar.h>
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
|
||||||
|
|
||||||
#include <QtGui/QAction>
|
|
||||||
#include <QtGui/QApplication>
|
|
||||||
#include <QtGui/QComboBox>
|
|
||||||
#include <QtGui/QFocusEvent>
|
|
||||||
#include <QtGui/QHBoxLayout>
|
|
||||||
#include <QtGui/QSplitter>
|
#include <QtGui/QSplitter>
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QVBoxLayout>
|
||||||
#include <QtGui/QToolButton>
|
|
||||||
#include <QtGui/QStackedWidget>
|
|
||||||
#include <QtGui/QMenu>
|
|
||||||
|
|
||||||
using namespace Core;
|
namespace Core {
|
||||||
using namespace Core::Internal;
|
|
||||||
|
|
||||||
OutputPanePlaceHolder *OutputPanePlaceHolder::m_current = 0;
|
struct OutputPanePlaceHolderPrivate {
|
||||||
|
explicit OutputPanePlaceHolderPrivate(Core::IMode *mode, QSplitter *parent);
|
||||||
|
|
||||||
|
Core::IMode *m_mode;
|
||||||
|
QSplitter *m_splitter;
|
||||||
|
bool m_closeable;
|
||||||
|
static OutputPanePlaceHolder* m_current;
|
||||||
|
};
|
||||||
|
|
||||||
|
OutputPanePlaceHolderPrivate::OutputPanePlaceHolderPrivate(Core::IMode *mode, QSplitter *parent) :
|
||||||
|
m_mode(mode), m_splitter(parent), m_closeable(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputPanePlaceHolder *OutputPanePlaceHolderPrivate::m_current = 0;
|
||||||
|
|
||||||
OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QSplitter* parent)
|
OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QSplitter* parent)
|
||||||
: QWidget(parent), m_mode(mode), m_closeable(true)
|
: QWidget(parent), d(new OutputPanePlaceHolderPrivate(mode, parent))
|
||||||
{
|
{
|
||||||
m_splitter = parent;
|
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
setLayout(new QVBoxLayout);
|
setLayout(new QVBoxLayout);
|
||||||
QSizePolicy sp;
|
QSizePolicy sp;
|
||||||
@@ -83,48 +73,50 @@ OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QSplitter* paren
|
|||||||
|
|
||||||
OutputPanePlaceHolder::~OutputPanePlaceHolder()
|
OutputPanePlaceHolder::~OutputPanePlaceHolder()
|
||||||
{
|
{
|
||||||
if (m_current == this) {
|
if (d->m_current == this) {
|
||||||
OutputPaneManager::instance()->setParent(0);
|
Internal::OutputPaneManager::instance()->setParent(0);
|
||||||
OutputPaneManager::instance()->hide();
|
Internal::OutputPaneManager::instance()->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPanePlaceHolder::setCloseable(bool b)
|
void OutputPanePlaceHolder::setCloseable(bool b)
|
||||||
{
|
{
|
||||||
m_closeable = b;
|
d->m_closeable = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OutputPanePlaceHolder::closeable()
|
bool OutputPanePlaceHolder::closeable()
|
||||||
{
|
{
|
||||||
return m_closeable;
|
return d->m_closeable;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPanePlaceHolder::currentModeChanged(Core::IMode *mode)
|
void OutputPanePlaceHolder::currentModeChanged(Core::IMode *mode)
|
||||||
{
|
{
|
||||||
if (m_current == this) {
|
if (d->m_current == this) {
|
||||||
m_current = 0;
|
d->m_current = 0;
|
||||||
OutputPaneManager::instance()->setParent(0);
|
Internal::OutputPaneManager *om = Internal::OutputPaneManager::instance();
|
||||||
OutputPaneManager::instance()->hide();
|
om->setParent(0);
|
||||||
OutputPaneManager::instance()->updateStatusButtons(false);
|
om->hide();
|
||||||
|
om->updateStatusButtons(false);
|
||||||
}
|
}
|
||||||
if (m_mode == mode) {
|
if (d->m_mode == mode) {
|
||||||
m_current = this;
|
d->m_current = this;
|
||||||
layout()->addWidget(OutputPaneManager::instance());
|
Internal::OutputPaneManager *om = Internal::OutputPaneManager::instance();
|
||||||
OutputPaneManager::instance()->show();
|
layout()->addWidget(om);
|
||||||
OutputPaneManager::instance()->updateStatusButtons(isVisible());
|
om->show();
|
||||||
OutputPaneManager::instance()->setCloseable(m_closeable);
|
om->updateStatusButtons(isVisible());
|
||||||
|
om->setCloseable(d->m_closeable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPanePlaceHolder::maximizeOrMinimize(bool maximize)
|
void OutputPanePlaceHolder::maximizeOrMinimize(bool maximize)
|
||||||
{
|
{
|
||||||
if (!m_splitter)
|
if (!d->m_splitter)
|
||||||
return;
|
return;
|
||||||
int idx = m_splitter->indexOf(this);
|
int idx = d->m_splitter->indexOf(this);
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QList<int> sizes = m_splitter->sizes();
|
QList<int> sizes = d->m_splitter->sizes();
|
||||||
|
|
||||||
if (maximize) {
|
if (maximize) {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
@@ -145,537 +137,36 @@ void OutputPanePlaceHolder::maximizeOrMinimize(bool maximize)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_splitter->setSizes(sizes);
|
d->m_splitter->setSizes(sizes);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OutputPanePlaceHolder::isMaximized() const
|
bool OutputPanePlaceHolder::isMaximized() const
|
||||||
{
|
{
|
||||||
return OutputPaneManager::instance()->isMaximized();
|
return Internal::OutputPaneManager::instance()->isMaximized();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPanePlaceHolder::unmaximize()
|
void OutputPanePlaceHolder::unmaximize()
|
||||||
{
|
{
|
||||||
if (OutputPaneManager::instance()->isMaximized())
|
if (Internal::OutputPaneManager::instance()->isMaximized())
|
||||||
OutputPaneManager::instance()->slotMinMax();
|
Internal::OutputPaneManager::instance()->slotMinMax();
|
||||||
}
|
}
|
||||||
|
|
||||||
////
|
OutputPanePlaceHolder *OutputPanePlaceHolder::getCurrent()
|
||||||
// OutputPaneManager
|
|
||||||
////
|
|
||||||
|
|
||||||
static OutputPaneManager *m_instance = 0;
|
|
||||||
|
|
||||||
void OutputPaneManager::create()
|
|
||||||
{
|
{
|
||||||
m_instance = new OutputPaneManager;
|
return OutputPanePlaceHolderPrivate::m_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPaneManager::destroy()
|
bool OutputPanePlaceHolder::canMaximizeOrMinimize() const
|
||||||
{
|
{
|
||||||
delete m_instance;
|
return d->m_splitter != 0;
|
||||||
m_instance = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputPaneManager *OutputPaneManager::instance()
|
bool OutputPanePlaceHolder::isCurrentVisible()
|
||||||
{
|
{
|
||||||
return m_instance;
|
return OutputPanePlaceHolderPrivate::m_current && OutputPanePlaceHolderPrivate::m_current->isVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputPaneManager::updateStatusButtons(bool visible)
|
} // namespace Core
|
||||||
{
|
|
||||||
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
|
||||||
if (m_buttons.value(idx))
|
|
||||||
m_buttons.value(idx)->setChecked(visible);
|
|
||||||
m_minMaxAction->setVisible(OutputPanePlaceHolder::m_current
|
|
||||||
&& OutputPanePlaceHolder::m_current->canMaximizeOrMinimize());
|
|
||||||
}
|
|
||||||
|
|
||||||
OutputPaneManager::OutputPaneManager(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
m_widgetComboBox(new QComboBox),
|
|
||||||
m_clearButton(new QToolButton),
|
|
||||||
m_closeButton(new QToolButton),
|
|
||||||
m_minMaxAction(0),
|
|
||||||
m_minMaxButton(new QToolButton),
|
|
||||||
m_nextAction(0),
|
|
||||||
m_prevAction(0),
|
|
||||||
m_lastIndex(-1),
|
|
||||||
m_outputWidgetPane(new QStackedWidget),
|
|
||||||
m_opToolBarWidgets(new QStackedWidget),
|
|
||||||
m_minimizeIcon(":/core/images/arrowdown.png"),
|
|
||||||
m_maximizeIcon(":/core/images/arrowup.png"),
|
|
||||||
m_maximised(false)
|
|
||||||
{
|
|
||||||
setWindowTitle(tr("Output"));
|
|
||||||
connect(m_widgetComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changePage()));
|
|
||||||
|
|
||||||
m_clearButton->setIcon(QIcon(QLatin1String(Constants::ICON_CLEAN_PANE)));
|
|
||||||
m_clearButton->setToolTip(tr("Clear"));
|
|
||||||
connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clearPage()));
|
|
||||||
|
|
||||||
m_nextAction = new QAction(this);
|
|
||||||
m_nextAction->setIcon(QIcon(QLatin1String(Constants::ICON_NEXT)));
|
|
||||||
m_nextAction->setText(tr("Next Item"));
|
|
||||||
connect(m_nextAction, SIGNAL(triggered()), this, SLOT(slotNext()));
|
|
||||||
|
|
||||||
m_prevAction = new QAction(this);
|
|
||||||
m_prevAction->setIcon(QIcon(QLatin1String(Constants::ICON_PREV)));
|
|
||||||
m_prevAction->setText(tr("Previous Item"));
|
|
||||||
connect(m_prevAction, SIGNAL(triggered()), this, SLOT(slotPrev()));
|
|
||||||
|
|
||||||
m_minMaxAction = new QAction(this);
|
|
||||||
m_minMaxAction->setIcon(m_maximizeIcon);
|
|
||||||
m_minMaxAction->setText(tr("Maximize Output Pane"));
|
|
||||||
|
|
||||||
m_closeButton->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE)));
|
|
||||||
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(slotHide()));
|
|
||||||
|
|
||||||
QVBoxLayout *mainlayout = new QVBoxLayout;
|
|
||||||
mainlayout->setSpacing(0);
|
|
||||||
mainlayout->setMargin(0);
|
|
||||||
m_toolBar = new Utils::StyledBar;
|
|
||||||
QHBoxLayout *toolLayout = new QHBoxLayout(m_toolBar);
|
|
||||||
toolLayout->setMargin(0);
|
|
||||||
toolLayout->setSpacing(0);
|
|
||||||
toolLayout->addWidget(m_widgetComboBox);
|
|
||||||
toolLayout->addWidget(m_clearButton);
|
|
||||||
m_prevToolButton = new QToolButton;
|
|
||||||
toolLayout->addWidget(m_prevToolButton);
|
|
||||||
m_nextToolButton = new QToolButton;
|
|
||||||
toolLayout->addWidget(m_nextToolButton);
|
|
||||||
toolLayout->addWidget(m_opToolBarWidgets);
|
|
||||||
toolLayout->addWidget(m_minMaxButton);
|
|
||||||
toolLayout->addWidget(m_closeButton);
|
|
||||||
mainlayout->addWidget(m_toolBar);
|
|
||||||
mainlayout->addWidget(m_outputWidgetPane, 10);
|
|
||||||
mainlayout->addWidget(new Core::FindToolBarPlaceHolder(this));
|
|
||||||
setLayout(mainlayout);
|
|
||||||
|
|
||||||
m_buttonsWidget = new QWidget;
|
|
||||||
m_buttonsWidget->setLayout(new QHBoxLayout);
|
|
||||||
m_buttonsWidget->layout()->setContentsMargins(5,0,0,0);
|
|
||||||
m_buttonsWidget->layout()->setSpacing(4);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
OutputPaneManager::~OutputPaneManager()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *OutputPaneManager::buttonsWidget()
|
|
||||||
{
|
|
||||||
return m_buttonsWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return shortcut as Ctrl+<number>
|
|
||||||
static inline int paneShortCut(int number)
|
|
||||||
{
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
int modifier = Qt::CTRL;
|
|
||||||
#else
|
|
||||||
int modifier = Qt::ALT;
|
|
||||||
#endif
|
|
||||||
return modifier | (Qt::Key_0 + number);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::init()
|
|
||||||
{
|
|
||||||
ActionManager *am = Core::ICore::instance()->actionManager();
|
|
||||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
|
||||||
const Context globalcontext(Core::Constants::C_GLOBAL);
|
|
||||||
|
|
||||||
// Window->Output Panes
|
|
||||||
ActionContainer *mpanes = am->createMenu(Constants::M_WINDOW_PANES);
|
|
||||||
mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
|
|
||||||
mpanes->menu()->setTitle(tr("Output &Panes"));
|
|
||||||
mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
|
|
||||||
mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup");
|
|
||||||
|
|
||||||
Core::Command *cmd;
|
|
||||||
|
|
||||||
cmd = am->registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalcontext);
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence("Shift+F6"));
|
|
||||||
m_prevToolButton->setDefaultAction(cmd->action());
|
|
||||||
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
|
||||||
|
|
||||||
cmd = am->registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalcontext);
|
|
||||||
m_nextToolButton->setDefaultAction(cmd->action());
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence("F6"));
|
|
||||||
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
|
||||||
|
|
||||||
cmd = am->registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalcontext);
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence("Ctrl+9"));
|
|
||||||
#else
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence("Alt+9"));
|
|
||||||
#endif
|
|
||||||
cmd->setAttribute(Command::CA_UpdateText);
|
|
||||||
cmd->setAttribute(Command::CA_UpdateIcon);
|
|
||||||
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
|
||||||
connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
|
|
||||||
m_minMaxButton->setDefaultAction(cmd->action());
|
|
||||||
|
|
||||||
QAction *sep = new QAction(this);
|
|
||||||
sep->setSeparator(true);
|
|
||||||
cmd = am->registerAction(sep, "Coreplugin.OutputPane.Sep", globalcontext);
|
|
||||||
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
|
||||||
|
|
||||||
QList<IOutputPane*> panes = ExtensionSystem::PluginManager::instance()
|
|
||||||
->getObjects<IOutputPane>();
|
|
||||||
QMultiMap<int, IOutputPane*> sorted;
|
|
||||||
foreach (IOutputPane* outPane, panes)
|
|
||||||
sorted.insertMulti(outPane->priorityInStatusBar(), outPane);
|
|
||||||
|
|
||||||
QMultiMap<int, IOutputPane*>::const_iterator it, begin;
|
|
||||||
begin = sorted.constBegin();
|
|
||||||
it = sorted.constEnd();
|
|
||||||
int shortcutNumber = 1;
|
|
||||||
do {
|
|
||||||
--it;
|
|
||||||
IOutputPane* outPane = it.value();
|
|
||||||
const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));
|
|
||||||
|
|
||||||
m_pageMap.insert(idx, outPane);
|
|
||||||
connect(outPane, SIGNAL(showPage(bool)), this, SLOT(showPage(bool)));
|
|
||||||
connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide()));
|
|
||||||
connect(outPane, SIGNAL(togglePage(bool)), this, SLOT(togglePage(bool)));
|
|
||||||
connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState()));
|
|
||||||
|
|
||||||
QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets);
|
|
||||||
QHBoxLayout *toolButtonsLayout = new QHBoxLayout;
|
|
||||||
toolButtonsLayout->setMargin(0);
|
|
||||||
toolButtonsLayout->setSpacing(0);
|
|
||||||
foreach (QWidget *toolButton, outPane->toolBarWidgets())
|
|
||||||
toolButtonsLayout->addWidget(toolButton);
|
|
||||||
toolButtonsLayout->addStretch(5);
|
|
||||||
toolButtonsContainer->setLayout(toolButtonsLayout);
|
|
||||||
|
|
||||||
m_opToolBarWidgets->addWidget(toolButtonsContainer);
|
|
||||||
|
|
||||||
QString actionId = QString("QtCreator.Pane.%1").arg(outPane->displayName().simplified());
|
|
||||||
actionId.remove(QLatin1Char(' '));
|
|
||||||
QAction *action = new QAction(outPane->displayName(), this);
|
|
||||||
|
|
||||||
Command *cmd = am->registerAction(action, actionId, Context(Constants::C_GLOBAL));
|
|
||||||
|
|
||||||
mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
|
|
||||||
m_actions.insert(cmd->action(), idx);
|
|
||||||
|
|
||||||
if (outPane->priorityInStatusBar() != -1) {
|
|
||||||
cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber)));
|
|
||||||
QPushButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(),
|
|
||||||
cmd->action());
|
|
||||||
++shortcutNumber;
|
|
||||||
m_buttonsWidget->layout()->addWidget(button);
|
|
||||||
connect(button, SIGNAL(clicked()), this, SLOT(buttonTriggered()));
|
|
||||||
m_buttons.insert(idx, button);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now add the entry to the combobox, since the first item we add sets the currentIndex, thus we need to be set up for that
|
|
||||||
m_widgetComboBox->addItem(outPane->displayName(), idx);
|
|
||||||
|
|
||||||
connect(cmd->action(), SIGNAL(triggered()), this, SLOT(shortcutTriggered()));
|
|
||||||
} while (it != begin);
|
|
||||||
|
|
||||||
changePage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::shortcutTriggered()
|
|
||||||
{
|
|
||||||
QAction *action = qobject_cast<QAction*>(sender());
|
|
||||||
if (action && m_actions.contains(action)) {
|
|
||||||
int idx = m_actions.value(action);
|
|
||||||
Core::IOutputPane *outputPane = m_pageMap.value(idx);
|
|
||||||
// Now check the special case, the output window is already visible,
|
|
||||||
// we are already on that page
|
|
||||||
// but the outputpane doesn't have focus
|
|
||||||
// then just give it focus
|
|
||||||
// else do the same as clicking on the button does
|
|
||||||
if (OutputPanePlaceHolder::m_current
|
|
||||||
&& OutputPanePlaceHolder::m_current->isVisible()
|
|
||||||
&& m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx) {
|
|
||||||
if (!outputPane->hasFocus() && outputPane->canFocus())
|
|
||||||
outputPane->setFocus();
|
|
||||||
else
|
|
||||||
slotHide();
|
|
||||||
} else {
|
|
||||||
outputPane->popup(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OutputPaneManager::isMaximized()const
|
|
||||||
{
|
|
||||||
return m_maximised;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::slotMinMax()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(OutputPanePlaceHolder::m_current, return);
|
|
||||||
|
|
||||||
if (!OutputPanePlaceHolder::m_current->isVisible()) // easier than disabling/enabling the action
|
|
||||||
return;
|
|
||||||
m_maximised = !m_maximised;
|
|
||||||
OutputPanePlaceHolder::m_current->maximizeOrMinimize(m_maximised);
|
|
||||||
m_minMaxAction->setIcon(m_maximised ? m_minimizeIcon : m_maximizeIcon);
|
|
||||||
m_minMaxAction->setText(m_maximised ? tr("Minimize Output Pane")
|
|
||||||
: tr("Maximize Output Pane"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::buttonTriggered()
|
|
||||||
{
|
|
||||||
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
|
||||||
QMap<int, QPushButton *>::const_iterator it, end;
|
|
||||||
end = m_buttons.constEnd();
|
|
||||||
for (it = m_buttons.begin(); it != end; ++it) {
|
|
||||||
if (it.value() == button)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
int idx = it.key();
|
|
||||||
|
|
||||||
if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx &&
|
|
||||||
OutputPanePlaceHolder::m_current &&
|
|
||||||
OutputPanePlaceHolder::m_current->isVisible() &&
|
|
||||||
OutputPanePlaceHolder::m_current->closeable()) {
|
|
||||||
// we should toggle and the page is already visible and we are actually closeable
|
|
||||||
slotHide();
|
|
||||||
} else {
|
|
||||||
showPage(idx, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::slotNext()
|
|
||||||
{
|
|
||||||
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
|
||||||
ensurePageVisible(idx);
|
|
||||||
IOutputPane *out = m_pageMap.value(idx);
|
|
||||||
if (out->canNext())
|
|
||||||
out->goToNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::slotPrev()
|
|
||||||
{
|
|
||||||
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
|
||||||
ensurePageVisible(idx);
|
|
||||||
IOutputPane *out = m_pageMap.value(idx);
|
|
||||||
if (out->canPrevious())
|
|
||||||
out->goToPrev();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::slotHide()
|
|
||||||
{
|
|
||||||
if (OutputPanePlaceHolder::m_current) {
|
|
||||||
OutputPanePlaceHolder::m_current->setVisible(false);
|
|
||||||
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
|
||||||
if (m_buttons.value(idx))
|
|
||||||
m_buttons.value(idx)->setChecked(false);
|
|
||||||
if (IEditor *editor = Core::EditorManager::instance()->currentEditor())
|
|
||||||
editor->widget()->setFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int OutputPaneManager::findIndexForPage(IOutputPane *out)
|
|
||||||
{
|
|
||||||
if (!out)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
int stackIndex = -1;
|
|
||||||
QMap<int, IOutputPane*>::const_iterator it = m_pageMap.constBegin();
|
|
||||||
while (it != m_pageMap.constEnd()) {
|
|
||||||
if (it.value() == out) {
|
|
||||||
stackIndex = it.key();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
if (stackIndex > -1)
|
|
||||||
return m_widgetComboBox->findData(stackIndex);
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::ensurePageVisible(int idx)
|
|
||||||
{
|
|
||||||
if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() != idx) {
|
|
||||||
m_widgetComboBox->setCurrentIndex(m_widgetComboBox->findData(idx));
|
|
||||||
} else {
|
|
||||||
changePage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::updateNavigateState()
|
|
||||||
{
|
|
||||||
IOutputPane* pane = qobject_cast<IOutputPane*>(sender());
|
|
||||||
int idx = findIndexForPage(pane);
|
|
||||||
if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx) {
|
|
||||||
m_prevAction->setEnabled(pane->canNavigate() && pane->canPrevious());
|
|
||||||
m_nextAction->setEnabled(pane->canNavigate() && pane->canNext());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Slot connected to showPage signal of each page
|
|
||||||
void OutputPaneManager::showPage(bool focus)
|
|
||||||
{
|
|
||||||
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
|
|
||||||
showPage(idx, focus);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::showPage(int idx, bool focus)
|
|
||||||
{
|
|
||||||
IOutputPane *out = m_pageMap.value(idx);
|
|
||||||
if (idx > -1) {
|
|
||||||
if (!OutputPanePlaceHolder::m_current) {
|
|
||||||
// In this mode we don't have a placeholder
|
|
||||||
// switch to the output mode and switch the page
|
|
||||||
ICore::instance()->modeManager()->activateMode(Constants::MODE_EDIT);
|
|
||||||
}
|
|
||||||
if (OutputPanePlaceHolder::m_current) {
|
|
||||||
// make the page visible
|
|
||||||
OutputPanePlaceHolder::m_current->setVisible(true);
|
|
||||||
ensurePageVisible(idx);
|
|
||||||
if (focus && out->canFocus())
|
|
||||||
out->setFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::togglePage(bool focus)
|
|
||||||
{
|
|
||||||
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
|
|
||||||
if (OutputPanePlaceHolder::m_current
|
|
||||||
&& OutputPanePlaceHolder::m_current->isVisible()
|
|
||||||
&& m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx) {
|
|
||||||
slotHide();
|
|
||||||
} else {
|
|
||||||
showPage(idx, focus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::setCloseable(bool b)
|
|
||||||
{
|
|
||||||
m_closeButton->setVisible(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OutputPaneManager::closeable()
|
|
||||||
{
|
|
||||||
return m_closeButton->isVisibleTo(m_closeButton->parentWidget());
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::focusInEvent(QFocusEvent *e)
|
|
||||||
{
|
|
||||||
if (m_outputWidgetPane->currentWidget())
|
|
||||||
m_outputWidgetPane->currentWidget()->setFocus(e->reason());
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::changePage()
|
|
||||||
{
|
|
||||||
if (m_outputWidgetPane->count() <= 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!m_pageMap.contains(m_lastIndex)) {
|
|
||||||
int idx = m_outputWidgetPane->currentIndex();
|
|
||||||
m_pageMap.value(idx)->visibilityChanged(true);
|
|
||||||
if (m_buttons.value(idx)) {
|
|
||||||
if (OutputPanePlaceHolder::m_current)
|
|
||||||
m_buttons.value(idx)->setChecked(OutputPanePlaceHolder::m_current->isVisible());
|
|
||||||
else
|
|
||||||
m_buttons.value(idx)->setChecked(false);
|
|
||||||
}
|
|
||||||
m_lastIndex = idx;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
|
||||||
if (m_lastIndex != idx) {
|
|
||||||
m_outputWidgetPane->setCurrentIndex(idx);
|
|
||||||
m_opToolBarWidgets->setCurrentIndex(idx);
|
|
||||||
m_pageMap.value(idx)->visibilityChanged(true);
|
|
||||||
m_pageMap.value(m_lastIndex)->visibilityChanged(false);
|
|
||||||
|
|
||||||
bool canNavigate = m_pageMap.value(idx)->canNavigate();
|
|
||||||
m_prevAction->setEnabled(canNavigate && m_pageMap.value(idx)->canPrevious());
|
|
||||||
m_nextAction->setEnabled(canNavigate && m_pageMap.value(idx)->canNext());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_buttons.value(m_lastIndex))
|
|
||||||
m_buttons.value(m_lastIndex)->setChecked(false);
|
|
||||||
|
|
||||||
if (m_buttons.value(idx)) {
|
|
||||||
if (OutputPanePlaceHolder::m_current)
|
|
||||||
m_buttons.value(idx)->setChecked(OutputPanePlaceHolder::m_current->isVisible());
|
|
||||||
else
|
|
||||||
m_buttons.value(idx)->setChecked(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_lastIndex = idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneManager::clearPage()
|
|
||||||
{
|
|
||||||
if (m_pageMap.contains(m_outputWidgetPane->currentIndex()))
|
|
||||||
m_pageMap.value(m_outputWidgetPane->currentIndex())->clearContents();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
OutputPaneToggleButton::OutputPaneToggleButton(int number, const QString &text,
|
|
||||||
QAction *action, QWidget *parent)
|
|
||||||
: QPushButton(parent)
|
|
||||||
, m_number(QString::number(number))
|
|
||||||
, m_text(text)
|
|
||||||
, m_action(action)
|
|
||||||
{
|
|
||||||
setFocusPolicy(Qt::NoFocus);
|
|
||||||
setCheckable(true);
|
|
||||||
setStyleSheet(
|
|
||||||
"QPushButton { border-image: url(:/core/images/panel_button.png) 2 2 2 19;"
|
|
||||||
" border-width: 2px 2px 2px 19px; padding-left: -17; padding-right: 4 } "
|
|
||||||
"QPushButton:checked { border-image: url(:/core/images/panel_button_checked.png) 2 2 2 19 } "
|
|
||||||
"QPushButton::menu-indicator { width:0; height:0 }"
|
|
||||||
#ifndef Q_WS_MAC // Mac UIs usually don't hover
|
|
||||||
"QPushButton:checked:hover { border-image: url(:/core/images/panel_button_checked_hover.png) 2 2 2 19 } "
|
|
||||||
"QPushButton:pressed:hover { border-image: url(:/core/images/panel_button_pressed.png) 2 2 2 19 } "
|
|
||||||
"QPushButton:hover { border-image: url(:/core/images/panel_button_hover.png) 2 2 2 19 } "
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
if (m_action)
|
|
||||||
connect(m_action, SIGNAL(changed()), this, SLOT(updateToolTip()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneToggleButton::updateToolTip()
|
|
||||||
{
|
|
||||||
Q_ASSERT(m_action);
|
|
||||||
setToolTip(m_action->toolTip());
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize OutputPaneToggleButton::sizeHint() const
|
|
||||||
{
|
|
||||||
ensurePolished();
|
|
||||||
|
|
||||||
QSize s = fontMetrics().size(Qt::TextSingleLine, m_text);
|
|
||||||
|
|
||||||
// Expand to account for border image set by stylesheet above
|
|
||||||
s.rwidth() += 19 + 5 + 2;
|
|
||||||
s.rheight() += 2 + 2;
|
|
||||||
|
|
||||||
return s.expandedTo(QApplication::globalStrut());
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputPaneToggleButton::paintEvent(QPaintEvent *event)
|
|
||||||
{
|
|
||||||
// For drawing the style sheet stuff
|
|
||||||
QPushButton::paintEvent(event);
|
|
||||||
|
|
||||||
const QFontMetrics fm = fontMetrics();
|
|
||||||
const int baseLine = (height() - fm.height() + 1) / 2 + fm.ascent();
|
|
||||||
const int numberWidth = fm.width(m_number);
|
|
||||||
|
|
||||||
QPainter p(this);
|
|
||||||
p.setFont(font());
|
|
||||||
p.setPen(Qt::white);
|
|
||||||
p.drawText((20 - numberWidth) / 2, baseLine, m_number);
|
|
||||||
if (!isChecked())
|
|
||||||
p.setPen(Qt::black);
|
|
||||||
int leftPart = 22;
|
|
||||||
p.drawText(leftPart, baseLine, fm.elidedText(m_text, Qt::ElideRight, width() - leftPart - 1));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -32,28 +32,22 @@
|
|||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
|
||||||
#include <QtGui/QPushButton>
|
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
|
#include <QtCore/QScopedPointer>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAction;
|
|
||||||
class QComboBox;
|
|
||||||
class QToolButton;
|
|
||||||
class QStackedWidget;
|
|
||||||
class QSplitter;
|
class QSplitter;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class IMode;
|
class IMode;
|
||||||
class IOutputPane;
|
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class OutputPaneManager;
|
class OutputPaneManager;
|
||||||
class MainWindow;
|
|
||||||
}
|
}
|
||||||
|
struct OutputPanePlaceHolderPrivate;
|
||||||
|
|
||||||
class CORE_EXPORT OutputPanePlaceHolder : public QWidget
|
class CORE_EXPORT OutputPanePlaceHolder : public QWidget
|
||||||
{
|
{
|
||||||
@@ -62,116 +56,25 @@ class CORE_EXPORT OutputPanePlaceHolder : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit OutputPanePlaceHolder(Core::IMode *mode, QSplitter *parent = 0);
|
explicit OutputPanePlaceHolder(Core::IMode *mode, QSplitter *parent = 0);
|
||||||
~OutputPanePlaceHolder();
|
~OutputPanePlaceHolder();
|
||||||
|
|
||||||
void setCloseable(bool b);
|
void setCloseable(bool b);
|
||||||
bool closeable();
|
bool closeable();
|
||||||
static OutputPanePlaceHolder *getCurrent() { return m_current; }
|
static OutputPanePlaceHolder *getCurrent();
|
||||||
|
static bool isCurrentVisible();
|
||||||
|
|
||||||
void unmaximize();
|
void unmaximize();
|
||||||
bool isMaximized() const;
|
bool isMaximized() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void currentModeChanged(Core::IMode *);
|
void currentModeChanged(Core::IMode *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline bool canMaximizeOrMinimize() const { return m_splitter != 0; }
|
bool canMaximizeOrMinimize() const;
|
||||||
void maximizeOrMinimize(bool maximize);
|
void maximizeOrMinimize(bool maximize);
|
||||||
Core::IMode *m_mode;
|
|
||||||
QSplitter *m_splitter;
|
QScopedPointer<OutputPanePlaceHolderPrivate> d;
|
||||||
bool m_closeable;
|
|
||||||
static OutputPanePlaceHolder* m_current;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class OutputPaneManager : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
void init();
|
|
||||||
static OutputPaneManager *instance();
|
|
||||||
void setCloseable(bool b);
|
|
||||||
bool closeable();
|
|
||||||
QWidget *buttonsWidget();
|
|
||||||
void updateStatusButtons(bool visible);
|
|
||||||
|
|
||||||
bool isMaximized()const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void slotHide();
|
|
||||||
void slotNext();
|
|
||||||
void slotPrev();
|
|
||||||
void shortcutTriggered();
|
|
||||||
void slotMinMax();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void focusInEvent(QFocusEvent *e);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void changePage();
|
|
||||||
void showPage(bool focus);
|
|
||||||
void togglePage(bool focus);
|
|
||||||
void clearPage();
|
|
||||||
void buttonTriggered();
|
|
||||||
void updateNavigateState();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// the only class that is allowed to create and destroy
|
|
||||||
friend class MainWindow;
|
|
||||||
|
|
||||||
static void create();
|
|
||||||
static void destroy();
|
|
||||||
|
|
||||||
OutputPaneManager(QWidget *parent = 0);
|
|
||||||
~OutputPaneManager();
|
|
||||||
|
|
||||||
void showPage(int idx, bool focus);
|
|
||||||
void ensurePageVisible(int idx);
|
|
||||||
int findIndexForPage(IOutputPane *out);
|
|
||||||
QComboBox *m_widgetComboBox;
|
|
||||||
QToolButton *m_clearButton;
|
|
||||||
QToolButton *m_closeButton;
|
|
||||||
|
|
||||||
QAction *m_minMaxAction;
|
|
||||||
QToolButton *m_minMaxButton;
|
|
||||||
|
|
||||||
QAction *m_nextAction;
|
|
||||||
QAction *m_prevAction;
|
|
||||||
QToolButton *m_prevToolButton;
|
|
||||||
QToolButton *m_nextToolButton;
|
|
||||||
QWidget *m_toolBar;
|
|
||||||
|
|
||||||
QMap<int, Core::IOutputPane*> m_pageMap;
|
|
||||||
int m_lastIndex;
|
|
||||||
|
|
||||||
QStackedWidget *m_outputWidgetPane;
|
|
||||||
QStackedWidget *m_opToolBarWidgets;
|
|
||||||
QWidget *m_buttonsWidget;
|
|
||||||
QMap<int, QPushButton *> m_buttons;
|
|
||||||
QMap<QAction *, int> m_actions;
|
|
||||||
QPixmap m_minimizeIcon;
|
|
||||||
QPixmap m_maximizeIcon;
|
|
||||||
bool m_maximised;
|
|
||||||
};
|
|
||||||
|
|
||||||
class OutputPaneToggleButton : public QPushButton
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
OutputPaneToggleButton(int number, const QString &text, QAction *action,
|
|
||||||
QWidget *parent = 0);
|
|
||||||
QSize sizeHint() const;
|
|
||||||
void paintEvent(QPaintEvent *event);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void updateToolTip();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString m_number;
|
|
||||||
QString m_text;
|
|
||||||
QAction *m_action;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
#endif // OUTPUTPANE_H
|
#endif // OUTPUTPANE_H
|
||||||
|
|||||||
583
src/plugins/coreplugin/outputpanemanager.cpp
Normal file
583
src/plugins/coreplugin/outputpanemanager.cpp
Normal file
@@ -0,0 +1,583 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "outputpanemanager.h"
|
||||||
|
#include "outputpane.h"
|
||||||
|
#include "coreconstants.h"
|
||||||
|
#include "findplaceholder.h"
|
||||||
|
|
||||||
|
#include "coreconstants.h"
|
||||||
|
#include "icore.h"
|
||||||
|
#include "ioutputpane.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "modemanager.h"
|
||||||
|
|
||||||
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
|
#include <coreplugin/actionmanager/command.h>
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/findplaceholder.h>
|
||||||
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
|
#include <utils/styledbar.h>
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
#include <QtCore/QDebug>
|
||||||
|
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
#include <QtGui/QApplication>
|
||||||
|
#include <QtGui/QComboBox>
|
||||||
|
#include <QtGui/QFocusEvent>
|
||||||
|
#include <QtGui/QHBoxLayout>
|
||||||
|
#include <QtGui/QSplitter>
|
||||||
|
#include <QtGui/QPainter>
|
||||||
|
#include <QtGui/QToolButton>
|
||||||
|
#include <QtGui/QStackedWidget>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
////
|
||||||
|
// OutputPaneManager
|
||||||
|
////
|
||||||
|
|
||||||
|
static OutputPaneManager *m_instance = 0;
|
||||||
|
|
||||||
|
void OutputPaneManager::create()
|
||||||
|
{
|
||||||
|
m_instance = new OutputPaneManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::destroy()
|
||||||
|
{
|
||||||
|
delete m_instance;
|
||||||
|
m_instance = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputPaneManager *OutputPaneManager::instance()
|
||||||
|
{
|
||||||
|
return m_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::updateStatusButtons(bool visible)
|
||||||
|
{
|
||||||
|
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
||||||
|
if (m_buttons.value(idx))
|
||||||
|
m_buttons.value(idx)->setChecked(visible);
|
||||||
|
m_minMaxAction->setVisible(OutputPanePlaceHolder::getCurrent()
|
||||||
|
&& OutputPanePlaceHolder::getCurrent()->canMaximizeOrMinimize());
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputPaneManager::OutputPaneManager(QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
m_widgetComboBox(new QComboBox),
|
||||||
|
m_clearButton(new QToolButton),
|
||||||
|
m_closeButton(new QToolButton),
|
||||||
|
m_minMaxAction(0),
|
||||||
|
m_minMaxButton(new QToolButton),
|
||||||
|
m_nextAction(0),
|
||||||
|
m_prevAction(0),
|
||||||
|
m_lastIndex(-1),
|
||||||
|
m_outputWidgetPane(new QStackedWidget),
|
||||||
|
m_opToolBarWidgets(new QStackedWidget),
|
||||||
|
m_minimizeIcon(":/core/images/arrowdown.png"),
|
||||||
|
m_maximizeIcon(":/core/images/arrowup.png"),
|
||||||
|
m_maximised(false)
|
||||||
|
{
|
||||||
|
setWindowTitle(tr("Output"));
|
||||||
|
connect(m_widgetComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changePage()));
|
||||||
|
|
||||||
|
m_clearButton->setIcon(QIcon(QLatin1String(Constants::ICON_CLEAN_PANE)));
|
||||||
|
m_clearButton->setToolTip(tr("Clear"));
|
||||||
|
connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clearPage()));
|
||||||
|
|
||||||
|
m_nextAction = new QAction(this);
|
||||||
|
m_nextAction->setIcon(QIcon(QLatin1String(Constants::ICON_NEXT)));
|
||||||
|
m_nextAction->setText(tr("Next Item"));
|
||||||
|
connect(m_nextAction, SIGNAL(triggered()), this, SLOT(slotNext()));
|
||||||
|
|
||||||
|
m_prevAction = new QAction(this);
|
||||||
|
m_prevAction->setIcon(QIcon(QLatin1String(Constants::ICON_PREV)));
|
||||||
|
m_prevAction->setText(tr("Previous Item"));
|
||||||
|
connect(m_prevAction, SIGNAL(triggered()), this, SLOT(slotPrev()));
|
||||||
|
|
||||||
|
m_minMaxAction = new QAction(this);
|
||||||
|
m_minMaxAction->setIcon(m_maximizeIcon);
|
||||||
|
m_minMaxAction->setText(tr("Maximize Output Pane"));
|
||||||
|
|
||||||
|
m_closeButton->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE)));
|
||||||
|
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(slotHide()));
|
||||||
|
|
||||||
|
QVBoxLayout *mainlayout = new QVBoxLayout;
|
||||||
|
mainlayout->setSpacing(0);
|
||||||
|
mainlayout->setMargin(0);
|
||||||
|
m_toolBar = new Utils::StyledBar;
|
||||||
|
QHBoxLayout *toolLayout = new QHBoxLayout(m_toolBar);
|
||||||
|
toolLayout->setMargin(0);
|
||||||
|
toolLayout->setSpacing(0);
|
||||||
|
toolLayout->addWidget(m_widgetComboBox);
|
||||||
|
toolLayout->addWidget(m_clearButton);
|
||||||
|
m_prevToolButton = new QToolButton;
|
||||||
|
toolLayout->addWidget(m_prevToolButton);
|
||||||
|
m_nextToolButton = new QToolButton;
|
||||||
|
toolLayout->addWidget(m_nextToolButton);
|
||||||
|
toolLayout->addWidget(m_opToolBarWidgets);
|
||||||
|
toolLayout->addWidget(m_minMaxButton);
|
||||||
|
toolLayout->addWidget(m_closeButton);
|
||||||
|
mainlayout->addWidget(m_toolBar);
|
||||||
|
mainlayout->addWidget(m_outputWidgetPane, 10);
|
||||||
|
mainlayout->addWidget(new Core::FindToolBarPlaceHolder(this));
|
||||||
|
setLayout(mainlayout);
|
||||||
|
|
||||||
|
m_buttonsWidget = new QWidget;
|
||||||
|
m_buttonsWidget->setLayout(new QHBoxLayout);
|
||||||
|
m_buttonsWidget->layout()->setContentsMargins(5,0,0,0);
|
||||||
|
m_buttonsWidget->layout()->setSpacing(4);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputPaneManager::~OutputPaneManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *OutputPaneManager::buttonsWidget()
|
||||||
|
{
|
||||||
|
return m_buttonsWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return shortcut as Ctrl+<number>
|
||||||
|
static inline int paneShortCut(int number)
|
||||||
|
{
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
int modifier = Qt::CTRL;
|
||||||
|
#else
|
||||||
|
int modifier = Qt::ALT;
|
||||||
|
#endif
|
||||||
|
return modifier | (Qt::Key_0 + number);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::init()
|
||||||
|
{
|
||||||
|
ActionManager *am = Core::ICore::instance()->actionManager();
|
||||||
|
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||||
|
const Context globalcontext(Core::Constants::C_GLOBAL);
|
||||||
|
|
||||||
|
// Window->Output Panes
|
||||||
|
ActionContainer *mpanes = am->createMenu(Constants::M_WINDOW_PANES);
|
||||||
|
mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
|
||||||
|
mpanes->menu()->setTitle(tr("Output &Panes"));
|
||||||
|
mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
|
||||||
|
mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup");
|
||||||
|
|
||||||
|
Core::Command *cmd;
|
||||||
|
|
||||||
|
cmd = am->registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalcontext);
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence("Shift+F6"));
|
||||||
|
m_prevToolButton->setDefaultAction(cmd->action());
|
||||||
|
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
||||||
|
|
||||||
|
cmd = am->registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalcontext);
|
||||||
|
m_nextToolButton->setDefaultAction(cmd->action());
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence("F6"));
|
||||||
|
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
||||||
|
|
||||||
|
cmd = am->registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalcontext);
|
||||||
|
#ifdef Q_WS_MAC
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence("Ctrl+9"));
|
||||||
|
#else
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence("Alt+9"));
|
||||||
|
#endif
|
||||||
|
cmd->setAttribute(Command::CA_UpdateText);
|
||||||
|
cmd->setAttribute(Command::CA_UpdateIcon);
|
||||||
|
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
||||||
|
connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
|
||||||
|
m_minMaxButton->setDefaultAction(cmd->action());
|
||||||
|
|
||||||
|
QAction *sep = new QAction(this);
|
||||||
|
sep->setSeparator(true);
|
||||||
|
cmd = am->registerAction(sep, "Coreplugin.OutputPane.Sep", globalcontext);
|
||||||
|
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
|
||||||
|
|
||||||
|
QList<IOutputPane*> panes = ExtensionSystem::PluginManager::instance()
|
||||||
|
->getObjects<IOutputPane>();
|
||||||
|
QMultiMap<int, IOutputPane*> sorted;
|
||||||
|
foreach (IOutputPane* outPane, panes)
|
||||||
|
sorted.insertMulti(outPane->priorityInStatusBar(), outPane);
|
||||||
|
|
||||||
|
QMultiMap<int, IOutputPane*>::const_iterator it, begin;
|
||||||
|
begin = sorted.constBegin();
|
||||||
|
it = sorted.constEnd();
|
||||||
|
int shortcutNumber = 1;
|
||||||
|
do {
|
||||||
|
--it;
|
||||||
|
IOutputPane* outPane = it.value();
|
||||||
|
const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));
|
||||||
|
|
||||||
|
m_pageMap.insert(idx, outPane);
|
||||||
|
connect(outPane, SIGNAL(showPage(bool)), this, SLOT(showPage(bool)));
|
||||||
|
connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide()));
|
||||||
|
connect(outPane, SIGNAL(togglePage(bool)), this, SLOT(togglePage(bool)));
|
||||||
|
connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState()));
|
||||||
|
|
||||||
|
QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets);
|
||||||
|
QHBoxLayout *toolButtonsLayout = new QHBoxLayout;
|
||||||
|
toolButtonsLayout->setMargin(0);
|
||||||
|
toolButtonsLayout->setSpacing(0);
|
||||||
|
foreach (QWidget *toolButton, outPane->toolBarWidgets())
|
||||||
|
toolButtonsLayout->addWidget(toolButton);
|
||||||
|
toolButtonsLayout->addStretch(5);
|
||||||
|
toolButtonsContainer->setLayout(toolButtonsLayout);
|
||||||
|
|
||||||
|
m_opToolBarWidgets->addWidget(toolButtonsContainer);
|
||||||
|
|
||||||
|
QString actionId = QString("QtCreator.Pane.%1").arg(outPane->displayName().simplified());
|
||||||
|
actionId.remove(QLatin1Char(' '));
|
||||||
|
QAction *action = new QAction(outPane->displayName(), this);
|
||||||
|
|
||||||
|
Command *cmd = am->registerAction(action, actionId, Context(Constants::C_GLOBAL));
|
||||||
|
|
||||||
|
mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
|
||||||
|
m_actions.insert(cmd->action(), idx);
|
||||||
|
|
||||||
|
if (outPane->priorityInStatusBar() != -1) {
|
||||||
|
cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber)));
|
||||||
|
QPushButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(),
|
||||||
|
cmd->action());
|
||||||
|
++shortcutNumber;
|
||||||
|
m_buttonsWidget->layout()->addWidget(button);
|
||||||
|
connect(button, SIGNAL(clicked()), this, SLOT(buttonTriggered()));
|
||||||
|
m_buttons.insert(idx, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now add the entry to the combobox, since the first item we add sets the currentIndex, thus we need to be set up for that
|
||||||
|
m_widgetComboBox->addItem(outPane->displayName(), idx);
|
||||||
|
|
||||||
|
connect(cmd->action(), SIGNAL(triggered()), this, SLOT(shortcutTriggered()));
|
||||||
|
} while (it != begin);
|
||||||
|
|
||||||
|
changePage();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::shortcutTriggered()
|
||||||
|
{
|
||||||
|
QAction *action = qobject_cast<QAction*>(sender());
|
||||||
|
if (action && m_actions.contains(action)) {
|
||||||
|
int idx = m_actions.value(action);
|
||||||
|
Core::IOutputPane *outputPane = m_pageMap.value(idx);
|
||||||
|
// Now check the special case, the output window is already visible,
|
||||||
|
// we are already on that page
|
||||||
|
// but the outputpane doesn't have focus
|
||||||
|
// then just give it focus
|
||||||
|
// else do the same as clicking on the button does
|
||||||
|
if (OutputPanePlaceHolder::isCurrentVisible()
|
||||||
|
&& m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx) {
|
||||||
|
if (!outputPane->hasFocus() && outputPane->canFocus())
|
||||||
|
outputPane->setFocus();
|
||||||
|
else
|
||||||
|
slotHide();
|
||||||
|
} else {
|
||||||
|
outputPane->popup(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputPaneManager::isMaximized()const
|
||||||
|
{
|
||||||
|
return m_maximised;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::slotMinMax()
|
||||||
|
{
|
||||||
|
QTC_ASSERT(OutputPanePlaceHolder::getCurrent(), return);
|
||||||
|
|
||||||
|
if (!OutputPanePlaceHolder::getCurrent()->isVisible()) // easier than disabling/enabling the action
|
||||||
|
return;
|
||||||
|
m_maximised = !m_maximised;
|
||||||
|
OutputPanePlaceHolder::getCurrent()->maximizeOrMinimize(m_maximised);
|
||||||
|
m_minMaxAction->setIcon(m_maximised ? m_minimizeIcon : m_maximizeIcon);
|
||||||
|
m_minMaxAction->setText(m_maximised ? tr("Minimize Output Pane")
|
||||||
|
: tr("Maximize Output Pane"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::buttonTriggered()
|
||||||
|
{
|
||||||
|
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
||||||
|
QMap<int, QPushButton *>::const_iterator it, end;
|
||||||
|
end = m_buttons.constEnd();
|
||||||
|
for (it = m_buttons.begin(); it != end; ++it) {
|
||||||
|
if (it.value() == button)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
int idx = it.key();
|
||||||
|
|
||||||
|
if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx &&
|
||||||
|
OutputPanePlaceHolder::isCurrentVisible()
|
||||||
|
&& OutputPanePlaceHolder::getCurrent()->closeable()) {
|
||||||
|
// we should toggle and the page is already visible and we are actually closeable
|
||||||
|
slotHide();
|
||||||
|
} else {
|
||||||
|
showPage(idx, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::slotNext()
|
||||||
|
{
|
||||||
|
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
||||||
|
ensurePageVisible(idx);
|
||||||
|
IOutputPane *out = m_pageMap.value(idx);
|
||||||
|
if (out->canNext())
|
||||||
|
out->goToNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::slotPrev()
|
||||||
|
{
|
||||||
|
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
||||||
|
ensurePageVisible(idx);
|
||||||
|
IOutputPane *out = m_pageMap.value(idx);
|
||||||
|
if (out->canPrevious())
|
||||||
|
out->goToPrev();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::slotHide()
|
||||||
|
{
|
||||||
|
if (OutputPanePlaceHolder::getCurrent()) {
|
||||||
|
OutputPanePlaceHolder::getCurrent()->setVisible(false);
|
||||||
|
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
||||||
|
if (m_buttons.value(idx))
|
||||||
|
m_buttons.value(idx)->setChecked(false);
|
||||||
|
if (IEditor *editor = Core::EditorManager::instance()->currentEditor())
|
||||||
|
editor->widget()->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int OutputPaneManager::findIndexForPage(IOutputPane *out)
|
||||||
|
{
|
||||||
|
if (!out)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int stackIndex = -1;
|
||||||
|
QMap<int, IOutputPane*>::const_iterator it = m_pageMap.constBegin();
|
||||||
|
while (it != m_pageMap.constEnd()) {
|
||||||
|
if (it.value() == out) {
|
||||||
|
stackIndex = it.key();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
if (stackIndex > -1)
|
||||||
|
return m_widgetComboBox->findData(stackIndex);
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::ensurePageVisible(int idx)
|
||||||
|
{
|
||||||
|
if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() != idx) {
|
||||||
|
m_widgetComboBox->setCurrentIndex(m_widgetComboBox->findData(idx));
|
||||||
|
} else {
|
||||||
|
changePage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::updateNavigateState()
|
||||||
|
{
|
||||||
|
IOutputPane* pane = qobject_cast<IOutputPane*>(sender());
|
||||||
|
int idx = findIndexForPage(pane);
|
||||||
|
if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx) {
|
||||||
|
m_prevAction->setEnabled(pane->canNavigate() && pane->canPrevious());
|
||||||
|
m_nextAction->setEnabled(pane->canNavigate() && pane->canNext());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slot connected to showPage signal of each page
|
||||||
|
void OutputPaneManager::showPage(bool focus)
|
||||||
|
{
|
||||||
|
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
|
||||||
|
showPage(idx, focus);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::showPage(int idx, bool focus)
|
||||||
|
{
|
||||||
|
IOutputPane *out = m_pageMap.value(idx);
|
||||||
|
if (idx > -1) {
|
||||||
|
if (!OutputPanePlaceHolder::getCurrent()) {
|
||||||
|
// In this mode we don't have a placeholder
|
||||||
|
// switch to the output mode and switch the page
|
||||||
|
ICore::instance()->modeManager()->activateMode(Constants::MODE_EDIT);
|
||||||
|
}
|
||||||
|
if (OutputPanePlaceHolder::getCurrent()) {
|
||||||
|
// make the page visible
|
||||||
|
OutputPanePlaceHolder::getCurrent()->setVisible(true);
|
||||||
|
ensurePageVisible(idx);
|
||||||
|
if (focus && out->canFocus())
|
||||||
|
out->setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::togglePage(bool focus)
|
||||||
|
{
|
||||||
|
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
|
||||||
|
if (OutputPanePlaceHolder::isCurrentVisible()
|
||||||
|
&& m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() == idx) {
|
||||||
|
slotHide();
|
||||||
|
} else {
|
||||||
|
showPage(idx, focus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::setCloseable(bool b)
|
||||||
|
{
|
||||||
|
m_closeButton->setVisible(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OutputPaneManager::closeable()
|
||||||
|
{
|
||||||
|
return m_closeButton->isVisibleTo(m_closeButton->parentWidget());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::focusInEvent(QFocusEvent *e)
|
||||||
|
{
|
||||||
|
if (m_outputWidgetPane->currentWidget())
|
||||||
|
m_outputWidgetPane->currentWidget()->setFocus(e->reason());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::changePage()
|
||||||
|
{
|
||||||
|
if (m_outputWidgetPane->count() <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!m_pageMap.contains(m_lastIndex)) {
|
||||||
|
int idx = m_outputWidgetPane->currentIndex();
|
||||||
|
m_pageMap.value(idx)->visibilityChanged(true);
|
||||||
|
if (m_buttons.value(idx)) {
|
||||||
|
m_buttons.value(idx)->setChecked(OutputPanePlaceHolder::isCurrentVisible());
|
||||||
|
}
|
||||||
|
m_lastIndex = idx;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
||||||
|
if (m_lastIndex != idx) {
|
||||||
|
m_outputWidgetPane->setCurrentIndex(idx);
|
||||||
|
m_opToolBarWidgets->setCurrentIndex(idx);
|
||||||
|
m_pageMap.value(idx)->visibilityChanged(true);
|
||||||
|
m_pageMap.value(m_lastIndex)->visibilityChanged(false);
|
||||||
|
|
||||||
|
bool canNavigate = m_pageMap.value(idx)->canNavigate();
|
||||||
|
m_prevAction->setEnabled(canNavigate && m_pageMap.value(idx)->canPrevious());
|
||||||
|
m_nextAction->setEnabled(canNavigate && m_pageMap.value(idx)->canNext());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_buttons.value(m_lastIndex))
|
||||||
|
m_buttons.value(m_lastIndex)->setChecked(false);
|
||||||
|
|
||||||
|
if (m_buttons.value(idx))
|
||||||
|
m_buttons.value(idx)->setChecked(OutputPanePlaceHolder::isCurrentVisible());
|
||||||
|
|
||||||
|
m_lastIndex = idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneManager::clearPage()
|
||||||
|
{
|
||||||
|
if (m_pageMap.contains(m_outputWidgetPane->currentIndex()))
|
||||||
|
m_pageMap.value(m_outputWidgetPane->currentIndex())->clearContents();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OutputPaneToggleButton::OutputPaneToggleButton(int number, const QString &text,
|
||||||
|
QAction *action, QWidget *parent)
|
||||||
|
: QPushButton(parent)
|
||||||
|
, m_number(QString::number(number))
|
||||||
|
, m_text(text)
|
||||||
|
, m_action(action)
|
||||||
|
{
|
||||||
|
setFocusPolicy(Qt::NoFocus);
|
||||||
|
setCheckable(true);
|
||||||
|
setStyleSheet(
|
||||||
|
"QPushButton { border-image: url(:/core/images/panel_button.png) 2 2 2 19;"
|
||||||
|
" border-width: 2px 2px 2px 19px; padding-left: -17; padding-right: 4 } "
|
||||||
|
"QPushButton:checked { border-image: url(:/core/images/panel_button_checked.png) 2 2 2 19 } "
|
||||||
|
"QPushButton::menu-indicator { width:0; height:0 }"
|
||||||
|
#ifndef Q_WS_MAC // Mac UIs usually don't hover
|
||||||
|
"QPushButton:checked:hover { border-image: url(:/core/images/panel_button_checked_hover.png) 2 2 2 19 } "
|
||||||
|
"QPushButton:pressed:hover { border-image: url(:/core/images/panel_button_pressed.png) 2 2 2 19 } "
|
||||||
|
"QPushButton:hover { border-image: url(:/core/images/panel_button_hover.png) 2 2 2 19 } "
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
if (m_action)
|
||||||
|
connect(m_action, SIGNAL(changed()), this, SLOT(updateToolTip()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneToggleButton::updateToolTip()
|
||||||
|
{
|
||||||
|
Q_ASSERT(m_action);
|
||||||
|
setToolTip(m_action->toolTip());
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize OutputPaneToggleButton::sizeHint() const
|
||||||
|
{
|
||||||
|
ensurePolished();
|
||||||
|
|
||||||
|
QSize s = fontMetrics().size(Qt::TextSingleLine, m_text);
|
||||||
|
|
||||||
|
// Expand to account for border image set by stylesheet above
|
||||||
|
s.rwidth() += 19 + 5 + 2;
|
||||||
|
s.rheight() += 2 + 2;
|
||||||
|
|
||||||
|
return s.expandedTo(QApplication::globalStrut());
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputPaneToggleButton::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
// For drawing the style sheet stuff
|
||||||
|
QPushButton::paintEvent(event);
|
||||||
|
|
||||||
|
const QFontMetrics fm = fontMetrics();
|
||||||
|
const int baseLine = (height() - fm.height() + 1) / 2 + fm.ascent();
|
||||||
|
const int numberWidth = fm.width(m_number);
|
||||||
|
|
||||||
|
QPainter p(this);
|
||||||
|
p.setFont(font());
|
||||||
|
p.setPen(Qt::white);
|
||||||
|
p.drawText((20 - numberWidth) / 2, baseLine, m_number);
|
||||||
|
if (!isChecked())
|
||||||
|
p.setPen(Qt::black);
|
||||||
|
int leftPart = 22;
|
||||||
|
p.drawText(leftPart, baseLine, fm.elidedText(m_text, Qt::ElideRight, width() - leftPart - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
|
||||||
148
src/plugins/coreplugin/outputpanemanager.h
Normal file
148
src/plugins/coreplugin/outputpanemanager.h
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef OUTPUTPANEMANAGER_H
|
||||||
|
#define OUTPUTPANEMANAGER_H
|
||||||
|
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QAction;
|
||||||
|
class QComboBox;
|
||||||
|
class QToolButton;
|
||||||
|
class QStackedWidget;
|
||||||
|
class QSplitter;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
|
||||||
|
class IMode;
|
||||||
|
class IOutputPane;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
class OutputPaneManager;
|
||||||
|
class MainWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class OutputPaneManager : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
void init();
|
||||||
|
static OutputPaneManager *instance();
|
||||||
|
void setCloseable(bool b);
|
||||||
|
bool closeable();
|
||||||
|
QWidget *buttonsWidget();
|
||||||
|
void updateStatusButtons(bool visible);
|
||||||
|
|
||||||
|
bool isMaximized()const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void slotHide();
|
||||||
|
void slotNext();
|
||||||
|
void slotPrev();
|
||||||
|
void shortcutTriggered();
|
||||||
|
void slotMinMax();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void focusInEvent(QFocusEvent *e);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void changePage();
|
||||||
|
void showPage(bool focus);
|
||||||
|
void togglePage(bool focus);
|
||||||
|
void clearPage();
|
||||||
|
void buttonTriggered();
|
||||||
|
void updateNavigateState();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// the only class that is allowed to create and destroy
|
||||||
|
friend class MainWindow;
|
||||||
|
|
||||||
|
static void create();
|
||||||
|
static void destroy();
|
||||||
|
|
||||||
|
explicit OutputPaneManager(QWidget *parent = 0);
|
||||||
|
~OutputPaneManager();
|
||||||
|
|
||||||
|
void showPage(int idx, bool focus);
|
||||||
|
void ensurePageVisible(int idx);
|
||||||
|
int findIndexForPage(IOutputPane *out);
|
||||||
|
QComboBox *m_widgetComboBox;
|
||||||
|
QToolButton *m_clearButton;
|
||||||
|
QToolButton *m_closeButton;
|
||||||
|
|
||||||
|
QAction *m_minMaxAction;
|
||||||
|
QToolButton *m_minMaxButton;
|
||||||
|
|
||||||
|
QAction *m_nextAction;
|
||||||
|
QAction *m_prevAction;
|
||||||
|
QToolButton *m_prevToolButton;
|
||||||
|
QToolButton *m_nextToolButton;
|
||||||
|
QWidget *m_toolBar;
|
||||||
|
|
||||||
|
QMap<int, Core::IOutputPane*> m_pageMap;
|
||||||
|
int m_lastIndex;
|
||||||
|
|
||||||
|
QStackedWidget *m_outputWidgetPane;
|
||||||
|
QStackedWidget *m_opToolBarWidgets;
|
||||||
|
QWidget *m_buttonsWidget;
|
||||||
|
QMap<int, QPushButton *> m_buttons;
|
||||||
|
QMap<QAction *, int> m_actions;
|
||||||
|
QPixmap m_minimizeIcon;
|
||||||
|
QPixmap m_maximizeIcon;
|
||||||
|
bool m_maximised;
|
||||||
|
};
|
||||||
|
|
||||||
|
class OutputPaneToggleButton : public QPushButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
OutputPaneToggleButton(int number, const QString &text, QAction *action,
|
||||||
|
QWidget *parent = 0);
|
||||||
|
QSize sizeHint() const;
|
||||||
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateToolTip();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_number;
|
||||||
|
QString m_text;
|
||||||
|
QAction *m_action;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
#endif // OUTPUTPANEMANAGER_H
|
||||||
@@ -30,6 +30,12 @@
|
|||||||
#include "futureprogress.h"
|
#include "futureprogress.h"
|
||||||
#include "progressbar.h"
|
#include "progressbar.h"
|
||||||
|
|
||||||
|
#include <QtCore/QFutureWatcher>
|
||||||
|
#include <QtCore/QTimer>
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
#include <QtCore/QPropertyAnimation>
|
||||||
|
#include <QtCore/QSequentialAnimationGroup>
|
||||||
|
|
||||||
#include <QtGui/QColor>
|
#include <QtGui/QColor>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QtGui/QVBoxLayout>
|
||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
@@ -37,15 +43,8 @@
|
|||||||
#include <QtGui/QHBoxLayout>
|
#include <QtGui/QHBoxLayout>
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
#include <QtGui/QMouseEvent>
|
#include <QtGui/QMouseEvent>
|
||||||
#include <QtCore/QTimer>
|
|
||||||
#include <QtCore/QCoreApplication>
|
|
||||||
#include <QtCore/QPropertyAnimation>
|
|
||||||
#include <QtCore/QSequentialAnimationGroup>
|
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
using namespace Core;
|
|
||||||
using namespace Core::Internal;
|
|
||||||
|
|
||||||
const int notificationTimeout = 8000;
|
const int notificationTimeout = 8000;
|
||||||
const int shortNotificationTimeout = 1000;
|
const int shortNotificationTimeout = 1000;
|
||||||
|
|
||||||
@@ -69,9 +68,6 @@ private:
|
|||||||
float m_opacity;
|
float m_opacity;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Core
|
|
||||||
|
|
||||||
void FadeWidgetHack::paintEvent(QPaintEvent *)
|
void FadeWidgetHack::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
if (m_opacity == 0)
|
if (m_opacity == 0)
|
||||||
@@ -83,6 +79,28 @@ void FadeWidgetHack::paintEvent(QPaintEvent *)
|
|||||||
Utils::StyleHelper::verticalGradient(&p, rect(), rect());
|
Utils::StyleHelper::verticalGradient(&p, rect(), rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
|
struct FutureProgressPrivate {
|
||||||
|
explicit FutureProgressPrivate(FutureProgress *q);
|
||||||
|
|
||||||
|
QFutureWatcher<void> m_watcher;
|
||||||
|
Internal::ProgressBar *m_progress;
|
||||||
|
QWidget *m_widget;
|
||||||
|
QHBoxLayout *m_widgetLayout;
|
||||||
|
QString m_type;
|
||||||
|
bool m_keep;
|
||||||
|
bool m_waitingForUserInteraction;
|
||||||
|
Internal::FadeWidgetHack *m_faderWidget;
|
||||||
|
};
|
||||||
|
|
||||||
|
FutureProgressPrivate::FutureProgressPrivate(FutureProgress *q) :
|
||||||
|
m_progress(new Internal::ProgressBar), m_widget(0), m_widgetLayout(new QHBoxLayout),
|
||||||
|
m_keep(false), m_waitingForUserInteraction(false),
|
||||||
|
m_faderWidget(new Internal::FadeWidgetHack(q))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\mainclass
|
\mainclass
|
||||||
\class Core::FutureProgress
|
\class Core::FutureProgress
|
||||||
@@ -118,32 +136,25 @@ void FadeWidgetHack::paintEvent(QPaintEvent *)
|
|||||||
\fn FutureProgress::FutureProgress(QWidget *parent)
|
\fn FutureProgress::FutureProgress(QWidget *parent)
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
FutureProgress::FutureProgress(QWidget *parent)
|
FutureProgress::FutureProgress(QWidget *parent) :
|
||||||
: QWidget(parent),
|
QWidget(parent), d(new FutureProgressPrivate(this))
|
||||||
m_progress(new ProgressBar),
|
|
||||||
m_widget(0),
|
|
||||||
m_widgetLayout(new QHBoxLayout)
|
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
layout->addWidget(m_progress);
|
layout->addWidget(d->m_progress);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
layout->addLayout(m_widgetLayout);
|
layout->addLayout(d->m_widgetLayout);
|
||||||
m_widgetLayout->setContentsMargins(7, 0, 7, 2);
|
d->m_widgetLayout->setContentsMargins(7, 0, 7, 2);
|
||||||
m_widgetLayout->setSpacing(0);
|
d->m_widgetLayout->setSpacing(0);
|
||||||
|
|
||||||
connect(&m_watcher, SIGNAL(started()), this, SLOT(setStarted()));
|
connect(&d->m_watcher, SIGNAL(started()), this, SLOT(setStarted()));
|
||||||
connect(&m_watcher, SIGNAL(finished()), this, SLOT(setFinished()));
|
connect(&d->m_watcher, SIGNAL(finished()), this, SLOT(setFinished()));
|
||||||
connect(&m_watcher, SIGNAL(progressRangeChanged(int,int)), this, SLOT(setProgressRange(int,int)));
|
connect(&d->m_watcher, SIGNAL(progressRangeChanged(int,int)), this, SLOT(setProgressRange(int,int)));
|
||||||
connect(&m_watcher, SIGNAL(progressValueChanged(int)), this, SLOT(setProgressValue(int)));
|
connect(&d->m_watcher, SIGNAL(progressValueChanged(int)), this, SLOT(setProgressValue(int)));
|
||||||
connect(&m_watcher, SIGNAL(progressTextChanged(const QString&)),
|
connect(&d->m_watcher, SIGNAL(progressTextChanged(const QString&)),
|
||||||
this, SLOT(setProgressText(const QString&)));
|
this, SLOT(setProgressText(const QString&)));
|
||||||
connect(m_progress, SIGNAL(clicked()), this, SLOT(cancel()));
|
connect(d->m_progress, SIGNAL(clicked()), this, SLOT(cancel()));
|
||||||
|
|
||||||
m_keep = false;
|
|
||||||
m_waitingForUserInteraction = false;
|
|
||||||
m_faderWidget = new FadeWidgetHack(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -152,8 +163,8 @@ FutureProgress::FutureProgress(QWidget *parent)
|
|||||||
*/
|
*/
|
||||||
FutureProgress::~FutureProgress()
|
FutureProgress::~FutureProgress()
|
||||||
{
|
{
|
||||||
if (m_widget)
|
if (d->m_widget)
|
||||||
delete m_widget;
|
delete d->m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -164,14 +175,14 @@ FutureProgress::~FutureProgress()
|
|||||||
*/
|
*/
|
||||||
void FutureProgress::setWidget(QWidget *widget)
|
void FutureProgress::setWidget(QWidget *widget)
|
||||||
{
|
{
|
||||||
if (m_widget)
|
if (d->m_widget)
|
||||||
delete m_widget;
|
delete d->m_widget;
|
||||||
QSizePolicy sp = widget->sizePolicy();
|
QSizePolicy sp = widget->sizePolicy();
|
||||||
sp.setHorizontalPolicy(QSizePolicy::Ignored);
|
sp.setHorizontalPolicy(QSizePolicy::Ignored);
|
||||||
widget->setSizePolicy(sp);
|
widget->setSizePolicy(sp);
|
||||||
m_widget = widget;
|
d->m_widget = widget;
|
||||||
if (m_widget)
|
if (d->m_widget)
|
||||||
m_widgetLayout->addWidget(m_widget);
|
d->m_widgetLayout->addWidget(d->m_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -180,7 +191,7 @@ void FutureProgress::setWidget(QWidget *widget)
|
|||||||
*/
|
*/
|
||||||
void FutureProgress::setTitle(const QString &title)
|
void FutureProgress::setTitle(const QString &title)
|
||||||
{
|
{
|
||||||
m_progress->setTitle(title);
|
d->m_progress->setTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -189,12 +200,12 @@ void FutureProgress::setTitle(const QString &title)
|
|||||||
*/
|
*/
|
||||||
QString FutureProgress::title() const
|
QString FutureProgress::title() const
|
||||||
{
|
{
|
||||||
return m_progress->title();
|
return d->m_progress->title();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FutureProgress::cancel()
|
void FutureProgress::cancel()
|
||||||
{
|
{
|
||||||
m_watcher.future().cancel();
|
d->m_watcher.future().cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FutureProgress::updateToolTip(const QString &text)
|
void FutureProgress::updateToolTip(const QString &text)
|
||||||
@@ -204,16 +215,16 @@ void FutureProgress::updateToolTip(const QString &text)
|
|||||||
|
|
||||||
void FutureProgress::setStarted()
|
void FutureProgress::setStarted()
|
||||||
{
|
{
|
||||||
m_progress->reset();
|
d->m_progress->reset();
|
||||||
m_progress->setError(false);
|
d->m_progress->setError(false);
|
||||||
m_progress->setRange(m_watcher.progressMinimum(), m_watcher.progressMaximum());
|
d->m_progress->setRange(d->m_watcher.progressMinimum(), d->m_watcher.progressMaximum());
|
||||||
m_progress->setValue(m_watcher.progressValue());
|
d->m_progress->setValue(d->m_watcher.progressValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FutureProgress::eventFilter(QObject *, QEvent *e)
|
bool FutureProgress::eventFilter(QObject *, QEvent *e)
|
||||||
{
|
{
|
||||||
if (m_waitingForUserInteraction
|
if (d->m_waitingForUserInteraction
|
||||||
&& (e->type() == QEvent::MouseMove || e->type() == QEvent::KeyPress)) {
|
&& (e->type() == QEvent::MouseMove || e->type() == QEvent::KeyPress)) {
|
||||||
qApp->removeEventFilter(this);
|
qApp->removeEventFilter(this);
|
||||||
QTimer::singleShot(notificationTimeout, this, SLOT(fadeAway()));
|
QTimer::singleShot(notificationTimeout, this, SLOT(fadeAway()));
|
||||||
@@ -223,36 +234,36 @@ bool FutureProgress::eventFilter(QObject *, QEvent *e)
|
|||||||
|
|
||||||
void FutureProgress::setFinished()
|
void FutureProgress::setFinished()
|
||||||
{
|
{
|
||||||
updateToolTip(m_watcher.future().progressText());
|
updateToolTip(d->m_watcher.future().progressText());
|
||||||
|
|
||||||
// Special case for concurrent jobs that don't use QFutureInterface to report progress
|
// Special case for concurrent jobs that don't use QFutureInterface to report progress
|
||||||
if (m_watcher.progressMinimum() == 0 && m_watcher.progressMaximum() == 0) {
|
if (d->m_watcher.progressMinimum() == 0 && d->m_watcher.progressMaximum() == 0) {
|
||||||
m_progress->setRange(0, 1);
|
d->m_progress->setRange(0, 1);
|
||||||
m_progress->setValue(1);
|
d->m_progress->setValue(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_watcher.future().isCanceled()) {
|
if (d->m_watcher.future().isCanceled()) {
|
||||||
m_progress->setError(true);
|
d->m_progress->setError(true);
|
||||||
} else {
|
} else {
|
||||||
m_progress->setError(false);
|
d->m_progress->setError(false);
|
||||||
}
|
}
|
||||||
emit finished();
|
emit finished();
|
||||||
if (m_keep) {
|
if (d->m_keep) {
|
||||||
m_waitingForUserInteraction = true;
|
d->m_waitingForUserInteraction = true;
|
||||||
qApp->installEventFilter(this);
|
qApp->installEventFilter(this);
|
||||||
} else if (!m_progress->hasError()) {
|
} else if (!d->m_progress->hasError()) {
|
||||||
QTimer::singleShot(shortNotificationTimeout, this, SLOT(fadeAway()));
|
QTimer::singleShot(shortNotificationTimeout, this, SLOT(fadeAway()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FutureProgress::setProgressRange(int min, int max)
|
void FutureProgress::setProgressRange(int min, int max)
|
||||||
{
|
{
|
||||||
m_progress->setRange(min, max);
|
d->m_progress->setRange(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FutureProgress::setProgressValue(int val)
|
void FutureProgress::setProgressValue(int val)
|
||||||
{
|
{
|
||||||
m_progress->setValue(val);
|
d->m_progress->setValue(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FutureProgress::setProgressText(const QString &text)
|
void FutureProgress::setProgressText(const QString &text)
|
||||||
@@ -266,7 +277,7 @@ void FutureProgress::setProgressText(const QString &text)
|
|||||||
*/
|
*/
|
||||||
void FutureProgress::setFuture(const QFuture<void> &future)
|
void FutureProgress::setFuture(const QFuture<void> &future)
|
||||||
{
|
{
|
||||||
m_watcher.setFuture(future);
|
d->m_watcher.setFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -275,7 +286,7 @@ void FutureProgress::setFuture(const QFuture<void> &future)
|
|||||||
*/
|
*/
|
||||||
QFuture<void> FutureProgress::future() const
|
QFuture<void> FutureProgress::future() const
|
||||||
{
|
{
|
||||||
return m_watcher.future();
|
return d->m_watcher.future();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -291,7 +302,7 @@ void FutureProgress::mousePressEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
void FutureProgress::resizeEvent(QResizeEvent *)
|
void FutureProgress::resizeEvent(QResizeEvent *)
|
||||||
{
|
{
|
||||||
m_faderWidget->setGeometry(rect());
|
d->m_faderWidget->setGeometry(rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -300,14 +311,14 @@ void FutureProgress::resizeEvent(QResizeEvent *)
|
|||||||
*/
|
*/
|
||||||
bool FutureProgress::hasError() const
|
bool FutureProgress::hasError() const
|
||||||
{
|
{
|
||||||
return m_progress->hasError();
|
return d->m_progress->hasError();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FutureProgress::fadeAway()
|
void FutureProgress::fadeAway()
|
||||||
{
|
{
|
||||||
m_faderWidget->raise();
|
d->m_faderWidget->raise();
|
||||||
QSequentialAnimationGroup *group = new QSequentialAnimationGroup;
|
QSequentialAnimationGroup *group = new QSequentialAnimationGroup;
|
||||||
QPropertyAnimation *animation = new QPropertyAnimation(m_faderWidget, "opacity");
|
QPropertyAnimation *animation = new QPropertyAnimation(d->m_faderWidget, "opacity");
|
||||||
animation->setDuration(600);
|
animation->setDuration(600);
|
||||||
animation->setEndValue(1.0);
|
animation->setEndValue(1.0);
|
||||||
group->addAnimation(animation);
|
group->addAnimation(animation);
|
||||||
@@ -322,4 +333,31 @@ void FutureProgress::fadeAway()
|
|||||||
connect(group, SIGNAL(finished()), this, SIGNAL(removeMe()));
|
connect(group, SIGNAL(finished()), this, SIGNAL(removeMe()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FutureProgress::setType(const QString &type)
|
||||||
|
{
|
||||||
|
d->m_type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString FutureProgress::type() const
|
||||||
|
{
|
||||||
|
return d->m_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FutureProgress::setKeepOnFinish(bool keep)
|
||||||
|
{
|
||||||
|
d->m_keep = keep;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FutureProgress::keepOnFinish() const
|
||||||
|
{
|
||||||
|
return d->m_keep;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *FutureProgress::widget() const
|
||||||
|
{
|
||||||
|
return d->m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
#include "futureprogress.moc"
|
#include "futureprogress.moc"
|
||||||
|
|||||||
@@ -33,31 +33,23 @@
|
|||||||
#include <coreplugin/core_global.h>
|
#include <coreplugin/core_global.h>
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
#include <QtCore/QScopedPointer>
|
||||||
|
|
||||||
#include <QtCore/QFuture>
|
#include <QtCore/QFuture>
|
||||||
#include <QtCore/QFutureWatcher>
|
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QProgressBar;
|
|
||||||
class QHBoxLayout;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
struct FutureProgressPrivate;
|
||||||
namespace Internal {
|
|
||||||
class ProgressBar;
|
|
||||||
class FadeWidgetHack;
|
|
||||||
} // namespace Internal
|
|
||||||
|
|
||||||
class CORE_EXPORT FutureProgress : public QWidget
|
class CORE_EXPORT FutureProgress : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FutureProgress(QWidget *parent = 0);
|
explicit FutureProgress(QWidget *parent = 0);
|
||||||
~FutureProgress();
|
virtual ~FutureProgress();
|
||||||
|
|
||||||
bool eventFilter(QObject *object, QEvent *);
|
virtual bool eventFilter(QObject *object, QEvent *);
|
||||||
|
|
||||||
void setFuture(const QFuture<void> &future);
|
void setFuture(const QFuture<void> &future);
|
||||||
QFuture<void> future() const;
|
QFuture<void> future() const;
|
||||||
@@ -65,16 +57,16 @@ public:
|
|||||||
void setTitle(const QString &title);
|
void setTitle(const QString &title);
|
||||||
QString title() const;
|
QString title() const;
|
||||||
|
|
||||||
void setType(const QString &type) {m_type = type; }
|
void setType(const QString &type);
|
||||||
QString type() const { return m_type; }
|
QString type() const;
|
||||||
|
|
||||||
void setKeepOnFinish(bool keep) { m_keep = keep; }
|
void setKeepOnFinish(bool keep);
|
||||||
bool keepOnFinish() const { return m_keep; }
|
bool keepOnFinish() const;
|
||||||
|
|
||||||
bool hasError() const;
|
bool hasError() const;
|
||||||
|
|
||||||
void setWidget(QWidget *widget);
|
void setWidget(QWidget *widget);
|
||||||
QWidget *widget() const { return m_widget; }
|
QWidget *widget() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
@@ -96,14 +88,7 @@ private slots:
|
|||||||
void fadeAway();
|
void fadeAway();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QFutureWatcher<void> m_watcher;
|
QScopedPointer<FutureProgressPrivate> d;
|
||||||
Internal::ProgressBar *m_progress;
|
|
||||||
QWidget *m_widget;
|
|
||||||
QHBoxLayout *m_widgetLayout;
|
|
||||||
QString m_type;
|
|
||||||
bool m_keep;
|
|
||||||
bool m_waitingForUserInteraction;
|
|
||||||
Internal::FadeWidgetHack *m_faderWidget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "sidebar.h"
|
#include "sidebar.h"
|
||||||
|
#include "sidebarwidget.h"
|
||||||
#include "imode.h"
|
#include "imode.h"
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
@@ -42,35 +43,72 @@
|
|||||||
#include <QtGui/QAction>
|
#include <QtGui/QAction>
|
||||||
#include <QtGui/QToolButton>
|
#include <QtGui/QToolButton>
|
||||||
|
|
||||||
using namespace Core;
|
namespace Core {
|
||||||
using namespace Core::Internal;
|
|
||||||
|
SideBarItem::SideBarItem(QWidget *widget, const QString &id) :
|
||||||
|
m_id(id), m_widget(widget)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
SideBarItem::~SideBarItem()
|
SideBarItem::~SideBarItem()
|
||||||
{
|
{
|
||||||
delete m_widget;
|
delete m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget *SideBarItem::widget() const
|
||||||
|
{
|
||||||
|
return m_widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SideBarItem::id() const
|
||||||
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SideBarItem::title() const
|
||||||
|
{
|
||||||
|
return m_widget->windowTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QToolButton *> SideBarItem::createToolBarWidgets()
|
||||||
|
{
|
||||||
|
return QList<QToolButton *>();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SideBarPrivate {
|
||||||
|
SideBarPrivate() :m_closeWhenEmpty(false) {}
|
||||||
|
|
||||||
|
QList<Internal::SideBarWidget*> m_widgets;
|
||||||
|
QMap<QString, QWeakPointer<SideBarItem> > m_itemMap;
|
||||||
|
QStringList m_availableItemIds;
|
||||||
|
QStringList m_availableItemTitles;
|
||||||
|
QStringList m_unavailableItemIds;
|
||||||
|
QStringList m_defaultVisible;
|
||||||
|
QMap<QString, Core::Command*> m_shortcutMap;
|
||||||
|
bool m_closeWhenEmpty;
|
||||||
|
};
|
||||||
|
|
||||||
SideBar::SideBar(QList<SideBarItem*> itemList,
|
SideBar::SideBar(QList<SideBarItem*> itemList,
|
||||||
QList<SideBarItem*> defaultVisible) :
|
QList<SideBarItem*> defaultVisible) :
|
||||||
m_closeWhenEmpty(false)
|
d(new SideBarPrivate)
|
||||||
{
|
{
|
||||||
setOrientation(Qt::Vertical);
|
setOrientation(Qt::Vertical);
|
||||||
foreach (SideBarItem *item, itemList) {
|
foreach (SideBarItem *item, itemList) {
|
||||||
m_itemMap.insert(item->id(), item);
|
d->m_itemMap.insert(item->id(), item);
|
||||||
m_availableItemIds.append(item->id());
|
d->m_availableItemIds.append(item->id());
|
||||||
m_availableItemTitles.append(item->title());
|
d->m_availableItemTitles.append(item->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SideBarItem *item, defaultVisible) {
|
foreach (SideBarItem *item, defaultVisible) {
|
||||||
if (!itemList.contains(item))
|
if (!itemList.contains(item))
|
||||||
continue;
|
continue;
|
||||||
m_defaultVisible.append(item->id());
|
d->m_defaultVisible.append(item->id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SideBar::~SideBar()
|
SideBar::~SideBar()
|
||||||
{
|
{
|
||||||
QMutableMapIterator<QString, QWeakPointer<SideBarItem> > iter(m_itemMap);
|
QMutableMapIterator<QString, QWeakPointer<SideBarItem> > iter(d->m_itemMap);
|
||||||
while(iter.hasNext()) {
|
while(iter.hasNext()) {
|
||||||
iter.next();
|
iter.next();
|
||||||
if (!iter.value().isNull())
|
if (!iter.value().isNull())
|
||||||
@@ -80,7 +118,7 @@ SideBar::~SideBar()
|
|||||||
|
|
||||||
QString SideBar::idForTitle(const QString &title) const
|
QString SideBar::idForTitle(const QString &title) const
|
||||||
{
|
{
|
||||||
QMapIterator<QString, QWeakPointer<SideBarItem> > iter(m_itemMap);
|
QMapIterator<QString, QWeakPointer<SideBarItem> > iter(d->m_itemMap);
|
||||||
while(iter.hasNext()) {
|
while(iter.hasNext()) {
|
||||||
iter.next();
|
iter.next();
|
||||||
if (iter.value().data()->title() == title)
|
if (iter.value().data()->title() == title)
|
||||||
@@ -91,37 +129,37 @@ QString SideBar::idForTitle(const QString &title) const
|
|||||||
|
|
||||||
QStringList SideBar::availableItemIds() const
|
QStringList SideBar::availableItemIds() const
|
||||||
{
|
{
|
||||||
return m_availableItemIds;
|
return d->m_availableItemIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList SideBar::availableItemTitles() const
|
QStringList SideBar::availableItemTitles() const
|
||||||
{
|
{
|
||||||
return m_availableItemTitles;
|
return d->m_availableItemTitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList SideBar::unavailableItemIds() const
|
QStringList SideBar::unavailableItemIds() const
|
||||||
{
|
{
|
||||||
return m_unavailableItemIds;
|
return d->m_unavailableItemIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SideBar::closeWhenEmpty() const
|
bool SideBar::closeWhenEmpty() const
|
||||||
{
|
{
|
||||||
return m_closeWhenEmpty;
|
return d->m_closeWhenEmpty;
|
||||||
}
|
}
|
||||||
void SideBar::setCloseWhenEmpty(bool value)
|
void SideBar::setCloseWhenEmpty(bool value)
|
||||||
{
|
{
|
||||||
m_closeWhenEmpty = value;
|
d->m_closeWhenEmpty = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SideBar::makeItemAvailable(SideBarItem *item)
|
void SideBar::makeItemAvailable(SideBarItem *item)
|
||||||
{
|
{
|
||||||
QMap<QString, QWeakPointer<SideBarItem> >::const_iterator it = m_itemMap.constBegin();
|
QMap<QString, QWeakPointer<SideBarItem> >::const_iterator it = d->m_itemMap.constBegin();
|
||||||
while (it != m_itemMap.constEnd()) {
|
while (it != d->m_itemMap.constEnd()) {
|
||||||
if (it.value().data() == item) {
|
if (it.value().data() == item) {
|
||||||
m_availableItemIds.append(it.key());
|
d->m_availableItemIds.append(it.key());
|
||||||
m_availableItemTitles.append(it.value().data()->title());
|
d->m_availableItemTitles.append(it.value().data()->title());
|
||||||
m_unavailableItemIds.removeAll(it.key());
|
d->m_unavailableItemIds.removeAll(it.key());
|
||||||
qSort(m_availableItemTitles);
|
qSort(d->m_availableItemTitles);
|
||||||
emit availableItemsChanged();
|
emit availableItemsChanged();
|
||||||
//updateWidgets();
|
//updateWidgets();
|
||||||
break;
|
break;
|
||||||
@@ -135,61 +173,61 @@ void SideBar::makeItemAvailable(SideBarItem *item)
|
|||||||
void SideBar::setUnavailableItemIds(const QStringList &itemIds)
|
void SideBar::setUnavailableItemIds(const QStringList &itemIds)
|
||||||
{
|
{
|
||||||
// re-enable previous items
|
// re-enable previous items
|
||||||
foreach(const QString &id, m_unavailableItemIds) {
|
foreach(const QString &id, d->m_unavailableItemIds) {
|
||||||
m_availableItemIds.append(id);
|
d->m_availableItemIds.append(id);
|
||||||
m_availableItemTitles.append(m_itemMap.value(id).data()->title());
|
d->m_availableItemTitles.append(d->m_itemMap.value(id).data()->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_unavailableItemIds.clear();
|
d->m_unavailableItemIds.clear();
|
||||||
|
|
||||||
foreach (const QString &id, itemIds) {
|
foreach (const QString &id, itemIds) {
|
||||||
if (!m_unavailableItemIds.contains(id))
|
if (!d->m_unavailableItemIds.contains(id))
|
||||||
m_unavailableItemIds.append(id);
|
d->m_unavailableItemIds.append(id);
|
||||||
m_availableItemIds.removeAll(id);
|
d->m_availableItemIds.removeAll(id);
|
||||||
m_availableItemTitles.removeAll(m_itemMap.value(id).data()->title());
|
d->m_availableItemTitles.removeAll(d->m_itemMap.value(id).data()->title());
|
||||||
}
|
}
|
||||||
qSort(m_availableItemTitles);
|
qSort(d->m_availableItemTitles);
|
||||||
updateWidgets();
|
updateWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
SideBarItem *SideBar::item(const QString &id)
|
SideBarItem *SideBar::item(const QString &id)
|
||||||
{
|
{
|
||||||
if (m_itemMap.contains(id)) {
|
if (d->m_itemMap.contains(id)) {
|
||||||
m_availableItemIds.removeAll(id);
|
d->m_availableItemIds.removeAll(id);
|
||||||
m_availableItemTitles.removeAll(m_itemMap.value(id).data()->title());
|
d->m_availableItemTitles.removeAll(d->m_itemMap.value(id).data()->title());
|
||||||
|
|
||||||
if (!m_unavailableItemIds.contains(id))
|
if (!d->m_unavailableItemIds.contains(id))
|
||||||
m_unavailableItemIds.append(id);
|
d->m_unavailableItemIds.append(id);
|
||||||
|
|
||||||
emit availableItemsChanged();
|
emit availableItemsChanged();
|
||||||
return m_itemMap.value(id).data();
|
return d->m_itemMap.value(id).data();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SideBarWidget *SideBar::insertSideBarWidget(int position, const QString &id)
|
Internal::SideBarWidget *SideBar::insertSideBarWidget(int position, const QString &id)
|
||||||
{
|
{
|
||||||
SideBarWidget *item = new SideBarWidget(this, id);
|
Internal::SideBarWidget *item = new Internal::SideBarWidget(this, id);
|
||||||
connect(item, SIGNAL(splitMe()), this, SLOT(splitSubWidget()));
|
connect(item, SIGNAL(splitMe()), this, SLOT(splitSubWidget()));
|
||||||
connect(item, SIGNAL(closeMe()), this, SLOT(closeSubWidget()));
|
connect(item, SIGNAL(closeMe()), this, SLOT(closeSubWidget()));
|
||||||
connect(item, SIGNAL(currentWidgetChanged()), this, SLOT(updateWidgets()));
|
connect(item, SIGNAL(currentWidgetChanged()), this, SLOT(updateWidgets()));
|
||||||
insertWidget(position, item);
|
insertWidget(position, item);
|
||||||
m_widgets.insert(position, item);
|
d->m_widgets.insert(position, item);
|
||||||
updateWidgets();
|
updateWidgets();
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SideBar::removeSideBarWidget(SideBarWidget *widget)
|
void SideBar::removeSideBarWidget(Internal::SideBarWidget *widget)
|
||||||
{
|
{
|
||||||
widget->removeCurrentItem();
|
widget->removeCurrentItem();
|
||||||
m_widgets.removeOne(widget);
|
d->m_widgets.removeOne(widget);
|
||||||
widget->hide();
|
widget->hide();
|
||||||
widget->deleteLater();
|
widget->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SideBar::splitSubWidget()
|
void SideBar::splitSubWidget()
|
||||||
{
|
{
|
||||||
SideBarWidget *original = qobject_cast<SideBarWidget*>(sender());
|
Internal::SideBarWidget *original = qobject_cast<Internal::SideBarWidget*>(sender());
|
||||||
int pos = indexOf(original) + 1;
|
int pos = indexOf(original) + 1;
|
||||||
insertSideBarWidget(pos);
|
insertSideBarWidget(pos);
|
||||||
updateWidgets();
|
updateWidgets();
|
||||||
@@ -197,21 +235,21 @@ void SideBar::splitSubWidget()
|
|||||||
|
|
||||||
void SideBar::closeSubWidget()
|
void SideBar::closeSubWidget()
|
||||||
{
|
{
|
||||||
if (m_widgets.count() != 1) {
|
if (d->m_widgets.count() != 1) {
|
||||||
SideBarWidget *widget = qobject_cast<SideBarWidget*>(sender());
|
Internal::SideBarWidget *widget = qobject_cast<Internal::SideBarWidget*>(sender());
|
||||||
if (!widget)
|
if (!widget)
|
||||||
return;
|
return;
|
||||||
removeSideBarWidget(widget);
|
removeSideBarWidget(widget);
|
||||||
updateWidgets();
|
updateWidgets();
|
||||||
} else {
|
} else {
|
||||||
if (m_closeWhenEmpty)
|
if (d->m_closeWhenEmpty)
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SideBar::updateWidgets()
|
void SideBar::updateWidgets()
|
||||||
{
|
{
|
||||||
foreach (SideBarWidget *i, m_widgets)
|
foreach (Internal::SideBarWidget *i, d->m_widgets)
|
||||||
i->updateAvailableItems();
|
i->updateAvailableItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,13 +258,13 @@ void SideBar::saveSettings(QSettings *settings, const QString &name)
|
|||||||
const QString prefix = name.isEmpty() ? name : (name + QLatin1Char('/'));
|
const QString prefix = name.isEmpty() ? name : (name + QLatin1Char('/'));
|
||||||
|
|
||||||
QStringList views;
|
QStringList views;
|
||||||
for (int i = 0; i < m_widgets.count(); ++i) {
|
for (int i = 0; i < d->m_widgets.count(); ++i) {
|
||||||
QString currentItemId = m_widgets.at(i)->currentItemId();
|
QString currentItemId = d->m_widgets.at(i)->currentItemId();
|
||||||
if (!currentItemId.isEmpty())
|
if (!currentItemId.isEmpty())
|
||||||
views.append(currentItemId);
|
views.append(currentItemId);
|
||||||
}
|
}
|
||||||
if (views.isEmpty() && m_itemMap.size()) {
|
if (views.isEmpty() && d->m_itemMap.size()) {
|
||||||
QMapIterator<QString, QWeakPointer<SideBarItem> > iter(m_itemMap);
|
QMapIterator<QString, QWeakPointer<SideBarItem> > iter(d->m_itemMap);
|
||||||
iter.next();
|
iter.next();
|
||||||
views.append(iter.key());
|
views.append(iter.key());
|
||||||
}
|
}
|
||||||
@@ -239,7 +277,7 @@ void SideBar::saveSettings(QSettings *settings, const QString &name)
|
|||||||
|
|
||||||
void SideBar::closeAllWidgets()
|
void SideBar::closeAllWidgets()
|
||||||
{
|
{
|
||||||
foreach (SideBarWidget *widget, m_widgets)
|
foreach (Internal::SideBarWidget *widget, d->m_widgets)
|
||||||
removeSideBarWidget(widget);
|
removeSideBarWidget(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,14 +291,14 @@ void SideBar::readSettings(QSettings *settings, const QString &name)
|
|||||||
QStringList views = settings->value(prefix + "Views").toStringList();
|
QStringList views = settings->value(prefix + "Views").toStringList();
|
||||||
if (views.count()) {
|
if (views.count()) {
|
||||||
foreach (const QString &id, views)
|
foreach (const QString &id, views)
|
||||||
insertSideBarWidget(m_widgets.count(), id);
|
insertSideBarWidget(d->m_widgets.count(), id);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
insertSideBarWidget(0);
|
insertSideBarWidget(0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach (const QString &id, m_defaultVisible)
|
foreach (const QString &id, d->m_defaultVisible)
|
||||||
insertSideBarWidget(m_widgets.count(), id);
|
insertSideBarWidget(d->m_widgets.count(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings->contains(prefix + "Visible"))
|
if (settings->contains(prefix + "Visible"))
|
||||||
@@ -278,9 +316,9 @@ void SideBar::readSettings(QSettings *settings, const QString &name)
|
|||||||
|
|
||||||
void SideBar::activateItem(SideBarItem *item)
|
void SideBar::activateItem(SideBarItem *item)
|
||||||
{
|
{
|
||||||
QMap<QString, QWeakPointer<SideBarItem> >::const_iterator it = m_itemMap.constBegin();
|
QMap<QString, QWeakPointer<SideBarItem> >::const_iterator it = d->m_itemMap.constBegin();
|
||||||
QString id;
|
QString id;
|
||||||
while (it != m_itemMap.constEnd()) {
|
while (it != d->m_itemMap.constEnd()) {
|
||||||
if (it.value().data() == item) {
|
if (it.value().data() == item) {
|
||||||
id = it.key();
|
id = it.key();
|
||||||
break;
|
break;
|
||||||
@@ -291,14 +329,14 @@ void SideBar::activateItem(SideBarItem *item)
|
|||||||
if (id.isEmpty())
|
if (id.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < m_widgets.count(); ++i) {
|
for (int i = 0; i < d->m_widgets.count(); ++i) {
|
||||||
if (m_widgets.at(i)->currentItemId() == id) {
|
if (d->m_widgets.at(i)->currentItemId() == id) {
|
||||||
item->widget()->setFocus();
|
item->widget()->setFocus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SideBarWidget *widget = m_widgets.first();
|
Internal::SideBarWidget *widget = d->m_widgets.first();
|
||||||
widget->setCurrentItem(id);
|
widget->setCurrentItem(id);
|
||||||
updateWidgets();
|
updateWidgets();
|
||||||
item->widget()->setFocus();
|
item->widget()->setFocus();
|
||||||
@@ -306,180 +344,12 @@ void SideBar::activateItem(SideBarItem *item)
|
|||||||
|
|
||||||
void SideBar::setShortcutMap(const QMap<QString, Core::Command*> &shortcutMap)
|
void SideBar::setShortcutMap(const QMap<QString, Core::Command*> &shortcutMap)
|
||||||
{
|
{
|
||||||
m_shortcutMap = shortcutMap;
|
d->m_shortcutMap = shortcutMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, Core::Command*> SideBar::shortcutMap() const
|
QMap<QString, Core::Command*> SideBar::shortcutMap() const
|
||||||
{
|
{
|
||||||
return m_shortcutMap;
|
return d->m_shortcutMap;
|
||||||
}
|
}
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
SideBarWidget::SideBarWidget(SideBar *sideBar, const QString &id)
|
|
||||||
: m_currentItem(0)
|
|
||||||
, m_sideBar(sideBar)
|
|
||||||
{
|
|
||||||
m_comboBox = new ComboBox(this);
|
|
||||||
m_comboBox->setMinimumContentsLength(15);
|
|
||||||
|
|
||||||
m_toolbar = new QToolBar(this);
|
|
||||||
m_toolbar->setContentsMargins(0, 0, 0, 0);
|
|
||||||
m_toolbar->addWidget(m_comboBox);
|
|
||||||
|
|
||||||
QWidget *spacerItem = new QWidget(this);
|
|
||||||
spacerItem->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
||||||
m_toolbar->addWidget(spacerItem);
|
|
||||||
|
|
||||||
m_splitAction = new QAction(tr("Split"), m_toolbar);
|
|
||||||
m_splitAction->setToolTip(tr("Split"));
|
|
||||||
m_splitAction->setIcon(QIcon(QLatin1String(Constants::ICON_SPLIT_HORIZONTAL)));
|
|
||||||
connect(m_splitAction, SIGNAL(triggered()), this, SIGNAL(splitMe()));
|
|
||||||
m_toolbar->addAction(m_splitAction);
|
|
||||||
|
|
||||||
QAction *closeAction = new QAction(tr("Close"), m_toolbar);
|
|
||||||
closeAction->setToolTip(tr("Close"));
|
|
||||||
closeAction->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE)));
|
|
||||||
connect(closeAction, SIGNAL(triggered()), this, SIGNAL(closeMe()));
|
|
||||||
m_toolbar->addAction(closeAction);
|
|
||||||
|
|
||||||
QVBoxLayout *lay = new QVBoxLayout();
|
|
||||||
lay->setMargin(0);
|
|
||||||
lay->setSpacing(0);
|
|
||||||
setLayout(lay);
|
|
||||||
lay->addWidget(m_toolbar);
|
|
||||||
|
|
||||||
QStringList titleList = m_sideBar->availableItemTitles();
|
|
||||||
qSort(titleList);
|
|
||||||
QString t = id;
|
|
||||||
if (titleList.count()) {
|
|
||||||
foreach(const QString &itemTitle, titleList)
|
|
||||||
m_comboBox->addItem(itemTitle, m_sideBar->idForTitle(itemTitle));
|
|
||||||
|
|
||||||
m_comboBox->setCurrentIndex(0);
|
|
||||||
if (t.isEmpty())
|
|
||||||
t = m_comboBox->itemData(0, ComboBox::IdRole).toString();
|
|
||||||
}
|
|
||||||
setCurrentItem(t);
|
|
||||||
|
|
||||||
connect(m_comboBox, SIGNAL(currentIndexChanged(int)),
|
|
||||||
this, SLOT(setCurrentIndex(int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
SideBarWidget::~SideBarWidget()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SideBarWidget::currentItemTitle() const
|
|
||||||
{
|
|
||||||
return m_comboBox->currentText();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SideBarWidget::currentItemId() const
|
|
||||||
{
|
|
||||||
if (m_currentItem)
|
|
||||||
return m_currentItem->id();
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SideBarWidget::setCurrentItem(const QString &id)
|
|
||||||
{
|
|
||||||
if (!id.isEmpty()) {
|
|
||||||
int idx = m_comboBox->findData(QVariant(id), ComboBox::IdRole);
|
|
||||||
|
|
||||||
if (idx < 0)
|
|
||||||
idx = 0;
|
|
||||||
|
|
||||||
bool blocked = m_comboBox->blockSignals(true);
|
|
||||||
m_comboBox->setCurrentIndex(idx);
|
|
||||||
m_comboBox->blockSignals(blocked);
|
|
||||||
}
|
|
||||||
|
|
||||||
SideBarItem *item = m_sideBar->item(id);
|
|
||||||
if (!item)
|
|
||||||
return;
|
|
||||||
removeCurrentItem();
|
|
||||||
m_currentItem = item;
|
|
||||||
|
|
||||||
layout()->addWidget(m_currentItem->widget());
|
|
||||||
m_currentItem->widget()->show();
|
|
||||||
|
|
||||||
// Add buttons and remember their actions for later removal
|
|
||||||
foreach (QToolButton *b, m_currentItem->createToolBarWidgets())
|
|
||||||
m_addedToolBarActions.append(m_toolbar->insertWidget(m_splitAction, b));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SideBarWidget::updateAvailableItems()
|
|
||||||
{
|
|
||||||
bool blocked = m_comboBox->blockSignals(true);
|
|
||||||
QString currentTitle = m_comboBox->currentText();
|
|
||||||
m_comboBox->clear();
|
|
||||||
QStringList titleList = m_sideBar->availableItemTitles();
|
|
||||||
if (!currentTitle.isEmpty() && !titleList.contains(currentTitle))
|
|
||||||
titleList.append(currentTitle);
|
|
||||||
qSort(titleList);
|
|
||||||
|
|
||||||
foreach(const QString &itemTitle, titleList)
|
|
||||||
m_comboBox->addItem(itemTitle, m_sideBar->idForTitle(itemTitle));
|
|
||||||
|
|
||||||
int idx = m_comboBox->findText(currentTitle);
|
|
||||||
|
|
||||||
if (idx < 0)
|
|
||||||
idx = 0;
|
|
||||||
|
|
||||||
m_comboBox->setCurrentIndex(idx);
|
|
||||||
m_splitAction->setEnabled(titleList.count() > 1);
|
|
||||||
m_comboBox->blockSignals(blocked);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SideBarWidget::removeCurrentItem()
|
|
||||||
{
|
|
||||||
if (!m_currentItem)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QWidget *w = m_currentItem->widget();
|
|
||||||
w->hide();
|
|
||||||
layout()->removeWidget(w);
|
|
||||||
w->setParent(0);
|
|
||||||
m_sideBar->makeItemAvailable(m_currentItem);
|
|
||||||
|
|
||||||
// Delete custom toolbar widgets
|
|
||||||
qDeleteAll(m_addedToolBarActions);
|
|
||||||
m_addedToolBarActions.clear();
|
|
||||||
|
|
||||||
m_currentItem = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SideBarWidget::setCurrentIndex(int)
|
|
||||||
{
|
|
||||||
setCurrentItem(m_comboBox->itemData(m_comboBox->currentIndex(),
|
|
||||||
ComboBox::IdRole).toString());
|
|
||||||
emit currentWidgetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::Command *SideBarWidget::command(const QString &id) const
|
|
||||||
{
|
|
||||||
const QMap<QString, Core::Command*> shortcutMap = m_sideBar->shortcutMap();
|
|
||||||
QMap<QString, Core::Command*>::const_iterator r = shortcutMap.find(id);
|
|
||||||
if (r != shortcutMap.end())
|
|
||||||
return r.value();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ComboBox::ComboBox(SideBarWidget *sideBarWidget)
|
|
||||||
: m_sideBarWidget(sideBarWidget)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ComboBox::event(QEvent *e)
|
|
||||||
{
|
|
||||||
if (e->type() == QEvent::ToolTip) {
|
|
||||||
QString txt = currentText();
|
|
||||||
Core::Command *cmd = m_sideBarWidget->command(txt);
|
|
||||||
if (cmd) {
|
|
||||||
txt = tr("Activate %1").arg(txt);
|
|
||||||
setToolTip(cmd->stringWithAppendedShortcut(txt));
|
|
||||||
} else {
|
|
||||||
setToolTip(txt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QComboBox::event(e);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -30,27 +30,25 @@
|
|||||||
#ifndef SIDEBAR_H
|
#ifndef SIDEBAR_H
|
||||||
#define SIDEBAR_H
|
#define SIDEBAR_H
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
#include "core_global.h"
|
||||||
#include <QtCore/QPointer>
|
#include "minisplitter.h"
|
||||||
#include <QtGui/QWidget>
|
|
||||||
#include <QtGui/QComboBox>
|
|
||||||
|
|
||||||
#include <coreplugin/minisplitter.h>
|
#include <QtCore/QMap>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QScopedPointer>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSettings;
|
class QSettings;
|
||||||
class QToolBar;
|
|
||||||
class QAction;
|
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class Command;
|
class Command;
|
||||||
|
struct SideBarPrivate;
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class SideBarWidget;
|
class SideBarWidget;
|
||||||
class ComboBox;
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -65,14 +63,12 @@ class CORE_EXPORT SideBarItem : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
// id is non-localized string of the item that's used to store the settings.
|
// id is non-localized string of the item that's used to store the settings.
|
||||||
SideBarItem(QWidget *widget, const QString &id)
|
explicit SideBarItem(QWidget *widget, const QString &id);
|
||||||
: m_widget(widget), m_id(id)
|
|
||||||
{}
|
|
||||||
|
|
||||||
virtual ~SideBarItem();
|
virtual ~SideBarItem();
|
||||||
QWidget *widget() { return m_widget; }
|
|
||||||
QString id() const { return m_id; }
|
QWidget *widget() const;
|
||||||
QString title() const { return m_widget->windowTitle(); }
|
QString id() const;
|
||||||
|
QString title() const;
|
||||||
|
|
||||||
/* Should always return a new set of tool buttons.
|
/* Should always return a new set of tool buttons.
|
||||||
*
|
*
|
||||||
@@ -80,14 +76,12 @@ public:
|
|||||||
* that have been added to a QToolBar without either not deleting the
|
* that have been added to a QToolBar without either not deleting the
|
||||||
* associated QAction or causing the QToolButton to be deleted.
|
* associated QAction or causing the QToolButton to be deleted.
|
||||||
*/
|
*/
|
||||||
virtual QList<QToolButton *> createToolBarWidgets()
|
virtual QList<QToolButton *> createToolBarWidgets();
|
||||||
{
|
|
||||||
return QList<QToolButton *>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_widget;
|
const QString m_id;
|
||||||
QString m_id;
|
|
||||||
|
QWidget *m_widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CORE_EXPORT SideBar : public MiniSplitter
|
class CORE_EXPORT SideBar : public MiniSplitter
|
||||||
@@ -99,9 +93,9 @@ public:
|
|||||||
* if you have one SideBar, or shared ownership in case
|
* if you have one SideBar, or shared ownership in case
|
||||||
* of multiple SideBars.
|
* of multiple SideBars.
|
||||||
*/
|
*/
|
||||||
SideBar(QList< SideBarItem*> widgetList,
|
explicit SideBar(QList< SideBarItem*> widgetList,
|
||||||
QList< SideBarItem*> defaultVisible);
|
QList< SideBarItem*> defaultVisible);
|
||||||
~SideBar();
|
virtual ~SideBar();
|
||||||
|
|
||||||
QStringList availableItemIds() const;
|
QStringList availableItemIds() const;
|
||||||
QStringList availableItemTitles() const;
|
QStringList availableItemTitles() const;
|
||||||
@@ -136,70 +130,9 @@ private:
|
|||||||
const QString &title = QString());
|
const QString &title = QString());
|
||||||
void removeSideBarWidget(Internal::SideBarWidget *widget);
|
void removeSideBarWidget(Internal::SideBarWidget *widget);
|
||||||
|
|
||||||
QList<Internal::SideBarWidget*> m_widgets;
|
QScopedPointer<SideBarPrivate> d;
|
||||||
QMap<QString, QWeakPointer<SideBarItem> > m_itemMap;
|
|
||||||
QStringList m_availableItemIds;
|
|
||||||
QStringList m_availableItemTitles;
|
|
||||||
QStringList m_unavailableItemIds;
|
|
||||||
QStringList m_defaultVisible;
|
|
||||||
QMap<QString, Core::Command*> m_shortcutMap;
|
|
||||||
bool m_closeWhenEmpty;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class SideBarWidget : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
SideBarWidget(SideBar *sideBar, const QString &title);
|
|
||||||
~SideBarWidget();
|
|
||||||
|
|
||||||
QString currentItemId() const;
|
|
||||||
QString currentItemTitle() const;
|
|
||||||
void setCurrentItem(const QString &id);
|
|
||||||
|
|
||||||
void updateAvailableItems();
|
|
||||||
void removeCurrentItem();
|
|
||||||
|
|
||||||
Core::Command *command(const QString &id) const;
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void splitMe();
|
|
||||||
void closeMe();
|
|
||||||
void currentWidgetChanged();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void setCurrentIndex(int);
|
|
||||||
|
|
||||||
private:
|
|
||||||
ComboBox *m_comboBox;
|
|
||||||
SideBarItem *m_currentItem;
|
|
||||||
QToolBar *m_toolbar;
|
|
||||||
QAction *m_splitAction;
|
|
||||||
QList<QAction *> m_addedToolBarActions;
|
|
||||||
SideBar *m_sideBar;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ComboBox : public QComboBox
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum DataRoles {
|
|
||||||
IdRole = Qt::UserRole
|
|
||||||
};
|
|
||||||
|
|
||||||
ComboBox(SideBarWidget *sideBarWidget);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool event(QEvent *event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
SideBarWidget *m_sideBarWidget;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
#endif // SIDEBAR_H
|
#endif // SIDEBAR_H
|
||||||
|
|||||||
211
src/plugins/coreplugin/sidebarwidget.cpp
Normal file
211
src/plugins/coreplugin/sidebarwidget.cpp
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#include "sidebarwidget.h"
|
||||||
|
#include "sidebar.h"
|
||||||
|
#include "navigationsubwidget.h"
|
||||||
|
|
||||||
|
#include <coreplugin/coreconstants.h>
|
||||||
|
|
||||||
|
#include <QtGui/QToolBar>
|
||||||
|
#include <QtGui/QToolButton>
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class SideBarComboBox : public CommandComboBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum DataRoles {
|
||||||
|
IdRole = Qt::UserRole
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit SideBarComboBox(SideBarWidget *sideBarWidget) : m_sideBarWidget(sideBarWidget) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual const Core::Command *command(const QString &text) const
|
||||||
|
{ return m_sideBarWidget->command(text); }
|
||||||
|
|
||||||
|
SideBarWidget *m_sideBarWidget;
|
||||||
|
};
|
||||||
|
|
||||||
|
SideBarWidget::SideBarWidget(SideBar *sideBar, const QString &id)
|
||||||
|
: m_currentItem(0)
|
||||||
|
, m_sideBar(sideBar)
|
||||||
|
{
|
||||||
|
m_comboBox = new SideBarComboBox(this);
|
||||||
|
m_comboBox->setMinimumContentsLength(15);
|
||||||
|
|
||||||
|
m_toolbar = new QToolBar(this);
|
||||||
|
m_toolbar->setContentsMargins(0, 0, 0, 0);
|
||||||
|
m_toolbar->addWidget(m_comboBox);
|
||||||
|
|
||||||
|
QWidget *spacerItem = new QWidget(this);
|
||||||
|
spacerItem->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||||
|
m_toolbar->addWidget(spacerItem);
|
||||||
|
|
||||||
|
m_splitAction = new QAction(tr("Split"), m_toolbar);
|
||||||
|
m_splitAction->setToolTip(tr("Split"));
|
||||||
|
m_splitAction->setIcon(QIcon(QLatin1String(Constants::ICON_SPLIT_HORIZONTAL)));
|
||||||
|
connect(m_splitAction, SIGNAL(triggered()), this, SIGNAL(splitMe()));
|
||||||
|
m_toolbar->addAction(m_splitAction);
|
||||||
|
|
||||||
|
QAction *closeAction = new QAction(tr("Close"), m_toolbar);
|
||||||
|
closeAction->setToolTip(tr("Close"));
|
||||||
|
closeAction->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE)));
|
||||||
|
connect(closeAction, SIGNAL(triggered()), this, SIGNAL(closeMe()));
|
||||||
|
m_toolbar->addAction(closeAction);
|
||||||
|
|
||||||
|
QVBoxLayout *lay = new QVBoxLayout();
|
||||||
|
lay->setMargin(0);
|
||||||
|
lay->setSpacing(0);
|
||||||
|
setLayout(lay);
|
||||||
|
lay->addWidget(m_toolbar);
|
||||||
|
|
||||||
|
QStringList titleList = m_sideBar->availableItemTitles();
|
||||||
|
qSort(titleList);
|
||||||
|
QString t = id;
|
||||||
|
if (titleList.count()) {
|
||||||
|
foreach(const QString &itemTitle, titleList)
|
||||||
|
m_comboBox->addItem(itemTitle, m_sideBar->idForTitle(itemTitle));
|
||||||
|
|
||||||
|
m_comboBox->setCurrentIndex(0);
|
||||||
|
if (t.isEmpty())
|
||||||
|
t = m_comboBox->itemData(0, SideBarComboBox::IdRole).toString();
|
||||||
|
}
|
||||||
|
setCurrentItem(t);
|
||||||
|
|
||||||
|
connect(m_comboBox, SIGNAL(currentIndexChanged(int)),
|
||||||
|
this, SLOT(setCurrentIndex(int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
SideBarWidget::~SideBarWidget()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SideBarWidget::currentItemTitle() const
|
||||||
|
{
|
||||||
|
return m_comboBox->currentText();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SideBarWidget::currentItemId() const
|
||||||
|
{
|
||||||
|
if (m_currentItem)
|
||||||
|
return m_currentItem->id();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SideBarWidget::setCurrentItem(const QString &id)
|
||||||
|
{
|
||||||
|
if (!id.isEmpty()) {
|
||||||
|
int idx = m_comboBox->findData(QVariant(id), SideBarComboBox::IdRole);
|
||||||
|
|
||||||
|
if (idx < 0)
|
||||||
|
idx = 0;
|
||||||
|
|
||||||
|
bool blocked = m_comboBox->blockSignals(true);
|
||||||
|
m_comboBox->setCurrentIndex(idx);
|
||||||
|
m_comboBox->blockSignals(blocked);
|
||||||
|
}
|
||||||
|
|
||||||
|
SideBarItem *item = m_sideBar->item(id);
|
||||||
|
if (!item)
|
||||||
|
return;
|
||||||
|
removeCurrentItem();
|
||||||
|
m_currentItem = item;
|
||||||
|
|
||||||
|
layout()->addWidget(m_currentItem->widget());
|
||||||
|
m_currentItem->widget()->show();
|
||||||
|
|
||||||
|
// Add buttons and remember their actions for later removal
|
||||||
|
foreach (QToolButton *b, m_currentItem->createToolBarWidgets())
|
||||||
|
m_addedToolBarActions.append(m_toolbar->insertWidget(m_splitAction, b));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SideBarWidget::updateAvailableItems()
|
||||||
|
{
|
||||||
|
bool blocked = m_comboBox->blockSignals(true);
|
||||||
|
QString currentTitle = m_comboBox->currentText();
|
||||||
|
m_comboBox->clear();
|
||||||
|
QStringList titleList = m_sideBar->availableItemTitles();
|
||||||
|
if (!currentTitle.isEmpty() && !titleList.contains(currentTitle))
|
||||||
|
titleList.append(currentTitle);
|
||||||
|
qSort(titleList);
|
||||||
|
|
||||||
|
foreach(const QString &itemTitle, titleList)
|
||||||
|
m_comboBox->addItem(itemTitle, m_sideBar->idForTitle(itemTitle));
|
||||||
|
|
||||||
|
int idx = m_comboBox->findText(currentTitle);
|
||||||
|
|
||||||
|
if (idx < 0)
|
||||||
|
idx = 0;
|
||||||
|
|
||||||
|
m_comboBox->setCurrentIndex(idx);
|
||||||
|
m_splitAction->setEnabled(titleList.count() > 1);
|
||||||
|
m_comboBox->blockSignals(blocked);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SideBarWidget::removeCurrentItem()
|
||||||
|
{
|
||||||
|
if (!m_currentItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QWidget *w = m_currentItem->widget();
|
||||||
|
w->hide();
|
||||||
|
layout()->removeWidget(w);
|
||||||
|
w->setParent(0);
|
||||||
|
m_sideBar->makeItemAvailable(m_currentItem);
|
||||||
|
|
||||||
|
// Delete custom toolbar widgets
|
||||||
|
qDeleteAll(m_addedToolBarActions);
|
||||||
|
m_addedToolBarActions.clear();
|
||||||
|
|
||||||
|
m_currentItem = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SideBarWidget::setCurrentIndex(int)
|
||||||
|
{
|
||||||
|
setCurrentItem(m_comboBox->itemData(m_comboBox->currentIndex(),
|
||||||
|
SideBarComboBox::IdRole).toString());
|
||||||
|
emit currentWidgetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Command *SideBarWidget::command(const QString &id) const
|
||||||
|
{
|
||||||
|
const QMap<QString, Core::Command*> shortcutMap = m_sideBar->shortcutMap();
|
||||||
|
QMap<QString, Core::Command*>::const_iterator r = shortcutMap.find(id);
|
||||||
|
if (r != shortcutMap.end())
|
||||||
|
return r.value();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Core
|
||||||
87
src/plugins/coreplugin/sidebarwidget.h
Normal file
87
src/plugins/coreplugin/sidebarwidget.h
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator
|
||||||
|
**
|
||||||
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
||||||
|
**
|
||||||
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||||
|
**
|
||||||
|
** Commercial Usage
|
||||||
|
**
|
||||||
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
||||||
|
** accordance with the Qt Commercial License Agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Nokia.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
**
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 as published by the Free Software
|
||||||
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||||
|
** packaging of this file. Please review the following information to
|
||||||
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||||
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** If you are unsure which license is appropriate for your use, please
|
||||||
|
** contact the sales department at http://qt.nokia.com/contact.
|
||||||
|
**
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SIDEBARWIDGET_H
|
||||||
|
#define SIDEBARWIDGET_H
|
||||||
|
|
||||||
|
#include <QtCore/QMap>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QSettings;
|
||||||
|
class QToolBar;
|
||||||
|
class QAction;
|
||||||
|
class QToolButton;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Core {
|
||||||
|
class SideBar;
|
||||||
|
class SideBarItem;
|
||||||
|
class Command;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
class SideBarComboBox;
|
||||||
|
|
||||||
|
class SideBarWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit SideBarWidget(SideBar *sideBar, const QString &title);
|
||||||
|
virtual ~SideBarWidget();
|
||||||
|
|
||||||
|
QString currentItemId() const;
|
||||||
|
QString currentItemTitle() const;
|
||||||
|
void setCurrentItem(const QString &id);
|
||||||
|
|
||||||
|
void updateAvailableItems();
|
||||||
|
void removeCurrentItem();
|
||||||
|
|
||||||
|
Core::Command *command(const QString &id) const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void splitMe();
|
||||||
|
void closeMe();
|
||||||
|
void currentWidgetChanged();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void setCurrentIndex(int);
|
||||||
|
|
||||||
|
private:
|
||||||
|
SideBarComboBox *m_comboBox;
|
||||||
|
SideBarItem *m_currentItem;
|
||||||
|
QToolBar *m_toolbar;
|
||||||
|
QAction *m_splitAction;
|
||||||
|
QList<QAction *> m_addedToolBarActions;
|
||||||
|
SideBar *m_sideBar;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
#endif // SIDEBARWIDGET_H
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
#include <texteditor/helpitem.h>
|
#include <texteditor/helpitem.h>
|
||||||
|
|
||||||
#include <QtGui/QTextCursor>
|
#include <QtGui/QTextCursor>
|
||||||
|
#include <QtCore/QUrl>
|
||||||
|
|
||||||
using namespace CppEditor::Internal;
|
using namespace CppEditor::Internal;
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|||||||
Reference in New Issue
Block a user