~ubuntu-branches/ubuntu/wily/oxygen/wily

« back to all changes in this revision

Viewing changes to kstyle/config/oxygenstyleconfig.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell, Scarlett Clark, Jonathan Riddell
  • Date: 2015-08-10 23:18:51 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20150810231851-wtw33zvkigya4f7t
Tags: 4:5.3.95-0ubuntu1
[ Scarlett Clark ]
* Vivid backport. 

[ Jonathan Riddell ]
* new upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
 
60
60
    //__________________________________________________________________
61
61
    StyleConfig::StyleConfig(QWidget* parent):
62
 
        QWidget(parent),
63
 
        _expertMode( false ),
64
 
        _animationConfigWidget(0)
 
62
        QWidget(parent)
65
63
    {
66
64
        setupUi(this);
67
65
 
68
 
        // connections
69
 
        connect( _expertModeButton, SIGNAL(pressed()), SLOT(toggleExpertModeInternal()) );
70
 
 
71
 
        _expertModeButton->setIcon( QIcon::fromTheme( QStringLiteral( "configure" ) ) );
72
 
 
73
 
        // toggle expert mode
74
 
        toggleExpertModeInternal( false );
75
 
 
76
66
        // load setup from configData
77
67
        load();
78
68
 
80
70
        connect( _toolBarDrawItemSeparator, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
81
71
        connect( _splitterProxyEnabled, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
82
72
        connect( _mnemonicsMode, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
83
 
        connect( _animationsEnabled, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
84
73
        connect( _viewDrawFocusIndicator, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
85
74
        connect( _viewTriangularExpanderSize, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
86
75
        connect( _viewDrawTreeBranchLines, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
92
81
        connect( _menuHighlightSubtle, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
93
82
        connect( _windowDragMode, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
94
83
 
 
84
 
95
85
    }
96
86
 
97
87
    //__________________________________________________________________
110
100
        StyleConfigData::setMenuHighlightMode( menuMode() );
111
101
        StyleConfigData::setWindowDragMode( _windowDragMode->currentIndex()  );
112
102
 
113
 
        if( _expertMode )
114
 
        {
115
 
 
116
 
            _animationConfigWidget->save();
117
 
 
118
 
        } else {
119
 
 
120
 
            StyleConfigData::setAnimationsEnabled( _animationsEnabled->isChecked() );
121
 
 
122
 
        }
 
103
        _animationConfigWidget->save();
123
104
 
124
105
        #if OXYGEN_USE_KDE4
125
106
        StyleConfigData::self()->writeConfig();
163
144
    }
164
145
 
165
146
    //__________________________________________________________________
166
 
    void StyleConfig::toggleExpertMode( bool value )
167
 
    {
168
 
        _expertModeContainer->hide();
169
 
        toggleExpertModeInternal( value );
170
 
    }
171
 
 
172
 
    //__________________________________________________________________
173
 
    void StyleConfig::toggleExpertModeInternal( bool value )
174
 
    {
175
 
 
176
 
        // store value
177
 
        _expertMode = value;
178
 
 
179
 
        // update button text
180
 
        _expertModeButton->setText( _expertMode ? i18n( "Hide Advanced Configuration Options" ):i18n( "Show Advanced Configuration Options" ) );
181
 
 
182
 
        // update widget visibility based on expert mode
183
 
        if( _expertMode )
184
 
        {
185
 
 
186
 
            // create animationConfigWidget if needed
187
 
            if( !_animationConfigWidget )
188
 
            {
189
 
                _animationConfigWidget = new AnimationConfigWidget();
190
 
                _animationConfigWidget->installEventFilter( this );
191
 
                connect( _animationConfigWidget, SIGNAL(changed(bool)), SLOT(updateChanged()) );
192
 
                connect( _animationConfigWidget, SIGNAL(layoutChanged()), SLOT(updateLayout()) );
193
 
                _animationConfigWidget->load();
194
 
            }
195
 
 
196
 
            // add animationConfigWidget to tabbar if needed
197
 
            if( tabWidget->indexOf( _animationConfigWidget ) < 0 )
198
 
            { tabWidget->insertTab( 1, _animationConfigWidget, i18n( "Animations" ) ); }
199
 
 
200
 
        } else if( _animationConfigWidget ) {
201
 
 
202
 
            if( int index = tabWidget->indexOf( _animationConfigWidget ) >= 0 )
203
 
            { tabWidget->removeTab( index ); }
204
 
 
205
 
        }
206
 
 
207
 
        _mnemonicsLabel->setVisible( _expertMode );
208
 
        _mnemonicsMode->setVisible( _expertMode );
209
 
        _animationsEnabled->setVisible( !_expertMode );
210
 
        _viewsExpertWidget->setVisible( _expertMode );
211
 
 
212
 
        updateMinimumSize();
213
 
 
214
 
    }
215
 
 
216
 
    //__________________________________________________________________
217
 
    bool StyleConfig::eventFilter( QObject* object, QEvent* event )
218
 
    {
219
 
 
220
 
        switch( event->type() )
221
 
        {
222
 
 
223
 
            case QEvent::ShowToParent:
224
 
            object->event( event );
225
 
            updateLayout();
226
 
            return true;
227
 
 
228
 
            default:
229
 
            return false;
230
 
        }
231
 
    }
232
 
 
233
 
    //__________________________________________________________________
234
 
    bool StyleConfig::event( QEvent* event )
235
 
    {
236
 
        const bool result( QWidget::event( event ) );
237
 
        switch( event->type() )
238
 
        {
239
 
            case QEvent::Show:
240
 
            case QEvent::ShowToParent:
241
 
            updateMinimumSize();
242
 
            break;
243
 
 
244
 
            default: break;
245
 
        }
246
 
 
247
 
        return result;
248
 
 
249
 
    }
250
 
 
251
 
    //__________________________________________________________________
252
 
    void StyleConfig::updateMinimumSize( void )
253
 
    { setMinimumSize( minimumSizeHint() ); }
254
 
 
255
 
    //__________________________________________________________________
256
 
    void StyleConfig::updateLayout( void )
257
 
    {
258
 
        if( _animationConfigWidget )
259
 
        {
260
 
            const int delta = _animationConfigWidget->minimumSizeHint().height() - _animationConfigWidget->size().height();
261
 
            window()->setMinimumSize( QSize( window()->minimumSizeHint().width(), window()->size().height() + delta ) );
262
 
        }
263
 
    }
264
 
 
265
 
    //__________________________________________________________________
266
147
    void StyleConfig::updateChanged()
267
148
    {
268
149
 
278
159
        else if( _scrollBarSubLineButtons->currentIndex() != StyleConfigData::scrollBarSubLineButtons() ) modified = true;
279
160
        else if( _splitterProxyEnabled->isChecked() != StyleConfigData::splitterProxyEnabled() ) modified = true;
280
161
        else if( menuMode() != StyleConfigData::menuHighlightMode() ) modified = true;
281
 
        else if( _animationsEnabled->isChecked() != StyleConfigData::animationsEnabled() ) modified = true;
282
162
        else if( _viewDrawFocusIndicator->isChecked() != StyleConfigData::viewDrawFocusIndicator() ) modified = true;
283
163
        else if( triangularExpanderSize() != StyleConfigData::viewTriangularExpanderSize() ) modified = true;
284
164
        else if( _animationConfigWidget && _animationConfigWidget->isChanged() ) modified = true;
310
190
        _menuHighlightStrong->setChecked( StyleConfigData::menuHighlightMode() == StyleConfigData::MM_STRONG );
311
191
        _menuHighlightSubtle->setChecked( StyleConfigData::menuHighlightMode() == StyleConfigData::MM_SUBTLE );
312
192
 
313
 
        _animationsEnabled->setChecked( StyleConfigData::animationsEnabled() );
314
193
        _windowDragMode->setCurrentIndex( StyleConfigData::windowDragMode() );
315
194
 
316
195
        _viewDrawFocusIndicator->setChecked( StyleConfigData::viewDrawFocusIndicator() );