kandy Library API Documentation

mobilemain.cpp

00001 // $Id: mobilemain.cpp,v 1.3 2001/10/15 12:08:24 faure Exp $
00002 // Copyright (C) 2001 Cornelius Schumacher <schumacher@kde.org>
00003 
00004 #include <qdragobject.h>
00005 
00006 #include <kglobal.h>
00007 #include <klocale.h>
00008 #include <kiconloader.h>
00009 #include <kmenubar.h>
00010 #include <kkeydialog.h>
00011 #include <kaccel.h>
00012 #include <kconfig.h>
00013 #include <kdebug.h>
00014 #include <kmessagebox.h>
00015 #include <kstddirs.h>
00016 #include <kedittoolbar.h>
00017 
00018 #include <kstdaccel.h>
00019 #include <kaction.h>
00020 #include <kstdaction.h>
00021 
00022 #include "mobilegui.h"
00023 
00024 #include "mobilemain.h"
00025 #include <kstatusbar.h>
00026 #include "mobilemain.moc"
00027 
00028 MobileMain::MobileMain(CommandScheduler *scheduler)
00029     : KMainWindow( 0, "MobileMain" )
00030 {
00031   mView = new MobileGui(scheduler,this);
00032 
00033   setCentralWidget(mView);
00034   setupActions();
00035 
00036 //  statusBar()->insertItem(i18n(""),0,10);
00037 
00038   statusBar()->insertItem(i18n(" Disconnected "),1,0,true);
00039   connect(mView,SIGNAL(statusMessage(const QString &)),
00040           SLOT(showStatusMessage(const QString &)));
00041   connect(mView,SIGNAL(transientStatusMessage(const QString &)),
00042           SLOT(showTransientStatusMessage(const QString &)));
00043   statusBar()->show();
00044 }
00045 
00046 MobileMain::~MobileMain()
00047 {
00048 }
00049 
00050 void MobileMain::setupActions()
00051 {
00052   KStdAction::quit(this, SLOT(close()), actionCollection());
00053 
00054   new KAction(i18n("Terminal"),0,this,SLOT(showTerminal()),
00055               actionCollection(),"show_terminal");
00056 
00057   m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection());
00058   m_statusbarAction = KStdAction::showStatusbar(this, SLOT(optionsShowStatusbar()), actionCollection());
00059 
00060   KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
00061   KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
00062   KStdAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
00063 
00064   new KAction(i18n("Connect"),0,this,SIGNAL(modemConnect()),
00065               actionCollection(),"modem_connect");
00066   new KAction(i18n("Disconnect"),0,this,SIGNAL(modemDisconnect()),
00067               actionCollection(),"modem_disconnect");
00068 
00069   createGUI("kandymobileui.rc");
00070 }
00071 
00072 void MobileMain::saveProperties(KConfig */*config*/)
00073 {
00074     // the 'config' object points to the session managed
00075     // config file.  anything you write here will be available
00076     // later when this app is restored
00077 }
00078 
00079 void MobileMain::readProperties(KConfig */*config*/)
00080 {
00081     // the 'config' object points to the session managed
00082     // config file.  this function is automatically called whenever
00083     // the app is being restored.  read in here whatever you wrote
00084     // in 'saveProperties'
00085 }
00086 
00087 void MobileMain::dragEnterEvent(QDragEnterEvent *event)
00088 {
00089     // do nothing
00090     KMainWindow::dragEnterEvent(event);
00091 
00092     // accept uri drops only
00093 //    event->accept(QUriDrag::canDecode(event));
00094 }
00095 
00096 void MobileMain::dropEvent(QDropEvent *event)
00097 {
00098     // this is a very simplistic implementation of a drop event.  we
00099     // will only accept a dropped URL.  the Qt dnd code can do *much*
00100     // much more, so please read the docs there
00101 
00102     // do nothing
00103     KMainWindow::dropEvent(event);
00104 /*
00105     QStrList uri;
00106 
00107     // see if we can decode a URI.. if not, just ignore it
00108     if (QUriDrag::decode(event, uri))
00109     {
00110         // okay, we have a URI.. process it
00111         QString url, target;
00112         url = uri.first();
00113 
00114         // load in the file
00115         load(url);
00116     }
00117 */
00118 }
00119 
00120 
00121 void MobileMain::optionsShowToolbar()
00122 {
00123     // this is all very cut and paste code for showing/hiding the
00124     // toolbar
00125     if (m_toolbarAction->isChecked())
00126         toolBar()->show();
00127     else
00128         toolBar()->hide();
00129 }
00130 
00131 void MobileMain::optionsShowStatusbar()
00132 {
00133     // this is all very cut and paste code for showing/hiding the
00134     // statusbar
00135     if (m_statusbarAction->isChecked())
00136         statusBar()->show();
00137     else
00138         statusBar()->hide();
00139 }
00140 
00141 void MobileMain::optionsConfigureKeys()
00142 {
00143     KKeyDialog::configureKeys(actionCollection(),"kandymobileui.rc");
00144 }
00145 
00146 void MobileMain::optionsConfigureToolbars()
00147 {
00148     // use the standard toolbar editor
00149     KEditToolbar dlg(actionCollection());
00150     if (dlg.exec())
00151     {
00152         // recreate our GUI
00153         createGUI("kandymobileui.rc");
00154     }
00155 }
00156 
00157 void MobileMain::optionsPreferences()
00158 {
00159   emit showPreferencesWin();
00160 }
00161 
00162 void MobileMain::showStatusMessage(const QString& text)
00163 {
00164   // display the text on the statusbar
00165   statusBar()->message(text);
00166 }
00167 
00168 void MobileMain::showTransientStatusMessage(const QString& text)
00169 {
00170   // display the text on the statusbar for 2 s.
00171   statusBar()->message(text,2000);
00172 }
00173 
00174 void MobileMain::changeCaption(const QString& text)
00175 {
00176   // display the text on the caption
00177   setCaption(text);
00178 }
00179 
00180 bool MobileMain::queryClose()
00181 {
00182 #if 0
00183   if (m_view->isModified()) {
00184     switch (KMessageBox::warningYesNoCancel(this,
00185         i18n("Save changes to profile %1?").arg(mFilename))) {
00186       case KMessageBox::Yes :
00187         fileSave();
00188         return true;
00189       case KMessageBox::No :
00190         return true;
00191       default: // cancel
00192         return false;
00193     }
00194   } else {
00195     return true;
00196   }
00197 #endif
00198   return true;
00199 }
00200 
00201 void MobileMain::showTerminal()
00202 {
00203   emit showTerminalWin();
00204 }
00205 
00206 void MobileMain::setConnected(bool connected)
00207 {
00208   if (connected) {
00209     statusBar()->changeItem(i18n(" Connected "),1);
00210     mView->readModelInformation();
00211     mView->refreshStatus();
00212 
00213   } else {
00214     statusBar()->changeItem(i18n(" Disconnected "),1);
00215   }
00216 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:32 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001