summaryrefslogtreecommitdiff
authorzecke <zecke>2004-05-01 21:10:02 (UTC)
committer zecke <zecke>2004-05-01 21:10:02 (UTC)
commit49227638e76fa71209390a9c42528a02e3803e3d (patch) (side-by-side diff)
tree3fbbf00962bbb2698e63a196a83fb156443bafd3
parent0d4fd8b708eddb609fd3b14ffe7df1cb3a1401f1 (diff)
downloadopie-49227638e76fa71209390a9c42528a02e3803e3d.zip
opie-49227638e76fa71209390a9c42528a02e3803e3d.tar.gz
opie-49227638e76fa71209390a9c42528a02e3803e3d.tar.bz2
Convert to quicklaunch. Integrate the Sharp ROM fixlet in c'tor and d'tor
of the mainwindow
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/fixit.h88
-rw-r--r--noncore/apps/opie-console/main.cpp106
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp19
-rw-r--r--noncore/apps/opie-console/mainwindow.h1
-rw-r--r--noncore/apps/opie-console/opie-console.pro4
5 files changed, 107 insertions, 111 deletions
diff --git a/noncore/apps/opie-console/fixit.h b/noncore/apps/opie-console/fixit.h
new file mode 100644
index 0000000..501914e
--- a/dev/null
+++ b/noncore/apps/opie-console/fixit.h
@@ -0,0 +1,88 @@
+#ifndef FIX_IT_H
+#define FIX_IT_H
+
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <qfile.h>
+
+/*
+ * The Zaurus rom
+ */
+class FixIt {
+public:
+ FixIt();
+ ~FixIt();
+ void fixIt();
+ /* no real interested in implementing it */
+ void breakIt() {
+
+ };
+ char* m_file;
+};
+
+FixIt::FixIt() {
+ /* the new inittab */
+ m_file = "#\n# /etc/inittab"
+"#"
+""
+"# 0 - halt (Do NOT set initdefault to this)"
+"# 1 - Single user mode"
+"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
+"# 3 - Full multiuser mode"
+"# 4 - JavaVM(Intent) developer mode"
+"# 5 - JavaVM(Intent)"
+"# 6 - reboot (Do NOT set initdefault to this)"
+"#"
+"id:5:initdefault:"
+""
+"# Specify things to do when starting"
+"si::sysinit:/etc/rc.d/rc.sysinit"
+""
+"l0:0:wait:/root/etc/rc.d/rc 0"
+"l1:1:wait:/etc/rc.d/rc 1"
+"l2:2:wait:/etc/rc.d/rc 2"
+"l3:3:wait:/etc/rc.d/rc 3"
+"l4:4:wait:/etc/rc.d/rc 4"
+"l5:5:wait:/etc/rc.d/rc 5"
+"l6:6:wait:/root/etc/rc.d/rc 6"
+""
+"# Specify things to do before rebooting"
+"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
+"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
+""
+"# Specify program to run on ttyS0"
+"s0:24:respawn:/sbin/getty 9600 ttyS0"
+"#pd:5:respawn:/etc/sync/serialctl"
+""
+"# Specify program to run on tty1"
+"1:2:respawn:/sbin/getty 9600 tty1"
+"ln:345:respawn:survive -l 6 /sbin/launch"
+"#qt:5:respawn:/sbin/qt"
+""
+"# collie sp."
+"sy::respawn:/sbin/shsync\n";
+
+}
+FixIt::~FixIt() {
+}
+/*
+ * the retail Zaurus is broken in many ways
+ * one is that pppd is listening on our port...
+ * we've to stop it from that and then do kill(SIGHUP,1);
+ */
+void FixIt::fixIt() {
+ ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
+ QFile file( "/etc/inittab" );
+ if ( file.open(IO_WriteOnly | IO_Raw ) ) {
+ file.writeBlock(m_file,strlen(m_file) );
+ }
+ file.close();
+ ::kill( SIGHUP, 1 );
+}
+
+
+#endif
diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp
index 92921ab..eafc9b2 100644
--- a/noncore/apps/opie-console/main.cpp
+++ b/noncore/apps/opie-console/main.cpp
@@ -1,110 +1,8 @@
-#include <sys/types.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <qfile.h>
-
-#include <qpe/qpeapplication.h>
+#include <opie2/oapplicationfactory.h>
#include "mainwindow.h"
-// #define FSCKED_DISTRIBUTION 1
-#ifdef FSCKED_DISTRIBUTION
-/*
- * The Zaurus rom
- */
-class FixIt {
-public:
- FixIt();
- ~FixIt();
- void fixIt();
- /* no real interested in implementing it */
- void breakIt() {
-
- };
- char* m_file;
-};
-
-FixIt::FixIt() {
- /* the new inittab */
- m_file = "#\n# /etc/inittab"
-"#"
-""
-"# 0 - halt (Do NOT set initdefault to this)"
-"# 1 - Single user mode"
-"# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)"
-"# 3 - Full multiuser mode"
-"# 4 - JavaVM(Intent) developer mode"
-"# 5 - JavaVM(Intent)"
-"# 6 - reboot (Do NOT set initdefault to this)"
-"#"
-"id:5:initdefault:"
-""
-"# Specify things to do when starting"
-"si::sysinit:/etc/rc.d/rc.sysinit"
-""
-"l0:0:wait:/root/etc/rc.d/rc 0"
-"l1:1:wait:/etc/rc.d/rc 1"
-"l2:2:wait:/etc/rc.d/rc 2"
-"l3:3:wait:/etc/rc.d/rc 3"
-"l4:4:wait:/etc/rc.d/rc 4"
-"l5:5:wait:/etc/rc.d/rc 5"
-"l6:6:wait:/root/etc/rc.d/rc 6"
-""
-"# Specify things to do before rebooting"
-"um::ctrlaltdel:/bin/umount -a -r > /dev/null 2>&1"
-"sw::ctrlaltdel:/sbin/swapoff -a > /dev/null 2>&1"
-""
-"# Specify program to run on ttyS0"
-"s0:24:respawn:/sbin/getty 9600 ttyS0"
-"#pd:5:respawn:/etc/sync/serialctl"
-""
-"# Specify program to run on tty1"
-"1:2:respawn:/sbin/getty 9600 tty1"
-"ln:345:respawn:survive -l 6 /sbin/launch"
-"#qt:5:respawn:/sbin/qt"
-""
-"# collie sp."
-"sy::respawn:/sbin/shsync\n";
-}
-FixIt::~FixIt() {
-}
-/*
- * the retail Zaurus is broken in many ways
- * one is that pppd is listening on our port...
- * we've to stop it from that and then do kill(SIGHUP,1);
- */
-void FixIt::fixIt() {
- ::rename("/etc/inittab", QPEApplication::qpeDir() + "/etc/inittab" );
- QFile file( "/etc/inittab" );
- if ( file.open(IO_WriteOnly | IO_Raw ) ) {
- file.writeBlock(m_file,strlen(m_file) );
- }
- file.close();
- ::kill( SIGHUP, 1 );
-}
-#endif
-
-int main(int argc, char **argv) {
-// too bad this gives us trouble the taskbar... argv[0]="embeddedkonsole";
- QPEApplication app( argc, argv );
-
-#ifdef FSCKED_DISTRIBUTION
-// owarn << "fscked" << oendl;
- FixIt it;
- it.fixIt();
-#endif
- MainWindow mw;
- mw.setCaption(QObject::tr("Opie Console") );
- app.showMainWidget( &mw );
+OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MainWindow> );
- int ap = app.exec();
-#ifdef FSCKED_DISTRIBUTION
- /* should add a signal handler too */
- it.breakIt();
-#endif
- return ap;
-}
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index b403b4d..b160604 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -1,79 +1,86 @@
#include "TEmulation.h"
#include "profileeditordialog.h"
#include "configdialog.h"
#include "default.h"
#include "profilemanager.h"
#include "mainwindow.h"
#include "tabwidget.h"
#include "transferdialog.h"
#include "function_keyboard.h"
#include "emulation_handler.h"
#include "script.h"
+#include "fixit.h"
/* OPIE */
#include <opie2/odebug.h>
#include <opie2/ofiledialog.h>
#include <qpe/filemanager.h>
using namespace Opie::Core;
using namespace Opie::Ui;
/* QT */
#include <qaction.h>
#include <qmenubar.h>
#include <qtoolbar.h>
#include <qmessagebox.h>
#include <qwhatsthis.h>
#include <qfileinfo.h>
/* STD */
#include <assert.h>
MainWindow::MainWindow(QWidget *parent, const char *name, WFlags) : QMainWindow(parent, name, WStyle_ContextHelp) {
+#ifdef FSCKED_DISTRI
+ FixIt fix;
+ fix.fixIt();
+#endif
+
+ setCaption(QObject::tr("Opie Console") );
KeyTrans::loadAll();
for (int i = 0; i < KeyTrans::count(); i++ ) {
KeyTrans* s = KeyTrans::find(i );
assert( s );
}
m_factory = new MetaFactory();
Default def(m_factory);
m_sessions.setAutoDelete( TRUE );
m_curSession = 0;
m_manager = new ProfileManager( m_factory );
m_manager->load();
m_scriptsData.setAutoDelete(TRUE);
initUI();
populateProfiles();
populateScripts();
}
void MainWindow::initUI() {
setToolBarsMovable( FALSE );
/* tool bar for the menu */
m_tool = new QToolBar( this );
m_tool->setHorizontalStretchable( TRUE );
m_bar = new QMenuBar( m_tool );
m_console = new QPopupMenu( this );
m_scripts = new QPopupMenu( this );
m_sessionsPop= new QPopupMenu( this );
m_scriptsPop = new QPopupMenu( this );
/* add a toolbar for icons */
m_icons = new QToolBar(this);
/*
* the settings action
*/
m_setProfiles = new QAction(tr("Configure Profiles"),
Resource::loadPixmap( "SettingsIcon" ),
QString::null, 0, this, 0);
m_setProfiles->addTo( m_console );
connect( m_setProfiles, SIGNAL(activated() ),
this, SLOT(slotConfigure() ) );
m_console->insertSeparator();
/*
* new Action for new sessions
@@ -253,96 +260,100 @@ void MainWindow::initUI() {
* connect to the menu activation
*/
connect( m_sessionsPop, SIGNAL(activated(int) ),
this, SLOT(slotProfile(int) ) );
m_consoleWindow = new TabWidget( this, "blah");
connect(m_consoleWindow, SIGNAL(activated(Session*) ),
this, SLOT(slotSessionChanged(Session*) ) );
setCentralWidget( m_consoleWindow );
slotQuickLaunch();
}
ProfileManager* MainWindow::manager() {
return m_manager;
}
TabWidget* MainWindow::tabWidget() {
return m_consoleWindow;
}
void MainWindow::populateProfiles() {
m_sessionsPop->clear();
Profile::ValueList list = manager()->all();
for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
m_sessionsPop->insertItem( (*it).name() );
}
}
void MainWindow::populateScripts() {
m_scriptsPop->clear();
m_scriptsData.clear();
DocLnkSet files(QPEApplication::documentDir(), "text/plain");
QListIterator<DocLnk> dit(files.children());
for (; dit.current(); ++dit) {
if (*dit && (*dit)->name().length()>0) {
QFileInfo info((*dit)->file());
if (info.extension(false) == "script") {
m_scriptsData.append(new DocLnk(**dit));
m_scriptsPop->insertItem((*dit)->name());
}
}
}
}
MainWindow::~MainWindow() {
delete m_factory;
manager()->save();
+#ifdef FSCKED_DISTRI
+ FixIt fix;
+ fix.breakIt();
+#endif
}
MetaFactory* MainWindow::factory() {
return m_factory;
}
Session* MainWindow::currentSession() {
return m_curSession;
}
QList<Session> MainWindow::sessions() {
return m_sessions;
}
void MainWindow::slotNew() {
ProfileEditorDialog dlg(factory() );
dlg.setCaption( tr("New Connection") );
int ret = QPEApplication::execDialog( &dlg );
if ( ret == QDialog::Accepted ) {
create( dlg.profile() );
}
}
void MainWindow::slotRecordScript() {
if (currentSession()) {
currentSession()->emulationHandler()->startRecording();
m_saveScript->setEnabled(true);
m_recordScript->setEnabled(false);
}
}
void MainWindow::slotSaveScript() {
if (currentSession() && currentSession()->emulationHandler()->isRecording()) {
QMap<QString, QStringList> map;
QStringList text;
text << "text/plain";
map.insert(tr("Script"), text );
QString filename = OFileDialog::getSaveFileName(2, QPEApplication::documentDir(), QString::null, map);
if (!filename.isEmpty()) {
QFileInfo info(filename);
if (info.extension(FALSE) != "script")
filename += ".script";
DocLnk nf;
nf.setType("text/plain");
nf.setFile(filename);
nf.setName(info.fileName());
FileManager fm;
@@ -404,103 +415,103 @@ void MainWindow::slotTerminate() {
if ( currentSession() )
currentSession()->layer()->close();
slotClose();
/* FIXME move to the next session */
}
void MainWindow::slotQuickLaunch() {
Profile prof = manager()->profile( "default" );
if ( prof.name() == "default" ) {
create( prof );
} else {
Profile newProf = Profile( "default", "console", "default" , 0, 3, 0 );
newProf.setAutoConnect( true );
create( newProf );
slotSaveSession();
}
}
void MainWindow::slotConfigure() {
ConfigDialog conf( manager()->all(), factory() );
int ret = QPEApplication::execDialog( &conf );
if ( QDialog::Accepted == ret ) {
manager()->setProfiles( conf.list() );
manager()->save();
populateProfiles();
}
}
/*
* we will remove
* this window from the tabwidget
* remove it from the list
* delete it
* and set the currentSession()
*/
void MainWindow::slotClose() {
if (!currentSession() )
return;
Session* ses = currentSession();
- owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl;
+ owarn << "removing! currentSession " << currentSession()->name().latin1() << "" << oendl;
/* set to NULL to be safe, if its needed slotSessionChanged resets it automatically */
m_curSession = NULL;
tabWidget()->remove( /*currentSession()*/ses );
/*it's autodelete */
m_sessions.remove( ses );
- owarn << "after remove!!" << oendl;
+ owarn << "after remove!!" << oendl;
if (!currentSession() ) {
m_connect->setEnabled( false );
m_disconnect->setEnabled( false );
m_terminate->setEnabled( false );
m_transfer->setEnabled( false );
m_recordScript->setEnabled( false );
m_saveScript->setEnabled( false );
m_scripts->setItemEnabled(m_runScript_id, false);
m_fullscreen->setEnabled( false );
m_wrap->setEnabled( false );
m_closewindow->setEnabled( false );
}
m_kb->loadDefaults();
}
/*
* We will get the name
* Then the profile
* and then we will make a profile
*/
void MainWindow::slotProfile( int id) {
Profile prof = manager()->profile( m_sessionsPop->text( id) );
create( prof );
}
void MainWindow::create( const Profile& prof ) {
if(m_curSession)
if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
Session *ses = manager()->fromProfile( prof, tabWidget() );
if((!ses) || (!ses->layer()) || (!ses->widgetStack()))
{
QMessageBox::warning(this,
QObject::tr("Session failed"),
QObject::tr("<qt>Cannot open session: Not all components were found.</qt>"));
//if(ses) delete ses;
return;
}
m_sessions.append( ses );
tabWidget()->add( ses );
tabWidget()->repaint();
m_curSession = ses;
@@ -528,106 +539,106 @@ void MainWindow::create( const Profile& prof ) {
if(w) w->setFocus();
if(currentSession()->profile().readNumEntry("Wrap", 80)){
m_isWrapped = true;
} else {
m_isWrapped = false;
}
m_kb->load(currentSession()->profile());
}
void MainWindow::slotTransfer()
{
if ( currentSession() ) {
Session *mysession = currentSession();
TransferDialog dlg(/*mysession->widgetStack()*/this, this);
mysession->setTransferDialog(&dlg);
//dlg.reparent(mysession->widgetStack(), QPoint(0, 0));
//dlg.showMaximized();
currentSession()->widgetStack()->addWidget(&dlg, -1);
dlg.show();
//dlg.exec();
while(dlg.isRunning()) qApp->processEvents();
mysession->setTransferDialog(0l);
}
}
void MainWindow::slotOpenKeb(bool state) {
if (state) m_keyBar->show();
else m_keyBar->hide();
}
void MainWindow::slotOpenButtons( bool state ) {
if ( state ) {
m_buttonBar->show();
} else {
m_buttonBar->hide();
}
}
void MainWindow::slotSessionChanged( Session* ses ) {
- owarn << "changed!" << oendl;
+ owarn << "changed!" << oendl;
if(m_curSession)
if(m_curSession->transferDialog()) m_curSession->transferDialog()->hide();
if(ses)
if(ses->transferDialog()) ses->transferDialog()->show();
if ( ses ) {
m_curSession = ses;
- odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl;
+ odebug << QString("is connected : %1").arg( m_curSession->layer()->isConnected() ) << oendl;
if ( m_curSession->layer()->isConnected() ) {
m_connect->setEnabled( false );
m_disconnect->setEnabled( true );
m_recordScript->setEnabled(!m_curSession->emulationHandler()->isRecording());
m_saveScript->setEnabled(m_curSession->emulationHandler()->isRecording());
m_scripts->setItemEnabled(m_runScript_id, true);
} else {
m_connect->setEnabled( true );
m_disconnect->setEnabled( false );
m_recordScript->setEnabled( false );
m_saveScript->setEnabled( false );
m_scripts->setItemEnabled(m_runScript_id, false);
}
if ( ( m_curSession->layer() )->supports()[1] == 0 ) {
m_transfer->setEnabled( false );
} else {
m_transfer->setEnabled( true );
}
QWidget *w = m_curSession->widget();
if(w) w->setFocus();
if(currentSession()->profile().readNumEntry("Wrap", 80)){
m_isWrapped = true;
} else {
m_isWrapped = false;
}
m_kb->load(currentSession()->profile());
}
}
void MainWindow::slotWrap()
{
if(m_curSession)
{
EmulationHandler *e = m_curSession->emulationHandler();
if(e)
{
if(m_isWrapped)
{
e->setWrap(80);
m_isWrapped = false;
}
else
{
e->setWrap(0);
diff --git a/noncore/apps/opie-console/mainwindow.h b/noncore/apps/opie-console/mainwindow.h
index 86939c1..b1f175a 100644
--- a/noncore/apps/opie-console/mainwindow.h
+++ b/noncore/apps/opie-console/mainwindow.h
@@ -1,78 +1,79 @@
#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 QToolButton;
class QMenuBar;
class QAction;
class MetaFactory;
class TabWidget;
class ProfileManager;
class Profile;
class FunctionKeyboard;
class FKey;
class DocLnk;
class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
~MainWindow();
+ static QString appName() {return QString::fromLatin1("console"); }
/**
* 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();
TabWidget* tabWidget();
private slots:
void slotNew();
void slotConnect();
void slotDisconnect();
void slotTerminate();
void slotConfigure();
void slotClose();
void slotProfile(int);
void slotTransfer();
void slotOpenKeb(bool);
void slotOpenButtons(bool);
void slotRecordScript();
void slotSaveScript();
void slotRunScript(int);
void slotFullscreen();
void slotQuickLaunch();
void slotWrap();
void slotSessionChanged( Session* );
void slotKeyReceived(FKey, ushort, ushort, bool);
void slotSaveHistory();
/* what could these both slot do? */
void slotCopy();
void slotPaste();
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 8268b01..baa5a55 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -1,51 +1,49 @@
-TEMPLATE = app
-CONFIG += qt warn_on
-DESTDIR = $(OPIEDIR)/bin
+CONFIG += qt warn_on quick-app
HEADERS = io_layer.h io_serial.h io_irda.h io_bt.h io_modem.h \
file_layer.h filetransfer.h \
metafactory.h \
session.h \
mainwindow.h \
profile.h \
profileconfig.h \
profilemanager.h \
tabwidget.h \
configdialog.h \
keytrans.h \
transferdialog.h \
profiledialogwidget.h \
profileeditordialog.h \
default.h \
iolayerbase.h \
serialconfigwidget.h irdaconfigwidget.h \
btconfigwidget.h modemconfigwidget.h \
atconfigdialog.h dialdialog.h \
procctl.h \
function_keyboard.h \
receive_layer.h filereceive.h \
script.h \
dialer.h \
terminalwidget.h \
emulation_handler.h TECommon.h \
TEHistory.h TEScreen.h TEWidget.h \
TEmuVt102.h TEmulation.h MyPty.h \
consoleconfigwidget.h
SOURCES = io_layer.cpp io_serial.cpp io_irda.cpp io_bt.cpp io_modem.cpp \
file_layer.cpp filetransfer.cpp \
main.cpp \
metafactory.cpp \
session.cpp \
mainwindow.cpp \
profile.cpp \
profileconfig.cpp \
profilemanager.cpp \
tabwidget.cpp \
configdialog.cpp \
keytrans.cpp \
transferdialog.cpp \
profiledialogwidget.cpp \
profileeditordialog.cpp \
iolayerbase.cpp \
serialconfigwidget.cpp irdaconfigwidget.cpp \
btconfigwidget.cpp modemconfigwidget.cpp \