Commit cc11186b authored by Eike Ziller's avatar Eike Ziller

Avoid setting large minimum size for output panes.

The search result pane set a minimum size for the "New Search"
panel which forced this relative big minimum size on all panels
and made it impossible to make the output pane area small.
Now, the new search is wrapped into a scroll area, doesn't
enforce a minimum size anymore, and, instead, when initiating
a new search (via shortcut or menu action) resizes the pane
so the panel fits nicely.

Change-Id: I9afe67e66f324111a10a97f33c203846231e6a93
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 06f53a4e
...@@ -78,15 +78,16 @@ public: ...@@ -78,15 +78,16 @@ public:
virtual void goToPrev() = 0; virtual void goToPrev() = 0;
public slots: public slots:
void popup() { popup(true); } void popup() { popup(true, false); }
void popup(bool withFocus) { emit showPage(withFocus); } void popup(bool withFocus) { popup(withFocus, false); }
void popup(bool withFocus, bool ensureSizeHint) { emit showPage(withFocus, ensureSizeHint); }
void hide() { emit hidePage(); } void hide() { emit hidePage(); }
void toggle() { toggle(true); } void toggle() { toggle(true); }
void toggle(bool withFocusIfShown) { emit togglePage(withFocusIfShown); } void toggle(bool withFocusIfShown) { emit togglePage(withFocusIfShown); }
void navigateStateChanged() { emit navigateStateUpdate(); } void navigateStateChanged() { emit navigateStateUpdate(); }
signals: signals:
void showPage(bool withFocus); void showPage(bool withFocus, bool ensureSizeHint);
void hidePage(); void hidePage();
void togglePage(bool withFocusIfShown); void togglePage(bool withFocusIfShown);
void navigateStateUpdate(); void navigateStateUpdate();
......
...@@ -143,6 +143,28 @@ bool OutputPanePlaceHolder::isMaximized() const ...@@ -143,6 +143,28 @@ bool OutputPanePlaceHolder::isMaximized() const
return Internal::OutputPaneManager::instance()->isMaximized(); return Internal::OutputPaneManager::instance()->isMaximized();
} }
void OutputPanePlaceHolder::ensureSizeHintAsMinimum()
{
if (!d->m_splitter)
return;
int idx = d->m_splitter->indexOf(this);
if (idx < 0)
return;
QList<int> sizes = d->m_splitter->sizes();
Internal::OutputPaneManager *om = Internal::OutputPaneManager::instance();
int minimum = (d->m_splitter->orientation() == Qt::Vertical
? om->sizeHint().height() : om->sizeHint().width());
int difference = minimum - sizes.at(idx);
if (difference <= 0) // is already larger
return;
for (int i = 0; i < sizes.count(); ++i) {
sizes[i] += difference / (sizes.count()-1);
}
sizes[idx] = minimum;
d->m_splitter->setSizes(sizes);
}
void OutputPanePlaceHolder::unmaximize() void OutputPanePlaceHolder::unmaximize()
{ {
if (Internal::OutputPaneManager::instance()->isMaximized()) if (Internal::OutputPaneManager::instance()->isMaximized())
......
...@@ -64,6 +64,7 @@ public: ...@@ -64,6 +64,7 @@ public:
void unmaximize(); void unmaximize();
bool isMaximized() const; bool isMaximized() const;
void ensureSizeHintAsMinimum();
private slots: private slots:
void currentModeChanged(Core::IMode *); void currentModeChanged(Core::IMode *);
......
...@@ -254,7 +254,7 @@ void OutputPaneManager::init() ...@@ -254,7 +254,7 @@ void OutputPaneManager::init()
const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this)); const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));
m_pageMap.insert(idx, outPane); m_pageMap.insert(idx, outPane);
connect(outPane, SIGNAL(showPage(bool)), this, SLOT(showPage(bool))); connect(outPane, SIGNAL(showPage(bool,bool)), this, SLOT(showPage(bool,bool)));
connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide())); connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide()));
connect(outPane, SIGNAL(togglePage(bool)), this, SLOT(togglePage(bool))); connect(outPane, SIGNAL(togglePage(bool)), this, SLOT(togglePage(bool)));
connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState())); connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState()));
...@@ -431,10 +431,12 @@ void OutputPaneManager::updateNavigateState() ...@@ -431,10 +431,12 @@ void OutputPaneManager::updateNavigateState()
} }
// Slot connected to showPage signal of each page // Slot connected to showPage signal of each page
void OutputPaneManager::showPage(bool focus) void OutputPaneManager::showPage(bool focus, bool ensureSizeHint)
{ {
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender())); int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
showPage(idx, focus); showPage(idx, focus);
if (ensureSizeHint && OutputPanePlaceHolder::getCurrent())
OutputPanePlaceHolder::getCurrent()->ensureSizeHintAsMinimum();
} }
void OutputPaneManager::showPage(int idx, bool focus) void OutputPaneManager::showPage(int idx, bool focus)
......
...@@ -78,7 +78,7 @@ protected: ...@@ -78,7 +78,7 @@ protected:
private slots: private slots:
void changePage(); void changePage();
void showPage(bool focus); void showPage(bool focus, bool ensureSizeHint);
void togglePage(bool focus); void togglePage(bool focus);
void clearPage(); void clearPage();
void buttonTriggered(); void buttonTriggered();
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <QtGui/QFont> #include <QtGui/QFont>
#include <QtGui/QAction> #include <QtGui/QAction>
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtGui/QScrollArea>
#include <QtGui/QStackedWidget> #include <QtGui/QStackedWidget>
static const char SETTINGSKEYSECTIONNAME[] = "SearchResults"; static const char SETTINGSKEYSECTIONNAME[] = "SearchResults";
...@@ -209,7 +210,10 @@ SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel) ...@@ -209,7 +210,10 @@ SearchResultWindow::SearchResultWindow(QWidget *newSearchPanel)
d->m_widget = new QStackedWidget; d->m_widget = new QStackedWidget;
d->m_widget->setWindowTitle(displayName()); d->m_widget->setWindowTitle(displayName());
d->m_widget->addWidget(newSearchPanel); QScrollArea *newSearchArea = new QScrollArea(d->m_widget);
newSearchArea->setFrameStyle(QFrame::NoFrame);
newSearchArea->setWidget(newSearchPanel);
d->m_widget->addWidget(newSearchArea);
d->m_currentIndex = 0; d->m_currentIndex = 0;
d->m_expandCollapseButton = new QToolButton(d->m_widget); d->m_expandCollapseButton = new QToolButton(d->m_widget);
...@@ -400,7 +404,7 @@ void SearchResultWindow::setTextEditorFont(const QFont &font) ...@@ -400,7 +404,7 @@ void SearchResultWindow::setTextEditorFont(const QFont &font)
void SearchResultWindow::openNewSearchPanel() void SearchResultWindow::openNewSearchPanel()
{ {
d->setCurrentIndex(0); d->setCurrentIndex(0);
popup(); popup(true/*focus*/, true/*sizeHint*/);
} }
/*! /*!
......
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