~ubuntu-branches/ubuntu/maverick/knemo/maverick

« back to all changes in this revision

Viewing changes to src/knemod/plotterconfigdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2010-01-06 17:16:51 UTC
  • mfrom: (1.1.9 upstream) (2.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100106171651-ff58ryfnav4l1zbm
Tags: 0.6.0-1
* New upstream release 
  - Fixes "FTBFS: sysbackend.cpp:362: error: 'KILO' was not declared in
  this scope" (Closes: #560496)
  - Fixes "context menu does not appear" (Closes: #504791)
* Add Build-Depends: libnl-dev - Linux netlink sockets library

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of KNemo
 
2
   Copyright (C) 2009 John Stamp <jstamp@users.sourceforge.net>
 
3
 
 
4
   KNemo is free software; you can redistribute it and/or modify
 
5
   it under the terms of the GNU Library General Public License as
 
6
   published by the Free Software Foundation; either version 2 of
 
7
   the License, or (at your option) any later version.
 
8
 
 
9
   KNemo is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
   GNU Library General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU Library General Public License
 
15
   along with this library; see the file COPYING.LIB.  If not, write to
 
16
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
   Boston, MA 02110-1301, USA.
 
18
*/
 
19
 
 
20
 
 
21
#include "plotterconfigdialog.h"
 
22
#include "data.h"
 
23
 
 
24
#include <KConfig>
 
25
 
 
26
PlotterConfigDialog::PlotterConfigDialog( QWidget * parent, const QString& iface, PlotterSettings* settings ) : KDialog( parent ),
 
27
      mName( iface ),
 
28
      mSettings( settings )
 
29
{
 
30
    setButtons( Ok | Apply | Default | Close );
 
31
    ui.setupUi( mainWidget() );
 
32
    load();
 
33
    enableButtonApply( false );
 
34
    //enableButtonDefault( true );
 
35
 
 
36
    connect( this, SIGNAL( defaultClicked() ), SLOT( defaults() ) );
 
37
    connect( this, SIGNAL( applyClicked() ), SLOT( save() ) );
 
38
    connect( this, SIGNAL( okClicked() ), SLOT( save() ) );
 
39
 
 
40
    // connect the plotter widgets
 
41
    connect( ui.checkBoxBottomBar, SIGNAL( toggled( bool ) ),
 
42
             this, SLOT( changed() ) );
 
43
    connect( ui.checkBoxLabels, SIGNAL( toggled( bool ) ),
 
44
             this, SLOT( changed() ) );
 
45
    connect( ui.checkBoxVLines, SIGNAL( toggled( bool ) ),
 
46
             this, SLOT( changed() ) );
 
47
    connect( ui.checkBoxHLines, SIGNAL( toggled( bool ) ),
 
48
             this, SLOT( changed() ) );
 
49
    connect( ui.checkBoxIncoming, SIGNAL( toggled( bool ) ),
 
50
             this, SLOT( changed() ) );
 
51
    connect( ui.checkBoxOutgoing, SIGNAL( toggled( bool ) ),
 
52
             this, SLOT( changed() ) );
 
53
    connect( ui.checkBoxVLinesScroll, SIGNAL( toggled( bool ) ),
 
54
             this, SLOT( changed() ) );
 
55
    connect( ui.checkBoxAutoDetection, SIGNAL( toggled( bool ) ),
 
56
             this, SLOT( changed() ) );
 
57
    connect( ui.spinBoxPixel, SIGNAL( valueChanged( int ) ),
 
58
             this, SLOT( changed() ) );
 
59
    connect( ui.spinBoxDistance, SIGNAL( valueChanged( int ) ),
 
60
             this, SLOT( changed() ) );
 
61
    connect( ui.spinBoxFontSize, SIGNAL( valueChanged( int ) ),
 
62
             this, SLOT( changed() ) );
 
63
    connect( ui.spinBoxMinValue, SIGNAL( valueChanged( int ) ),
 
64
             this, SLOT( changed() ) );
 
65
    connect( ui.spinBoxMaxValue, SIGNAL( valueChanged( int ) ),
 
66
             this, SLOT( changed() ) );
 
67
    connect( ui.kColorButtonVLines, SIGNAL( changed( const QColor& ) ),
 
68
             this, SLOT( changed() ) );
 
69
    connect( ui.kColorButtonHLines, SIGNAL( changed( const QColor& ) ),
 
70
             this, SLOT( changed() ) );
 
71
    connect( ui.kColorButtonIncoming, SIGNAL( changed( const QColor& ) ),
 
72
             this, SLOT( changed() ) );
 
73
    connect( ui.kColorButtonOutgoing, SIGNAL( changed( const QColor& ) ),
 
74
             this, SLOT( changed() ) );
 
75
    connect( ui.kColorButtonBackground, SIGNAL( changed( const QColor& ) ),
 
76
             this, SLOT( changed() ) );
 
77
    connect( ui.spinBoxOpacity, SIGNAL( valueChanged( const int ) ),
 
78
             this, SLOT( changed() ) );
 
79
}
 
80
 
 
81
PlotterConfigDialog::~PlotterConfigDialog()
 
82
{
 
83
}
 
84
 
 
85
void PlotterConfigDialog::load()
 
86
{
 
87
    ui.spinBoxPixel->setValue( mSettings->pixel );
 
88
    ui.spinBoxDistance->setValue( mSettings->distance );
 
89
    ui.spinBoxFontSize->setValue( mSettings->fontSize );
 
90
    ui.spinBoxMinValue->setValue( mSettings->minimumValue );
 
91
    ui.spinBoxMaxValue->setValue( mSettings->maximumValue );
 
92
    ui.checkBoxLabels->setChecked( mSettings->labels );
 
93
    ui.checkBoxBottomBar->setChecked( mSettings->bottomBar );
 
94
    ui.checkBoxVLines->setChecked( mSettings->verticalLines );
 
95
    ui.checkBoxHLines->setChecked( mSettings->horizontalLines );
 
96
    ui.checkBoxIncoming->setChecked( mSettings->showIncoming );
 
97
    ui.checkBoxOutgoing->setChecked( mSettings->showOutgoing );
 
98
    ui.checkBoxAutoDetection->setChecked( mSettings->automaticDetection );
 
99
    ui.checkBoxVLinesScroll->setChecked( mSettings->verticalLinesScroll );
 
100
    ui.kColorButtonVLines->setColor( mSettings->colorVLines );
 
101
    ui.kColorButtonHLines->setColor( mSettings->colorHLines );
 
102
    ui.kColorButtonIncoming->setColor( mSettings->colorIncoming );
 
103
    ui.kColorButtonOutgoing->setColor( mSettings->colorOutgoing );
 
104
    ui.kColorButtonBackground->setColor( mSettings->colorBackground );
 
105
    ui.spinBoxOpacity->setValue( mSettings->opacity );
 
106
}
 
107
 
 
108
void PlotterConfigDialog::save()
 
109
{
 
110
    mSettings->pixel = ui.spinBoxPixel->value();
 
111
    mSettings->distance = ui.spinBoxDistance->value();
 
112
    mSettings->fontSize = ui.spinBoxFontSize->value();
 
113
    mSettings->minimumValue = ui.spinBoxMinValue->value();
 
114
    mSettings->maximumValue = ui.spinBoxMaxValue->value();
 
115
    mSettings->labels = ui.checkBoxLabels->isChecked();
 
116
    mSettings->bottomBar = ui.checkBoxBottomBar->isChecked();
 
117
    mSettings->verticalLines = ui.checkBoxVLines->isChecked();
 
118
    mSettings->horizontalLines = ui.checkBoxHLines->isChecked();
 
119
    mSettings->showIncoming = ui.checkBoxIncoming->isChecked();
 
120
    mSettings->showOutgoing = ui.checkBoxOutgoing->isChecked();
 
121
    mSettings->automaticDetection = ui.checkBoxAutoDetection->isChecked();
 
122
    mSettings->verticalLinesScroll = ui.checkBoxVLinesScroll->isChecked();
 
123
    mSettings->colorVLines = ui.kColorButtonVLines->color();
 
124
    mSettings->colorHLines = ui.kColorButtonHLines->color();
 
125
    mSettings->colorIncoming = ui.kColorButtonIncoming->color();
 
126
    mSettings->colorOutgoing = ui.kColorButtonOutgoing->color();
 
127
    mSettings->colorBackground = ui.kColorButtonBackground->color();
 
128
    mSettings->opacity = ui.spinBoxOpacity->value();
 
129
    emit saved();
 
130
}
 
131
 
 
132
void PlotterConfigDialog::defaults()
 
133
{
 
134
    enableButtonApply( true );
 
135
    PlotterSettings s;
 
136
    // Default plotter settings
 
137
    ui.spinBoxPixel->setValue( s.pixel );
 
138
    ui.spinBoxDistance->setValue( s.distance );
 
139
    ui.spinBoxFontSize->setValue( s.fontSize );
 
140
    ui.spinBoxMinValue->setValue( s.minimumValue );
 
141
    ui.spinBoxMaxValue->setValue( s.maximumValue );
 
142
    ui.checkBoxLabels->setChecked( s.labels );
 
143
    ui.checkBoxBottomBar->setChecked( s.bottomBar );
 
144
    ui.checkBoxVLines->setChecked( s.verticalLines );
 
145
    ui.checkBoxHLines->setChecked( s.horizontalLines );
 
146
    ui.checkBoxIncoming->setChecked( s.showIncoming );
 
147
    ui.checkBoxOutgoing->setChecked( s.showOutgoing );
 
148
    ui.checkBoxAutoDetection->setChecked( s.automaticDetection );
 
149
    ui.checkBoxVLinesScroll->setChecked( s.verticalLinesScroll );
 
150
    ui.kColorButtonVLines->setColor( s.colorVLines );
 
151
    ui.kColorButtonHLines->setColor( s.colorHLines );
 
152
    ui.kColorButtonIncoming->setColor( s.colorIncoming );
 
153
    ui.kColorButtonOutgoing->setColor( s.colorOutgoing );
 
154
    ui.kColorButtonBackground->setColor( s.colorBackground );
 
155
    ui.spinBoxOpacity->setValue( s.opacity );
 
156
}
 
157
 
 
158
void PlotterConfigDialog::changed()
 
159
{
 
160
    enableButtonApply( true );
 
161
}
 
162
 
 
163
#include "plotterconfigdialog.moc"
 
164