summaryrefslogtreecommitdiffstats
path: root/src/kcm/configdialog.h
blob: a4ff764cca64c309854569b98fa6ec30bf3a860b (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
/* This file is part of KNemo
   Copyright (C) 2004, 2005, 2006 Percy Leonhardt <percy@eris23.de>

   KNemo is free software; you can redistribute it and/or modify
   it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of
   the License, or (at your option) any later version.

   KNemo 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 Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef CONFIGDIALOG_H
#define CONFIGDIALOG_H

#include <qdict.h>
#include <qpair.h>
#include <qstring.h>
#include <qlistview.h>

#include <kcmodule.h>

#include "data.h"

class QTimer;
class ConfigDlg;
class KNemoCheckListItem;

/**
 * This is the configuration dialog for KNemo
 * It is implemented as a control center module so that it is still
 * possible to configure KNemo even when there is no icon visible
 * in the system tray.
 *
 * @short Configuration dialog for KNemo
 * @author Percy Leonhardt <percy@eris23.de>
 */

class ConfigDialog : public KCModule
{
    Q_OBJECT
public:
    /**
     * Default Constructor
     */
    ConfigDialog( QWidget *parent, const char *name, const QStringList& );

    /**
     * Default Destructor
     */
    virtual ~ConfigDialog();

    void load();
    void save();
    void defaults();

private slots:
    void buttonNewSelected();
    void buttonDeleteSelected();
    void buttonAddCommandSelected();
    void buttonRemoveCommandSelected();
    void buttonCommandUpSelected();
    void buttonCommandDownSelected();
    void buttonAddToolTipSelected();
    void buttonRemoveToolTipSelected();
    void buttonNotificationsSelected();
    void buttonStatisticsDirSelected();
    void interfaceSelected( const QString& interface );
    void aliasChanged( const QString& text );
    void iconSetChanged( int set );
    void backendChanged( int set );
    void checkBoxNotConnectedToggled( bool on );
    void checkBoxNotExistingToggled( bool on );
    void checkBoxStatisticsToggled( bool on );
    void checkBoxStartKNemoToggled( bool on );
    void spinBoxTrafficValueChanged( int value );
    void checkBoxCustomToggled( bool on );
    void listViewCommandsSelectionChanged();
    void listViewCommandsCheckListItemChanged( KNemoCheckListItem* item, bool state );
    void listViewCommandsRenamed( QListViewItem* item, int col, const QString & text );

    /**
     * These three are generic.
     * They are used for all plotter settings to activate the
     * 'Apply' button when something was changed by the user.
     */
    void checkBoxToggled( bool );
    void spinBoxValueChanged( int );
    void kColorButtonChanged( const QColor& );

private:
    void setupToolTipTab();
    void setupToolTipArray();
    void updateStatisticsEntries( void );

    enum IconSet
    {
        MONITOR = 0,
        MODEM,
        NETWORK,
        WIRELESS
    };

    int mToolTipContent;
    bool mLock;
    ConfigDlg* mDlg;
    QColor mColorVLines;
    QColor mColorHLines;
    QColor mColorIncoming;
    QColor mColorOutgoing;
    QColor mColorBackground;
    QDict<InterfaceSettings> mSettingsDict;
    QPair<QString, int> mToolTips[25];

    static const QString ICON_DISCONNECTED;
    static const QString ICON_CONNECTED;
    static const QString ICON_INCOMING;
    static const QString ICON_OUTGOING;
    static const QString ICON_TRAFFIC;
    static const QString SUFFIX_PPP;
    static const QString SUFFIX_LAN;
    static const QString SUFFIX_WLAN;
};

class KNemoCheckListItem : public QObject, public QCheckListItem
{
    Q_OBJECT
public:
    KNemoCheckListItem( QListView* view )
        : QCheckListItem( view, QString::null, QCheckListItem::CheckBox )
    {}

signals:
    void stateChanged( KNemoCheckListItem*, bool );

protected:
    void stateChange( bool state )
    {
        emit stateChanged( this, state );
    }
};

#endif // CONFIGDIALOG_H