File: TransparencyConfiguration.cpp

package info (click to toggle)
qtop 2.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,840 kB
  • ctags: 5,775
  • sloc: cpp: 38,795; makefile: 9
file content (169 lines) | stat: -rw-r--r-- 6,263 bytes parent folder | download
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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/******************************************************************************
*
* Copyright (C) 2002 Hugo PEREIRA <mailto: hugo.pereira@free.fr>
*
* This 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 software 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, see <http://www.gnu.org/licenses/>.
*
*******************************************************************************/

#include "TransparencyConfiguration.h"

#include "CompositeEngine.h"
#include "Debug.h"
#include "GridLayout.h"
#include "OptionCheckBox.h"
#include "OptionColorDisplay.h"
#include "OptionSlider.h"
#include "OptionSpinBox.h"

#include <QGroupBox>
#include <QLabel>
#include <QLayout>

namespace Transparency
{

    //________________________________________________________________________
    TransparencyConfiguration::TransparencyConfiguration( QWidget* parent, Flags flags ):
        QWidget( parent ),
        OptionWidgetList( this ),
        Counter( "Transparency::TransparencyConfiguration" )
    {
        Debug::Throw( "TransparencyConfiguration::TransparencyConfiguration.\n" );

        if( (flags&Foreground) && (flags&Background) )
        {
            setLayout( new QVBoxLayout() );
            layout()->setSpacing(5);
            layout()->setMargin(0);
        }

        // generic widget
        QWidget* box;

        // foreground
        if( flags&Foreground )
        {

            if( flags&Background )
            {
                box = new QGroupBox( "Foreground", this );
                layout()->addWidget( box );
            } else box = this;

            _foregroundConfiguration( box );
        }

        // background
        if( flags&Background )
        {
            if( flags&Foreground )
            {
                box = new QGroupBox( "Background", this );
                layout()->addWidget( box );
            } else box = this;

            _backgroundConfiguration( box );
        }

        return;
    }

    //________________________________________________________________________
    void TransparencyConfiguration::_foregroundConfiguration( QWidget* parent )
    {

        OptionColorDisplay* colorDisplay;
        OptionSlider* slider;
        OptionSpinBox* spinbox;
        OptionCheckBox* checkbox;

        GridLayout* gridLayout = new GridLayout();
        gridLayout->setSpacing(5);
        gridLayout->setMargin(5);
        gridLayout->setMaxCount( 2 );
        gridLayout->setColumnAlignment( 0, (Qt::Alignment)(Qt::AlignRight|Qt::AlignVCenter));
        parent->setLayout( gridLayout );

        // foreground color
        gridLayout->addWidget( new QLabel( tr( "Foreground Color:" ), parent ) );
        gridLayout->addWidget( colorDisplay = new OptionColorDisplay( parent, "TRANSPARENCY_FOREGROUND_COLOR" ) );
        colorDisplay->setToolTip( tr( "Text/display foreground color" ) );
        addOptionWidget( colorDisplay );

        // shadow color
        gridLayout->addWidget( new QLabel( tr( "Highlight color:" ), parent ) );
        gridLayout->addWidget( colorDisplay = new OptionColorDisplay( parent, "TRANSPARENCY_SHADOW_COLOR" ) );
        colorDisplay->setToolTip( tr( "Text/display highlight color" ) );
        addOptionWidget( colorDisplay );

        // foreground intensity
        gridLayout->addWidget( new QLabel( tr( "Foreground intensity:" ), parent ) );
        gridLayout->addWidget( slider = new OptionSlider( parent, "TRANSPARENCY_FOREGROUND_INTENSITY" ) );
        slider->setScale( 1.0/2.55 );
        slider->setRange( 0, 100 );
        slider->setSuffix( tr( "%" ) );
        slider->setToolTip( tr( "Foreground color intensity" ) );
        addOptionWidget( slider );

        // foreground highlight offset
        gridLayout->addWidget( new QLabel( tr( "Highlight size: " ), parent ) );
        gridLayout->addWidget( spinbox = new OptionSpinBox( parent, "TRANSPARENCY_SHADOW_OFFSET" ) );
        spinbox->setMinimum( 0 );
        spinbox->setMaximum( 10 );
        spinbox->setSuffix( tr( "px" ) );
        spinbox->setToolTip(
            tr( "Offset between text shadow and text.\n"
            "0 means no shadow." ) );
        addOptionWidget( spinbox );

        // inverse colors
        gridLayout->addWidget( checkbox = new OptionCheckBox( tr( "Inverse colors" ), parent, "TRANSPARENCY_INVERSE_COLORS" ), 4, 1, 1, 1 );
        addOptionWidget( checkbox );
        checkbox->setToolTip( tr( "Inverse foreground and highlight color, typically for dark themes" ) );

    }

    //________________________________________________________________________
    void TransparencyConfiguration::_backgroundConfiguration( QWidget* parent )
    {

        OptionColorDisplay* colorDisplay;
        OptionSlider* slider;

        GridLayout* gridLayout = new GridLayout();
        gridLayout->setSpacing(5);
        gridLayout->setMargin(5);
        gridLayout->setMaxCount( 2 );
        gridLayout->setColumnAlignment( 0, Qt::AlignRight|Qt::AlignVCenter );
        parent->setLayout( gridLayout );

        // background color
        gridLayout->addWidget( new QLabel( tr( "Background color:" ), parent ) );
        gridLayout->addWidget( colorDisplay = new OptionColorDisplay( parent, "TRANSPARENCY_TINT_COLOR" ) );
        colorDisplay->setToolTip( tr( "Transparent background tint color" ) );
        addOptionWidget( colorDisplay );

        // background intensity
        gridLayout->addWidget( new QLabel( tr( "Background intensity:" ), parent ) );
        gridLayout->addWidget( slider = new OptionSlider( parent, "TRANSPARENCY_TINT_INTENSITY" ) );
        slider->setScale( 1.0/2.55 );
        slider->setRange( 0, 100 );
        slider->setSuffix( tr( "%" ) );
        slider->setToolTip( tr( "Transparent background tint intensity" ) );
        addOptionWidget( slider );

    }

}