rightpane.h 2.99 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30
31
32
33
#ifndef RIGHTPANE_H
#define RIGHTPANE_H

#include "core_global.h"
hjk's avatar
hjk committed
34

con's avatar
con committed
35
36
37
38
39
#include <QtGui/QWidget>
#include <QtCore/QSettings>

namespace Core {

hjk's avatar
hjk committed
40
class IMode;
con's avatar
con committed
41
42
class RightPaneWidget;

hjk's avatar
hjk committed
43
44
45
46
47
48
49
// TODO: The right pane works only for the help plugin atm.  It can't cope
// with more than one plugin publishing objects they want in the right pane
// For that the API would need to be different. (Might be that instead of
// adding objects to the pool, there should be a method
// RightPaneWidget::setWidget(QWidget *w) Anyway if a second plugin wants to
// show something there, redesign this API

con's avatar
con committed
50
51
52
53
class CORE_EXPORT RightPanePlaceHolder : public QWidget
{
    friend class Core::RightPaneWidget;
    Q_OBJECT
hjk's avatar
hjk committed
54

con's avatar
con committed
55
56
57
58
public:
    RightPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0);
    ~RightPanePlaceHolder();
    static RightPanePlaceHolder *current();
hjk's avatar
hjk committed
59

con's avatar
con committed
60
61
private slots:
    void currentModeChanged(Core::IMode *);
hjk's avatar
hjk committed
62

con's avatar
con committed
63
64
65
66
67
68
private:
    void applyStoredSize(int width);
    Core::IMode *m_mode;
    static RightPanePlaceHolder* m_current;
};

hjk's avatar
hjk committed
69

con's avatar
con committed
70
71
72
class CORE_EXPORT BaseRightPaneWidget : public QObject
{
    Q_OBJECT
hjk's avatar
hjk committed
73

con's avatar
con committed
74
75
76
77
public:
    BaseRightPaneWidget(QWidget *widget);
    ~BaseRightPaneWidget();
    QWidget *widget() const;
hjk's avatar
hjk committed
78

con's avatar
con committed
79
80
81
82
private:
    QWidget *m_widget;
};

hjk's avatar
hjk committed
83

con's avatar
con committed
84
85
86
class CORE_EXPORT RightPaneWidget : public QWidget
{
    Q_OBJECT
hjk's avatar
hjk committed
87

con's avatar
con committed
88
89
90
91
92
93
94
95
96
97
public:
    RightPaneWidget();
    ~RightPaneWidget();

    void saveSettings(QSettings *settings);
    void readSettings(QSettings *settings);

    bool isShown();
    void setShown(bool b);

hjk's avatar
hjk committed
98
    static RightPaneWidget *instance();
con's avatar
con committed
99
100

    int storedWidth();
hjk's avatar
hjk committed
101

con's avatar
con committed
102
103
protected:
    void resizeEvent(QResizeEvent *);
hjk's avatar
hjk committed
104

con's avatar
con committed
105
106
107
108
109
110
111
112
113
114
115
116
117
private slots:
    void objectAdded(QObject *obj);
    void aboutToRemoveObject(QObject *obj);

private:
    bool m_shown;
    int m_width;
    static RightPaneWidget *m_instance;
};

} // namespace Core

#endif // RIGHTPANE_H