summaryrefslogtreecommitdiffstats
path: root/src/configdialog.cpp
blob: 1bc0efbb0ea96aab480caf893fb1f46bdc3066da (plain)
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
170
171
172
173
174


#include "configdialog.h"

#include "config.h"
#include "configgeneralpage.h"
#include "configpluginspage.h"
#include "configenvironmentpage.h"
#include "configbackendspage.h"

/*#include "config_dialogue_interface.h"
#include "config_dialogue_backend_plugins.h"
#include "config_dialogue_backends.h"
#include "config_dialogue_en_decoder.h"
#include "config_dialogue_en_decoder_options.h"

#include "tools.h"
#include "backend_plugins.h"
#include "replaygain_plugins.h"

#include <tqlayout.h>
*/
//#include <tdeconfig.h>
#include <kiconloader.h>
#include <tdelocale.h>
#include <kpushbutton.h>

ConfigDialog::ConfigDialog( Config* _config, TQWidget *parent, const char *name, Page startPage )
    : KDialogBase(
        IconList,
        i18n("Settings"),
        Apply | Cancel | Default | Help | Ok,
        Ok, // default button
        parent,
        name,
        true, // modal
        true // separator
    )
{
    config = _config;

    //resize( 600, 400 );

    binaries = config->binaries;

    connect( this, TQT_SIGNAL(applyClicked()),
               this,TQT_SLOT(applyClickedSlot())
             );
    connect( this, TQT_SIGNAL(okClicked()),
               this,TQT_SLOT(okClickedSlot())
             );
    connect( this, TQT_SIGNAL(defaultClicked()),
               this,TQT_SLOT(defaultClickedSlot())
             );

    generalPage = addPage( i18n("General"), "misc" );
    configGeneralPage = new ConfigGeneralPage( config, generalPage, "configGeneralPage" );
    connect( configGeneralPage, TQT_SIGNAL(configChanged()),
               this, TQT_SLOT(configChanged())
    );
    connect( this, TQT_SIGNAL(saveGeneral()),
               configGeneralPage, TQT_SLOT(saveSettings())
    );
    connect( this, TQT_SIGNAL(resetGeneral()),
               configGeneralPage, TQT_SLOT(resetDefaults())
    );

    pluginsPage = addPage( i18n("Plugins"), "connect_creating" );
    configPluginsPage = new ConfigPluginsPage( config, pluginsPage, "configPluginsPage" );
    connect( configPluginsPage, TQT_SIGNAL(configChanged()),
               this, TQT_SLOT(configChanged())
    );
    connect( this, TQT_SIGNAL(savePlugins()),
               configPluginsPage, TQT_SLOT(saveSettings())
    );
    connect( this, TQT_SIGNAL(resetPlugins()),
               configPluginsPage, TQT_SLOT(resetDefaults())
    );

    environmentPage = addPage( i18n("Environment"), "filefind" );
    configEnvironmentPage = new ConfigEnvironmentPage( config, &binaries, environmentPage, "configEnvironmentPage" );
    connect( configEnvironmentPage, TQT_SIGNAL(configChanged()),
               this, TQT_SLOT(configChanged())
    );
    connect( this, TQT_SIGNAL(saveEnvironment()),
               configEnvironmentPage, TQT_SLOT(saveSettings())
    );
    connect( this, TQT_SIGNAL(resetEnvironment()),
               configEnvironmentPage, TQT_SLOT(resetDefaults())
    );

    backendsPage = addPage( i18n("Backends"), "preferences-system" );
    configBackendsPage = new ConfigBackendsPage( config, &binaries, backendsPage, "configBackendsPage" );
    connect( configBackendsPage, TQT_SIGNAL(configChanged()),
               this, TQT_SLOT(configChanged())
    );
    connect( this, TQT_SIGNAL(saveBackends()),
               configBackendsPage, TQT_SLOT(saveSettings())
    );
    connect( this, TQT_SIGNAL(resetBackends()),
               configBackendsPage, TQT_SLOT(resetDefaults())
    );
    connect( configEnvironmentPage, TQT_SIGNAL(rebuildBackendsPage()),
               configBackendsPage, TQT_SLOT(rebuild())
    );

    setConfigChanged( false );

    showPage( startPage );
}

ConfigDialog::~ConfigDialog()
{
}

TQFrame *ConfigDialog::addPage(const TQString &itemName, const TQString &iconName)
{
    return KDialogBase::addPage( itemName, TQString(), MainBarIcon(iconName,32) );
}

void ConfigDialog::setConfigChanged( const bool value )
{
    actionButton( Apply )->setEnabled(value);
}

void ConfigDialog::configChanged()
{
    setConfigChanged( true );
}

void ConfigDialog::applyClickedSlot()
{
    okClickedSlot();
    setConfigChanged( false );
}

void ConfigDialog::okClickedSlot()
{
    emit saveGeneral();
    emit savePlugins();
    emit saveEnvironment();
    emit saveBackends();
    config->write();
}

void ConfigDialog::defaultClickedSlot()
{
    int index = activePageIndex();
    TQStringList listDefaults;

    if( index == -1 )
        return;

    if( index == pageIndex(generalPage) )
    {
        emit resetGeneral();
        setConfigChanged( true );
    }
    else if( index == pageIndex(pluginsPage) )
    {
        emit resetPlugins();
        setConfigChanged( true );
    }
    else if( index == pageIndex(environmentPage) )
    {
        emit resetEnvironment();
        setConfigChanged( true );
    }
    else if( index == pageIndex(backendsPage) )
    {
        emit resetBackends();
        setConfigChanged( true );
    }
}