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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
|
/***************************************************************************
* Copyright (C) 2005 by Danny Kukawka *
* <dkukawka@suse.de>, <danny.kukawka@web.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of version 2 of the GNU General Public License *
* as published by the Free Software Foundation. *
* *
* This program 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 General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
/*! \file configuredialog.cpp
* All here displayed file members of configureDialog.cpp are related to operations with the
* configure dialog for tdepowersave
* \brief In this file can be found all configure dialog related code.
* \author Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
* \date 2005
*/
// KDE - Headers
#include <kaudioplayer.h>
#include <tdeconfig.h>
#include <kiconloader.h>
#include <tdelocale.h>
#include <tdemessagebox.h>
#include <kinputdialog.h>
#include <tdeaccelmanager.h>
// QT - Headers
#include <tqcheckbox.h>
#include <tqcombobox.h>
#include <tqdialog.h>
#include <tqgroupbox.h>
#include <tqlabel.h>
#include <tqlineedit.h>
#include <tqlistbox.h>
#include <tqpushbutton.h>
#include <tqslider.h>
#include <tqspinbox.h>
#include <tqstringlist.h>
#include <tqtabwidget.h>
#include <tqtoolbox.h>
#include <tqtooltip.h>
#include <tqstring.h>
#include "configuredialog.h"
/*! This is the default constructor of the class ConfigureDialog. */
ConfigureDialog::ConfigureDialog( TDEConfig *_config, HardwareInfo *_hwinfo, Settings *_settings,
TQWidget *parent, const char *name)
:configure_Dialog(parent, name, false, WDestructiveClose )
{
kdDebugFuncIn(trace);
tdeconfig = _config;
settings = _settings;
hwinfo = _hwinfo;
suspend = hwinfo->getSuspendSupport();
TQString session = getenv("DESKTOP_SESSION");
if(session.startsWith("gnome")) gnome_session = true;
else gnome_session = false;
initalised = false;
general_changed = false;
scheme_changed = false;
displayed_WARN_autosuspend = false;
// check if brightness is supporte
if(hwinfo->supportBrightness()) {
brightnessLevels = hwinfo->getMaxBrightnessLevel() -1;
brightness_last = hwinfo->getCurrentBrightnessLevel();
} else {
brightnessLevels = -1;
brightness_last = -1;
}
brightness_changed = false;
currentScheme = -1;
// get the correct available suspend types
SuspendStates suspend = hwinfo->getSuspendSupport();
if( suspend.suspend2ram && (suspend.suspend2ram_allowed || suspend.suspend2ram_allowed == -1))
actions.append("Suspend to RAM");
if ( suspend.suspend2disk && (suspend.suspend2disk_allowed || suspend.suspend2disk_allowed == -1))
actions.append("Suspend to Disk");
if ( suspend.standby && (suspend.standby_allowed || suspend.standby_allowed == -1))
actions.append("Standby");
setIcons();
setTooltips();
getSchemeList();
setSchemeList();
setGeneralSettings();
setInactivityBox();
selectScheme(settings->currentScheme);
tL_valueBrightness->setFrameStyle(TQFrame::Panel | TQFrame::Sunken);
tL_valueBrightness->setBackgroundMode(TQt::PaletteBase);
tL_valueBrightness->setAlignment(TQt::AlignCenter);
tL_valueBrightness->setFocusPolicy(TQ_NoFocus);
// hide Lid item if this is not a laptop
if (!hwinfo->isLaptop())
cB_lockLid->hide();
// hide CPU Freq page if not supported
if (!hwinfo->supportCPUFreq()) {
tB_scheme->setItemLabel( 4, tB_scheme->itemLabel(4) + i18n(" - not supported"));
tB_scheme->setItemEnabled( 4, false);
}
if (!hwinfo->supportBrightness()) {
tB_scheme->setItemLabel( 3, tB_scheme->itemLabel(3) + i18n(" - not supported"));
tB_scheme->setItemEnabled( 3, false);
}
initalised = true;
kdDebugFuncOut(trace);
}
/*! This is the default destructor of the class ConfigureDialog. */
ConfigureDialog::~ConfigureDialog(){
kdDebugFuncIn(trace);
// no need to delete child widgets, TQt does it all for us
}
/* ---- START General setup SECTION ---- */
/*!
* This used to fill the TQListBox listBox_schemes and the scheme related TQComboBoxes
* with the existing schemes.
*/
void ConfigureDialog::setSchemeList(){
kdDebugFuncIn(trace);
listBox_schemes->clear();
cB_acScheme->clear();
cB_batteryScheme->clear();
for ( TQStringList::Iterator it = schemes.begin(); it != schemes.end(); ++it ) {
const char *_tmp = (*it).ascii();
if(_tmp == "Performance" || _tmp == i18n("Performance")) {
listBox_schemes->insertItem(SmallIcon("scheme_power", TQIconSet::Automatic), i18n(_tmp));
cB_acScheme->insertItem(i18n(_tmp));
cB_batteryScheme->insertItem(i18n(_tmp));
} else if(_tmp == "Powersave" || _tmp == i18n("Powersave")) {
listBox_schemes->insertItem(SmallIcon("scheme_powersave", TQIconSet::Automatic),
i18n(_tmp));
cB_acScheme->insertItem(i18n(_tmp));
cB_batteryScheme->insertItem(i18n(_tmp));
} else if(_tmp == "Presentation" || _tmp == i18n("Presentation")){
listBox_schemes->insertItem(SmallIcon("scheme_presentation", TQIconSet::Automatic),
i18n(_tmp));
cB_acScheme->insertItem(i18n(_tmp));
cB_batteryScheme->insertItem(i18n(_tmp));
} else if(_tmp == "Acoustic" || _tmp == i18n("Acoustic")) {
listBox_schemes->insertItem(SmallIcon("scheme_acoustic", TQIconSet::Automatic),
i18n(_tmp));
cB_acScheme->insertItem(i18n(_tmp));
cB_batteryScheme->insertItem(i18n(_tmp));
} else if(_tmp == "AdvancedPowersave" || _tmp == i18n("Advanced Powersave")) {
listBox_schemes->insertItem(SmallIcon("scheme_advanced_powersave",
TQIconSet::Automatic), i18n("Advanced Powersave"));
cB_acScheme->insertItem(i18n("Advanced Powersave"));
cB_batteryScheme->insertItem(i18n("Advanced Powersave"));
} else {
listBox_schemes->insertItem(i18n(_tmp));
cB_acScheme->insertItem(i18n(_tmp));
cB_batteryScheme->insertItem(i18n(_tmp));
}
}
TDEAcceleratorManager::manage(pB_newScheme);
kdDebugFuncOut(trace);
}
/*!
* This used to get the list of schemes in from the config
*/
void ConfigureDialog::getSchemeList(){
kdDebugFuncIn(trace);
if (tdeconfig->hasGroup("General")) {
tdeconfig->setGroup("General");
schemes = tdeconfig->readListEntry("schemes", ',');
}
kdDebugFuncOut(trace);
}
/*!
* This used to set the current scheme based on the name of the scheme
* \param _scheme TQString with the name of the scheme
*/
void ConfigureDialog::selectScheme (TQString _scheme){
kdDebugFuncIn(trace);
// select the current scheme in the listbox
if(!_scheme.isEmpty()) {
int pos = schemes.findIndex(_scheme);
if(pos > -1) {
listBox_schemes->setCurrentItem(pos);
currentScheme = pos;
} else {
listBox_schemes->setCurrentItem(0);
}
} else {
listBox_schemes->setCurrentItem(0);
}
kdDebugFuncOut(trace);
}
/*!
* This used to set all needed Icons for the dialog.
*/
void ConfigureDialog::setIcons(){
kdDebugFuncIn(trace);
/* set all Icons */
this->setIcon(SmallIcon("tdepowersave", TQIconSet::Automatic));
buttonApply->setIconSet(SmallIconSet("apply", TQIconSet::Automatic));
buttonCancel->setIconSet(SmallIconSet("cancel", TQIconSet::Automatic));
buttonOk->setIconSet(SmallIconSet("ok", TQIconSet::Automatic));
buttonHelp->setIconSet(SmallIconSet("help", TQIconSet::Automatic));
pB_editBlacklist->setIconSet(SmallIconSet("configure", TQIconSet::Automatic));
pB_editBlacklistDimm->setIconSet(SmallIconSet("configure", TQIconSet::Automatic));
pB_editAutosuspendGBlacklist->setIconSet(SmallIconSet("configure", TQIconSet::Automatic));
pB_editAutodimmGBlacklist->setIconSet(SmallIconSet("configure", TQIconSet::Automatic));
tB_scheme->setItemIconSet( 0 ,SmallIcon("tdescreensaver", TQIconSet::Automatic));
tB_scheme->setItemIconSet( 1 ,SmallIcon("display", TQIconSet::Automatic));
if(actions[0] == "Suspend to Disk")
tB_scheme->setItemIconSet( 2 ,SmallIcon("suspend_to_disk", TQIconSet::Automatic));
else if(actions[0] == "Suspend to RAM")
tB_scheme->setItemIconSet( 2 ,SmallIcon("suspend_to_ram", TQIconSet::Automatic));
else if(actions[0] == "Standby")
tB_scheme->setItemIconSet( 2 ,SmallIcon("stand_by", TQIconSet::Automatic));
tB_scheme->setItemIconSet( 3 ,SmallIcon("autodimm", TQIconSet::Automatic));
tB_scheme->setItemIconSet( 4 ,SmallIcon("processor", TQIconSet::Automatic));
tB_scheme->setItemIconSet( 5 ,SmallIcon("misc", TQIconSet::Automatic));
tB_general->setItemIconSet( 0, SmallIcon( "scheme_powersave", TQIconSet::Automatic));
tB_general->setItemIconSet( 1, SmallIcon( "button", TQIconSet::Automatic));
tB_general->setItemIconSet( 2, SmallIcon( "scheme_power", TQIconSet::Automatic));
tB_general->setItemIconSet( 3, SmallIcon( "lock", TQIconSet::Automatic));
tB_general->setItemIconSet( 4, SmallIcon( "misc", TQIconSet::Automatic));
pB_configNotify->setIconSet(SmallIconSet("knotify", TQIconSet::Automatic));
kdDebugFuncOut(trace);
}
/*!
* This used to set all needed Tooltips for the dialog.
*/
void ConfigureDialog::setTooltips(){
kdDebugFuncIn(trace);
// TQToolTip::setWakeUpDelay ( 1000 );
TQToolTip::add(cB_specificSettings, i18n("This enables specific screen saver settings. \n"
"Note: If selected, the global screen saver settings are \n"
"overwritten while tdepowersave runs."));
TQToolTip::add(cB_disable_Ss, i18n("This disables the screen saver. \n"
"Note: If selected, the global screen saver settings are \n"
"overwritten while tdepowersave runs."));
TQToolTip::add(cB_blankScreen, i18n("This blanks the screen instead of using a specific screen saver. \n"
"Note: This may work only with TDEScreensaver."));
TQToolTip::add(cB_SpecificPM, i18n("This enables specific DPMS settings. \n"
"Note: If selected, the global DPMS settings are \n"
"overwritten while tdepowersave runs."));
TQToolTip::add(cB_disablePM, i18n("This disables DPMS support."));
TQToolTip::add(cB_lockSuspend, i18n("If selected, the screen is locked on suspend or standby."));
TQToolTip::add(cB_lockLid, i18n("If selected, the screen is locked if the lid close event is triggered."));
TQToolTip::add(cB_autoSuspend, i18n("Check this box to enable or disable automatic suspension of "
"the computer."));
TQToolTip::add(cB_autoInactivity, i18n("Activate this action if the user was inactive for the defined "
"time \n(greater than 0 minutes). If empty, nothing happens."));
tB_scheme->setItemToolTip ( 0, i18n("All scheme-related screen saver and DPMS settings."));
tB_scheme->setItemToolTip ( 1, i18n("All scheme-related display brightness settings."));
tB_scheme->setItemToolTip ( 2, i18n("All scheme-related automatic suspend settings."));
TQToolTip::add(brightnessSlider, i18n("Here you can change the brightness of your display. \n"
"Use the slider to change the brightness directly for \n"
"testing. To reset back to previous level, please press \n"
"the 'Reset' button. "));
TQToolTip::add(pB_resetBrightness, i18n("Use this button to set back the slider and the "
"display brightness."));
kdDebugFuncOut(trace);
}
/*!
* This function is used to get the real name of the predefined schemes.
* This is a workaround for the case if Yast translated the name of the
* scheme In this case is a new config section created and the old settings
* would be lost.
* \param s_scheme TQString with the 'current' name of the scheme
* \return TQString with the english name of the scheme
*/
TQString ConfigureDialog::getSchemeRealName(TQString s_scheme) {
kdDebugFuncIn(trace);
TQString ret = s_scheme;
if( s_scheme == "Performance" || s_scheme == i18n("Performance"))
ret = "Performance";
else if( s_scheme == "Powersave" || s_scheme == i18n("Powersave"))
ret = "Powersave";
else if( s_scheme == "Presentation" || s_scheme == i18n("Presentation"))
ret = "Presentation";
else if( s_scheme == "Acoustic" || s_scheme == i18n("Acoustic"))
ret = "Acoustic";
kdDebugFuncOut(trace);
return ret;
}
/*!
* This function is used to read the settings from configfile and
* set the values to the related dialog elements.
* \param schemeID Integer value, represent the position of the
* scheme in the TQListBox and within the pdaemon-list.
*/
void ConfigureDialog::setConfigToDialog( int schemeID ){
if (trace) kdDebug() << funcinfo << "IN , scheme: " << schemeID << endl;
initalised = false;
TQString s_scheme = getSchemeRealName(schemes[schemeID]);
if (tdeconfig->hasGroup(s_scheme)){
settings->load_general_settings();
// set the delete scheme button enabled if needed
if (!s_scheme.startsWith("Performance") && !s_scheme.startsWith("Powersave") &&
!s_scheme.startsWith("Presentation") && !s_scheme.startsWith("Acoustic")) {
if (!s_scheme.startsWith(settings->ac_scheme) ||
!s_scheme.startsWith(settings->battery_scheme)) {
// enable delete button
pB_deleteScheme->setEnabled( true );
TQToolTip::add(pB_deleteScheme, i18n("Press this button to delete the "
"selected scheme."));
} else {
// disable button
pB_deleteScheme->setEnabled( false );
TQToolTip::add(pB_deleteScheme, i18n("You can't delete the current AC "
"or battery scheme."));
}
} else {
// disable button, can't delete these scheme, they are default
pB_deleteScheme->setEnabled( false );
TQToolTip::add(pB_deleteScheme, i18n("You can't delete this default scheme."));
}
tdeconfig->setGroup(s_scheme);
}
// no configuration found, set to default values ?!
else {
if(tdeconfig->hasGroup("default-scheme"))
tdeconfig->setGroup("default-scheme");
else {
kdDebugFuncOut(trace);
return;
}
}
cB_disable_Ss_toggled(tdeconfig->readBoolEntry("disableSs",false));
cB_blankScreen->setChecked(tdeconfig->readBoolEntry("blankSs",false));
cB_specificSettings_toggled(tdeconfig->readBoolEntry("specSsSettings",false));
int i_standby = tdeconfig->readNumEntry("standbyAfter", -1);
if(i_standby >= 0) {
sB_standby->setValue(i_standby);
}
else {
// load value from default-scheme
if(tdeconfig->hasGroup("default-scheme")){
tdeconfig->setGroup("default-scheme");
i_standby = tdeconfig->readNumEntry("standbyAfter", -1);
if(i_standby >= 0) {
sB_standby->setValue(i_standby);
}
else sB_standby->setValue(0);
}
else{
sB_standby->setValue(0);
}
// reset group to selected scheme
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme");
}
int i_suspend = tdeconfig->readNumEntry("suspendAfter", -1);
if(i_suspend >= 0) {
sB_suspend->setValue(i_suspend);
}
else {
// load value from default-scheme
if(tdeconfig->hasGroup("default-scheme")){
tdeconfig->setGroup("default-scheme");
i_standby = tdeconfig->readNumEntry("suspendAfter", -1);
if(i_standby >= 0) {
sB_standby->setValue(i_standby);
}
else sB_standby->setValue(0);
}
else{
sB_standby->setValue(0);
}
// reset group to selected scheme
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme");
}
int i_poweroff = tdeconfig->readNumEntry("powerOffAfter", -1);
if(i_poweroff >= 0) {
sB_powerOff->setValue(i_poweroff);
}
else {
// load value from default-scheme
if(tdeconfig->hasGroup("default-scheme")){
tdeconfig->setGroup("default-scheme");
i_standby = tdeconfig->readNumEntry("powerOffAfter", -1);
if(i_poweroff >= 0) {
sB_powerOff->setValue(i_poweroff);
}
else sB_powerOff->setValue(0);
}
else{
sB_powerOff->setValue(0);
}
// reset group to selected scheme
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme");
}
cB_SpecificPM_toggled(tdeconfig->readBoolEntry("specPMSettings",false));
cB_disablePM_toggled(tdeconfig->readBoolEntry("disableDPMS",false));
// set autosuspend related settings
TQString _action = tdeconfig->readEntry("autoInactiveAction", "NULL");
if( _action != "NULL") {
int _index = actions.findIndex(_action);
if( _index != -1) {
cB_autoInactivity->setCurrentItem( _index );
cB_autoInactivity_activated( _index );
cB_Blacklist->setEnabled(true);
}
else {
// set to empty element if not supported by current machine or
// if the value is "_NONE_"
cB_autoInactivity->setCurrentItem( 0 );
cB_autoInactivity_activated( 0 );
cB_Blacklist->setEnabled(false);
}
}
else {
// set to disabled (to reduce code), if a entry found set to enabled !
cB_Blacklist->setEnabled(false);
if(tdeconfig->hasGroup("default-scheme")){
tdeconfig->setGroup("default-scheme");
_action = tdeconfig->readEntry("autoInactiveAction", "NULL");
if(_action != "NULL") {
int _index = actions.findIndex(_action);
if( _index != -1) {
cB_autoInactivity->setCurrentItem( _index );
tL_autoInactivity_After->setEnabled(true);
cB_Blacklist->setEnabled(true);
}
else {
cB_autoInactivity->setCurrentItem( 0 );
}
}
else {
cB_autoInactivity->setCurrentItem( 0 );
}
// reset group to selected scheme
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme");
}
else{
cB_autoInactivity->setCurrentItem( 0 );
}
}
if( cB_autoInactivity->currentItem() == 0 ) {
sB_autoInactivity->setEnabled(false);
tL_autoInactivity_After->setEnabled(false);
}
int i_autoInactivityAfter = tdeconfig->readNumEntry("autoInactiveActionAfter", -1);
if(i_autoInactivityAfter >= 0) {
sB_autoInactivity->setValue(i_autoInactivityAfter);
}
else {
// load value from default-scheme
if(tdeconfig->hasGroup("default-scheme")){
tdeconfig->setGroup("default-scheme");
i_autoInactivityAfter = tdeconfig->readNumEntry("autoInactiveActionAfter", -1);
if(i_autoInactivityAfter >= 0) {
sB_autoInactivity->setValue(i_autoInactivityAfter);
}
else sB_autoInactivity->setValue(0);
}
else{
sB_autoInactivity->setValue(0);
}
// reset group to selected scheme
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme");
}
if (hwinfo->supportBrightness()) {
// enable the widgets
cB_Brightness->setEnabled(true);
cB_Brightness_toggled(tdeconfig->readBoolEntry("enableBrightness",false));
if (brightnessLevels > 33)
brightnessSlider->setLineStep(3);
else
brightnessSlider->setLineStep(100/brightnessLevels);
brightnessSlider->setPageStep(10);
int i_brightnessPercent = tdeconfig->readNumEntry("brightnessPercent", -1);
if(i_brightnessPercent >= 0) {
brightnessSlider->setValue(i_brightnessPercent);
tL_valueBrightness->setText(TQString::number(i_brightnessPercent) + " %");
}
else {
brightnessSlider->setValue(100);
tL_valueBrightness->setText(TQString::number(100)+ " %");
}
tL_brightness->setText(i18n("Your hardware supports to change the brightness. The "
"values of the slider are in percent and mapped "
"to the available brightness levels of your hardware."));
}
else {
cB_Brightness->setEnabled(false);
gB_Brightness->setEnabled(false);
tL_brightness->setText(i18n("Your Hardware currently not support changing the brightness "
"of your display."));
}
// no need to enable autodimm if not support change brightness
if (hwinfo->supportBrightness()) {
int i_autoDimmAfter = tdeconfig->readNumEntry("autoDimmAfter", -1);
if(i_autoDimmAfter >= 0) {
sB_autoDimmTime->setValue(i_autoDimmAfter);
}
else {
// load value from default-scheme
if(tdeconfig->hasGroup("default-scheme")){
tdeconfig->setGroup("default-scheme");
i_autoDimmAfter = tdeconfig->readNumEntry("autoDimmAfter", -1);
if(i_autoDimmAfter >= 0) {
sB_autoDimmTime->setValue(i_autoDimmAfter);
}
else sB_autoDimmTime->setValue(0);
}
else{
sB_autoDimmTime->setValue(0);
}
// reset group to selected scheme
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme");
}
int i_autoDimmTo = tdeconfig->readNumEntry("autoDimmTo", -1);
if(i_autoDimmTo >= 0) {
sB_autoDimmTo->setValue(i_autoDimmTo);
}
else {
// load value from default-scheme
if(tdeconfig->hasGroup("default-scheme")){
tdeconfig->setGroup("default-scheme");
i_autoDimmTo = tdeconfig->readNumEntry("autoDimmTo", -1);
if(i_autoDimmAfter >= 0) {
sB_autoDimmTo->setValue(i_autoDimmTo);
}
else sB_autoDimmTo->setValue(0);
}
else{
sB_autoDimmTo->setValue(0);
}
// reset group to selected scheme
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme");
}
}
if (hwinfo->supportCPUFreq()) {
TQString cpuFreqPolicy = tdeconfig->readEntry("cpuFreqPolicy");
if (cpuFreqPolicy.isEmpty()) {
// load value from default-scheme
if(tdeconfig->hasGroup("default-scheme")){
tdeconfig->setGroup("default-scheme");
cpuFreqPolicy = tdeconfig->readEntry("cpuFreqPolicy");
}
if (cpuFreqPolicy.isEmpty()) {
cpuFreqPolicy = "DYNAMIC";
}
// reset group to selected scheme
if (tdeconfig->hasGroup(s_scheme)) tdeconfig->setGroup(s_scheme);
else tdeconfig->setGroup("default-scheme");
}
if (cpuFreqPolicy.startsWith("PERFORMANCE")) {
comboB_cpuFreq->setCurrentItem(0);
} else if (cpuFreqPolicy.startsWith("DYNAMIC")) {
comboB_cpuFreq->setCurrentItem(1);
} else if (cpuFreqPolicy.startsWith("POWERSAVE")) {
comboB_cpuFreq->setCurrentItem(2);
} else {
kdWarning() << "Could not read/map CPU Freq Policy, set to dynamic" << endl;
comboB_cpuFreq->setCurrentItem(1);
}
}
cB_disableNotifications->setChecked(tdeconfig->readBoolEntry("disableNotifications",false));
cB_Blacklist_toggled(tdeconfig->readBoolEntry("autoInactiveSchemeBlacklistEnabled",false));
cB_autoSuspend_toggled(tdeconfig->readBoolEntry("autoSuspend",false));
cB_BlacklistDimm_toggled(tdeconfig->readBoolEntry("autoDimmSchemeBlacklistEnabled",false));
cB_autoDimm_toggled(tdeconfig->readBoolEntry("autoDimm",false));
initalised = true;
scheme_changed = false;
if(!general_changed) buttonApply->setEnabled(false);
currentScheme = schemeID;
kdDebugFuncOut(trace);
}
/*!
* This is used to set the values from the section general in configfile to the
* related items in the dialog.
*/
void ConfigureDialog::setGeneralSettings() {
kdDebugFuncIn(trace);
tdeconfig->setGroup("General");
cB_lockSuspend->setChecked(tdeconfig->readBoolEntry("lockOnSuspend",false));
cB_lockLid->setChecked(tdeconfig->readBoolEntry("lockOnLidClose",false));
cB_autostart->setChecked(tdeconfig->readBoolEntry("Autostart",false));
cB_autostart_neverAsk->setChecked(tdeconfig->readBoolEntry("AutostartNeverAsk",false));
TQString lockmethod = tdeconfig->readEntry("lockMethod", "NULL");
if(comboB_lock->count() == 0 ){
comboB_lock->insertItem(i18n("Select Automatically"),0);
comboB_lock->insertItem(i18n("TDEScreensaver"),1);
comboB_lock->insertItem(i18n("XScreensaver"),2);
comboB_lock->insertItem(i18n("xlock"),3);
if (gnome_session) comboB_lock->insertItem(i18n("GNOME Screensaver"),4);
}
if (lockmethod == "automatic") comboB_lock->setCurrentItem(0);
else if (lockmethod == "tdescreensaver") comboB_lock->setCurrentItem(1);
else if (lockmethod == "xscreensaver") comboB_lock->setCurrentItem(2);
else if (lockmethod == "xlock") comboB_lock->setCurrentItem(3);
else if (gnome_session && (lockmethod == "gnomescreensaver")) comboB_lock->setCurrentItem(4);
else comboB_lock->setCurrentItem(0);
if(cB_lockSuspend->isOn() || cB_lockLid->isOn() ) {
tL_lockWith->setEnabled(true);
comboB_lock->setEnabled(true);
}
else {
tL_lockWith->setEnabled(false);
comboB_lock->setEnabled(false);
}
// battery tab
BatteryCollection* _primBats = hwinfo->getPrimaryBatteries();
if (_primBats->getNumBatteries() > 0) {
// set widgets in the tab
sB_batWarning->setValue(tdeconfig->readNumEntry("batteryWarning",0));
sB_batLow->setValue(tdeconfig->readNumEntry("batteryLow",0));
sB_batCritical->setValue(tdeconfig->readNumEntry("batteryCritical",0));
// hide them and enable only if needed
sB_batWarnAction_value->hide();
sB_batLowAction_value->hide();
sB_batCritAction_value->hide();
TQString _select;
TQStringList _actions = tdeconfig->readListEntry("batteryAllowedActions", TQString());
_select = tdeconfig->readEntry("batteryWarningAction", TQString());
fillActionComboBox(cB_batWarning, _actions, _select);
if (_select == "BRIGHTNESS" && hwinfo->supportBrightness()) {
sB_batWarnAction_value->show();
sB_batWarnAction_value->setValue(tdeconfig->readNumEntry( "batteryWarningActionValue",0));
}
_select = tdeconfig->readEntry("batteryLowAction", TQString());
fillActionComboBox(cB_batLow, _actions, _select);
if (_select == "BRIGHTNESS" && hwinfo->supportBrightness()) {
sB_batLowAction_value->show();
sB_batLowAction_value->setValue( tdeconfig->readNumEntry( "batteryLowActionValue",0));
}
_select = tdeconfig->readEntry("batteryCriticalAction", TQString());
fillActionComboBox(cB_batCritical, _actions, _select);
if (_select == "BRIGHTNESS" && hwinfo->supportBrightness()) {
sB_batCritAction_value->show();
sB_batCritAction_value->setValue(tdeconfig->readNumEntry("batteryCriticalActionValue",0));
}
} else {
// disable tab
tB_general->setItemLabel( 0, tB_scheme->itemLabel(0) + i18n(" - not supported"));
tB_general->setItemEnabled( 0, false);
}
// buttons tab:
TQStringList _actions = tdeconfig->readListEntry("buttonsAllowedActions", TQString());
fillActionComboBox(cB_PowerButton, _actions, tdeconfig->readEntry("ActionOnPowerButton", TQString()));
fillActionComboBox(cB_SleepButton, _actions, tdeconfig->readEntry("ActionOnSleepButton", TQString()));
fillActionComboBox(cB_S2DiskButton, _actions, tdeconfig->readEntry("ActionOnS2DiskButton", TQString()));
// avoid logout dialog for lidclose - this make no sense
_actions.remove("LOGOUT_DIALOG");
fillActionComboBox(cB_LidcloseButton, _actions, tdeconfig->readEntry("ActionOnLidClose", TQString()));
// default scheme tab:
TQString _ac_scheme = tdeconfig->readEntry( "ac_scheme", "Performance");
TQString _bat_scheme = tdeconfig->readEntry( "battery_scheme", "Powersave");
cB_acScheme->setCurrentItem(schemes.findIndex(_ac_scheme));
cB_batteryScheme->setCurrentItem(schemes.findIndex(_bat_scheme));
kdDebugFuncOut(trace);
}
/* ---- END General setup SECTION ---- */
/* ---- START store settings SECTION ---- */
/*!
* This used to save changes in settings of the current scheme.
*/
void ConfigureDialog::saveSchemeSettings() {
kdDebugFuncIn(trace);
TQString s_scheme = getSchemeRealName(schemes[currentScheme]);
tdeconfig->setGroup(s_scheme);
tdeconfig->writeEntry("specSsSettings",cB_specificSettings->isOn());
tdeconfig->writeEntry("disableSs",cB_disable_Ss->isOn());
tdeconfig->writeEntry("blankSs",cB_blankScreen->isOn());
tdeconfig->writeEntry("specPMSettings",cB_SpecificPM->isOn());
tdeconfig->writeEntry("disableDPMS",cB_disablePM->isOn());
tdeconfig->writeEntry("standbyAfter",sB_standby->value());
tdeconfig->writeEntry("suspendAfter",sB_suspend->value());
tdeconfig->writeEntry("powerOffAfter",sB_powerOff->value());
tdeconfig->writeEntry("disableNotifications",cB_disableNotifications->isOn());
if(cB_autoInactivity->currentText() == " "){
tdeconfig->writeEntry("autoInactiveAction", "_NONE_");
}
else{
int _index = cB_autoInactivity->currentItem();
if(_index > 0) {
/*if(_index == (cB_autoInactivity->count()-1)) {
tdeconfig->writeEntry("autoInactiveAction","shutdown");
}
else {
tdeconfig->writeEntry("autoInactiveAction",actions[(_index)]);
}*/
tdeconfig->writeEntry("autoInactiveAction",actions[(_index)]);
}
tdeconfig->writeEntry("autoInactiveActionAfter",sB_autoInactivity->value());
}
tdeconfig->writeEntry("autoSuspend",cB_autoSuspend->isOn());
tdeconfig->writeEntry("autoInactiveSchemeBlacklistEnabled",cB_Blacklist->isOn());
tdeconfig->writeEntry("autoDimm",cB_autoDimm->isOn());
tdeconfig->writeEntry("autoDimmAfter", sB_autoDimmTime->value());
tdeconfig->writeEntry("autoDimmTo", sB_autoDimmTo->value());
tdeconfig->writeEntry("autoDimmSchemeBlacklistEnabled",cB_BlacklistDimm->isOn());
tdeconfig->writeEntry("enableBrightness",cB_Brightness->isOn());
if(brightness_changed)
tdeconfig->writeEntry("brightnessPercent",brightnessSlider->value());
if(hwinfo->supportCPUFreq()) {
switch( comboB_cpuFreq->currentItem()) {
case 0:
tdeconfig->writeEntry("cpuFreqPolicy", "PERFORMANCE");
break;
case 2:
tdeconfig->writeEntry("cpuFreqPolicy", "POWERSAVE");
break;
case 1:
default:
tdeconfig->writeEntry("cpuFreqPolicy", "DYNAMIC");
break;
}
}
tdeconfig->sync();
scheme_changed = false;
if(!general_changed) buttonApply->setEnabled(false);
kdDebugFuncOut(trace);
}
/*!
* This used to save changes in settings of the current scheme.
*/
void ConfigureDialog::saveGeneralSettings() {
kdDebugFuncIn(trace);
tdeconfig->setGroup("General");
tdeconfig->writeEntry("lockOnSuspend",cB_lockSuspend->isOn());
tdeconfig->writeEntry("lockOnLidClose",cB_lockLid->isOn());
tdeconfig->writeEntry("Autostart",cB_autostart->isOn());
tdeconfig->writeEntry("AutostartNeverAsk",cB_autostart_neverAsk->isOn());
TQString selected_method = "";
int _selected = comboB_lock->currentItem();
if(_selected == 0) selected_method = "automatic";
else if(_selected == 1) selected_method = "tdescreensaver";
else if(_selected == 2) selected_method = "xscreensaver";
else if(_selected == 3) selected_method = "xlock";
else if(gnome_session && (_selected == 4)) selected_method = "gnomescreensaver";
tdeconfig->writeEntry( "lockMethod", selected_method );
tdeconfig->writeEntry("batteryWarning", sB_batWarning->value());
tdeconfig->writeEntry("batteryLow", sB_batLow->value());
tdeconfig->writeEntry("batteryCritical", sB_batCritical->value());
// battery level tab
TQString _action = mapDescriptionToAction(cB_batWarning->currentText());
tdeconfig->writeEntry("batteryWarningAction", _action);
if (_action == "BRIGHTNESS") {
tdeconfig->writeEntry("batteryWarningActionValue", sB_batWarnAction_value->value());
}
_action = mapDescriptionToAction(cB_batLow->currentText());
tdeconfig->writeEntry("batteryLowAction", _action);
if (_action == "BRIGHTNESS") {
tdeconfig->writeEntry("batteryLowActionValue", sB_batLowAction_value->value());
}
_action = mapDescriptionToAction(cB_batCritical->currentText());
tdeconfig->writeEntry("batteryCriticalAction", _action);
if (_action == "BRIGHTNESS") {
tdeconfig->writeEntry("batteryCriticalActionValue", sB_batCritAction_value->value());
}
// button tab
tdeconfig->writeEntry("ActionOnPowerButton", mapDescriptionToAction(cB_PowerButton->currentText()));
tdeconfig->writeEntry("ActionOnLidClose", mapDescriptionToAction(cB_LidcloseButton->currentText()));
tdeconfig->writeEntry("ActionOnSleepButton", mapDescriptionToAction(cB_SleepButton->currentText()));
tdeconfig->writeEntry("ActionOnS2DiskButton", mapDescriptionToAction(cB_S2DiskButton->currentText()));
// schemes tab
tdeconfig->writeEntry("ac_scheme", getSchemeRealName(schemes[cB_acScheme->currentItem()]));
tdeconfig->writeEntry("battery_scheme", getSchemeRealName(schemes[cB_batteryScheme->currentItem()]));
tdeconfig->sync();
general_changed = false;
if(!scheme_changed) buttonApply->setEnabled(false);
kdDebugFuncOut(trace);
}
/* ---- END store settings SECTION ---- */
/* ---- START monitor changes SECTION ---- */
/*!
* SLOT: Called if a value within the Tab 'General Settings' is changed.
*/
void ConfigureDialog::general_valueChanged(){
kdDebugFuncIn(trace);
if(initalised) {
general_changed = true;
buttonApply->setEnabled(true);
// enable/disable the comboB_lock and tL_lockWith
if(cB_lockSuspend->isOn() || cB_lockLid->isOn() ) {
tL_lockWith->setEnabled(true);
comboB_lock->setEnabled(true);
}
else {
tL_lockWith->setEnabled(false);
comboB_lock->setEnabled(false);
}
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: Called if a value within the Tab 'Scheme Settings' is changed.
*/
void ConfigureDialog::scheme_valueChanged(){
kdDebugFuncIn(trace);
if(initalised) {
scheme_changed = true;
buttonApply->setEnabled(true);
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if the current scheme in the TQListBox listBox_schemes is
* changed/ a other scheme was selected.
*/
void ConfigureDialog::listBox_schemes_currentChanged(){
kdDebugFuncIn(trace);
// store current settings if something changed
if(initalised && scheme_changed ) {
int res = KMessageBox::warningYesNo(this,
i18n("There are unsaved changes in the active scheme.\n"
"Apply the changes before jumping to the next scheme "
"or discard the changes?"),
i18n("Unsaved Changes"), KStdGuiItem::apply(),
KStdGuiItem::discard());
if (res == KMessageBox::Yes) {
// Save changes
saveSchemeSettings();
}
if (res == KMessageBox::No) {
// discard changes and reset trigger
scheme_changed = false;
}
}
// set to new Item
setConfigToDialog(listBox_schemes->currentItem());
kdDebugFuncOut(trace);
}
/* ---- END monitor changes SECTION ---- */
/* ---- START BUTTON SECTION ---- */
/*!
* SLOT: called if the 'Apply' button is clicked.
*/
void ConfigureDialog::buttonApply_clicked(){
kdDebugFuncIn(trace);
if(initalised && scheme_changed ) {
saveSchemeSettings();
scheme_changed = false;
}
if(initalised && general_changed ) {
saveGeneralSettings();
general_changed = false;
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if the 'Chancel' button is clicked.
*/
void ConfigureDialog::buttonCancel_clicked(){
kdDebugFuncOut(trace);
if (scheme_changed || general_changed) {
int res = KMessageBox::warningYesNoCancel(this,
i18n("There are unsaved changes.\nApply the changes "
"before cancel or discard the changes?"),
i18n("Unsaved Changes"), KStdGuiItem::apply(),
KStdGuiItem::discard());
if (res == KMessageBox::Yes) {
buttonApply_clicked();
}
else if (res == KMessageBox::Cancel) return;
}
kdDebugFuncOut(trace);
close();
}
/*!
* SLOT: called if the 'OK' button is clicked.
*/
void ConfigureDialog::buttonOk_clicked(){
kdDebugFuncIn(trace);
buttonApply_clicked();
buttonApply->setEnabled(false);
kdDebugFuncOut(trace);
close();
}
/*!
* SLOT: called if the 'Help' button is clicked.
*/
void ConfigureDialog::buttonHelp_clicked(){
kdDebugFuncIn(trace);
emit openHelp();
kdDebugFuncOut(trace);
}
/* ---- END BUTTON SECTION ---- */
/* ---- START SCHEME ADD/DELETE SECTION ---- */
/*!
* SLOT: called if the 'New' scheme button is clicked.
*/
void ConfigureDialog::pB_newScheme_clicked(){
kdDebugFuncIn(trace);
bool _ok = false;
bool _end = false;
TQString _new;
TQString _text = i18n("Please insert a name for the new scheme:");
TQString _error;
getSchemeList();
while (!_end) {
_new = KInputDialog::getText( i18n("TDEPowersave Configuration"),
_error + _text, TQString(), &_ok, this);
if (!_ok ) {
_end = true;
} else {
_error = TQString();
if (!_new.isEmpty()) {
if ( schemes.contains(_new))
_error = i18n("Error: A scheme with this name already exist.\n");
else
_end = true;
}
}
}
if (!_new.isEmpty()) {
// write append new scheme to list
schemes.append(_new);
tdeconfig->setGroup("General");
tdeconfig->writeEntry("schemes", schemes, ",");
tdeconfig->sync();
// update GUI
setSchemeList();
selectScheme(_new);
saveSchemeSettings();
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if the 'Delete' scheme button is clicked.
*/
void ConfigureDialog::pB_deleteScheme_clicked(){
kdDebugFuncIn(trace);
if (pB_deleteScheme->isEnabled()) {
int answer = KMessageBox::questionYesNo( this, i18n("Do you really want to delete the "
"%1 scheme?").arg(schemes[currentScheme]),
i18n("Confirm delete scheme"),
i18n("Delete"), i18n("Cancel"));
if (answer == KMessageBox::Yes) {
// delete the scheme, we can be sure this is a userscheme
TQString _s_tmp = getSchemeRealName(schemes[currentScheme]);
if (tdeconfig->hasGroup(_s_tmp) && tdeconfig->deleteGroup(_s_tmp)) {
schemes.remove(_s_tmp);
tdeconfig->setGroup("General");
tdeconfig->writeEntry("schemes", schemes, ",");
tdeconfig->sync();
// update GUI
setSchemeList();
selectScheme(settings->currentScheme);
} else {
// could not delete the scheme ... error case
KMessageBox::queuedMessageBox(this, KMessageBox::Error,
i18n("Could not delete the selected scheme."));
}
}
}
kdDebugFuncOut(trace);
}
/* ---- END SCHEME ADD/DELETE SECTION ---- */
/* ---- START SCREENSAVER SECTION ---- */
/*!
* SLOT: called if TQCheckBox cB_specificSettings is toggled.
* \param state boolean, true if toggled on
* false if toggled off
*/
void ConfigureDialog::cB_specificSettings_toggled(bool state){
kdDebugFuncIn(trace);
if(!initalised) cB_specificSettings->setChecked(state);
/* set widgets visible/disabled */
if(state){
cB_disable_Ss->setEnabled(true);
if(cB_disable_Ss->isOn()){
cB_blankScreen->setEnabled(false);
}
else {
cB_blankScreen->setEnabled(true);
}
}
else {
cB_disable_Ss->setEnabled(false);
cB_blankScreen->setEnabled(false);
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if TQCheckBox cB_disable_Ss is toggled.
* \param state boolean, true if toggled on
* false if toggled off
*/
void ConfigureDialog::cB_disable_Ss_toggled(bool state){
kdDebugFuncIn(trace);
/* set widgets visible/disabled */
if(!initalised) cB_disable_Ss->setChecked(state);
cB_blankScreen->setEnabled(!state);
kdDebugFuncOut(trace);
}
/* ---- END SCREENSAVER SECTION ---- */
/* ---- START DPMS SECTION ---- */
/*!
* SLOT: called if TQCheckBox cB_SpecificPM is toggled.
* \param state boolean, true if toggled on
* false if toggled offtrue
*/
void ConfigureDialog::cB_SpecificPM_toggled(bool state){
kdDebugFuncIn(trace);
if(!initalised) cB_SpecificPM->setChecked(state);
/* set widgets visible/disabled */
cB_disablePM->setEnabled(state);
if(cB_disablePM->isOn()) {
state = false;
}
tL_standbyAfter->setEnabled(state);
sB_standby->setEnabled(state);
tL_suspendAfter->setEnabled(state);
sB_suspend->setEnabled(state);
tL_powerOffAfter->setEnabled(state);
sB_powerOff->setEnabled(state);
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if TQCheckBox cB_disablePM is toggled.
* \param state boolean, true if toggled on
* false if toggled off
*/
void ConfigureDialog::cB_disablePM_toggled(bool state){
kdDebugFuncIn(trace);
if(!initalised) cB_disablePM->setChecked(state);
/* set widgets visible/disabled */
tL_standbyAfter->setEnabled(!state);
sB_standby->setEnabled(!state);
tL_suspendAfter->setEnabled(!state);
sB_suspend->setEnabled(!state);
tL_powerOffAfter->setEnabled(!state);
sB_powerOff->setEnabled(!state);
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if the standby TQSpinBoxes for DPMS timout is changed.
*/
void ConfigureDialog::sB_standby_valueChanged() {
kdDebugFuncIn(trace);
if (initalised) {
if (sB_standby->value() == 0 )
return;
if ( sB_standby->value() > sB_suspend->value()) {
sB_suspend->setValue(sB_standby->value());
}
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if the suspend TQSpinBoxes for DPMS timout is changed.
*/
void ConfigureDialog::sB_suspend_valueChanged() {
kdDebugFuncIn(trace);
if (initalised) {
if (sB_suspend->value() == 0 )
return;
if ( sB_suspend->value() < sB_standby->value()) {
sB_standby->setValue(sB_suspend->value());
}
if ( sB_suspend->value() > sB_powerOff->value()) {
sB_powerOff->setValue(sB_suspend->value());
}
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if the powerOff TQSpinBoxes for DPMS timout is changed.
*/
void ConfigureDialog::sB_powerOff_valueChanged() {
kdDebugFuncIn(trace);
if (initalised) {
if (sB_powerOff->value() == 0 )
return;
if ( sB_powerOff->value() < sB_suspend->value()) {
sB_suspend->setValue(sB_powerOff->value());
}
}
kdDebugFuncOut(trace);
}
/* ---- END DPMS SECTION ---- */
/* ---- START Inactivity SECTION ---- */
/*!
* This used to set the inactivity related combobox cB_autoInactivity .
*/
void ConfigureDialog::setInactivityBox(){
kdDebugFuncIn(trace);
cB_autoInactivity->clear();
// add "nothing" at start of the list
actions.push_front(" ");
// add "Turn Off Computer" at end of the list
// TQString _to_i18n = i18n("Turn Off Computer");
// actions.append("Turn Off Computer");
for ( TQStringList::Iterator it = actions.begin(); it != actions.end(); ++it ) {
cB_autoInactivity->insertItem( i18n( (*it).ascii() ) );
}
kdDebugFuncOut(trace);
}
/*!
* This used to set the autosuspend related widgets.
*/
void ConfigureDialog::cB_autoSuspend_toggled( bool toggled ) {
kdDebugFuncIn(trace);
if(cB_autoSuspend->isOn() != toggled)
cB_autoSuspend->setChecked(toggled);
tL_autoInactivity_explain->setEnabled(toggled);
cB_autoInactivity->setEnabled(toggled);
if(cB_autoInactivity->currentItem() > 0) {
cB_autoInactivity->setEnabled(true);
tL_autoInactivity_After->setEnabled(true);
sB_autoInactivity->setEnabled(true);
cB_Blacklist->setEnabled(true);
cB_Blacklist_toggled(cB_Blacklist->isOn());
}
if(!toggled) {
cB_autoSuspend->setChecked(false);
tL_autoInactivity_After->setEnabled(false);
cB_autoInactivity->setEnabled(false);
sB_autoInactivity->setEnabled(false);
cB_Blacklist->setEnabled(false);
pB_editBlacklist->setEnabled(false);
}
scheme_changed = true;
buttonApply->setEnabled(true);
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if a new item in cB_autoInactivity is selected.
* \param selectedItem Integer, contains the ID of the new item in the
* comboBox.
*/
void ConfigureDialog::cB_autoInactivity_activated( int selectedItem ) {
kdDebugFuncIn(trace);
if( actions[selectedItem] != " " ) {
if(!displayed_WARN_autosuspend && initalised) {
TQString _msg = "<qt>" + i18n("<b>Note:</b> If you select this option, the computer "
"will suspend or standby if the current user is "
"inactive for the defined time even if somebody is "
"logged in remotely to the X server.<br><br> This "
"feature can also produce problems with some programs, "
"such as video players or cd burner. These programs can "
"be blacklisted by checking <b>Enable scheme-specific "
"blacklist</b> and click <b>Edit Blacklist...</b>. If "
"this does not help, report the problem or deactivate "
"autosuspend.<br><br> Really use this option?") +
"</qt>";
int tmp = KMessageBox::warningContinueCancel(this, _msg);
if (tmp == KMessageBox::Cancel) {
selectedItem = 0;
}
displayed_WARN_autosuspend = true;
}
sB_autoInactivity->setEnabled(true);
tL_autoInactivity_After->setEnabled(true);
cB_Blacklist->setEnabled(true);
if(cB_Blacklist->isChecked()) pB_editBlacklist->setEnabled(true);
}
else {
sB_autoInactivity->setEnabled(false);
tL_autoInactivity_After->setEnabled(false);
cB_Blacklist->setEnabled(false);
pB_editBlacklist->setEnabled(false);
}
cB_autoInactivity->setCurrentItem( selectedItem );
if(initalised) {
scheme_changed = true;
buttonApply->setEnabled(true);
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: Called if the 'Enable scheme specific blacklist' is toggled.
* \param toggled boolean, true if toggled on
* false if toggled off
*/
void ConfigureDialog::cB_Blacklist_toggled( bool toggled ){
kdDebugFuncIn(trace);
pB_editBlacklist->setEnabled(toggled);
if(initalised) {
buttonApply->setEnabled(true);
scheme_changed = true;
} else {
cB_Blacklist->setChecked(toggled);
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: Called if the 'edit blacklist' button is toggled.
*/
void ConfigureDialog::pB_editBlacklistSuspend_clicked(){
kdDebugFuncIn(trace);
TQString _top_text = "";
bool initialiseImport = false;
if(tabWidget->currentPageIndex() == 0 ) {
TQString s_scheme = getSchemeRealName(schemes[listBox_schemes->currentItem()]);
_top_text = listBox_schemes->currentText();
if (tdeconfig->hasGroup(s_scheme)){
tdeconfig->setGroup(s_scheme);
}
blacklist = tdeconfig->readListEntry("autoInactiveSchemeBlacklist", ',');
if( blacklist.empty()) {
TQString _msg = i18n("The blacklist of the selected scheme is empty. "
"Import the general blacklist?");
int tmp = KMessageBox::questionYesNo(this, _msg, TQString(), i18n("Import"), i18n("Do Not Import"));
if (tmp == KMessageBox::Yes) {
initialiseImport = true;
if(tdeconfig->hasGroup("General")){
tdeconfig->setGroup("General");
blacklist = tdeconfig->readListEntry("autoInactiveBlacklist", ',');
}
}
}
}
else {
if(tdeconfig->hasGroup("General")){
_top_text = i18n("General Autosuspend Blacklist");
tdeconfig->setGroup("General");
blacklist = tdeconfig->readListEntry("autoInactiveBlacklist", ',');
}
}
blacklistEDlgAS = new blacklistEditDialog(blacklist, _top_text, initialiseImport, this);
connect( blacklistEDlgAS, TQT_SIGNAL(config_finished(TQStringList)), this,
TQT_SLOT(saveSchemeSuspendBlacklist(TQStringList)));
blacklistEDlgAS->exec();
kdDebugFuncOut(trace);
}
/*!
* SLOT: Called if the signal config_finished(TQStringList) recieved
* and the autosuspend blacklist is edited.
* \param new_blacklist TQStringlist with the edited blacklisted processes
*/
void ConfigureDialog::saveSchemeSuspendBlacklist( TQStringList new_blacklist){
kdDebugFuncIn(trace);
if(tabWidget->currentPageIndex() == 0 ) {
TQString s_scheme = getSchemeRealName(schemes[currentScheme]);
tdeconfig->setGroup(s_scheme);
tdeconfig->writeEntry("autoInactiveSchemeBlacklist", new_blacklist, ',');
}
else {
tdeconfig->setGroup("General");
tdeconfig->writeEntry("autoInactiveBlacklist", new_blacklist, ',');
}
tdeconfig->sync();
kdDebugFuncOut(trace);
}
/* ---- END Inactivity SECTION ---- */
/* ---- START Autodimm SECTION ---- */
/*!
* This used to set the autodimm related widgets.
*/
void ConfigureDialog::cB_autoDimm_toggled( bool toggled ) {
kdDebugFuncIn(trace);
if(cB_autoDimm->isOn() != toggled)
cB_autoDimm->setChecked(toggled);
if (toggled)
tL_autoDimmExplain->setEnabled(toggled);
tL_autoDimmAfter->setEnabled(toggled);
sB_autoDimmTime->setEnabled(toggled);
tL_autoDimmTo->setEnabled(toggled);
sB_autoDimmTo->setEnabled(toggled);
if (sB_autoDimmTime->value() > 0)
cB_BlacklistDimm->setEnabled(toggled);
if (cB_BlacklistDimm->isOn())
pB_editBlacklistDimm->setEnabled(toggled);
if (toggled) {
if (sB_autoDimmTime->value() > 0) {
tL_autoDimmTo->setEnabled(true);
sB_autoDimmTo->setEnabled(true);
} else {
tL_autoDimmTo->setEnabled(false);
sB_autoDimmTo->setEnabled(false);
}
}
scheme_changed = true;
buttonApply->setEnabled(true);
kdDebugFuncOut(trace);
}
/*!
* SLOT: Called if the 'Enable scheme specific blacklist' is toggled.
* \param toggled boolean, true if toggled on
* false if toggled off
*/
void ConfigureDialog::cB_BlacklistDimm_toggled( bool toggled ){
kdDebugFuncIn(trace);
pB_editBlacklistDimm->setEnabled(toggled);
if(initalised) {
buttonApply->setEnabled(true);
scheme_changed = true;
} else {
cB_BlacklistDimm->setChecked(toggled);
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: Called if the 'edit blacklist' button for autodimm is toggled.
*/
void ConfigureDialog::pB_editBlacklistDimm_clicked(){
kdDebugFuncIn(trace);
TQString _top_text = "";
bool initialiseImport = false;
if(tabWidget->currentPageIndex() == 0 ) {
TQString s_scheme = getSchemeRealName(schemes[listBox_schemes->currentItem()]);
_top_text = listBox_schemes->currentText();
if (tdeconfig->hasGroup(s_scheme)){
tdeconfig->setGroup(s_scheme);
}
blacklist = tdeconfig->readListEntry("autoDimmSchemeBlacklist", ',');
if( blacklist.empty()) {
TQString _msg = i18n("The blacklist of the selected scheme is empty. "
"Import the general blacklist?");
int tmp = KMessageBox::questionYesNo(this, _msg, TQString(), i18n("Import"), i18n("Do Not Import"));
if (tmp == KMessageBox::Yes) {
initialiseImport = true;
if(tdeconfig->hasGroup("General")){
tdeconfig->setGroup("General");
blacklist = tdeconfig->readListEntry("autoDimmBlacklist", ',');
}
}
}
}
else {
if(tdeconfig->hasGroup("General")){
_top_text = i18n("General Autodimm Blacklist");
tdeconfig->setGroup("General");
blacklist = tdeconfig->readListEntry("autoDimmBlacklist", ',');
}
}
blacklistEDlgAD = new blacklistEditDialog(blacklist, _top_text, initialiseImport, this);
connect( blacklistEDlgAD, TQT_SIGNAL(config_finished(TQStringList)), this,
TQT_SLOT(saveSchemeDimmBlacklist(TQStringList)));
blacklistEDlgAD->exec();
kdDebugFuncOut(trace);
}
/*!
* SLOT: Called if the signal config_finished(TQStringList) recieved
* and the autdimm blacklist is edited.
* \param new_blacklist TQStringlist with the edited blacklisted processes
*/
void ConfigureDialog::saveSchemeDimmBlacklist( TQStringList new_blacklist){
kdDebugFuncIn(trace);
if(tabWidget->currentPageIndex() == 0 ) {
TQString s_scheme = getSchemeRealName(schemes[currentScheme]);
tdeconfig->setGroup(s_scheme);
tdeconfig->writeEntry("autoDimmSchemeBlacklist", new_blacklist, ',');
}
else {
tdeconfig->setGroup("General");
tdeconfig->writeEntry("autoDimmBlacklist", new_blacklist, ',');
}
tdeconfig->sync();
kdDebugFuncOut(trace);
}
/*!
* SLOT: Called if there \ref sB_autoDimmTime get changed
* \param value Integer with the new value
*/
void ConfigureDialog::sB_autoDimmTime_valueChanged( int value ) {
kdDebugFuncIn(trace);
if (value > 0) {
if (!tL_autoDimmTo->isEnabled()) {
tL_autoDimmTo->setEnabled(true);
sB_autoDimmTo->setEnabled(true);
cB_BlacklistDimm->setEnabled(true);
if (cB_BlacklistDimm->isOn())
pB_editBlacklistDimm->setEnabled(true);
}
} else {
if (tL_autoDimmTo->isEnabled()) {
tL_autoDimmTo->setEnabled(false);
sB_autoDimmTo->setEnabled(false);
cB_BlacklistDimm->setEnabled(false);
pB_editBlacklistDimm->setEnabled(false);
}
}
kdDebugFuncOut(trace);
}
/* ---- END Autodimm SECTION ---- */
/* ---- START Brightness SECTION ---- */
/*! \b SLOT: to enable the brigthness related widgets */
void ConfigureDialog::cB_Brightness_toggled( bool toggled ) {
kdDebugFuncIn(trace);
gB_Brightness->setEnabled(toggled);
cB_Brightness->setChecked(toggled);
connect(brightnessSlider, TQT_SIGNAL(valueChanged (int)), this, TQT_SLOT(brightnessSlider_sliderMoved(int)));
kdDebugFuncOut(trace);
}
/*! \b SLOT: to change the brightness if the slider is changed */
void ConfigureDialog::brightnessSlider_sliderMoved( int new_value ) {
kdDebugFuncIn(trace);
if (cB_Brightness->isEnabled() && cB_Brightness->isChecked()) {
scheme_valueChanged();
tL_valueBrightness->setText(TQString::number(new_value) + " %");
hwinfo->setBrightness(-1, new_value);
pB_resetBrightness->setEnabled(true);
brightness_changed = true;
}
kdDebugFuncOut(trace);
}
/*! \b SLOT: to reset the brightness if the reset button clicked */
void ConfigureDialog::pB_resetBrightness_clicked( ) {
kdDebugFuncIn(trace);
hwinfo->setBrightness(brightness_last, -1);
brightnessSlider->setValue(brightness_last);
pB_resetBrightness->setEnabled(false);
brightness_changed = false;
kdDebugFuncOut(trace);
}
/* ---- END Brightness SECTION ---- */
/* ---- START battery level SECTION ---- */
/*!
* SLOT: called if the warning TQSpinBoxes for battery level is changed.
*/
void ConfigureDialog::sB_batWarning_valueChanged() {
kdDebugFuncIn(trace);
if (initalised) {
if (sB_batWarning->value() == 0 )
sB_batWarning->setValue(1);
if ( sB_batWarning->value() <= sB_batLow->value()) {
sB_batLow->setValue(sB_batWarning->value()-1);
}
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if the low TQSpinBoxes for battery level is changed.
*/
void ConfigureDialog::sB_batLow_valueChanged() {
kdDebugFuncIn(trace);
if (initalised) {
if (sB_batLow->value() == 0 )
sB_batLow->setValue(1);
if ( sB_batLow->value() >= sB_batWarning->value()) {
sB_batWarning->setValue(sB_batLow->value()+1);
}
if ( sB_batLow->value() <= sB_batCritical->value()) {
sB_batCritical->setValue(sB_batLow->value()-1);
}
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if the critical TQSpinBoxes for battery level is changed.
*/
void ConfigureDialog::sB_batCritical_valueChanged() {
kdDebugFuncIn(trace);
if (initalised) {
if (sB_batCritical->value() == 0 )
sB_batCritical->setValue(1);
if ( sB_batCritical->value() >= sB_batLow->value()) {
sB_batLow->setValue(sB_batCritical->value()+1);
}
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if the TQComboBox for the battery warning level action changed,
* used to hide/show the related TQSpinboxes if needed.
*/
void ConfigureDialog::cB_batWarning_activated() {
kdDebugFuncIn(trace);
if ( mapDescriptionToAction(cB_batWarning->currentText()) == "BRIGHTNESS") {
sB_batWarnAction_value->show();
} else {
sB_batWarnAction_value->hide();
}
kdDebugFuncOut(trace);
}
//! called if the TQComboBox for the battery low level action changed
/*!
* used to hide/show the related TQSpinboxes if needed.
*/
void ConfigureDialog::cB_batLow_activated() {
kdDebugFuncIn(trace);
if ( mapDescriptionToAction(cB_batLow->currentText()) == "BRIGHTNESS") {
sB_batLowAction_value->show();
} else {
sB_batLowAction_value->hide();
}
kdDebugFuncOut(trace);
}
/*!
* SLOT: called if the TQComboBox for the battery critical level action changed,
* used to hide/show the related TQSpinboxes if needed.
*/
void ConfigureDialog::cB_batCritical_activated() {
kdDebugFuncIn(trace);
if ( mapDescriptionToAction(cB_batCritical->currentText()) == "BRIGHTNESS") {
sB_batCritAction_value->show();
} else {
sB_batCritAction_value->hide();
}
kdDebugFuncOut(trace);
}
/* ---- END battery level SECTION ---- */
/*! \b SLOT: to open the KNotify config dialog */
void ConfigureDialog::pB_configNotify_released( ) {
kdDebugFuncIn(trace);
emit openKNotify();
kdDebugFuncOut(trace);
}
/* ---- START helper functions SECTION ---- */
/*!
* Map the key from config for a action to a descriptive name.
* \param action TQString with the config key value
* \return TQString with the description
*/
TQString ConfigureDialog::mapActionToDescription( TQString action ) {
kdDebugFuncIn(trace);
TQString ret;
if (action.startsWith("SHUTDOWN")) {
ret = i18n("Shutdown");
} else if (action.startsWith("LOGOUT_DIALOG")) {
ret = i18n("Logout Dialog");
} else if (action.startsWith("SUSPEND2DISK")) {
if (actions.contains("Suspend to Disk"))
ret = i18n("Suspend to Disk");
} else if (action.startsWith("SUSPEND2RAM")) {
if (actions.contains("Suspend to RAM"))
ret = i18n("Suspend to RAM");
} else if (action.startsWith("CPUFRETQ_POWERSAVE")) {
if (hwinfo->supportCPUFreq())
ret = i18n("CPU Powersave policy");
} else if (action.startsWith("CPUFRETQ_DYNAMIC")) {
if (hwinfo->supportCPUFreq())
ret = i18n("CPU Dynamic policy");
} else if (action.startsWith("CPUFRETQ_PERFORMANCE")) {
if (hwinfo->supportCPUFreq())
ret = i18n("CPU Performance policy");
} else if (action.startsWith("BRIGHTNESS")) {
if (hwinfo->supportBrightness())
ret = i18n("Set Brightness to");
}
kdDebugFuncOut(trace);
return ret;
}
/*!
* Map the action description (maybe translated) back to a TQString key for the config.
* \param description TQString with the description
* \return TQString with the config key value
*/
TQString ConfigureDialog::mapDescriptionToAction( TQString description ) {
kdDebugFuncIn(trace);
TQString ret;
if (description.startsWith("Shutdown") || description.startsWith(i18n("Shutdown"))) {
ret = "SHUTDOWN";
} else if (description.startsWith("Logout Dialog") ||
description.startsWith(i18n("Logout Dialog"))) {
ret = "LOGOUT_DIALOG";
} else if (description.startsWith("Suspend to Disk") ||
description.startsWith(i18n("Suspend to Disk"))) {
ret = "SUSPEND2DISK";
} else if (description.startsWith("Suspend to RAM") ||
description.startsWith(i18n("Suspend to RAM"))) {
ret = "SUSPEND2RAM";
} else if (description.startsWith("CPU Powersave policy") ||
description.startsWith(i18n("CPU Powersave policy"))) {
ret = "CPUFRETQ_POWERSAVE";
} else if (description.startsWith("CPU Dynamic policy") ||
description.startsWith(i18n("CPU Dynamic policy"))) {
ret = "CPUFRETQ_DYNAMIC";
} else if (description.startsWith("CPU Performance policy") ||
description.startsWith(i18n("CPU Performance policy"))) {
ret = "CPUFRETQ_PERFORMANCE";
} else if (description.startsWith("Set Brightness to") ||
description.startsWith(i18n("Set Brightness to"))) {
ret = "BRIGHTNESS";
}
kdDebugFuncOut(trace);
return ret;
}
/*!
* Helper to fill a TQComboBox with their text and select the correct item
* \param _cb Pointer to the TQComboBox
* \param _actions TQStringList with the allowed actions
* \param _select TQString with the action to select
*/
void ConfigureDialog::fillActionComboBox(TQComboBox *_cb, TQStringList _actions, TQString _select) {
kdDebugFuncIn(trace);
_cb->clear();
_cb->insertItem("");
for ( TQStringList::Iterator it = _actions.begin(); it != _actions.end(); ++it ) {
TQString _tmp = *it;
TQString _desc = mapActionToDescription( _tmp );
if (!_desc.isEmpty()) {
_cb->insertItem( _desc );
if (_tmp == _select) {
_cb->setCurrentItem(_cb->count()-1);
}
}
}
kdDebugFuncOut(trace);
}
/* ---- END helper functions SECTION ---- */
#include "configuredialog.moc"
|