1 /* BEGIN_COMMON_COPYRIGHT_HEADER 2 * (c)LGPL2+ 3 * 4 * LXQt - a lightweight, Qt based, desktop toolset 5 * https://lxqt.org 6 * 7 * Copyright: 2010-2011 Razor team 8 * Authors: 9 * Alexander Sokoloff <sokoloff.a@gmail.com> 10 * 11 * This program or library is free software; you can redistribute it 12 * and/or modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2.1 of the License, or (at your option) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 21 * You should have received a copy of the GNU Lesser General 22 * Public License along with this library; if not, write to the 23 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 * Boston, MA 02110-1301 USA 25 * 26 * END_COMMON_COPYRIGHT_HEADER */ 27 28 29 #ifndef LXQTPANELLAYOUT_H 30 #define LXQTPANELLAYOUT_H 31 32 #include <QLayout> 33 #include <QList> 34 #include <QWidget> 35 #include <QLayoutItem> 36 #include "ilxqtpanel.h" 37 #include "lxqtpanelglobals.h" 38 39 class MoveInfo; 40 class QMouseEvent; 41 class QEvent; 42 43 class Plugin; 44 class LayoutItemGrid; 45 46 class LXQT_PANEL_API LXQtPanelLayout : public QLayout 47 { 48 Q_OBJECT 49 public: 50 explicit LXQtPanelLayout(QWidget *parent); 51 ~LXQtPanelLayout(); 52 53 void addItem(QLayoutItem *item); 54 QLayoutItem *itemAt(int index) const; 55 QLayoutItem *takeAt(int index); 56 int count() const; 57 void moveItem(int from, int to, bool withAnimation=false); 58 59 QSize sizeHint() const; 60 //QSize minimumSize() const; 61 void setGeometry(const QRect &geometry); 62 63 bool isHorizontal() const; 64 65 void invalidate(); 66 67 int lineCount() const; 68 void setLineCount(int value); 69 70 int lineSize() const; 71 void setLineSize(int value); 72 position()73 ILXQtPanel::Position position() const { return mPosition; } 74 void setPosition(ILXQtPanel::Position value); 75 76 /*! \brief Force the layout to re-read items/plugins "static" configuration 77 */ 78 void rebuild(); 79 80 static bool itemIsSeparate(QLayoutItem *item); 81 signals: 82 void pluginMoved(Plugin * plugin); 83 84 public slots: 85 void startMovePlugin(); 86 void finishMovePlugin(); 87 void moveUpPlugin(Plugin * plugin); 88 void addPlugin(Plugin * plugin); 89 90 private: 91 mutable QSize mMinPluginSize; 92 LayoutItemGrid *mLeftGrid; 93 LayoutItemGrid *mRightGrid; 94 ILXQtPanel::Position mPosition; 95 bool mAnimate; 96 97 98 void setGeometryHoriz(const QRect &geometry); 99 void setGeometryVert(const QRect &geometry); 100 void globalIndexToLocal(int index, LayoutItemGrid **grid, int *gridIndex); 101 void globalIndexToLocal(int index, LayoutItemGrid **grid, int *gridIndex) const; 102 103 void setItemGeometry(QLayoutItem *item, const QRect &geometry, bool withAnimation); 104 }; 105 106 #endif // LXQTPANELLAYOUT_H 107