forked from qt-creator/qt-creator
C++ editor: Restrict outline combo popup width
Use Creator's main window as a reference for the width. Note that this does not necessarily imply they are aligned. Task-number: QTCREATORBUG-4021 Change-Id: Id0be8a7435d9b3f9eaab638f7a82bb0bd1afa192 Reviewed-on: http://codereview.qt.nokia.com/109 Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
This commit is contained in:
committed by
Leandro T. C. Melo
parent
c3a9436cf3
commit
b9bbf24680
@@ -105,6 +105,7 @@
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QTreeView>
|
||||
#include <QtGui/QSortFilterProxyModel>
|
||||
#include <QtGui/QMainWindow>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
@@ -160,7 +161,26 @@ public:
|
||||
void sync()
|
||||
{
|
||||
expandAll();
|
||||
setMinimumWidth(qMax(sizeHintForColumn(0), minimumSizeHint().width()));
|
||||
}
|
||||
|
||||
void adjustWidth()
|
||||
{
|
||||
const int w = Core::ICore::instance()->mainWindow()->geometry().width();
|
||||
setMaximumWidth(w);
|
||||
setMinimumWidth(qMin(qMax(sizeHintForColumn(0), minimumSizeHint().width()), w));
|
||||
}
|
||||
};
|
||||
|
||||
class OverviewCombo : public QComboBox
|
||||
{
|
||||
public:
|
||||
OverviewCombo(QWidget *parent = 0) : QComboBox(parent)
|
||||
{}
|
||||
|
||||
void showPopup()
|
||||
{
|
||||
static_cast<OverviewTreeView *>(view())->adjustWidth();
|
||||
QComboBox::showPopup();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -467,7 +487,7 @@ TextEditor::BaseTextEditor *CPPEditorWidget::createEditor()
|
||||
|
||||
void CPPEditorWidget::createToolBar(CPPEditor *editor)
|
||||
{
|
||||
m_outlineCombo = new QComboBox;
|
||||
m_outlineCombo = new OverviewCombo;
|
||||
m_outlineCombo->setMinimumContentsLength(22);
|
||||
|
||||
// Make the combo box prefer to expand
|
||||
|
||||
Reference in New Issue
Block a user