author | zecke <zecke> | 2002-09-28 20:45:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-28 20:45:11 (UTC) |
commit | 7980189a2cb34e2864c339ef68bfbe7fb4910750 (patch) (side-by-side diff) | |
tree | a14028faccc70982d105c229f84d77e13741e987 | |
parent | b6df65ad2ffb50f029b96ebf9d0d78dfa23f3f19 (diff) | |
download | opie-7980189a2cb34e2864c339ef68bfbe7fb4910750.zip opie-7980189a2cb34e2864c339ef68bfbe7fb4910750.tar.gz opie-7980189a2cb34e2864c339ef68bfbe7fb4910750.tar.bz2 |
Add profiles and the profilemanager to the mainwindow
if one would have a ConfigureDialog one could see it....
-rw-r--r-- | noncore/apps/opie-console/mainwindow.cpp | 33 | ||||
-rw-r--r-- | noncore/apps/opie-console/mainwindow.h | 10 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileconfig.cpp | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/profilemanager.cpp | 2 |
4 files changed, 46 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 1ae4a20..3c1c8ea 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp @@ -1,123 +1,156 @@ #include <qaction.h> #include <qmenubar.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qtoolbar.h> #include "metafactory.h" +#include "profilemanager.h" #include "mainwindow.h" MainWindow::MainWindow() { m_factory = new MetaFactory(); m_sessions.setAutoDelete( TRUE ); m_curSession = 0; + m_manager = new ProfileManager(m_factory); initUI(); + populateProfiles(); } void MainWindow::initUI() { setToolBarsMovable( FALSE ); m_tool = new QToolBar( this ); m_tool->setHorizontalStretchable( TRUE ); m_bar = new QMenuBar( m_tool ); m_console = new QPopupMenu( this ); m_sessionsPop= new QPopupMenu( this ); m_settings = new QPopupMenu( this ); /* * new Action for new sessions */ QAction* a = new QAction(); a->setText( tr("New Connection") ); a->addTo( m_console ); connect(a, SIGNAL(activated() ), this, SLOT(slotNew() ) ); /* * connect action */ m_connect = new QAction(); m_connect->setText( tr("Connect") ); m_connect->addTo( m_console ); connect(m_connect, SIGNAL(activated() ), this, SLOT(slotConnect() ) ); /* * disconnect action */ m_disconnect = new QAction(); m_disconnect->setText( tr("Disconnect") ); m_disconnect->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotDisconnect() ) ); /* * terminate action */ m_terminate = new QAction(); m_terminate->setText( tr("Terminate") ); m_terminate->addTo( m_console ); connect(m_disconnect, SIGNAL(activated() ), this, SLOT(slotTerminate() ) ); + a = new QAction(); + a->setText( tr("Close Window") ); + a->addTo( m_console ); + connect(a, SIGNAL(activated() ), + this, SLOT(slotClose() ) ); + /* * the settings action */ m_setProfiles = new QAction(); m_setProfiles->setText( tr("Configure Profiles") ); m_setProfiles->addTo( m_settings ); connect( m_setProfiles, SIGNAL(activated() ), this, SLOT(slotConfigure() ) ); /* insert the submenu */ m_console->insertItem(tr("New from Profile"), m_sessionsPop, -1, 0); /* insert the connection menu */ m_bar->insertItem( tr("Connection"), m_console ); /* the settings menu */ m_bar->insertItem( tr("Settings"), m_settings ); + /* + * connect to the menu activation + */ + connect( m_sessionsPop, SIGNAL(activated(int) ), + this, SLOT(slotProfile(int) ) ); + +} +ProfileManager* MainWindow::manager() { + return m_manager; +} +void MainWindow::populateProfiles() { + manager()->load(); + Profile::ValueList list = manager()->all(); + for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); + ++it ) { + m_sessionsPop->insertItem( (*it).name() ); + } + } MainWindow::~MainWindow() { delete m_factory; } MetaFactory* MainWindow::factory() { return m_factory; } Session* MainWindow::currentSession() { return m_curSession; } QList<Session> MainWindow::sessions() { return m_sessions; } void MainWindow::slotNew() { qWarning("New Connection"); } void MainWindow::slotConnect() { if ( currentSession() ) currentSession()->layer()->open(); } void MainWindow::slotDisconnect() { if ( currentSession() ) currentSession()->layer()->close(); } void MainWindow::slotTerminate() { if ( currentSession() ) currentSession()->layer()->close(); delete m_curSession; m_curSession = 0l; /* FIXME move to the next session */ } void MainWindow::slotConfigure() { qWarning("configure"); } +void MainWindow::slotClose() { + +} +void MainWindow::slotProfile(int) { + +} diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h index b6a8419..be4b469 100644 --- a/noncore/apps/opie-console/mainwindow.h +++ b/noncore/apps/opie-console/mainwindow.h @@ -1,79 +1,89 @@ #ifndef OPIE_MAIN_WINDOW_H #define OPIE_MAIN_WINDOW_H #include <qmainwindow.h> #include <qlist.h> #include "session.h" /** * this is the MainWindow of the new opie console * it's also the dispatcher between the different * actions supported by the gui */ class QToolBar; class QMenuBar; class QAction; class MetaFactory; +class ProfileManager; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( ); ~MainWindow(); /** * our factory to generate IOLayer and so on * */ MetaFactory* factory(); /** * A session contains a QWidget*, * an IOLayer* and some infos for us */ Session* currentSession(); /** * the session list */ QList<Session> sessions(); + /** + * + */ + ProfileManager* manager(); + private slots: void slotNew(); void slotConnect(); void slotDisconnect(); void slotTerminate(); void slotConfigure(); + void slotClose(); + void slotProfile(int); private: void initUI(); + void populateProfiles(); /** * the current session */ Session* m_curSession; /** * the session list */ QList<Session> m_sessions; /** * the metafactory */ MetaFactory* m_factory; + ProfileManager* m_manager; QToolBar* m_tool; QMenuBar* m_bar; QPopupMenu* m_console; QPopupMenu* m_settings; QPopupMenu* m_sessionsPop; QAction* m_connect; QAction* m_disconnect; QAction* m_terminate; QAction* m_setProfiles; }; #endif diff --git a/noncore/apps/opie-console/profileconfig.cpp b/noncore/apps/opie-console/profileconfig.cpp index bd089c8..732fae7 100644 --- a/noncore/apps/opie-console/profileconfig.cpp +++ b/noncore/apps/opie-console/profileconfig.cpp @@ -1,45 +1,46 @@ #include "profileconfig.h" ProfileConfig::ProfileConfig( const QString& prof ) : Config( prof ) { } ProfileConfig::~ProfileConfig() { } QStringList ProfileConfig::groups()const { QStringList list; QMap<QString, ConfigGroup>::ConstIterator it; it= Config::groups.begin(); + qWarning("config %d", Config::groups.count() ); for (; it != Config::groups.end(); ++it ) list << it.key(); return list; } void ProfileConfig::clearAll() { QMap<QString, ConfigGroup>::ConstIterator it; it = Config::groups.begin(); for ( ; it != Config::groups.end(); ++it ) clearGroup( it.key() ); } void ProfileConfig::clearGroup( const QString& str ) { QString cur =git.key(); setGroup( str ); Config::clearGroup(); setGroup( cur ); } QMap<QString, QString> ProfileConfig::items( const QString& group )const { QMap<QString, QString> map; QMap<QString, ConfigGroup>::ConstIterator it; it = Config::groups.find( group ); if (it != Config::groups.end() ) map = it.data(); return map; } diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index c8a4db5..24256a5 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp @@ -1,78 +1,80 @@ #include <qpe/config.h> #include "metafactory.h" #include "profileconfig.h" #include "profilemanager.h" ProfileManager::ProfileManager( MetaFactory* fact ) : m_fact( fact ) { } ProfileManager::~ProfileManager() { } void ProfileManager::load() { m_list.clear(); + qWarning("load"); ProfileConfig conf("opie-console-profiles"); QStringList groups = conf.groups(); QStringList::Iterator it; /* * for each profile */ for ( it = groups.begin(); it != groups.end(); ++it ) { + qWarning("group " + (*it) ); conf.setGroup( (*it) ); Profile prof; prof.setName( conf.readEntry("name") ); prof.setIOLayer( conf.readEntry("iolayer") ); prof.setBackground( conf.readNumEntry("back") ); prof.setForeground( conf.readNumEntry("fore") ); prof.setTerminal( conf.readNumEntry("terminal") ); prof.setConf( conf.items( (*it) ) ); /* now add it */ m_list.append( prof ); } } void ProfileManager::clear() { m_list.clear(); } Profile::ValueList ProfileManager::all()const { return m_list; } Session* ProfileManager::fromProfile( const Profile& prof) { Session* session = new Session(); session->setName( prof.name() ); session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), prof) ); /* * FIXME * load emulation * load widget? * set colors + fonts */ return session; } void ProfileManager::save( ) { ProfileConfig conf("opie-console-profiles"); conf.clearAll(); Profile::ValueList::Iterator it; for (it = m_list.begin(); it != m_list.end(); ++it ) { conf.setGroup( (*it).name() ); conf.writeEntry( "name", (*it).name() ); conf.writeEntry( "ioplayer", (*it).ioLayerName() ); conf.writeEntry( "back", (*it).background() ); conf.writeEntry( "fore", (*it).foreground() ); conf.writeEntry( "terminal", (*it).terminal() ); /* now the config stuff */ QMap<QString, QString> map = (*it).conf(); QMap<QString, QString>::Iterator it; for ( it = map.begin(); it != map.end(); ++it ) { conf.writeEntry( it.key(), it.data() ); } } // FIXME save } |