Commit 43515f1c authored by mae's avatar mae
Browse files

Add a minimize/maximize action to the output pane

This is part of a bigger change to get rid of the output mode.

Reviewed-by: con
parent c91c4161
......@@ -68,7 +68,7 @@ EditMode::EditMode(EditorManager *editorManager) :
MiniSplitter *splitter = new MiniSplitter;
splitter->setOrientation(Qt::Vertical);
splitter->insertWidget(0, rightPaneSplitter);
splitter->insertWidget(1, new Core::OutputPanePlaceHolder(this));
splitter->insertWidget(1, new Core::OutputPanePlaceHolder(this, splitter));
splitter->setStretchFactor(0, 3);
splitter->setStretchFactor(1, 0);
......
......@@ -43,6 +43,7 @@
#include <extensionsystem/pluginmanager.h>
#include <utils/styledbar.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
......@@ -51,6 +52,7 @@
#include <QtGui/QComboBox>
#include <QtGui/QFocusEvent>
#include <QtGui/QHBoxLayout>
#include <QtGui/QSplitter>
#include <QtGui/QMenu>
#include <QtGui/QPainter>
#include <QtGui/QPushButton>
......@@ -80,9 +82,10 @@ private:
OutputPanePlaceHolder *OutputPanePlaceHolder::m_current = 0;
OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent)
OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QSplitter* parent)
: QWidget(parent), m_mode(mode), m_closeable(true)
{
m_splitter = parent;
setVisible(false);
setLayout(new QVBoxLayout);
QSizePolicy sp;
......@@ -130,6 +133,40 @@ void OutputPanePlaceHolder::currentModeChanged(Core::IMode *mode)
}
}
void OutputPanePlaceHolder::maximizeOrMinimize(bool maximize)
{
if (!m_splitter)
return;
int idx = m_splitter->indexOf(this);
if (idx < 0)
return;
QList<int> sizes = m_splitter->sizes();
if (maximize) {
int sum;
foreach(int s, sizes)
sum += s;
for (int i = 0; i < sizes.count(); ++i) {
sizes[i] = 32;
}
sizes[idx] = sum - (sizes.count()-1) * 32;
} else {
int target = sizeHint().height();
int space = sizes[idx] - target;
if (space > 0) {
for (int i = 0; i < sizes.count(); ++i) {
sizes[i] += space / (sizes.count()-1);
}
sizes[idx] = target;
}
}
m_splitter->setSizes(sizes);
}
////
// OutputPaneManager
////
......@@ -157,6 +194,8 @@ 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_minMaxButton->setVisible(OutputPanePlaceHolder::m_current
&& OutputPanePlaceHolder::m_current->canMaximizeOrMinimize());
}
OutputPaneManager::OutputPaneManager(QWidget *parent) :
......@@ -164,6 +203,8 @@ OutputPaneManager::OutputPaneManager(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),
......@@ -187,6 +228,10 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) :
m_prevAction->setText(tr("Previous Item"));
connect(m_prevAction, SIGNAL(triggered()), this, SLOT(slotPrev()));
m_minMaxAction = new QAction(this);
m_minMaxAction->setText(tr("Minimize/Maximize Output Pane"));
m_minMaxButton->setArrowType(Qt::UpArrow);
m_closeButton->setIcon(QIcon(":/core/images/closebutton.png"));
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(slotHide()));
......@@ -204,6 +249,7 @@ OutputPaneManager::OutputPaneManager(QWidget *parent) :
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);
......@@ -262,6 +308,12 @@ void OutputPaneManager::init()
cmd->setDefaultKeySequence(QKeySequence("F6"));
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
cmd = am->registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalcontext);
cmd->setDefaultKeySequence(QKeySequence("Ctrl+9"));
mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
m_minMaxButton->setDefaultAction(cmd->action());
connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
QAction *sep = new QAction(this);
sep->setSeparator(true);
cmd = am->registerAction(sep, QLatin1String("Coreplugin.OutputPane.Sep"), globalcontext);
......@@ -357,6 +409,18 @@ void OutputPaneManager::shortcutTriggered()
}
}
void OutputPaneManager::slotMinMax()
{
QTC_ASSERT(OutputPanePlaceHolder::m_current, return);
if (!OutputPanePlaceHolder::m_current->isVisible()) // easier than disabling/enabling the action
return;
bool maximize = m_minMaxButton->arrowType() == Qt::UpArrow;
OutputPanePlaceHolder::m_current->maximizeOrMinimize(maximize);
m_minMaxButton->setArrowType(maximize ? Qt::DownArrow : Qt::UpArrow);
}
void OutputPaneManager::buttonTriggered()
{
QPushButton *button = qobject_cast<QPushButton *>(sender());
......
......@@ -41,6 +41,7 @@ class QComboBox;
class QToolButton;
class QStackedWidget;
class QPushButton;
class QSplitter;
QT_END_NAMESPACE
namespace Core {
......@@ -59,16 +60,19 @@ class CORE_EXPORT OutputPanePlaceHolder : public QWidget
friend class Core::Internal::OutputPaneManager; // needs to set m_visible and thus access m_current
Q_OBJECT
public:
OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0);
OutputPanePlaceHolder(Core::IMode *mode, QSplitter *parent = 0);
~OutputPanePlaceHolder();
void setCloseable(bool b);
bool closeable();
static OutputPanePlaceHolder *getCurrent() { return m_current; }
inline bool canMaximizeOrMinimize() const { return m_splitter != 0; }
void maximizeOrMinimize(bool maximize);
private slots:
void currentModeChanged(Core::IMode *);
private:
Core::IMode *m_mode;
QSplitter *m_splitter;
bool m_closeable;
static OutputPanePlaceHolder* m_current;
};
......@@ -92,6 +96,7 @@ public slots:
void slotNext();
void slotPrev();
void shortcutTriggered();
void slotMinMax();
protected:
void focusInEvent(QFocusEvent *e);
......@@ -122,6 +127,9 @@ private:
QToolButton *m_clearButton;
QToolButton *m_closeButton;
QAction *m_minMaxAction;
QToolButton *m_minMaxButton;
QAction *m_nextAction;
QAction *m_prevAction;
QToolButton *m_prevToolButton;
......
......@@ -895,7 +895,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
MiniSplitter *splitter = new MiniSplitter;
splitter->addWidget(m_manager->mainWindow());
splitter->addWidget(new OutputPanePlaceHolder(m_debugMode));
splitter->addWidget(new OutputPanePlaceHolder(m_debugMode, splitter));
splitter->setStretchFactor(0, 10);
splitter->setStretchFactor(1, 0);
splitter->setOrientation(Qt::Vertical);
......
......@@ -396,7 +396,7 @@ QWidget *QmlInspectorMode::createModeWindow()
// right-side window with editor, output etc.
Core::MiniSplitter *mainWindowSplitter = new Core::MiniSplitter;
mainWindowSplitter->addWidget(createMainView());
mainWindowSplitter->addWidget(new Core::OutputPanePlaceHolder(this));
mainWindowSplitter->addWidget(new Core::OutputPanePlaceHolder(this, mainWindowSplitter));
mainWindowSplitter->setStretchFactor(0, 10);
mainWindowSplitter->setStretchFactor(1, 0);
mainWindowSplitter->setOrientation(Qt::Vertical);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment