File indexing completed on 2024-04-21 14:55:56

0001 /* This file is part of the KDE libraries
0002     Copyright (C) 1997, 1998, 1999, 2000  Sven Radej (radej@kde.org)
0003     Copyright (C) 1997, 1998, 1999, 2000 Matthias Ettrich (ettrich@kde.org)
0004     Copyright (C) 1999, 2000 Daniel "Mosfet" Duley (mosfet@kde.org)
0005 
0006     This library is free software; you can redistribute it and/or
0007     modify it under the terms of the GNU Library General Public
0008     License as published by the Free Software Foundation; either
0009     version 2 of the License, or (at your option) any later version.
0010 
0011     This library 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 GNU
0014     Library General Public License for more details.
0015 
0016     You should have received a copy of the GNU Library General Public License
0017     along with this library; see the file COPYING.LIB.  If not, write to
0018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019     Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef KMENUBAR_H
0023 #define KMENUBAR_H
0024 
0025 #include <kdelibs4support_export.h>
0026 
0027 #include <QMenuBar>
0028 
0029 /**
0030  * %KDE Style-able menubar.
0031  *
0032  * This is required since QMenuBar is currently not handled by
0033  * QStyle.
0034  *
0035  * @author Daniel "Mosfet" Duley.
0036  */
0037 
0038 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KMenuBar : public QMenuBar
0039 {
0040     Q_OBJECT
0041     Q_PROPERTY(bool topLevelMenu READ isTopLevelMenu WRITE setTopLevelMenu)
0042 
0043 public:
0044 
0045     KDELIBS4SUPPORT_DEPRECATED explicit KMenuBar(QWidget *parent = nullptr);
0046     ~KMenuBar() override;
0047 
0048     /**
0049      * This controls whether or not this menubar will be a top-level
0050      * bar similar to the way Macintosh handles menubars.  This
0051      * overrides any global config settings.
0052      *
0053      * Keep in mind that it is probably a really bad idea to use this
0054      * unless you really know what you're doing.  A feature like a
0055      * top-level menubar is one that should really be shared by all
0056      * applications.  If your app is the only one with a top-level
0057      * bar, then things might look very... odd.
0058      *
0059      * This is included only for those people that @p do know that
0060      * they need to use it.
0061      *
0062      * @param top_level If set to true, then this menubar will be a
0063      *                  top-level menu
0064      */
0065     void setTopLevelMenu(bool top_level = true);
0066 
0067     /**
0068      * Is our menubar a top-level (Macintosh style) menubar?
0069      *
0070      * @return True if it is top-level.
0071      */
0072     bool isTopLevelMenu() const;
0073 
0074     // TT are overloading virtuals :(
0075     virtual void setGeometry(const QRect &r);
0076     virtual void setGeometry(int x, int y, int w, int h);
0077     virtual void resize(int w, int h);
0078     void resize(const QSize &s);
0079 
0080     virtual void setFrameStyle(int);
0081     virtual void setLineWidth(int);
0082     virtual void setMargin(int);
0083     QSize sizeHint() const override;
0084 protected Q_SLOTS:
0085     void slotReadConfig();
0086 protected:
0087     void resizeEvent(QResizeEvent *) override;
0088     bool eventFilter(QObject *, QEvent *) override;
0089 #pragma message("Port to Qt5 native filter")
0090 #if 0
0091     virtual bool x11Event(XEvent *);
0092 #endif
0093     void closeEvent(QCloseEvent *) override;
0094     void paintEvent(QPaintEvent *) override;
0095 private Q_SLOTS:
0096     void updateFallbackSize();
0097     void selectionTimeout();
0098 private:
0099     void setTopLevelMenuInternal(bool top_level);
0100     void updateMenuBarSize();
0101     void checkSize(int &w, int &h);
0102 private:
0103     class KMenuBarPrivate;
0104     KMenuBarPrivate *const d;
0105 };
0106 
0107 #endif