UBFeaturesActionBar.h 3.49 KB
Newer Older
1
/*
2
 * Copyright (C) 2015-2018 Département de l'Instruction Publique (DIP-SEM)
Craig Watson's avatar
Craig Watson committed
3
 *
Claudio Valerio's avatar
Claudio Valerio committed
4
 * Copyright (C) 2013 Open Education Foundation
5
 *
Claudio Valerio's avatar
Claudio Valerio committed
6 7
 * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour
 * l'Education Numérique en Afrique (GIP ENA)
8
 *
Claudio Valerio's avatar
Claudio Valerio committed
9 10 11
 * This file is part of OpenBoard.
 *
 * OpenBoard is free software: you can redistribute it and/or modify
Claudio Valerio's avatar
Claudio Valerio committed
12 13
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License,
14 15 16 17
 * with a specific linking exception for the OpenSSL project's
 * "OpenSSL" library (or with modified versions of it that use the
 * same license as the "OpenSSL" library).
 *
Claudio Valerio's avatar
Claudio Valerio committed
18
 * OpenBoard is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Claudio Valerio's avatar
Claudio Valerio committed
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Claudio Valerio's avatar
Claudio Valerio committed
21
 * GNU General Public License for more details.
22
 *
Claudio Valerio's avatar
Claudio Valerio committed
23
 * You should have received a copy of the GNU General Public License
Claudio Valerio's avatar
Claudio Valerio committed
24
 * along with OpenBoard. If not, see <http://www.gnu.org/licenses/>.
25 26 27
 */


Claudio Valerio's avatar
Claudio Valerio committed
28

Claudio Valerio's avatar
Claudio Valerio committed
29

30 31 32 33 34
#ifndef UBFEATURESACTIONBAR_H
#define UBFEATURESACTIONBAR_H

#include <QWidget>
#include <QToolButton>
35
#include <QDropEvent>
36 37 38
#include <QLineEdit>
#include <QLayout>

39 40
#include "board/UBFeaturesController.h"

41 42 43
#define BUTTON_SIZE 24
#define ACTIONBAR_HEIGHT 42

44 45
class UBFeaturesMimeData;

46 47 48 49 50 51 52 53 54 55 56 57 58 59
typedef enum
{
    eButtonSet_Default,
    eButtonSet_Properties,
    eButtonSet_Favorite
} eButtonSet;

class UBActionButton : public QToolButton
{
public:
    UBActionButton(QWidget* parent=0, QAction* action=0, const char* name="UBActionButton");
    ~UBActionButton();
};

60 61
enum UBFeaturesActionBarState
{
Claudio Valerio's avatar
Claudio Valerio committed
62 63 64 65 66
    IN_ROOT,
    IN_FOLDER,
    IN_PROPERTIES,
    IN_FAVORITE,
    IN_TRASH
67
};
68 69 70

class UBFeaturesActionBar : public QWidget
{
Claudio Valerio's avatar
Claudio Valerio committed
71
    Q_OBJECT
72
public:
Claudio Valerio's avatar
Claudio Valerio committed
73
    UBFeaturesActionBar(UBFeaturesController *controller, QWidget* parent=0, const char* name="UBFeaturesActionBar");
74
    ~UBFeaturesActionBar();
Claudio Valerio's avatar
Claudio Valerio committed
75 76
    
    void setCurrentState( UBFeaturesActionBarState state );
77
    void cleanText(){ mSearchBar->clear(); }
78

79
signals:
Claudio Valerio's avatar
Claudio Valerio committed
80 81
    void searchElement(const QString &text);
    void newFolderToCreate();
82 83 84
    void deleteElements(const UBFeaturesMimeData *data);
    void addToFavorite(const UBFeaturesMimeData *data);
    void removeFromFavorite(const UBFeaturesMimeData *data);
85
    void addElementsToFavorite();
86
    void removeElementsFromFavorite();
87
    void deleteSelectedElements();
88 89
    void rescanModel();

90
private slots:
Claudio Valerio's avatar
Claudio Valerio committed
91 92
    void onSearchTextChanged(QString txt);
    void onActionNewFolder();
93
    void onActionFavorite();
94
    void onActionRemoveFavorite();
95
    void onActionTrash();
96
    void onActionRescanModel();
97 98
    void lockIt();
    void unlockIt();
99

100
protected:
101
    void dragEnterEvent( QDragEnterEvent *event );
Claudio Valerio's avatar
Claudio Valerio committed
102
    void dropEvent( QDropEvent *event );
103

104
private:
Claudio Valerio's avatar
Claudio Valerio committed
105 106 107
    void setButtons();
    UBFeaturesController *featuresController;
    UBFeaturesActionBarState currentState;
108

Claudio Valerio's avatar
Claudio Valerio committed
109
    eButtonSet mCrntButtonSet;
110 111
    eButtonSet mPreviousButtonSet;

Claudio Valerio's avatar
Claudio Valerio committed
112
    QButtonGroup* mButtonGroup;
113 114 115 116
    QLineEdit* mSearchBar;
    QHBoxLayout* mLayout;
    QAction* mpFavoriteAction;
    QAction* mpSocialAction;
117
    QAction* mpRescanModelAction;
118 119 120 121 122 123 124
    QAction* mpDeleteAction;
    QAction* mpSearchAction;
    QAction* mpCloseAction;
    QAction* mpRemoveFavorite;
    QAction* mpNewFolderAction;
    UBActionButton* mpFavoriteBtn;
    UBActionButton* mpSocialBtn;
125
    UBActionButton* mpRescanModelBtn;
126 127 128 129
    UBActionButton* mpDeleteBtn;
    UBActionButton* mpCloseBtn;
    UBActionButton* mpRemoveFavoriteBtn;
    UBActionButton* mpNewFolderBtn;
130 131
};

132
#endif