From 0b91cc18169a703b7f9f87050e17e57285ea226d Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 15 Jan 2012 12:35:29 +0100 Subject: [PATCH] Scrolling bookmarks menu whene there is alot of entries. Closes #175 - the same issue was also reported in #159 --- src/app/proxystyle.cpp | 15 +++++++++++++++ src/app/proxystyle.h | 20 ++++++++++++++++++++ src/main.cpp | 3 +++ src/src.pro | 6 ++++-- src/tools/enhancedmenu.cpp | 2 -- src/tools/enhancedmenu.h | 1 + 6 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 src/app/proxystyle.cpp create mode 100644 src/app/proxystyle.h diff --git a/src/app/proxystyle.cpp b/src/app/proxystyle.cpp new file mode 100644 index 000000000..7c10b0155 --- /dev/null +++ b/src/app/proxystyle.cpp @@ -0,0 +1,15 @@ +#include "proxystyle.h" + +ProxyStyle::ProxyStyle() + : QProxyStyle() +{ +} + +int ProxyStyle::styleHint(StyleHint hint, const QStyleOption* option, const QWidget* widget, QStyleHintReturn* returnData) const +{ + if (hint == QStyle::SH_Menu_Scrollable) { + return 1; + } + + return QProxyStyle::styleHint(hint, option, widget, returnData); +} diff --git a/src/app/proxystyle.h b/src/app/proxystyle.h new file mode 100644 index 000000000..1bad04def --- /dev/null +++ b/src/app/proxystyle.h @@ -0,0 +1,20 @@ +#ifndef PROXYSTYLE_H +#define PROXYSTYLE_H + +#include + +class ProxyStyle : public QProxyStyle +{ + Q_OBJECT +public: + explicit ProxyStyle(); + + int styleHint(StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const; + +signals: + +public slots: + +}; + +#endif // PROXYSTYLE_H diff --git a/src/main.cpp b/src/main.cpp index 220d0d3c1..a93bba2d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,6 +22,7 @@ #include "commandlineoptions.h" #include "mainapplication.h" +#include "proxystyle.h" int main(int argc, char* argv[]) { @@ -52,6 +53,8 @@ int main(int argc, char* argv[]) } MainApplication app(cmdActions, argc, argv); + app.setStyle(new ProxyStyle()); + if (app.isExited()) { // Not showing any output, otherwise XFCE shows "Failed to execute default browser. I/O error" error // if (argc == 1) { diff --git a/src/src.pro b/src/src.pro index c7a978f22..e50e4db34 100644 --- a/src/src.pro +++ b/src/src.pro @@ -184,7 +184,8 @@ SOURCES += main.cpp\ rss/rssicon.cpp \ navigation/downicon.cpp \ network/cabundleupdater.cpp \ - app/settings.cpp + app/settings.cpp \ + app/proxystyle.cpp HEADERS += \ 3rdparty/qtwin.h \ @@ -309,7 +310,8 @@ HEADERS += \ rss/rssicon.h \ navigation/downicon.h \ network/cabundleupdater.h \ - app/settings.h + app/settings.h \ + app/proxystyle.h FORMS += \ preferences/autofillmanager.ui \ diff --git a/src/tools/enhancedmenu.cpp b/src/tools/enhancedmenu.cpp index e074f69b1..948119c74 100644 --- a/src/tools/enhancedmenu.cpp +++ b/src/tools/enhancedmenu.cpp @@ -17,8 +17,6 @@ * ============================================================ */ #include "enhancedmenu.h" -#include - Menu::Menu(QWidget* parent) : QMenu(parent) { diff --git a/src/tools/enhancedmenu.h b/src/tools/enhancedmenu.h index 5ec2dd4ac..284f02a86 100644 --- a/src/tools/enhancedmenu.h +++ b/src/tools/enhancedmenu.h @@ -20,6 +20,7 @@ #include #include +#include class Action; class Menu : public QMenu