From bb9bccf58005e13bf72bca339783c917c8b37d6f Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Thu, 21 Feb 2013 01:09:26 +0330 Subject: [PATCH] Added 'MacToolButton' as a replacement for QToolButton on Mac --- src/lib/autofill/autofillnotification.ui | 9 ++- src/lib/lib.pro | 6 +- src/lib/other/sourceviewersearch.ui | 11 +++- .../qtwebkit/spellcheck/spellcheckdialog.ui | 9 ++- src/lib/preferences/preferences.ui | 23 +++++--- src/lib/rss/rssnotification.ui | 9 ++- src/lib/tools/docktitlebarwidget.ui | 9 ++- .../html5permissionsnotification.ui | 9 ++- src/lib/tools/mactoolbutton.cpp | 53 ++++++++++++++++++ src/lib/tools/mactoolbutton.h | 55 +++++++++++++++++++ src/lib/webview/searchtoolbar.ui | 15 +++-- src/plugins/GreaseMonkey/gm_notification.ui | 9 ++- 12 files changed, 193 insertions(+), 24 deletions(-) create mode 100644 src/lib/tools/mactoolbutton.cpp create mode 100644 src/lib/tools/mactoolbutton.h diff --git a/src/lib/autofill/autofillnotification.ui b/src/lib/autofill/autofillnotification.ui index b1838f612..5dc1e0dd2 100644 --- a/src/lib/autofill/autofillnotification.ui +++ b/src/lib/autofill/autofillnotification.ui @@ -121,7 +121,7 @@ - + @@ -132,6 +132,13 @@ + + + MacToolButton + QToolButton +
mactoolbutton.h
+
+
diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 56e5ab688..d1584f371 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -214,7 +214,8 @@ SOURCES += \ autofill/autofillwidget.cpp \ tools/menubar.cpp \ navigation/navigationcontainer.cpp \ - tools/horizontallistwidget.cpp + tools/horizontallistwidget.cpp \ + tools/mactoolbutton.cpp HEADERS += \ webview/tabpreview.h \ @@ -383,7 +384,8 @@ HEADERS += \ autofill/autofillwidget.h \ tools/menubar.h \ navigation/navigationcontainer.h \ - tools/horizontallistwidget.h + tools/horizontallistwidget.h \ + tools/mactoolbutton.h FORMS += \ preferences/autofillmanager.ui \ diff --git a/src/lib/other/sourceviewersearch.ui b/src/lib/other/sourceviewersearch.ui index 56bb2b8ec..5c727b2d3 100644 --- a/src/lib/other/sourceviewersearch.ui +++ b/src/lib/other/sourceviewersearch.ui @@ -21,7 +21,7 @@ 4 - + 0 @@ -51,7 +51,7 @@ - + 0 @@ -67,7 +67,7 @@ - + 0 @@ -105,6 +105,11 @@ + + MacToolButton + QToolButton +
mactoolbutton.h
+
FocusSelectLineEdit QLineEdit diff --git a/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.ui b/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.ui index cf8af56d7..71d7f790b 100644 --- a/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.ui +++ b/src/lib/plugins/qtwebkit/spellcheck/spellcheckdialog.ui @@ -31,7 +31,7 @@
- + Change... @@ -123,6 +123,13 @@ + + + MacToolButton + QToolButton +
mactoolbutton.h
+
+
diff --git a/src/lib/preferences/preferences.ui b/src/lib/preferences/preferences.ui index cd723463f..88b364a97 100644 --- a/src/lib/preferences/preferences.ui +++ b/src/lib/preferences/preferences.ui @@ -165,7 +165,7 @@ - + Use current @@ -307,7 +307,7 @@ - + Use current @@ -952,7 +952,7 @@ 0 - + Select color @@ -962,7 +962,7 @@ - + Reset @@ -1307,7 +1307,7 @@ - + ... @@ -1892,7 +1892,7 @@ - + ... @@ -1997,7 +1997,7 @@ - + ... @@ -2441,7 +2441,7 @@ - + ... @@ -2573,6 +2573,13 @@ + + + MacToolButton + QToolButton +
mactoolbutton.h
+
+
buttonBox afterLaunch diff --git a/src/lib/rss/rssnotification.ui b/src/lib/rss/rssnotification.ui index f0ef9620e..a8c55e085 100644 --- a/src/lib/rss/rssnotification.ui +++ b/src/lib/rss/rssnotification.ui @@ -83,7 +83,7 @@
- + @@ -94,6 +94,13 @@
+ + + MacToolButton + QToolButton +
mactoolbutton.h
+
+
diff --git a/src/lib/tools/docktitlebarwidget.ui b/src/lib/tools/docktitlebarwidget.ui index fe75f3aaa..c486ef290 100644 --- a/src/lib/tools/docktitlebarwidget.ui +++ b/src/lib/tools/docktitlebarwidget.ui @@ -30,7 +30,7 @@ - + Qt::NoFocus @@ -50,6 +50,13 @@ + + + MacToolButton + QToolButton +
mactoolbutton.h
+
+
diff --git a/src/lib/tools/html5permissions/html5permissionsnotification.ui b/src/lib/tools/html5permissions/html5permissionsnotification.ui index c139fbe5b..9e860525b 100644 --- a/src/lib/tools/html5permissions/html5permissionsnotification.ui +++ b/src/lib/tools/html5permissions/html5permissionsnotification.ui @@ -78,7 +78,7 @@ - + @@ -89,6 +89,13 @@ + + + MacToolButton + QToolButton +
mactoolbutton.h
+
+
diff --git a/src/lib/tools/mactoolbutton.cpp b/src/lib/tools/mactoolbutton.cpp new file mode 100644 index 000000000..5c68c9f49 --- /dev/null +++ b/src/lib/tools/mactoolbutton.cpp @@ -0,0 +1,53 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2013 David Rosca +* Copyright (C) 2013 S. Razi Alavizadeh +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#include "mactoolbutton.h" + +#ifdef Q_OS_MAC +MacToolButton::MacToolButton(QWidget* parent) + : QPushButton(parent) + , m_autoRise(false) + , m_buttonFixedSize(18, 18) +{ +} + +void MacToolButton::setIconSize(const QSize &size) +{ + QPushButton::setIconSize(size); + m_buttonFixedSize = QSize(size.width()+2, size.height()+2); +} + +void MacToolButton::setAutoRaise(bool enable) +{ + m_autoRise = enable; + setFlat(enable); + if (enable) { + setFixedSize(m_buttonFixedSize); + } +} + +bool MacToolButton::autoRaise() const +{ + return m_autoRise; +} +#else +MacToolButton::MacToolButton(QWidget* parent) + : QToolButton(parent) +{ +} +#endif diff --git a/src/lib/tools/mactoolbutton.h b/src/lib/tools/mactoolbutton.h new file mode 100644 index 000000000..032e717a2 --- /dev/null +++ b/src/lib/tools/mactoolbutton.h @@ -0,0 +1,55 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2013 David Rosca +* Copyright (C) 2013 S. Razi Alavizadeh +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef MACTOOLBUTTON_H +#define MACTOOLBUTTON_H + +#include "qz_namespace.h" + +#ifdef Q_OS_MAC +#include + +class QT_QUPZILLA_EXPORT MacToolButton : public QPushButton +{ + Q_OBJECT + Q_PROPERTY(bool autoRaise READ autoRaise WRITE setAutoRaise) + +public: + explicit MacToolButton(QWidget* parent = 0); + + void setIconSize(const QSize &size); + + void setAutoRaise(bool enable); + bool autoRaise() const; + +private: + bool m_autoRise; + QSize m_buttonFixedSize; +}; +#else +#include + +class QT_QUPZILLA_EXPORT MacToolButton : public QToolButton +{ + Q_OBJECT + +public: + explicit MacToolButton(QWidget* parent = 0); +}; +#endif +#endif // MACTOOLBUTTON_H diff --git a/src/lib/webview/searchtoolbar.ui b/src/lib/webview/searchtoolbar.ui index dec93784a..cd324bbba 100644 --- a/src/lib/webview/searchtoolbar.ui +++ b/src/lib/webview/searchtoolbar.ui @@ -18,7 +18,7 @@ 4 - + 0 @@ -57,7 +57,7 @@ - + 0 @@ -70,7 +70,7 @@ - + 0 @@ -83,7 +83,7 @@ - + Highlight @@ -93,7 +93,7 @@ - + Case sensitive @@ -130,6 +130,11 @@ QLineEdit
focusselectlineedit.h
+ + MacToolButton + QToolButton +
mactoolbutton.h
+
diff --git a/src/plugins/GreaseMonkey/gm_notification.ui b/src/plugins/GreaseMonkey/gm_notification.ui index 56fdc6960..7b8a30ee2 100644 --- a/src/plugins/GreaseMonkey/gm_notification.ui +++ b/src/plugins/GreaseMonkey/gm_notification.ui @@ -67,7 +67,7 @@
- + @@ -78,6 +78,13 @@ + + + MacToolButton + QToolButton +
mactoolbutton.h
+
+