You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
218 lines
6.6 KiB
218 lines
6.6 KiB
15 years ago
|
/*
|
||
|
KSysGuard, the KDE System Guard
|
||
|
|
||
|
Copyright (c) 1999, 2000 Chris Schlaeger <cs@kde.org>
|
||
|
|
||
|
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.
|
||
|
|
||
|
*/
|
||
|
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
12 years ago
|
#include <tdeaccelmanager.h>
|
||
15 years ago
|
#include <kcombobox.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
15 years ago
|
#include <tqbuttongroup.h>
|
||
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqradiobutton.h>
|
||
|
#include <tqspinbox.h>
|
||
|
#include <tqtooltip.h>
|
||
|
#include <tqwhatsthis.h>
|
||
15 years ago
|
|
||
|
#include "HostConnector.h"
|
||
|
|
||
15 years ago
|
HostConnector::HostConnector( TQWidget *parent, const char *name )
|
||
15 years ago
|
: KDialogBase( Plain, i18n( "Connect Host" ), Help | Ok | Cancel, Ok,
|
||
|
parent, name, true, true )
|
||
|
{
|
||
15 years ago
|
TQFrame *page = plainPage();
|
||
14 years ago
|
TQGridLayout *layout = new TQGridLayout( page, 2, 2, 0, spacingHint() );
|
||
|
layout->setColStretch( 1, 1 );
|
||
15 years ago
|
|
||
15 years ago
|
TQLabel *label = new TQLabel( i18n( "Host:" ), page );
|
||
14 years ago
|
layout->addWidget( label, 0, 0 );
|
||
15 years ago
|
|
||
|
mHostNames = new KComboBox( true, page );
|
||
|
mHostNames->setMaxCount( 20 );
|
||
15 years ago
|
mHostNames->setInsertionPolicy( TQComboBox::AtTop );
|
||
15 years ago
|
mHostNames->setAutoCompletion( true );
|
||
|
mHostNames->setDuplicatesEnabled( false );
|
||
14 years ago
|
layout->addWidget( mHostNames, 0, 1 );
|
||
15 years ago
|
label->setBuddy( mHostNames );
|
||
15 years ago
|
TQWhatsThis::add( mHostNames, i18n( "Enter the name of the host you want to connect to." ) );
|
||
15 years ago
|
|
||
15 years ago
|
mHostNameLabel = new TQLabel( page );
|
||
15 years ago
|
mHostNameLabel->hide();
|
||
14 years ago
|
layout->addWidget( mHostNameLabel, 0, 1 );
|
||
15 years ago
|
|
||
15 years ago
|
TQButtonGroup *group = new TQButtonGroup( 0, Qt::Vertical,
|
||
15 years ago
|
i18n( "Connection Type" ), page );
|
||
13 years ago
|
TQGridLayout *groupLayout = new TQGridLayout( group->layout(), 4, 4,
|
||
15 years ago
|
spacingHint() );
|
||
13 years ago
|
groupLayout->setAlignment( Qt::AlignTop );
|
||
15 years ago
|
|
||
15 years ago
|
mUseSsh = new TQRadioButton( i18n( "ssh" ), group );
|
||
15 years ago
|
mUseSsh->setEnabled( true );
|
||
|
mUseSsh->setChecked( true );
|
||
15 years ago
|
TQWhatsThis::add( mUseSsh, i18n( "Select this to use the secure shell to login to the remote host." ) );
|
||
15 years ago
|
groupLayout->addWidget( mUseSsh, 0, 0 );
|
||
|
|
||
15 years ago
|
mUseRsh = new TQRadioButton( i18n( "rsh" ), group );
|
||
|
TQWhatsThis::add( mUseRsh, i18n( "Select this to use the remote shell to login to the remote host." ) );
|
||
15 years ago
|
groupLayout->addWidget( mUseRsh, 0, 1 );
|
||
|
|
||
15 years ago
|
mUseDaemon = new TQRadioButton( i18n( "Daemon" ), group );
|
||
|
TQWhatsThis::add( mUseDaemon, i18n( "Select this if you want to connect to a ksysguard daemon that is running on the machine you want to connect to, and is listening for client requests." ) );
|
||
15 years ago
|
groupLayout->addWidget( mUseDaemon, 0, 2 );
|
||
|
|
||
15 years ago
|
mUseCustom = new TQRadioButton( i18n( "Custom command" ), group );
|
||
|
TQWhatsThis::add( mUseCustom, i18n( "Select this to use the command you entered below to start ksysguardd on the remote host." ) );
|
||
15 years ago
|
groupLayout->addWidget( mUseCustom, 0, 3 );
|
||
|
|
||
15 years ago
|
label = new TQLabel( i18n( "Port:" ), group );
|
||
15 years ago
|
groupLayout->addWidget( label, 1, 0 );
|
||
|
|
||
15 years ago
|
mPort = new TQSpinBox( 1, 65535, 1, group );
|
||
15 years ago
|
mPort->setEnabled( false );
|
||
|
mPort->setValue( 3112 );
|
||
15 years ago
|
TQToolTip::add( mPort, i18n( "Enter the port number on which the ksysguard daemon is listening for connections." ) );
|
||
15 years ago
|
groupLayout->addWidget( mPort, 1, 2 );
|
||
|
|
||
15 years ago
|
label = new TQLabel( i18n( "e.g. 3112" ), group );
|
||
15 years ago
|
groupLayout->addWidget( label, 1, 3 );
|
||
|
|
||
15 years ago
|
label = new TQLabel( i18n( "Command:" ), group );
|
||
15 years ago
|
groupLayout->addWidget( label, 2, 0 );
|
||
|
|
||
|
mCommands = new KComboBox( true, group );
|
||
|
mCommands->setEnabled( false );
|
||
|
mCommands->setMaxCount( 20 );
|
||
15 years ago
|
mCommands->setInsertionPolicy( TQComboBox::AtTop );
|
||
15 years ago
|
mCommands->setAutoCompletion( true );
|
||
|
mCommands->setDuplicatesEnabled( false );
|
||
15 years ago
|
TQWhatsThis::add( mCommands, i18n( "Enter the command that runs ksysguardd on the host you want to monitor." ) );
|
||
15 years ago
|
groupLayout->addMultiCellWidget( mCommands, 2, 2, 2, 3 );
|
||
|
label->setBuddy( mCommands );
|
||
|
|
||
15 years ago
|
label = new TQLabel( i18n( "e.g. ssh -l root remote.host.org ksysguardd" ), group );
|
||
15 years ago
|
groupLayout->addMultiCellWidget( label, 3, 3, 2, 3 );
|
||
|
|
||
14 years ago
|
layout->addMultiCellWidget( group, 1, 1, 0, 1 );
|
||
15 years ago
|
|
||
15 years ago
|
connect( mUseCustom, TQT_SIGNAL( toggled( bool ) ),
|
||
|
mCommands, TQT_SLOT( setEnabled( bool ) ) );
|
||
|
connect( mUseDaemon, TQT_SIGNAL( toggled( bool ) ),
|
||
|
mPort, TQT_SLOT( setEnabled( bool ) ) );
|
||
|
connect( mHostNames->lineEdit(), TQT_SIGNAL( textChanged ( const TQString & ) ),
|
||
|
this, TQT_SLOT( slotHostNameChanged( const TQString & ) ) );
|
||
15 years ago
|
enableButtonOK( !mHostNames->lineEdit()->text().isEmpty() );
|
||
12 years ago
|
TDEAcceleratorManager::manage( this );
|
||
15 years ago
|
}
|
||
|
|
||
|
HostConnector::~HostConnector()
|
||
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
void HostConnector::slotHostNameChanged( const TQString &_text )
|
||
15 years ago
|
{
|
||
|
enableButtonOK( !_text.isEmpty() );
|
||
|
}
|
||
|
|
||
15 years ago
|
void HostConnector::setHostNames( const TQStringList &list )
|
||
15 years ago
|
{
|
||
|
mHostNames->insertStringList( list );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQStringList HostConnector::hostNames() const
|
||
15 years ago
|
{
|
||
15 years ago
|
TQStringList list;
|
||
15 years ago
|
|
||
|
for ( int i = 0; i < mHostNames->count(); ++i )
|
||
|
list.append( mHostNames->text( i ) );
|
||
|
|
||
|
return list;
|
||
|
}
|
||
|
|
||
15 years ago
|
void HostConnector::setCommands( const TQStringList &list )
|
||
15 years ago
|
{
|
||
|
mCommands->insertStringList( list );
|
||
|
}
|
||
|
|
||
15 years ago
|
TQStringList HostConnector::commands() const
|
||
15 years ago
|
{
|
||
15 years ago
|
TQStringList list;
|
||
15 years ago
|
|
||
|
for ( int i = 0; i < mCommands->count(); ++i )
|
||
|
list.append( mCommands->text( i ) );
|
||
|
|
||
|
return list;
|
||
|
}
|
||
|
|
||
15 years ago
|
void HostConnector::setCurrentHostName( const TQString &hostName )
|
||
15 years ago
|
{
|
||
|
if ( !hostName.isEmpty() ) {
|
||
|
mHostNames->hide();
|
||
|
mHostNameLabel->setText( hostName );
|
||
|
mHostNameLabel->show();
|
||
|
enableButtonOK( true );//enable true when mHostNames is empty and hidden fix #66955
|
||
|
} else {
|
||
|
mHostNameLabel->hide();
|
||
|
mHostNames->show();
|
||
|
mHostNames->setFocus();
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString HostConnector::currentHostName() const
|
||
15 years ago
|
{
|
||
|
return mHostNames->currentText();
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString HostConnector::currentCommand() const
|
||
15 years ago
|
{
|
||
|
return mCommands->currentText();
|
||
|
}
|
||
|
|
||
|
int HostConnector::port() const
|
||
|
{
|
||
|
return mPort->value();
|
||
|
}
|
||
|
|
||
|
bool HostConnector::useSsh() const
|
||
|
{
|
||
|
return mUseSsh->isChecked();
|
||
|
}
|
||
|
|
||
|
bool HostConnector::useRsh() const
|
||
|
{
|
||
|
return mUseRsh->isChecked();
|
||
|
}
|
||
|
|
||
|
bool HostConnector::useDaemon() const
|
||
|
{
|
||
|
return mUseDaemon->isChecked();
|
||
|
}
|
||
|
|
||
|
bool HostConnector::useCustom() const
|
||
|
{
|
||
|
return mUseCustom->isChecked();
|
||
|
}
|
||
|
|
||
|
void HostConnector::slotHelp()
|
||
|
{
|
||
|
kapp->invokeHelp( "CONNECTINGTOOTHERHOSTS", "ksysguard/the-sensor-browser.html" );
|
||
|
}
|
||
|
|
||
|
#include "HostConnector.moc"
|