File: ConsoleConfig.cpp

package info (click to toggle)
bsc 2.27-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,644 kB
  • ctags: 2,610
  • sloc: cpp: 14,104; perl: 114; makefile: 46
file content (113 lines) | stat: -rw-r--r-- 4,429 bytes parent folder | download | duplicates (2)
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
/********************************************************************
 * Copyright (C) 2005 Piotr Pszczolkowski
 *-------------------------------------------------------------------
 * This file is part of BSCommander (Beesoft Commander).
 *
 * BSCommander is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * BSCommander 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 BsC; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *******************************************************************/

/*------- include files:
-------------------------------------------------------------------*/
#include "ConsoleConfig.h"
#include "Shared.h"
#include "Config.h"
#include "Settings.h"
#include <qlabel.h>
#include <qlayout.h>
#include <qgroupbox.h>
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qpushbutton.h>

/*------- local constants:
-------------------------------------------------------------------*/
const QString ConsoleConfig::OtherTerminal = QT_TR_NOOP( "&Other terminal" );
const QString ConsoleConfig::KonsoleName   = QT_TR_NOOP( "Default terminal: <b>konsole</b>" );


//*******************************************************************
// ConsoleConfig                                         CONSTRUCTOR
//*******************************************************************
ConsoleConfig::ConsoleConfig( QWidget* const in_parent )
: QFrame( in_parent )
, d_main_layout( new QVBoxLayout( this ) )
, d_konsole_grpbox( new QGroupBox( 2, Qt::Vertical, this ))
, d_konsole_name( new QLabel( tr(KonsoleName), d_konsole_grpbox ))
, d_konsole_call( new QLineEdit( Shared::KonsoleCall, d_konsole_grpbox ))
, d_other_grpbox( new QGroupBox( 2, Qt::Vertical, this ))
, d_other_cbox( new QCheckBox( tr(OtherTerminal), d_other_grpbox ))
, d_other_call( new QLineEdit( d_other_grpbox ))
, d_button_layout( new QHBoxLayout )
, d_apply_button( new QPushButton( tr(Shared::ApplyBtnLabel), this ))
{
	d_main_layout->setSpacing( Shared::LayoutSpacing );
	d_main_layout->setMargin( Shared::LayoutMargin );

	// konsole
	d_konsole_call->setReadOnly( TRUE );
	d_main_layout->addWidget( d_konsole_grpbox );
	
	// other
	//d_other_call->setEnabled( FALSE );
	d_main_layout->addWidget( d_other_grpbox );

	// apply
	Shared::add_icon( d_apply_button, Shared::ApplyIcon );
	d_button_layout->addStretch( Shared::OverStretch );
	d_button_layout->addWidget( d_apply_button );
	d_main_layout->addLayout( d_button_layout );	
	
	connect( d_other_cbox, SIGNAL( toggled( bool )), this, SLOT( other_toggled( bool )));
	connect( d_apply_button, SIGNAL( clicked() ), this, SLOT( apply_clicked() ));
}
// end of ConsoleConfig

//*******************************************************************
// show                                            PRIVATE inherited
//*******************************************************************
void ConsoleConfig::show()
{
	const QString call = Config::instance()->terminal_call();
	if( call.isEmpty() ) {
		d_other_call->setEnabled( FALSE );
	}
	else {
		d_other_call->setText( call );
		d_other_cbox->setChecked( TRUE );
	}
	QFrame::show();
}
// end of show

//*******************************************************************
// other_toggled                                        PRIVATE slot
//*******************************************************************
void ConsoleConfig::other_toggled( const bool in_on )
{
	d_other_call->setEnabled( in_on );
	if( in_on ) d_other_call->setFocus();
}
// end of other_toggled

//*******************************************************************
// apply_clicked                                        PRIVATE slot
//*******************************************************************
void ConsoleConfig::apply_clicked()
{
	const QString call = ( d_other_cbox->isChecked() ) ? d_other_call->text() : "";
	Settings::save( Config::AppConfigGroup, Config::TerminalKey, call );
	Config::instance()->refresh();
}
// end of apply_clicked