dlgpresentation.h 2.43 KB
Newer Older
1
/***************************************************************************
2
 *   Copyright (C) 2006,2008 by Pino Toscano <pino@kde.org>                *
3
4
5
6
7
8
9
10
11
12
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/

#ifndef _DLGPRESENTATION_H
#define _DLGPRESENTATION_H

13
14
#include <QComboBox>
#include <QWidget>
15
16
17

class DlgPresentation : public QWidget
{
18
19
    Q_OBJECT

Albert Astals Cid's avatar
Albert Astals Cid committed
20
21
public:
    explicit DlgPresentation(QWidget *parent = nullptr);
22
23
};

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
 * We need this because there are some special screens,
 * which are not represented by the typical currentIndex(),
 * which would be used by KConfigWidgets.
 *
 * Additionally this class allows to remember a disconnected screen.
 */
class PreferredScreenSelector : public QComboBox
{
    Q_OBJECT

    Q_PROPERTY(int preferredScreen READ preferredScreen WRITE setPreferredScreen NOTIFY preferredScreenChanged)

public:
    explicit PreferredScreenSelector(QWidget *parent);
    int preferredScreen() const;

Q_SIGNALS:
    void preferredScreenChanged(int screen);

public Q_SLOTS:
    void setPreferredScreen(int newScreen);

protected:
    // These two variables protect the screen setting from changing
    // when the configured screen is currently disconnected.

    /**
     * When setScreen() is called with a disconnected screen,
     * a “disconnected” entry is created at this index:
     */
    int m_disconnectedScreenIndex;

    /**
     * Which screen is referred by @c m_disconnectedScreenIndex.
     * Until @c m_disconnectedScreenIndex entry is created, this is @c k_noDisconnectedScreenNumber.
     */
    int m_disconnectedScreenNumber;
62
63
64
65
66
67
68
69

protected Q_SLOTS:
    /**
     * Populates the combobox list with items for the special screens,
     * and for every connected screen.
     * If @c m_disconnectedScreenNumber is set, adds an item for this disconnected screen.
     */
    void repopulateList();
70
71
72
73
74
75
76
};

/** “Current” and “Default” */
const int k_specialScreenCount = 2;
/** Default value of m_disconnectedScreenNumber when no disconnected screen is remembered */
const int k_noDisconnectedScreenNumber = -3;

77
#endif