00001 #include "terminalwidget.h"
00002
00003
00004 #include <qlabel.h>
00005 #include <qcheckbox.h>
00006 #include <qcombobox.h>
00007 #include <qradiobutton.h>
00008 #include <qhgroupbox.h>
00009 #include <qhbuttongroup.h>
00010 #include <qlayout.h>
00011 #include <qhbox.h>
00012
00013 namespace {
00014 enum TermIds {
00015 id_term_vt100 = 0,
00016 id_term_vt102,
00017 id_term_linux,
00018 id_term_xterm
00019 };
00020
00021 enum ColourIds {
00022 id_term_black,
00023 id_term_white,
00024 id_term_green,
00025 id_term_orange
00026 };
00027
00028 enum FontIds {
00029 id_size_small,
00030 id_size_medium,
00031 id_size_large
00032 };
00033 };
00034
00035 TerminalWidget::TerminalWidget( const QString& name, QWidget* parent,
00036 const char* na )
00037 : ProfileDialogTerminalWidget( name, parent, na ) {
00038
00039 m_terminal = new QLabel(tr("Terminal Type"), this );
00040 m_terminalBox = new QComboBox(this);
00041 m_colorLabel = new QLabel(tr("Color scheme"), this);
00042 m_colorCmb = new QComboBox(this );
00043
00044
00045 m_groupSize = new QHBox( this );
00046 m_fontSelector = new Opie::Ui::OFontSelector( false, m_groupSize );
00047
00048
00049
00050
00051
00052 m_groupConv = new QHGroupBox( tr("Line-break conversions"), this );
00053 m_convInbound = new QCheckBox( tr("Inbound"), m_groupConv );
00054 m_convOutbound = new QCheckBox( tr("Outbound"), m_groupConv );
00055
00056
00057 m_groupOptions = new QHGroupBox( tr("Options"), this );
00058 m_optionEcho = new QCheckBox( tr("Local echo"), m_groupOptions );
00059 m_optionWrap = new QCheckBox( tr("Line wrap"), m_groupOptions );
00060
00061 m_lroot = new QVBoxLayout( this );
00062 m_typeBox = new QVBoxLayout( m_lroot );
00063 m_colorBox = new QVBoxLayout( m_lroot );
00064
00065
00066 m_typeBox->add( m_terminal );
00067 m_typeBox->add( m_terminalBox );
00068 m_lroot->add( m_groupSize );
00069
00070 m_colorBox->add( m_colorLabel );
00071 m_colorBox->add( m_colorCmb );
00072
00073 m_lroot->add( m_groupConv );
00074 m_lroot->add( m_groupOptions );
00075 m_lroot->addStretch( 0 );
00076
00077
00078 m_terminalBox->insertItem( tr("VT 100"), 0 );
00079 m_terminalBox->insertItem( tr("VT 102"), 1 );
00080 m_terminalBox->insertItem( tr("Linux Console"), 2 );
00081 m_terminalBox->insertItem( tr("X-Terminal"), 3 );
00082
00083
00084 m_colorCmb->insertItem( tr("black on white"), id_term_black );
00085 m_colorCmb->insertItem( tr("white on black"), id_term_white );
00086 m_colorCmb->insertItem( tr("green on black"), id_term_green );
00087 m_colorCmb->insertItem( tr("orange on black"), id_term_orange );
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 }
00108 TerminalWidget::~TerminalWidget() {
00109 }
00110 void TerminalWidget::load( const Profile& prof ) {
00111 int term = prof.readNumEntry("Terminal");
00112 int color = prof.readNumEntry("Color");
00113
00114 int opt_echo = prof.readNumEntry("Echo");
00115 int opt_wrap = prof.readNumEntry("Wrap");
00116 int opt_inbound = prof.readNumEntry("Inbound");
00117 int opt_outbound = prof.readNumEntry("Outbound");
00118
00119 switch( term ) {
00120 case Profile::VT100:
00121 m_terminalBox->setCurrentItem(id_term_vt100 );
00122 break;
00123 case Profile::VT102:
00124 m_terminalBox->setCurrentItem(id_term_vt102 );
00125 break;
00126 case Profile::Linux:
00127 m_terminalBox->setCurrentItem(id_term_linux );
00128 break;
00129 case Profile::XTerm:
00130 m_terminalBox->setCurrentItem(id_term_xterm );
00131 break;
00132 default:
00133 m_terminalBox->setCurrentItem(id_term_vt102 );
00134 break;
00135 };
00136
00137 switch( color ) {
00138 case Profile::Black:
00139 m_colorCmb->setCurrentItem(id_term_black );
00140 break;
00141 case Profile::White:
00142 m_colorCmb->setCurrentItem(id_term_white );
00143 break;
00144 case Profile::Green:
00145 m_colorCmb->setCurrentItem(id_term_green );
00146 break;
00147 case Profile::Orange:
00148 m_colorCmb->setCurrentItem(id_term_orange );
00149 break;
00150 default:
00151 break;
00152 };
00153
00154
00155 m_fontSelector->setSelectedFont( prof.readEntry( "Font"), prof.readEntry( "FontStyle"), prof.readNumEntry( "FontSize" ), prof.readEntry( "FontCharset") );
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 if (opt_echo) m_optionEcho->setChecked( true );
00173 if (opt_wrap) m_optionWrap->setChecked( true );
00174 if (opt_inbound) m_convInbound->setChecked( true );
00175 if (opt_outbound) m_convOutbound->setChecked( true );
00176
00177 }
00178 void TerminalWidget::save( Profile& profile ) {
00179 switch(m_terminalBox->currentItem() ) {
00180 case id_term_vt100:
00181 profile.writeEntry("Terminal", Profile::VT100 );
00182 break;
00183 case id_term_vt102:
00184 profile.writeEntry("Terminal", Profile::VT102 );
00185 break;
00186 case id_term_linux:
00187 profile.writeEntry("Terminal", Profile::Linux );
00188 break;
00189 case id_term_xterm:
00190 profile.writeEntry("Terminal", Profile::XTerm );
00191 break;
00192
00193
00194
00195 default:
00196 break;
00197 };
00198
00199
00200 switch(m_colorCmb->currentItem() ) {
00201 case id_term_black:
00202 profile.writeEntry("Color", Profile::Black );
00203 break;
00204 case id_term_white:
00205 profile.writeEntry("Color", Profile::White );
00206 break;
00207 case id_term_green:
00208 profile.writeEntry("Color", Profile::Green );
00209 break;
00210 case id_term_orange:
00211 profile.writeEntry("Color", Profile::Orange );
00212 break;
00213 default:
00214 break;
00215 };
00216
00217
00218 profile.writeEntry( "FontSize", m_fontSelector->fontSize() );
00219 profile.writeEntry( "FontStyle", m_fontSelector->fontStyle() );
00220 profile.writeEntry( "FontCharset", m_fontSelector->fontCharSet() );
00221 profile.writeEntry( "Font", m_fontSelector->fontFamily() );
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 profile.writeEntry("Echo", m_optionEcho->isChecked() );
00233 profile.writeEntry("Wrap", m_optionWrap->isChecked() );
00234 profile.writeEntry("Inbound", m_convInbound->isChecked() );
00235 profile.writeEntry("Outbound",m_convOutbound->isChecked() );
00236 }