File indexing completed on 2024-05-05 04:38:43

0001 /*
0002     SPDX-FileCopyrightText: 2014 Kevin Funk <kfunk@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KDEVPLATFORM_AUTOORIENTEDSPLITTER_H
0008 #define KDEVPLATFORM_AUTOORIENTEDSPLITTER_H
0009 
0010 #include "utilexport.h"
0011 
0012 #include <QSplitter>
0013 
0014 namespace KDevelop {
0015 
0016 /**
0017  * Auto-oriented version of QSplitter based on the aspect ratio of the widget size
0018  *
0019  * In case this widget is resized, we check whether we're currently in
0020  * "portrait" (width < height) or "landscape" (width >= height) mode.
0021  * Consequently, in "portrait" mode the QSplitter orientation is set to Qt::Vertical
0022  * in order to get a vertical layout of the items -- Qt::Horizontal is set for
0023  * "landscape" mode
0024  */
0025 class KDEVPLATFORMUTIL_EXPORT AutoOrientedSplitter : public QSplitter
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     explicit AutoOrientedSplitter(QWidget* parent = nullptr);
0031     explicit AutoOrientedSplitter(Qt::Orientation orientation, QWidget* parent = nullptr);
0032 
0033 protected:
0034     void resizeEvent(QResizeEvent*) override;
0035 };
0036 
0037 }
0038 
0039 #endif