1 //=============================================================================
2 //
3 // File : OptionsWidget_lag.cpp
4 // Creation date : Wed Oct 16 10:45:54 CEST 2002 by Juanjo Álvarez (juanjux@yahoo.es)
5 //
6 // This file is part of the KVIrc IRC client distribution
7 // Copyright (C) 2002 Juanjo Álvarez
8 // Copyright (C) 2002-2010 Szymon Stefanek (pragma at kvirc dot net)
9 //
10 // This program is FREE software. You can redistribute it and/or
11 // modify it under the terms of the GNU General Public License
12 // as published by the Free Software Foundation; either version 2
13 // of the License, or (at your option) any later version.
14 //
15 // This program is distributed in the HOPE that it will be USEFUL,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 // See the GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, write to the Free Software Foundation,
22 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 //
24 //=============================================================================
25
26 #include "OptionsWidget_lag.h"
27
28 #include "KviOptions.h"
29 #include "KviLocale.h"
30 #include "KviTalToolTip.h"
31
32 #include <QLayout>
33
OptionsWidget_lag(QWidget * parent)34 OptionsWidget_lag::OptionsWidget_lag(QWidget * parent)
35 : KviOptionsWidget(parent)
36 {
37 setObjectName("lag_options_widget");
38 createLayout();
39
40 KviBoolSelector * pUse = addBoolSelector(0, 0, 0, 0, __tr2qs_ctx("Enable lag meter", "options"), KviOption_boolUseLagMeterEngine);
41 mergeTip(pUse, __tr2qs_ctx("This enables the lag meter engine, which checks at regular intervals how much latency the server has.", "options"));
42 KviTalGroupBox * g = addGroupBox(0, 1, 0, 1, Qt::Horizontal, __tr2qs_ctx("Configuration", "options"), KVI_OPTION_BOOL(KviOption_boolUseLagMeterEngine));
43 KviUIntSelector * pInterval = addUIntSelector(g, __tr2qs_ctx("Lag meter heartbeat:", "options"), KviOption_uintLagMeterHeartbeat, 2000, 10000, 5000,
44 KVI_OPTION_BOOL(KviOption_boolUseLagMeterEngine));
45 pInterval->setSuffix(__tr2qs_ctx(" msec", "options"));
46 mergeTip(pInterval, __tr2qs_ctx("This option allows you to set the lag meter heartbeat interval.<br>"
47 "The lower the heartbeat interval the higher will be the accuracy of the lag check "
48 "but also higher CPU usage and data traffic to the server.<br>"
49 "Please note that this is NOT the interval between pings sent to the server: "
50 "the pings (if any) will be sent really less often. "
51 "5000 is a reasonable value.", "options"));
52
53 connect(pUse, SIGNAL(toggled(bool)), pInterval, SLOT(setEnabled(bool)));
54
55 KviUIntSelector * pAlarm = addUIntSelector(g, __tr2qs_ctx("Trigger event if lag exceeds:", "options"), KviOption_uintLagAlarmTime, 5000, 1000000, 30000,
56 KVI_OPTION_BOOL(KviOption_boolUseLagMeterEngine));
57 pAlarm->setSuffix(__tr2qs_ctx(" msec", "options"));
58 mergeTip(pAlarm, __tr2qs_ctx("This option controls the threshold for the "
59 "OnLagAlarmTimeUp and OnLagAlarmTimeDown events. When the lag goes above "
60 "the threshold OnLagAlarmTimeUp will be triggered and when the lag falls "
61 "back below the threshold then OnLagAlarmTimeDown will be triggered", "options"));
62
63 connect(pUse, SIGNAL(toggled(bool)), pAlarm, SLOT(setEnabled(bool)));
64
65 KviBoolSelector * pShow = addBoolSelector(g, __tr2qs_ctx("Show lag in IRC context display", "options"), KviOption_boolShowLagOnContextDisplay,
66 KVI_OPTION_BOOL(KviOption_boolUseLagMeterEngine));
67 mergeTip(pShow, __tr2qs_ctx("This makes the IRC context display applet show the current lag after the user's nickname (in seconds)", "options"));
68
69 connect(pUse, SIGNAL(toggled(bool)), pShow, SLOT(setEnabled(bool)));
70 connect(pUse, SIGNAL(toggled(bool)), g, SLOT(setEnabled(bool)));
71
72 addRowSpacer(0, 2, 0, 2);
73 }
74
75 OptionsWidget_lag::~OptionsWidget_lag()
76 = default;
77