Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

terminalwidget.cpp

Go to the documentation of this file.
00001 #include "terminalwidget.h"
00002 
00003 /* QT */
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 //     m_groupSize = new QHButtonGroup(tr("Font size"), this );
00045     m_groupSize = new QHBox( this );
00046     m_fontSelector = new Opie::Ui::OFontSelector( false, m_groupSize );
00047 
00048 //      m_sizeSmall = new QRadioButton(tr("small"),  m_groupSize );
00049 //      m_sizeMedium = new QRadioButton(tr("medium"),  m_groupSize );
00050 //      m_sizeLarge = new QRadioButton(tr("large"),  m_groupSize );
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     // Layout
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     // Fill in some options
00078     m_terminalBox->insertItem( tr("VT 100"), 0 ); // /*, id_term_vt100*/ );
00079     m_terminalBox->insertItem( tr("VT 102"), 1 );  // /* , id_term_vt102 */);
00080     m_terminalBox->insertItem( tr("Linux Console"), 2 ); //, id_term_linux );
00081     m_terminalBox->insertItem( tr("X-Terminal"), 3 ); //, id_term_xterm );
00082     //m_terminalBox->insertItem( tr("ANSI"), id_term_ansi );
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     // signals + slots
00090     /*
00091     connect(m_terminalBox, SIGNAL(activated(int) ),
00092             this, SLOT(slotTermTerm(int) ) );
00093     connect(m_colorBox, SIGNAL(activated(int) ),
00094             tis, SLOT(slotTermColor(int) ) );
00095     connect(m_groupSize, SIGNAL(activated(int) ),
00096             this, SLOT(slotTermFont(int) ) );
00097 
00098     connect(m_optionEcho, SIGNAL(toggled(bool) ),
00099             this, SLOT(slotTermEcho(bool) ) );
00100     connect(m_optionWrap, SIGNAL(toggled(bool) ),
00101             this, SLOT(slotTermWrap(bool) ) );
00102     connect(m_convInbound, SIGNAL(toggled(bool) ),
00103             this, SLOT(slotTermInbound(bool) ) );
00104     connect(m_convOutbound, SIGNAL(toggled(bool) ),
00105             this, SLOT(slotTermOutbound(bool) ) );
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 //     int fontsize = prof.readNumEntry("Font");
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 //     switch( fontsize ) {
00158 //     case Profile::Micro:
00159 //         m_sizeSmall->setChecked(true );
00160 //         break;
00161 //     case Profile::Small:
00162 //         m_sizeMedium->setChecked(true );
00163 //         break;
00164 //     case Profile::Medium:
00165 //         m_sizeLarge->setChecked( true );
00166 //         break;
00167 //     default:
00168 //         m_sizeMedium->setChecked(true );
00169 //         break;
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     //case id_term_ansi:
00193     //    profile.writeEntry("Terminal", Profile::VT102 );
00194     //    break;
00195     default:
00196         break;
00197     };
00198 
00199     // color
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 //     if (m_sizeSmall->isChecked() ) {
00225 //         profile.writeEntry("Font", Profile::Micro );
00226 //     }else if (m_sizeMedium->isChecked() ) {
00227 //         profile.writeEntry("Font", Profile::Small );
00228 //     }else {
00229 //         profile.writeEntry("Font", Profile::Medium );
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 }

Generated on Sat Nov 5 16:16:51 2005 for OPIE by  doxygen 1.4.2