File indexing completed on 2024-05-19 15:01:11

0001 /****************************************************************************
0002 ** Copyright (C) 2019-2020 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com.
0003 ** All rights reserved.
0004 **
0005 ** This file is part of the KD MacTouchBar library.
0006 **
0007 ** This file may be distributed and/or modified under the terms of the
0008 ** GNU Lesser General Public License version 3 as published by the
0009 ** Free Software Foundation and appearing in the file LICENSE.LGPL.txt included.
0010 **
0011 ** You may even contact us at info@kdab.com for different licensing options.
0012 **
0013 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
0014 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
0015 **
0016 ** Contact info@kdab.com if any conditions of this licensing are not
0017 ** clear to you.
0018 **
0019 **********************************************************************/
0020 
0021 #ifndef KDMACTOUCHBAR_H
0022 #define KDMACTOUCHBAR_H
0023 
0024 #include "kdmactouchbar_global.h"
0025 
0026 #include <QtWidgets/QWidget>
0027 
0028 QT_BEGIN_NAMESPACE
0029 
0030 class QDialogButtonBox;
0031 class QMessageBox;
0032 class QTabBar;
0033 
0034 
0035 class KDMACTOUCHBAR_EXPORT KDMacTouchBar : public QWidget
0036 {
0037     Q_OBJECT
0038     Q_PROPERTY(QAction *principialAction READ principialAction WRITE setPrincipialAction)
0039     Q_PROPERTY(QAction *escapeAction READ escapeAction WRITE setEscapeAction)
0040     Q_PROPERTY(TouchButtonStyle touchButtonStyle READ touchButtonStyle WRITE setTouchButtonStyle)
0041 public:
0042     explicit KDMacTouchBar(QWidget *parent = nullptr);
0043     explicit KDMacTouchBar(QMessageBox *messageBox);
0044     ~KDMacTouchBar();
0045 
0046     enum TouchButtonStyle
0047     {
0048         IconOnly,
0049         TextOnly,
0050         TextBesideIcon
0051     };
0052 
0053     static void setAutomaticallyCreateMessageBoxTouchBar(bool automatic);
0054     static bool isAutomacicallyCreatingMessageBoxTouchBar();
0055 
0056     QAction *addSeparator();
0057     QAction *addTabBar(QTabBar *tabBar);
0058     void removeTabBar(QTabBar *tabBar);
0059 
0060     QAction *addMessageBox(QMessageBox *messageBox);
0061     void removeMessageBox(QMessageBox *messageBox);
0062 
0063     QAction *addDialogButtonBox(QDialogButtonBox *buttonBox);
0064     void removeDialogButtonBox(QDialogButtonBox *buttonBox);
0065 
0066     void setPrincipialAction(QAction *action);
0067     QAction *principialAction() const;
0068 
0069     void setEscapeAction(QAction *action);
0070     QAction *escapeAction() const;
0071 
0072     void setTouchButtonStyle(TouchButtonStyle touchButtonStyle);
0073     TouchButtonStyle touchButtonStyle() const;
0074 
0075     void clear();
0076 
0077 protected:
0078     bool event(QEvent *event);
0079 
0080 private:
0081     class Private;
0082     Private *const d;
0083 };
0084 
0085 QT_END_NAMESPACE
0086 
0087 #endif