kandy Library API Documentation

mobilemain.cpp

00001 /* 00002 This file is part of Kandy. 00003 00004 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 00023 */ 00024 00025 #include <kglobal.h> 00026 #include <klocale.h> 00027 #include <kiconloader.h> 00028 #include <kmenubar.h> 00029 #include <kkeydialog.h> 00030 #include <kaccel.h> 00031 #include <kconfig.h> 00032 #include <kdebug.h> 00033 #include <kmessagebox.h> 00034 #include <kstandarddirs.h> 00035 #include <kedittoolbar.h> 00036 #include <kurldrag.h> 00037 00038 #include <kstdaccel.h> 00039 #include <kaction.h> 00040 #include <kstdaction.h> 00041 00042 #include "mobilegui.h" 00043 00044 #include "mobilemain.h" 00045 #include <kstatusbar.h> 00046 #include "mobilemain.moc" 00047 00048 MobileMain::MobileMain(CommandScheduler *scheduler) 00049 : KMainWindow( 0, "MobileMain" ) 00050 { 00051 mView = new MobileGui(scheduler,this); 00052 00053 setCentralWidget(mView); 00054 setupActions(); 00055 00056 // statusBar()->insertItem(i18n(""),0,10); 00057 00058 statusBar()->insertItem(i18n(" Disconnected "),1,0,true); 00059 connect(mView,SIGNAL(statusMessage(const QString &)), 00060 SLOT(showStatusMessage(const QString &))); 00061 connect(mView,SIGNAL(transientStatusMessage(const QString &)), 00062 SLOT(showTransientStatusMessage(const QString &))); 00063 statusBar()->show(); 00064 00065 setAutoSaveSettings(); 00066 } 00067 00068 MobileMain::~MobileMain() 00069 { 00070 } 00071 00072 void MobileMain::setupActions() 00073 { 00074 KStdAction::quit(this, SLOT(close()), actionCollection()); 00075 00076 new KAction(i18n("Terminal"),0,this,SLOT(showTerminal()), 00077 actionCollection(),"show_terminal"); 00078 00079 createStandardStatusBarAction(); 00080 setStandardToolBarMenuEnabled(true); 00081 00082 KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection()); 00083 KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection()); 00084 KStdAction::preferences(this, SLOT(optionsPreferences()), actionCollection()); 00085 00086 new KAction(i18n("Connect"),0,this,SIGNAL(modemConnect()), 00087 actionCollection(),"modem_connect"); 00088 new KAction(i18n("Disconnect"),0,this,SIGNAL(modemDisconnect()), 00089 actionCollection(),"modem_disconnect"); 00090 00091 createGUI("kandymobileui.rc"); 00092 } 00093 00094 void MobileMain::saveProperties(KConfig */*config*/) 00095 { 00096 // the 'config' object points to the session managed 00097 // config file. anything you write here will be available 00098 // later when this app is restored 00099 } 00100 00101 void MobileMain::readProperties(KConfig */*config*/) 00102 { 00103 // the 'config' object points to the session managed 00104 // config file. this function is automatically called whenever 00105 // the app is being restored. read in here whatever you wrote 00106 // in 'saveProperties' 00107 } 00108 00109 void MobileMain::dragEnterEvent(QDragEnterEvent *event) 00110 { 00111 // do nothing 00112 KMainWindow::dragEnterEvent(event); 00113 00114 // accept uri drops only 00115 // event->accept(KURLDrag::canDecode(event)); 00116 } 00117 00118 void MobileMain::dropEvent(QDropEvent *event) 00119 { 00120 // this is a very simplistic implementation of a drop event. we 00121 // will only accept a dropped URL. the Qt dnd code can do *much* 00122 // much more, so please read the docs there 00123 00124 // do nothing 00125 KMainWindow::dropEvent(event); 00126 /* 00127 KURL::List list; 00128 00129 // see if we can decode a URI.. if not, just ignore it 00130 if (KURLDrag::decode(event, list) && !list.isEmpty()) 00131 { 00132 const KURL &url = uri.first(); 00133 00134 if (url.isLocalFile()) 00135 { 00136 // load in the file 00137 load(url.path()); 00138 } 00139 } 00140 */ 00141 } 00142 00143 void MobileMain::optionsConfigureKeys() 00144 { 00145 KKeyDialog::configure( actionCollection(), this ); 00146 } 00147 00148 void MobileMain::optionsConfigureToolbars() 00149 { 00150 // use the standard toolbar editor 00151 saveMainWindowSettings( KGlobal::config(), autoSaveGroup() ); 00152 KEditToolbar dlg(actionCollection()); 00153 connect(&dlg, SIGNAL(newToolbarConfig()), this, SLOT(newToolbarConfig())); 00154 dlg.exec(); 00155 } 00156 00157 void MobileMain::newToolbarConfig() 00158 { 00159 // recreate our GUI 00160 createGUI("kandymobileui.rc"); 00161 applyMainWindowSettings( KGlobal::config(), autoSaveGroup() ); 00162 } 00163 00164 void MobileMain::optionsPreferences() 00165 { 00166 emit showPreferencesWin(); 00167 } 00168 00169 void MobileMain::showStatusMessage(const QString& text) 00170 { 00171 // display the text on the statusbar 00172 statusBar()->message(text); 00173 } 00174 00175 void MobileMain::showTransientStatusMessage(const QString& text) 00176 { 00177 // display the text on the statusbar for 2 s. 00178 statusBar()->message(text,2000); 00179 } 00180 00181 void MobileMain::changeCaption(const QString& text) 00182 { 00183 // display the text on the caption 00184 setCaption(text); 00185 } 00186 00187 bool MobileMain::queryClose() 00188 { 00189 #if 0 00190 if (m_view->isModified()) { 00191 switch (KMessageBox::warningYesNoCancel(this, 00192 i18n("Save changes to profile %1?").arg(mFilename))) { 00193 case KMessageBox::Yes : 00194 fileSave(); 00195 return true; 00196 case KMessageBox::No : 00197 return true; 00198 default: // cancel 00199 return false; 00200 } 00201 } else { 00202 return true; 00203 } 00204 #endif 00205 return true; 00206 } 00207 00208 void MobileMain::showTerminal() 00209 { 00210 emit showTerminalWin(); 00211 } 00212 00213 void MobileMain::setConnected(bool connected) 00214 { 00215 if (connected) { 00216 statusBar()->changeItem(i18n(" Connected "),1); 00217 mView->readModelInformation(); 00218 mView->refreshStatus(); 00219 00220 } else { 00221 statusBar()->changeItem(i18n(" Disconnected "),1); 00222 } 00223 }
KDE Logo
This file is part of the documentation for kandy Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Oct 1 15:19:02 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003