1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Merge pull request #773 from srazi/Mac_work

Mac related fixes.
This commit is contained in:
David Rosca 2013-02-21 02:11:07 -08:00
commit 2a5ff86972
18 changed files with 227 additions and 40 deletions

View File

@ -36,7 +36,9 @@ AdBlockDialog::AdBlockDialog(QWidget* parent)
{
setAttribute(Qt::WA_DeleteOnClose);
setupUi(this);
#ifdef Q_OS_MAC
tabWidget->setDocumentMode(false);
#endif
adblockCheckBox->setChecked(m_manager->isEnabled());
QMenu* menu = new QMenu(buttonMenu);

View File

@ -121,7 +121,7 @@
</layout>
</item>
<item>
<widget class="QToolButton" name="closeButton">
<widget class="MacToolButton" name="closeButton">
<property name="text">
<string/>
</property>
@ -132,6 +132,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MacToolButton</class>
<extends>QToolButton</extends>
<header>mactoolbutton.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../data/icons.qrc"/>
</resources>

View File

@ -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 \

View File

@ -552,6 +552,7 @@ void LocationBar::hideProgress()
void LocationBar::paintEvent(QPaintEvent* event)
{
#ifndef Q_OS_MAC
if (m_completer.isPopupVisible() && !m_completer.showingMostVisited()) {
// We need to draw cursor when popup is visible
// But don't paint it if we are just showing most visited sites
@ -582,6 +583,7 @@ void LocationBar::paintEvent(QPaintEvent* event)
p.fillRect(cursorRect, option.palette.text().color());
return;
}
#endif
if (hasFocus() || text().isEmpty() || m_forceLineEditPaintEvent) {
LineEdit::paintEvent(event);

View File

@ -21,7 +21,7 @@
<number>4</number>
</property>
<item>
<widget class="QToolButton" name="closeButton">
<widget class="MacToolButton" name="closeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -51,7 +51,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="previous">
<widget class="MacToolButton" name="previous">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -67,7 +67,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="next">
<widget class="MacToolButton" name="next">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -105,6 +105,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MacToolButton</class>
<extends>QToolButton</extends>
<header>mactoolbutton.h</header>
</customwidget>
<customwidget>
<class>FocusSelectLineEdit</class>
<extends>QLineEdit</extends>

View File

@ -31,7 +31,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="changeDictPath">
<widget class="MacToolButton" name="changeDictPath">
<property name="text">
<string>Change...</string>
</property>
@ -123,6 +123,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MacToolButton</class>
<extends>QToolButton</extends>
<header>mactoolbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>

View File

@ -165,7 +165,7 @@
<widget class="QLineEdit" name="newTabUrl"/>
</item>
<item>
<widget class="QToolButton" name="newTabUseCurrent">
<widget class="MacToolButton" name="newTabUseCurrent">
<property name="text">
<string>Use current</string>
</property>
@ -307,7 +307,7 @@
<widget class="QLineEdit" name="homepage"/>
</item>
<item>
<widget class="QToolButton" name="useCurrentBut">
<widget class="MacToolButton" name="useCurrentBut">
<property name="text">
<string>Use current</string>
</property>
@ -952,7 +952,7 @@
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="customColorToolButton">
<widget class="MacToolButton" name="customColorToolButton">
<property name="toolTip">
<string>Select color</string>
</property>
@ -962,7 +962,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="resetProgressBarcolor">
<widget class="MacToolButton" name="resetProgressBarcolor">
<property name="text">
<string>Reset</string>
</property>
@ -1307,7 +1307,7 @@
<widget class="QLineEdit" name="cachePath"/>
</item>
<item>
<widget class="QToolButton" name="changeCachePath">
<widget class="MacToolButton" name="changeCachePath">
<property name="text">
<string>...</string>
</property>
@ -1892,7 +1892,7 @@
<widget class="QLineEdit" name="downLoc"/>
</item>
<item>
<widget class="QToolButton" name="downButt">
<widget class="MacToolButton" name="downButt">
<property name="text">
<string>...</string>
</property>
@ -1997,7 +1997,7 @@
<widget class="QLineEdit" name="externalDownExecutable"/>
</item>
<item>
<widget class="QToolButton" name="chooseExternalDown">
<widget class="MacToolButton" name="chooseExternalDown">
<property name="text">
<string>...</string>
</property>
@ -2441,7 +2441,7 @@
<widget class="QLineEdit" name="userStyleSheet"/>
</item>
<item row="11" column="2">
<widget class="QToolButton" name="chooseUserStylesheet">
<widget class="MacToolButton" name="chooseUserStylesheet">
<property name="text">
<string>...</string>
</property>
@ -2573,6 +2573,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MacToolButton</class>
<extends>QToolButton</extends>
<header>mactoolbutton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>buttonBox</tabstop>
<tabstop>afterLaunch</tabstop>

View File

@ -43,7 +43,9 @@ RSSManager::RSSManager(QupZilla* mainClass, QWidget* parent)
, p_QupZilla(mainClass)
{
ui->setupUi(this);
#ifdef Q_OS_MAC
ui->tabWidget->setDocumentMode(false);
#endif
ui->tabWidget->setElideMode(Qt::ElideRight);
m_networkManager = mApp->networkManager();

View File

@ -83,7 +83,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="closeButton">
<widget class="MacToolButton" name="closeButton">
<property name="text">
<string/>
</property>
@ -94,6 +94,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MacToolButton</class>
<extends>QToolButton</extends>
<header>mactoolbutton.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../data/icons.qrc"/>
</resources>

View File

@ -30,7 +30,7 @@
<widget class="QLabel" name="label"/>
</item>
<item>
<widget class="QToolButton" name="closeButton">
<widget class="MacToolButton" name="closeButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
@ -50,6 +50,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MacToolButton</class>
<extends>QToolButton</extends>
<header>mactoolbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -78,7 +78,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="close">
<widget class="MacToolButton" name="close">
<property name="text">
<string/>
</property>
@ -89,6 +89,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MacToolButton</class>
<extends>QToolButton</extends>
<header>mactoolbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,53 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
* Copyright (C) 2013 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
* ============================================================ */
#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

View File

@ -0,0 +1,55 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2013 David Rosca <nowrep@gmail.com>
* Copyright (C) 2013 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
* ============================================================ */
#ifndef MACTOOLBUTTON_H
#define MACTOOLBUTTON_H
#include "qz_namespace.h"
#ifdef Q_OS_MAC
#include <QPushButton>
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 <QToolButton>
class QT_QUPZILLA_EXPORT MacToolButton : public QToolButton
{
Q_OBJECT
public:
explicit MacToolButton(QWidget* parent = 0);
};
#endif
#endif // MACTOOLBUTTON_H

View File

@ -18,7 +18,7 @@
<number>4</number>
</property>
<item>
<widget class="QToolButton" name="closeButton">
<widget class="MacToolButton" name="closeButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -57,7 +57,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="previous">
<widget class="MacToolButton" name="previous">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -70,7 +70,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="next">
<widget class="MacToolButton" name="next">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -83,7 +83,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="highligh">
<widget class="MacToolButton" name="highligh">
<property name="text">
<string>Highlight</string>
</property>
@ -93,7 +93,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="caseSensitive">
<widget class="MacToolButton" name="caseSensitive">
<property name="text">
<string>Case sensitive</string>
</property>
@ -130,6 +130,11 @@
<extends>QLineEdit</extends>
<header>focusselectlineedit.h</header>
</customwidget>
<customwidget>
<class>MacToolButton</class>
<extends>QToolButton</extends>
<header>mactoolbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@ -319,7 +319,7 @@ void TabBar::showCloseButton(int index)
}
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
QAbstractButton* button = qobject_cast<QAbstractButton*>(tabButton(index, QTabBar::RightSide));
QAbstractButton* button = qobject_cast<QAbstractButton*>(tabButton(index, closeButtonPosition()));
if (button || (webTab && webTab->isPinned())) {
return;
@ -327,7 +327,7 @@ void TabBar::showCloseButton(int index)
QAbstractButton* closeButton = new CloseButton(this);
connect(closeButton, SIGNAL(clicked()), this, SLOT(closeTabFromButton()));
setTabButton(index, QTabBar::RightSide, closeButton);
setTabButton(index, closeButtonPosition(), closeButton);
}
void TabBar::hideCloseButton(int index)
@ -336,12 +336,12 @@ void TabBar::hideCloseButton(int index)
return;
}
CloseButton* button = qobject_cast<CloseButton*>(tabButton(index, QTabBar::RightSide));
CloseButton* button = qobject_cast<CloseButton*>(tabButton(index, closeButtonPosition()));
if (!button) {
return;
}
setTabButton(index, QTabBar::RightSide, 0);
setTabButton(index, closeButtonPosition(), 0);
button->deleteLater();
}
@ -352,7 +352,7 @@ void TabBar::updatePinnedTabCloseButton(int index)
}
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(index));
QAbstractButton* button = qobject_cast<QAbstractButton*>(tabButton(index, QTabBar::RightSide));
QAbstractButton* button = qobject_cast<QAbstractButton*>(tabButton(index, closeButtonPosition()));
bool pinned = webTab && webTab->isPinned();
@ -383,7 +383,7 @@ void TabBar::closeTabFromButton()
int tabToClose = -1;
for (int i = 0; i < count(); ++i) {
if (tabButton(i, QTabBar::RightSide) == button) {
if (tabButton(i, closeButtonPosition()) == button) {
tabToClose = i;
break;
}
@ -463,6 +463,16 @@ int TabBar::normalTabsCount()
return count() - m_pinnedTabsCount;
}
QTabBar::ButtonPosition TabBar::iconButtonPosition()
{
return (closeButtonPosition() == QTabBar::RightSide ? QTabBar::LeftSide : QTabBar::RightSide);
}
QTabBar::ButtonPosition TabBar::closeButtonPosition()
{
return (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, this);
}
void TabBar::showTabPreview()
{
WebTab* webTab = qobject_cast<WebTab*>(m_tabWidget->widget(m_tabPreview->previewIndex()));
@ -709,10 +719,9 @@ void CloseButton::paintEvent(QPaintEvent*)
opt.state |= QStyle::State_Sunken;
}
if (const QTabBar* tb = qobject_cast<const QTabBar*>(parent())) {
if (TabBar* tb = qobject_cast<TabBar*>(parent())) {
int index = tb->currentIndex();
QTabBar::ButtonPosition position = (QTabBar::ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb);
if (tb->tabButton(index, position) == this) {
if (tb->tabButton(index, tb->closeButtonPosition()) == this) {
opt.state |= QStyle::State_Selected;
}
}

View File

@ -42,6 +42,9 @@ public:
int pinnedTabsCount();
int normalTabsCount();
QTabBar::ButtonPosition iconButtonPosition();
QTabBar::ButtonPosition closeButtonPosition();
void updatePinnedTabCloseButton(int index);
void disconnectObjects();

View File

@ -468,10 +468,10 @@ void TabWidget::startTabAnimation(int index)
return;
}
QLabel* label = qobject_cast<QLabel*>(m_tabBar->tabButton(index, QTabBar::LeftSide));
QLabel* label = qobject_cast<QLabel*>(m_tabBar->tabButton(index, m_tabBar->iconButtonPosition()));
if (!label) {
label = new QLabel();
m_tabBar->setTabButton(index, QTabBar::LeftSide, label);
m_tabBar->setTabButton(index, m_tabBar->iconButtonPosition(), label);
}
if (label->movie()) {
@ -492,7 +492,7 @@ void TabWidget::stopTabAnimation(int index)
return;
}
QLabel* label = qobject_cast<QLabel*>(m_tabBar->tabButton(index, QTabBar::LeftSide));
QLabel* label = qobject_cast<QLabel*>(m_tabBar->tabButton(index, m_tabBar->iconButtonPosition()));
if (label && label->movie()) {
label->movie()->stop();
@ -512,11 +512,11 @@ void TabWidget::setTabIcon(int index, const QIcon &icon)
return;
}
QLabel* label = qobject_cast<QLabel*>(m_tabBar->tabButton(index, QTabBar::LeftSide));
QLabel* label = qobject_cast<QLabel*>(m_tabBar->tabButton(index, m_tabBar->iconButtonPosition()));
if (!label) {
label = new QLabel();
label->resize(16, 16);
m_tabBar->setTabButton(index, QTabBar::LeftSide, label);
m_tabBar->setTabButton(index, m_tabBar->iconButtonPosition(), label);
}
label->setPixmap(icon.pixmap(16, 16));

View File

@ -67,7 +67,7 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="close">
<widget class="MacToolButton" name="close">
<property name="text">
<string/>
</property>
@ -78,6 +78,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MacToolButton</class>
<extends>QToolButton</extends>
<header>mactoolbutton.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="greasemonkey.qrc"/>
</resources>