kandy

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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 <qpushbutton.h>
00043 
00044 #include "mobilegui.h"
00045 
00046 #include "mobilemain.h"
00047 #include <kstatusbar.h>
00048 #include "mobilemain.moc"
00049 
00050 MobileMain::MobileMain(CommandScheduler *scheduler, KandyPrefs *prefs)
00051     : KMainWindow( 0, "MobileMain" )
00052 {
00053   mView = new MobileGui(scheduler, prefs, this);
00054   setCentralWidget(mView);
00055   setupActions();
00056 
00057   statusBar()->insertItem(i18n(" Disconnected "),1,0,true);
00058   connect(mView,SIGNAL(statusMessage(const QString &)),
00059           SLOT(showStatusMessage(const QString &)));
00060   connect(mView,SIGNAL(transientStatusMessage(const QString &)),
00061           SLOT(showTransientStatusMessage(const QString &)));
00062 
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   createGUI("kandymobileui.rc");
00087 }
00088 
00089 void MobileMain::saveProperties(KConfig */*config*/)
00090 {
00091     // the 'config' object points to the session managed
00092     // config file.  anything you write here will be available
00093     // later when this app is restored
00094 }
00095 
00096 void MobileMain::readProperties(KConfig */*config*/)
00097 {
00098     // the 'config' object points to the session managed
00099     // config file.  this function is automatically called whenever
00100     // the app is being restored.  read in here whatever you wrote
00101     // in 'saveProperties'
00102 }
00103 
00104 void MobileMain::dragEnterEvent(QDragEnterEvent *event)
00105 {
00106     // do nothing
00107     KMainWindow::dragEnterEvent(event);
00108 
00109     // accept uri drops only
00110 //    event->accept(KURLDrag::canDecode(event));
00111 }
00112 
00113 void MobileMain::dropEvent(QDropEvent *event)
00114 {
00115     // this is a very simplistic implementation of a drop event.  we
00116     // will only accept a dropped URL.  the Qt dnd code can do *much*
00117     // much more, so please read the docs there
00118 
00119     // do nothing
00120     KMainWindow::dropEvent(event);
00121 }
00122 
00123 void MobileMain::optionsConfigureKeys()
00124 {
00125     KKeyDialog::configure( actionCollection(), this );
00126 }
00127 
00128 void MobileMain::optionsConfigureToolbars()
00129 {
00130     // use the standard toolbar editor
00131     saveMainWindowSettings( KGlobal::config(), autoSaveGroup() );
00132     KEditToolbar dlg(actionCollection());
00133     connect(&dlg, SIGNAL(newToolbarConfig()), this, SLOT(newToolbarConfig()));
00134     dlg.exec();
00135 }
00136 
00137 void MobileMain::newToolbarConfig()
00138 {
00139     // recreate our GUI
00140     createGUI("kandymobileui.rc");
00141     applyMainWindowSettings( KGlobal::config(), autoSaveGroup() );
00142 }
00143 
00144 void MobileMain::optionsPreferences()
00145 {
00146   emit showPreferencesWin();
00147 }
00148 
00149 void MobileMain::showStatusMessage(const QString& text)
00150 {
00151   // display the text on the statusbar
00152   statusBar()->message(text);
00153 }
00154 
00155 void MobileMain::showTransientStatusMessage(const QString& text)
00156 {
00157   // display the text on the statusbar for 2 s.
00158   statusBar()->message(text,2000);
00159 }
00160 
00161 void MobileMain::changeCaption(const QString& text)
00162 {
00163   // display the text on the caption
00164   setCaption(text);
00165 }
00166 
00167 bool MobileMain::queryClose()
00168 {
00169 #if 0
00170   if (m_view->isModified()) {
00171     switch (KMessageBox::warningYesNoCancel(this,
00172         i18n("Save changes to profile %1?").arg(mFilename))) {
00173       case KMessageBox::Yes :
00174         fileSave();
00175         return true;
00176       case KMessageBox::No :
00177         return true;
00178       default: // cancel
00179         return false;
00180     }
00181   } else {
00182     return true;
00183   }
00184 #endif
00185   return true;
00186 }
00187 
00188 void MobileMain::showTerminal()
00189 {
00190   emit showTerminalWin();
00191 }
KDE Home | KDE Accessibility Home | Description of Access Keys