1 /***************************************************************************
2  *   Copyright (C) 2006-2012 by Ilya Kotov                                 *
3  *   forkotov02@ya.ru                                                      *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20 #ifndef DOCK_H
21 #define DOCK_H
22 
23 #include <QObject>
24 #include <QPoint>
25 #include <QWidget>
26 
27 class QAction;
28 /**
29     @author Ilya Kotov <forkotov02@ya.ru>
30 */
31 class Dock : public QObject
32 {
33     Q_OBJECT
34 public:
35     Dock(QObject *parent = nullptr);
36 
37     ~Dock();
38 
39     static Dock *instance();
40     void setMainWidget(QWidget*);
41     void addWidget(QWidget *);
42     void move(QWidget*, QPoint);
43     void calculateDistances();
44     void updateDock();
45     void addActions(QList<QAction *> actions);
46     void align(QWidget*, int dy);
47 
48 private:
49     QPoint snapDesktop(QPoint, QWidget*);
50     QPoint snap(QPoint, QWidget*, QWidget*);
51     bool isDocked(QWidget*, QWidget*);
52     bool isUnder(QWidget*, QWidget*, int);
53     static Dock *m_instance;
54     QWidget *m_mainWidget;
55     QList <QWidget *> m_widgetList;
56     QList <bool> m_dockedList;
57     QList <QPoint> m_delta_list;
58 };
59 
60 #endif
61