From 02ebee6d23eaea537b571a56d51876c33b942565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= <thorbjorn.lindeijer@nokia.com> Date: Thu, 15 Apr 2010 17:13:10 +0200 Subject: [PATCH] Tweak frame for open editors and open help pages switchers In the GTK style the scroll bar likes to be outside of the scroll area frame. Like with the completion widget, we put the visible frame explicitly outside of the scroll bar. Reviewed-by: Jens Bache-Wiig --- .../editormanager/openeditorswindow.cpp | 17 ++++++++++++++--- .../editormanager/openeditorswindow.h | 4 ++-- src/plugins/help/openpagesswitcher.cpp | 15 +++++++++++++-- src/plugins/help/openpagesswitcher.h | 4 ++-- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp index 6048f7aba82..393ee6bdb65 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp @@ -35,9 +35,10 @@ #include <utils/qtcassert.h> +#include <QtGui/QFocusEvent> #include <QtGui/QHeaderView> #include <QtGui/QTreeWidget> -#include <QtGui/QFocusEvent> +#include <QtGui/QVBoxLayout> Q_DECLARE_METATYPE(Core::Internal::EditorView*) Q_DECLARE_METATYPE(Core::IFile *) @@ -49,7 +50,7 @@ const int WIDTH = 300; const int HEIGHT = 200; OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) : - QWidget(parent, Qt::Popup), + QFrame(parent, Qt::Popup), m_emptyIcon(QLatin1String(":/core/images/empty14.png")), m_editorList(new QTreeWidget(this)) { @@ -63,7 +64,17 @@ OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) : m_editorList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); #endif m_editorList->installEventFilter(this); - m_editorList->setGeometry(0, 0, WIDTH, HEIGHT); + + // We disable the frame on this list view and use a QFrame around it instead. + // This improves the look with QGTKStyle. +#ifndef Q_WS_MAC + setFrameStyle(m_editorList->frameStyle()); +#endif + m_editorList->setFrameStyle(QFrame::NoFrame); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->addWidget(m_editorList); connect(m_editorList, SIGNAL(itemClicked(QTreeWidgetItem*, int)), this, SLOT(editorClicked(QTreeWidgetItem*))); diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.h b/src/plugins/coreplugin/editormanager/openeditorswindow.h index c3c20477fed..b448fab5100 100644 --- a/src/plugins/coreplugin/editormanager/openeditorswindow.h +++ b/src/plugins/coreplugin/editormanager/openeditorswindow.h @@ -30,7 +30,7 @@ #ifndef OPENEDITORSWINDOW_H #define OPENEDITORSWINDOW_H -#include <QtGui/QWidget> +#include <QtGui/QFrame> #include <QtGui/QIcon> QT_BEGIN_NAMESPACE @@ -48,7 +48,7 @@ namespace Internal { class EditorHistoryItem; class EditorView; -class OpenEditorsWindow : public QWidget +class OpenEditorsWindow : public QFrame { Q_OBJECT diff --git a/src/plugins/help/openpagesswitcher.cpp b/src/plugins/help/openpagesswitcher.cpp index 7c446c3b600..9cdf4bfacf2 100644 --- a/src/plugins/help/openpagesswitcher.cpp +++ b/src/plugins/help/openpagesswitcher.cpp @@ -36,6 +36,7 @@ #include <QtCore/QEvent> #include <QtGui/QKeyEvent> +#include <QtGui/QVBoxLayout> using namespace Help::Internal; @@ -43,16 +44,26 @@ const int gWidth = 300; const int gHeight = 200; OpenPagesSwitcher::OpenPagesSwitcher(OpenPagesModel *model) - : QWidget(0, Qt::Popup) + : QFrame(0, Qt::Popup) , m_openPagesModel(model) { resize(gWidth, gHeight); m_openPagesWidget = new OpenPagesWidget(m_openPagesModel, this); + // We disable the frame on this list view and use a QFrame around it instead. + // This improves the look with QGTKStyle. +#ifndef Q_WS_MAC + setFrameStyle(m_openPagesWidget->frameStyle()); +#endif + m_openPagesWidget->setFrameStyle(QFrame::NoFrame); + m_openPagesWidget->allowContextMenu(false); m_openPagesWidget->installEventFilter(this); - m_openPagesWidget->setGeometry(0, 0, gWidth, gHeight); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->setMargin(0); + layout->addWidget(m_openPagesWidget); connect(m_openPagesWidget, SIGNAL(closePage(QModelIndex)), this, SIGNAL(closePage(QModelIndex))); diff --git a/src/plugins/help/openpagesswitcher.h b/src/plugins/help/openpagesswitcher.h index 9cbd0e20447..e4f9bc1232d 100644 --- a/src/plugins/help/openpagesswitcher.h +++ b/src/plugins/help/openpagesswitcher.h @@ -30,7 +30,7 @@ #ifndef OPENPAGESSWITCHER_H #define OPENPAGESSWITCHER_H -#include <QtGui/QWidget> +#include <QtGui/QFrame> QT_FORWARD_DECLARE_CLASS(QModelIndex) @@ -40,7 +40,7 @@ namespace Help { class OpenPagesModel; class OpenPagesWidget; -class OpenPagesSwitcher : public QWidget +class OpenPagesSwitcher : public QFrame { Q_OBJECT -- GitLab