|
Packit Bot |
052d53 |
/*************************************************************************
|
|
Packit Bot |
052d53 |
* Copyright (C) 2014 by Hugo Pereira Da Costa <hugo.pereira@free.fr> *
|
|
Packit Bot |
052d53 |
* *
|
|
Packit Bot |
052d53 |
* This program is free software; you can redistribute it and/or modify *
|
|
Packit Bot |
052d53 |
* it under the terms of the GNU General Public License as published by *
|
|
Packit Bot |
052d53 |
* the Free Software Foundation; either version 2 of the License, or *
|
|
Packit Bot |
052d53 |
* (at your option) any later version. *
|
|
Packit Bot |
052d53 |
* *
|
|
Packit Bot |
052d53 |
* This program is distributed in the hope that it will be useful, *
|
|
Packit Bot |
052d53 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
Packit Bot |
052d53 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
Packit Bot |
052d53 |
* GNU General Public License for more details. *
|
|
Packit Bot |
052d53 |
* *
|
|
Packit Bot |
052d53 |
* You should have received a copy of the GNU General Public License *
|
|
Packit Bot |
052d53 |
* along with this program; if not, write to the *
|
|
Packit Bot |
052d53 |
* Free Software Foundation, Inc., *
|
|
Packit Bot |
052d53 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
|
Packit Bot |
052d53 |
*************************************************************************/
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#ifndef ADWAITA_SPLITTER_PROXY_H
|
|
Packit Bot |
052d53 |
#define ADWAITA_SPLITTER_PROXY_H
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#include "adwaita.h"
|
|
Packit Bot |
052d53 |
#include "adwaitaaddeventfilter.h"
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#include <QEvent>
|
|
Packit Bot |
052d53 |
#include <QHoverEvent>
|
|
Packit Bot |
052d53 |
#include <QMainWindow>
|
|
Packit Bot |
052d53 |
#include <QMap>
|
|
Packit Bot |
052d53 |
#include <QMouseEvent>
|
|
Packit Bot |
052d53 |
#include <QSplitterHandle>
|
|
Packit Bot |
052d53 |
#include <QWidget>
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
namespace Adwaita
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
class SplitterProxy;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* factory
|
|
Packit Bot |
052d53 |
class ADWAITAQT_EXPORT SplitterFactory : public QObject
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
Q_OBJECT
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
public:
|
|
Packit Bot |
052d53 |
//* constructor
|
|
Packit Bot |
052d53 |
explicit SplitterFactory(QObject *parent)
|
|
Packit Bot |
052d53 |
: QObject(parent)
|
|
Packit Bot |
052d53 |
, _enabled(false)
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* destructor
|
|
Packit Bot |
052d53 |
virtual ~SplitterFactory()
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* enabled state
|
|
Packit Bot |
052d53 |
void setEnabled(bool);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* register widget
|
|
Packit Bot |
052d53 |
bool registerWidget(QWidget *);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* unregister widget
|
|
Packit Bot |
052d53 |
void unregisterWidget(QWidget *);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
private:
|
|
Packit Bot |
052d53 |
//* enabled state
|
|
Packit Bot |
052d53 |
bool _enabled;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* needed to block ChildAdded events when creating proxy
|
|
Packit Bot |
052d53 |
AddEventFilter _addEventFilter;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* pointer to SplitterProxy
|
|
Packit Bot |
052d53 |
using SplitterProxyPointer = WeakPointer<SplitterProxy>;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* registered widgets
|
|
Packit Bot |
052d53 |
using WidgetMap = QMap<QWidget *, SplitterProxyPointer>;
|
|
Packit Bot |
052d53 |
WidgetMap _widgets;
|
|
Packit Bot |
052d53 |
};
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* splitter 'proxy' widget, with extended hit area
|
|
Packit Bot |
052d53 |
class SplitterProxy : public QWidget
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
Q_OBJECT
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
public:
|
|
Packit Bot |
052d53 |
//* constructor
|
|
Packit Bot |
052d53 |
explicit SplitterProxy(QWidget *, bool = false);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* destructor
|
|
Packit Bot |
052d53 |
virtual ~SplitterProxy();
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* event filter
|
|
Packit Bot |
052d53 |
virtual bool eventFilter(QObject *, QEvent *);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* enable state
|
|
Packit Bot |
052d53 |
void setEnabled(bool);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* enable state
|
|
Packit Bot |
052d53 |
bool enabled() const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return _enabled;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
protected:
|
|
Packit Bot |
052d53 |
//* event handler
|
|
Packit Bot |
052d53 |
virtual bool event(QEvent *);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
protected:
|
|
Packit Bot |
052d53 |
//* reset 'true' splitter widget
|
|
Packit Bot |
052d53 |
void clearSplitter();
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* keep track of 'true' splitter widget
|
|
Packit Bot |
052d53 |
void setSplitter(QWidget *);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
private:
|
|
Packit Bot |
052d53 |
//* enabled state
|
|
Packit Bot |
052d53 |
bool _enabled;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* splitter object
|
|
Packit Bot |
052d53 |
WeakPointer<QWidget> _splitter;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* hook
|
|
Packit Bot |
052d53 |
QPoint _hook;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* timer id
|
|
Packit Bot |
052d53 |
int _timerId;
|
|
Packit Bot |
052d53 |
};
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
} // namespace Adwaita
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#endif // ADWAITA_SPLITTER_PROXY_H
|