summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/consoleconfigwidget.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/consoleconfigwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/consoleconfigwidget.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/noncore/apps/opie-console/consoleconfigwidget.cpp b/noncore/apps/opie-console/consoleconfigwidget.cpp
index 3f2d154..faedc58 100644
--- a/noncore/apps/opie-console/consoleconfigwidget.cpp
+++ b/noncore/apps/opie-console/consoleconfigwidget.cpp
@@ -1,22 +1,26 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qlistview.h> 6#include <qlistview.h>
7#include <qhbox.h> 7#include <qhbox.h>
8#include <qregexp.h> 8#include <qregexp.h>
9#include <stdio.h> 9#include <stdio.h>
10 10
11#include <pwd.h>
12#include <sys/types.h>
13
14
11#include "consoleconfigwidget.h" 15#include "consoleconfigwidget.h"
12 16
13ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent, 17ConsoleConfigWidget::ConsoleConfigWidget( const QString& name, QWidget* parent,
14 const char* na ) 18 const char* na )
15 : ProfileDialogConnectionWidget( name, parent, na ) { 19 : ProfileDialogConnectionWidget( name, parent, na ) {
16 m_lay = new QVBoxLayout( this ); 20 m_lay = new QVBoxLayout( this );
17 QLabel *label = new QLabel(tr("Command to execute"), this); 21 QLabel *label = new QLabel(tr("Command to execute"), this);
18 m_lay->addWidget(label); 22 m_lay->addWidget(label);
19 m_cmd = new QLineEdit(this); 23 m_cmd = new QLineEdit(this);
20 m_lay->addWidget(m_cmd); 24 m_lay->addWidget(m_cmd);
21 label = new QLabel(tr("Environment Variables"), this); 25 label = new QLabel(tr("Environment Variables"), this);
22 m_lay->addWidget(label); 26 m_lay->addWidget(label);
@@ -56,29 +60,36 @@ void ConsoleConfigWidget::slotAdd() {
56void ConsoleConfigWidget::slotRemove() { 60void ConsoleConfigWidget::slotRemove() {
57 QListViewItem *item = m_env->currentItem(); 61 QListViewItem *item = m_env->currentItem();
58 if (item) { 62 if (item) {
59 m_env->takeItem(item); 63 m_env->takeItem(item);
60 } 64 }
61} 65}
62 66
63ConsoleConfigWidget::~ConsoleConfigWidget() { 67ConsoleConfigWidget::~ConsoleConfigWidget() {
64} 68}
65 69
66void ConsoleConfigWidget::load( const Profile& prof ) { 70void ConsoleConfigWidget::load( const Profile& prof ) {
67 /* 71 /*
68 * we will use /bin/bash as default 72 * default to the users default shell
69 * but will fallback in MyPty to /bin/sh
70 * if necessary
71 */ 73 */
72 m_cmd->setText(prof.readEntry("Command", "/bin/bash")); 74 struct passwd *ent = 0;
75 char *shell = "/bin/sh";
76
77 while ( (ent = getpwent()) != 0 ) {
78 if (ent->pw_shell != "") {
79 shell = ent->pw_shell;
80 }
81 }
82
83 m_cmd->setText(prof.readEntry("Command", shell ));
73 int envcount = prof.readNumEntry("EnvVars", 0); 84 int envcount = prof.readNumEntry("EnvVars", 0);
74 for (int i=0; i<envcount; i++) { 85 for (int i=0; i<envcount; i++) {
75 QString name = prof.readEntry("Env_Name_" + QString::number(i), ""); 86 QString name = prof.readEntry("Env_Name_" + QString::number(i), "");
76 QString value = prof.readEntry("Env_Value_" + QString::number(i), ""); 87 QString value = prof.readEntry("Env_Value_" + QString::number(i), "");
77 if (!(name.isEmpty() || value.isEmpty())) { 88 if (!(name.isEmpty() || value.isEmpty())) {
78 QListViewItem *item = new QListViewItem(m_env); 89 QListViewItem *item = new QListViewItem(m_env);
79 item->setText(0, name); 90 item->setText(0, name);
80 item->setText(1, value); 91 item->setText(1, value);
81 m_env->insertItem(item); 92 m_env->insertItem(item);
82 } 93 }
83 } 94 }
84} 95}