18
18
#include " Inspector.h"
19
19
#include < QSettings>
20
20
21
+ #define INSPECTOR_GEOM " inspector/geometry"
22
+
21
23
/*
22
24
A dialog for getting/setting general info about a Make Controller
23
25
*/
24
- Inspector::Inspector (MainWindow *mainWindow) : QDialog( 0 )
26
+ Inspector::Inspector (MainWindow *mainWindow) : QDialog(0 )
25
27
{
26
28
this ->mainWindow = mainWindow;
27
29
setupUi (this );
@@ -42,10 +44,7 @@ Inspector::Inspector(MainWindow *mainWindow) : QDialog( 0 )
42
44
connect (dhcpBox, SIGNAL (clicked (bool )), this , SLOT (onAnyValueEdited ()));
43
45
44
46
QSettings settings;
45
- QPoint inspectorPos = settings.value (" inspector_pos" ).toPoint ();
46
- if (!inspectorPos.isNull ())
47
- move (inspectorPos);
48
-
47
+ restoreGeometry (settings.value (INSPECTOR_GEOM).toByteArray ());
49
48
resize (gridLayout->sizeHint ());
50
49
}
51
50
@@ -56,6 +55,13 @@ void Inspector::loadAndShow( )
56
55
show ();
57
56
}
58
57
58
+ void Inspector::closeEvent (QCloseEvent *e)
59
+ {
60
+ QSettings settings;
61
+ settings.setValue (INSPECTOR_GEOM, saveGeometry ());
62
+ e->accept ();
63
+ }
64
+
59
65
/*
60
66
Populate the line edits with the board's info.
61
67
This should only be called when there's new info for the board,
@@ -82,16 +88,16 @@ void Inspector::setData(Board* board)
82
88
*/
83
89
void Inspector::clear ( )
84
90
{
85
- nameEdit->setText ( " " );
86
- serialEdit->setText ( " " );
87
- versionEdit->setText ( " " );
88
- freememEdit->setText ( " " );
89
- ipEdit->setText ( " " );
90
- netmaskEdit->setText ( " " );
91
- gatewayEdit->setText ( " " );
92
- listenPortEdit->setText ( " " );
93
- sendPortEdit->setText ( " " );
94
- dhcpBox->setCheckState ( Qt::Unchecked );
91
+ nameEdit->text (). clear ( );
92
+ serialEdit->text (). clear ( );
93
+ versionEdit->text (). clear ( );
94
+ freememEdit->text (). clear ( );
95
+ ipEdit->text (). clear ( );
96
+ netmaskEdit->text (). clear ( );
97
+ gatewayEdit->text (). clear ( );
98
+ listenPortEdit->text (). clear ( );
99
+ sendPortEdit->text (). clear ( );
100
+ dhcpBox->setChecked ( false );
95
101
}
96
102
97
103
/*
@@ -110,7 +116,7 @@ void Inspector::onFinished()
110
116
void Inspector::getBoardInfo ()
111
117
{
112
118
Board *board = mainWindow->getCurrentBoard ();
113
- if (board)
119
+ if (board)
114
120
board->sendMessage (" /system/info-internal" );
115
121
}
116
122
@@ -121,15 +127,14 @@ void Inspector::getBoardInfo()
121
127
*/
122
128
void Inspector::onApply ()
123
129
{
124
- Board* board = mainWindow->getCurrentBoard ( );
125
- if ( board == NULL )
130
+ Board* board = mainWindow->getCurrentBoard ();
131
+ if ( board == NULL )
126
132
return ;
127
133
128
134
QStringList msgs;
129
135
130
136
QString newName = nameEdit->text ();
131
- if ( !newName.isEmpty () && board->name != newName )
132
- {
137
+ if (!newName.isEmpty () && board->name != newName) {
133
138
msgs << QString ( " /system/name %1" ).arg ( QString ( " \" %1\" " ).arg ( newName ) );
134
139
mainWindow->setBoardName ( board->key (), QString ( " %1 : %2" ).arg (newName).arg (board->key ()) );
135
140
}
@@ -161,10 +166,9 @@ void Inspector::onApply()
161
166
if ( !newPort.isEmpty () && board->udp_send_port != newPort )
162
167
msgs << QString ( " /network/osc_udp_send_port %1" ).arg ( newPort );
163
168
164
- setLabelsRole ( QPalette::WindowText );
165
- if ( msgs.size ( ) > 0 )
166
- {
167
- board->sendMessage ( msgs );
169
+ setLabelsRole (QPalette::WindowText);
170
+ if (!msgs.isEmpty ()) {
171
+ board->sendMessage (msgs);
168
172
mainWindow->updateBoardInfo (board);
169
173
mainWindow->message (msgs, MsgType::Command, board->location ());
170
174
}
@@ -178,7 +182,7 @@ void Inspector::onRevert()
178
182
{
179
183
setLabelsRole (QPalette::WindowText);
180
184
Board *brd = mainWindow->getCurrentBoard ();
181
- if (brd)
185
+ if (brd)
182
186
setData (brd);
183
187
}
184
188
@@ -189,16 +193,16 @@ void Inspector::onAnyValueEdited()
189
193
190
194
void Inspector::setLabelsRole (QPalette::ColorRole role)
191
195
{
192
- nameLabel->setForegroundRole ( role );
193
- sernumLabel->setForegroundRole ( role );
194
- versionLabel->setForegroundRole ( role );
195
- freememLabel->setForegroundRole ( role );
196
- ipLabel->setForegroundRole ( role );
197
- netmaskLabel->setForegroundRole ( role );
198
- gatewayLabel->setForegroundRole ( role );
199
- listenPortLabel->setForegroundRole ( role );
200
- sendPortLabel->setForegroundRole ( role );
201
- dhcpBox->setForegroundRole ( role ); // how to actually get at the text?
196
+ nameLabel->setForegroundRole (role);
197
+ sernumLabel->setForegroundRole (role);
198
+ versionLabel->setForegroundRole (role);
199
+ freememLabel->setForegroundRole (role);
200
+ ipLabel->setForegroundRole (role);
201
+ netmaskLabel->setForegroundRole (role);
202
+ gatewayLabel->setForegroundRole (role);
203
+ listenPortLabel->setForegroundRole (role);
204
+ sendPortLabel->setForegroundRole (role);
205
+ dhcpBox->setForegroundRole (role); // how to actually get at the text?
202
206
}
203
207
204
208
0 commit comments