File indexing completed on 2024-05-12 04:58:27

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2013-2017 David Rosca <nowrep@gmail.com>
0004 * Copyright (C) 2013-2014 S. Razi Alavizadeh <s.r.alavizadeh@gmail.com>
0005 *
0006 * This program is free software: you can redistribute it and/or modify
0007 * it under the terms of the GNU General Public License as published by
0008 * the Free Software Foundation, either version 3 of the License, or
0009 * (at your option) any later version.
0010 *
0011 * This program is distributed in the hope that it will be useful,
0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014 * GNU General Public License for more details.
0015 *
0016 * You should have received a copy of the GNU General Public License
0017 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018 * ============================================================ */
0019 #include "mactoolbutton.h"
0020 
0021 #ifdef Q_OS_MACOS
0022 MacToolButton::MacToolButton(QWidget* parent)
0023     : QPushButton(parent)
0024     , m_autoRise(false)
0025     , m_buttonFixedSize(18, 18)
0026 {
0027 }
0028 
0029 void MacToolButton::setIconSize(const QSize &size)
0030 {
0031     QPushButton::setIconSize(size);
0032     m_buttonFixedSize = QSize(size.width() + 2, size.height() + 2);
0033 }
0034 
0035 void MacToolButton::setAutoRaise(bool enable)
0036 {
0037     m_autoRise = enable;
0038     setFlat(enable);
0039     if (enable) {
0040         setFixedSize(m_buttonFixedSize);
0041     }
0042 }
0043 
0044 bool MacToolButton::autoRaise() const
0045 {
0046     return m_autoRise;
0047 }
0048 #else
0049 MacToolButton::MacToolButton(QWidget* parent)
0050     : QToolButton(parent)
0051 {
0052 }
0053 #endif