forked from qt-creator/qt-creator
Editor: Automatically adjust size of open editors window.
Task-number: QTCREATORBUG-10618 Change-Id: If17fbb85596c9ea4d6a42eb99566b843812bd7fc Reviewed-by: Knut Petter Svendsen <knutpett@pvv.org> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -2183,9 +2183,13 @@ void EditorManager::showPopupOrSelectDocument()
|
||||
QWidget *referenceWidget = activeRoot->isVisible() ? activeRoot : activeRoot->window();
|
||||
QTC_CHECK(referenceWidget->isVisible());
|
||||
const QPoint p = referenceWidget->mapToGlobal(QPoint(0, 0));
|
||||
windowPopup()->move((referenceWidget->width() - d->m_windowPopup->width()) / 2 + p.x(),
|
||||
(referenceWidget->height() - d->m_windowPopup->height()) / 2 + p.y());
|
||||
windowPopup()->setVisible(true);
|
||||
OpenEditorsWindow *popup = windowPopup();
|
||||
popup->setMaximumSize(qMax(popup->minimumWidth(), referenceWidget->width() / 2),
|
||||
qMax(popup->minimumHeight(), referenceWidget->height() / 2));
|
||||
popup->adjustSize();
|
||||
popup->move((referenceWidget->width() - popup->width()) / 2 + p.x(),
|
||||
(referenceWidget->height() - popup->height()) / 2 + p.y());
|
||||
popup->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
|
||||
#include <QFocusEvent>
|
||||
#include <QHeaderView>
|
||||
#include <QTreeWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QScrollBar>
|
||||
|
||||
Q_DECLARE_METATYPE(Core::Internal::EditorView*)
|
||||
Q_DECLARE_METATYPE(Core::IDocument*)
|
||||
@@ -47,15 +47,12 @@ Q_DECLARE_METATYPE(Core::IDocument*)
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
const int WIDTH = 300;
|
||||
const int HEIGHT = 200;
|
||||
|
||||
OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) :
|
||||
QFrame(parent, Qt::Popup),
|
||||
m_emptyIcon(QLatin1String(":/core/images/empty14.png")),
|
||||
m_editorList(new QTreeWidget(this))
|
||||
m_editorList(new OpenEditorsTreeWidget(this))
|
||||
{
|
||||
resize(QSize(WIDTH, HEIGHT));
|
||||
setMinimumSize(300, 200);
|
||||
m_editorList->setColumnCount(1);
|
||||
m_editorList->header()->hide();
|
||||
m_editorList->setIndentation(0);
|
||||
@@ -158,6 +155,17 @@ void OpenEditorsWindow::selectPreviousEditor()
|
||||
selectUpDown(false);
|
||||
}
|
||||
|
||||
QSize OpenEditorsTreeWidget::sizeHint() const
|
||||
{
|
||||
return QSize(sizeHintForColumn(0) + verticalScrollBar()->width() + frameWidth() * 2,
|
||||
viewportSizeHint().height() + frameWidth() * 2);
|
||||
}
|
||||
|
||||
QSize OpenEditorsWindow::sizeHint() const
|
||||
{
|
||||
return m_editorList->sizeHint() + QSize(frameWidth() * 2, frameWidth() * 2);
|
||||
}
|
||||
|
||||
void OpenEditorsWindow::selectNextEditor()
|
||||
{
|
||||
selectUpDown(true);
|
||||
|
||||
@@ -35,10 +35,10 @@
|
||||
#include <QFrame>
|
||||
#include <QIcon>
|
||||
#include <QList>
|
||||
#include <QTreeWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QTreeWidgetItem;
|
||||
class QTreeWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
@@ -48,6 +48,13 @@ class IEditor;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class OpenEditorsTreeWidget : public QTreeWidget {
|
||||
public:
|
||||
explicit OpenEditorsTreeWidget(QWidget *parent = 0) : QTreeWidget(parent) {}
|
||||
~OpenEditorsTreeWidget() {}
|
||||
QSize sizeHint() const;
|
||||
};
|
||||
|
||||
class EditorHistoryItem;
|
||||
|
||||
class OpenEditorsWindow : public QFrame
|
||||
@@ -66,6 +73,7 @@ public:
|
||||
void setVisible(bool visible);
|
||||
void selectNextEditor();
|
||||
void selectPreviousEditor();
|
||||
QSize sizeHint() const;
|
||||
|
||||
public slots:
|
||||
void selectAndHide();
|
||||
@@ -83,7 +91,7 @@ private:
|
||||
bool isSameFile(IEditor *editorA, IEditor *editorB) const;
|
||||
|
||||
const QIcon m_emptyIcon;
|
||||
QTreeWidget *m_editorList;
|
||||
OpenEditorsTreeWidget *m_editorList;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user