Diffstat (limited to 'noncore/apps/opie-console/profilemanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index e66ebcc..dcf3cbd 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp | |||
@@ -1,88 +1,114 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | #include <qfile.h> | 4 | #include <qfile.h> |
5 | #include <qlayout.h> | ||
6 | #include <qwidgetstack.h> | ||
5 | 7 | ||
6 | #include <qpe/config.h> | 8 | #include <qpe/config.h> |
7 | 9 | ||
10 | #include "widget.h" | ||
8 | #include "metafactory.h" | 11 | #include "metafactory.h" |
9 | #include "profileconfig.h" | 12 | #include "profileconfig.h" |
10 | #include "profilemanager.h" | 13 | #include "profilemanager.h" |
11 | 14 | ||
12 | ProfileManager::ProfileManager( MetaFactory* fact ) | 15 | ProfileManager::ProfileManager( MetaFactory* fact ) |
13 | : m_fact( fact ) | 16 | : m_fact( fact ) |
14 | { | 17 | { |
15 | 18 | ||
16 | } | 19 | } |
17 | ProfileManager::~ProfileManager() { | 20 | ProfileManager::~ProfileManager() { |
18 | 21 | ||
19 | } | 22 | } |
20 | void ProfileManager::load() { | 23 | void ProfileManager::load() { |
21 | m_list.clear(); | 24 | m_list.clear(); |
22 | qWarning("load"); | 25 | qWarning("load"); |
23 | ProfileConfig conf("opie-console-profiles"); | 26 | ProfileConfig conf("opie-console-profiles"); |
24 | QStringList groups = conf.groups(); | 27 | QStringList groups = conf.groups(); |
25 | QStringList::Iterator it; | 28 | QStringList::Iterator it; |
26 | 29 | ||
27 | /* | 30 | /* |
28 | * for each profile | 31 | * for each profile |
29 | */ | 32 | */ |
30 | for ( it = groups.begin(); it != groups.end(); ++it ) { | 33 | for ( it = groups.begin(); it != groups.end(); ++it ) { |
31 | qWarning("group " + (*it) ); | 34 | qWarning("group " + (*it) ); |
32 | conf.setGroup( (*it) ); | 35 | conf.setGroup( (*it) ); |
33 | Profile prof; | 36 | Profile prof; |
34 | prof.setName( conf.readEntry("name") ); | 37 | prof.setName( conf.readEntry("name") ); |
35 | prof.setIOLayer( conf.readEntry("iolayer").utf8() ); | 38 | prof.setIOLayer( conf.readEntry("iolayer").utf8() ); |
36 | prof.setTerminalName( conf.readEntry("term").utf8() ); | 39 | prof.setTerminalName( conf.readEntry("term").utf8() ); |
37 | qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() ); | 40 | qWarning(" %s %s", conf.readEntry("iolayer").latin1(), prof.ioLayerName().data() ); |
38 | prof.setBackground( conf.readNumEntry("back") ); | 41 | prof.setBackground( conf.readNumEntry("back") ); |
39 | prof.setForeground( conf.readNumEntry("fore") ); | 42 | prof.setForeground( conf.readNumEntry("fore") ); |
40 | prof.setTerminal( conf.readNumEntry("terminal") ); | 43 | prof.setTerminal( conf.readNumEntry("terminal") ); |
41 | prof.setConf( conf.items( (*it) ) ); | 44 | prof.setConf( conf.items( (*it) ) ); |
42 | 45 | ||
43 | /* now add it */ | 46 | /* now add it */ |
44 | m_list.append( prof ); | 47 | m_list.append( prof ); |
45 | } | 48 | } |
46 | 49 | ||
47 | } | 50 | } |
48 | void ProfileManager::clear() { | 51 | void ProfileManager::clear() { |
49 | m_list.clear(); | 52 | m_list.clear(); |
50 | } | 53 | } |
51 | Profile::ValueList ProfileManager::all()const { | 54 | Profile::ValueList ProfileManager::all()const { |
52 | return m_list; | 55 | return m_list; |
53 | } | 56 | } |
54 | Session* ProfileManager::fromProfile( const Profile& prof) { | 57 | /* |
58 | * Our goal is to create a Session | ||
59 | * We will load the the IOLayer and EmulationLayer | ||
60 | * from the factory | ||
61 | * we will generate a QWidgetStack | ||
62 | * add a dummy widget with layout | ||
63 | * add "Widget" to the layout | ||
64 | * add the dummy to the stack | ||
65 | * raise the dummy | ||
66 | * call session->connect(= | ||
67 | * this way we only need to reparent | ||
68 | * in TabWidget | ||
69 | */ | ||
70 | Session* ProfileManager::fromProfile( const Profile& prof, QWidget* parent) { | ||
55 | Session* session = new Session(); | 71 | Session* session = new Session(); |
56 | session->setName( prof.name() ); | 72 | session->setName( prof.name() ); |
57 | session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), | 73 | /* translate the internal name to the external */ |
58 | prof) ); | 74 | session->setIOLayer(m_fact->newIOLayer( m_fact->external(prof.ioLayerName()) , |
59 | /* | 75 | prof) ); |
60 | * FIXME | 76 | |
61 | * load emulation | 77 | QWidgetStack *stack = new QWidgetStack(parent); |
62 | * load widget? | 78 | session->setWidgetStack( stack ); |
63 | * set colors + fonts | 79 | QWidget* dummy = new QWidget(stack ); |
64 | */ | 80 | QHBoxLayout* lay = new QHBoxLayout(dummy ); |
81 | stack->addWidget( dummy, 0 ); | ||
82 | stack->raiseWidget( 0 ); | ||
83 | Widget* wid = new Widget(dummy ); | ||
84 | lay->addWidget( wid ); | ||
85 | |||
86 | session->setEmulationWidget( wid ); | ||
87 | session->setEmulationLayer( m_fact->newEmulationLayer( m_fact->external( prof.terminalName() ), | ||
88 | wid ) ); | ||
89 | session->connect(); | ||
90 | |||
65 | return session; | 91 | return session; |
66 | } | 92 | } |
67 | void ProfileManager::save( ) { | 93 | void ProfileManager::save( ) { |
68 | QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); | 94 | QFile::remove( (QString(getenv("HOME") )+ "/Settings/opie-console-profiles.conf" ) ); |
69 | ProfileConfig conf("opie-console-profiles"); | 95 | ProfileConfig conf("opie-console-profiles"); |
70 | Profile::ValueList::Iterator it; | 96 | Profile::ValueList::Iterator it; |
71 | for (it = m_list.begin(); it != m_list.end(); ++it ) { | 97 | for (it = m_list.begin(); it != m_list.end(); ++it ) { |
72 | conf.setGroup( (*it).name() ); | 98 | conf.setGroup( (*it).name() ); |
73 | conf.writeEntry( "name", (*it).name() ); | 99 | conf.writeEntry( "name", (*it).name() ); |
74 | conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) ); | 100 | conf.writeEntry( "iolayer", QString::fromUtf8( (*it).ioLayerName() ) ); |
75 | conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); | 101 | conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); |
76 | conf.writeEntry( "back", (*it).background() ); | 102 | conf.writeEntry( "back", (*it).background() ); |
77 | conf.writeEntry( "fore", (*it).foreground() ); | 103 | conf.writeEntry( "fore", (*it).foreground() ); |
78 | conf.writeEntry( "terminal", (*it).terminal() ); | 104 | conf.writeEntry( "terminal", (*it).terminal() ); |
79 | /* now the config stuff */ | 105 | /* now the config stuff */ |
80 | QMap<QString, QString> map = (*it).conf(); | 106 | QMap<QString, QString> map = (*it).conf(); |
81 | QMap<QString, QString>::Iterator it; | 107 | QMap<QString, QString>::Iterator it; |
82 | for ( it = map.begin(); it != map.end(); ++it ) { | 108 | for ( it = map.begin(); it != map.end(); ++it ) { |
83 | conf.writeEntry( it.key(), it.data() ); | 109 | conf.writeEntry( it.key(), it.data() ); |
84 | } | 110 | } |
85 | } | 111 | } |
86 | } | 112 | } |
87 | void ProfileManager::setProfiles( const Profile::ValueList& list ) { | 113 | void ProfileManager::setProfiles( const Profile::ValueList& list ) { |
88 | m_list = list; | 114 | m_list = list; |