toolbar.hpp 3.3 KB
Newer Older
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/*****************************************************************************
 * ToolbarEdit.hpp : ToolbarEdit dialogs
 ****************************************************************************
 * Copyright (C) 2007 the VideoLAN team
 * $Id$
 *
 * Authors: Jean-Baptiste Kempf <jb (at) videolan.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#ifndef _TOOLBAREDIT_DIALOG_H_
#define _TOOLBAREDIT_DIALOG_H_

#include "util/qvlcframe.hpp"
#include "components/controller.hpp"

#include <QRubberBand>
#include <QListWidget>
32
#include <QCheckBox>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
33 34

class ToolbarEditDialog;
35
class DroppingController;
36
class QCheckBox;
37
class QComboBox;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

class WidgetListing : public QListWidget
{
    Q_OBJECT;
public:
    WidgetListing( intf_thread_t *, QWidget *_parent = 0 );
protected:
    virtual void startDrag( Qt::DropActions /*supportedActions*/ );
private:
    ToolbarEditDialog *parent;
};

class ToolbarEditDialog : public QVLCFrame
{
    Q_OBJECT;
public:
    static ToolbarEditDialog * getInstance( intf_thread_t *p_intf )
    {
        if( !instance)
            instance = new ToolbarEditDialog( p_intf );
        return instance;
    }
    virtual ~ToolbarEditDialog();
    int getOptions() { return flatBox->isChecked() * WIDGET_FLAT +
62 63
                        bigBox->isChecked() * WIDGET_BIG +
                        shinyBox->isChecked() * WIDGET_SHINY; }
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
64 65 66 67 68
private:
    ToolbarEditDialog( intf_thread_t * );
    static ToolbarEditDialog *instance;

    QCheckBox *flatBox, *bigBox, *shinyBox;
69
    QComboBox *positionCombo;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
70 71

    WidgetListing *widgetListing;
72 73 74 75 76 77
    DroppingController *controller1, *controller2, *controllerA;
    DroppingController *controllerFSC, *controller;

private slots:
    void cancel();
    void close();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
78 79 80 81 82 83
};

class DroppingController: public AbstractController
{
    Q_OBJECT;
public:
84
    DroppingController( intf_thread_t *, QString line, QWidget *parent = 0 );
85
    QString getValue();
86
    virtual ~DroppingController();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
87 88 89 90 91 92 93 94 95 96

protected:
    virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
            buttonType_e i_type, int i_option );
    virtual void dragEnterEvent ( QDragEnterEvent * event );
    virtual void dragMoveEvent(QDragMoveEvent *event);
    virtual void dropEvent ( QDropEvent * event );
    virtual void dragLeaveEvent ( QDragLeaveEvent * event );

    virtual void doAction( int );
97 98

    bool eventFilter( QObject *, QEvent * );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
99
private:
100 101 102 103 104
    struct doubleInt
    {
        int i_type;
        int i_option;
    };
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
105
    QRubberBand *rubberband;
106
    QList <doubleInt *> widgetList;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
107 108 109

    int getParentPosInLayout( QPoint point);

110 111
    bool b_draging;

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
112 113 114 115
};

#endif