kandy

mobilemain.cpp
1/*
2 This file is part of Kandy.
3
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of TQt, and distribute the resulting executable,
22 without including the source code for TQt in the source distribution.
23*/
24
25#include <tdeglobal.h>
26#include <tdelocale.h>
27#include <kiconloader.h>
28#include <tdemenubar.h>
29#include <kkeydialog.h>
30#include <tdeaccel.h>
31#include <tdeconfig.h>
32#include <kdebug.h>
33#include <tdemessagebox.h>
34#include <tdestandarddirs.h>
35#include <kedittoolbar.h>
36#include <kurldrag.h>
37
38#include <tdestdaccel.h>
39#include <tdeaction.h>
40#include <kstdaction.h>
41
42#include <tqpushbutton.h>
43
44#include "mobilegui.h"
45
46#include "mobilemain.h"
47#include <kstatusbar.h>
48#include "mobilemain.moc"
49
50MobileMain::MobileMain(CommandScheduler *scheduler, KandyPrefs *prefs)
51 : TDEMainWindow( 0, "MobileMain" )
52{
53 mView = new MobileGui(scheduler, prefs, this);
54 setCentralWidget(mView);
55 setupActions();
56
57 statusBar()->insertItem(i18n(" Disconnected "),1,0,true);
58 connect(mView,TQ_SIGNAL(statusMessage(const TQString &)),
59 TQ_SLOT(showStatusMessage(const TQString &)));
60 connect(mView,TQ_SIGNAL(transienStatusMessage(const TQString &)),
61 TQ_SLOT(showTransienStatusMessage(const TQString &)));
62
63 statusBar()->show();
64
65 setAutoSaveSettings();
66}
67
69{
70}
71
72void MobileMain::setupActions()
73{
74 KStdAction::quit(this, TQ_SLOT(close()), actionCollection());
75
76 new TDEAction(i18n("Terminal"),0,this,TQ_SLOT(showTerminal()),
77 actionCollection(),"show_terminal");
78
79 createStandardStatusBarAction();
80 setStandardToolBarMenuEnabled(true);
81
82 KStdAction::keyBindings(this, TQ_SLOT(optionsConfigureKeys()), actionCollection());
83 KStdAction::configureToolbars(this, TQ_SLOT(optionsConfigureToolbars()), actionCollection());
84 KStdAction::preferences(this, TQ_SLOT(optionsPreferences()), actionCollection());
85
86 createGUI("kandymobileui.rc");
87}
88
89void MobileMain::saveProperties(TDEConfig */*config*/)
90{
91 // the 'config' object points to the session managed
92 // config file. anything you write here will be available
93 // later when this app is restored
94}
95
96void MobileMain::readProperties(TDEConfig */*config*/)
97{
98 // the 'config' object points to the session managed
99 // config file. this function is automatically called whenever
100 // the app is being restored. read in here whatever you wrote
101 // in 'saveProperties'
102}
103
104void MobileMain::dragEnterEvent(TQDragEnterEvent *event)
105{
106 // do nothing
107 TDEMainWindow::dragEnterEvent(event);
108
109 // accept uri drops only
110// event->accept(KURLDrag::canDecode(event));
111}
112
113void MobileMain::dropEvent(TQDropEvent *event)
114{
115 // this is a very simplistic implementation of a drop event. we
116 // will only accept a dropped URL. the TQt dnd code can do *much*
117 // much more, so please read the docs there
118
119 // do nothing
120 TDEMainWindow::dropEvent(event);
121}
122
123void MobileMain::optionsConfigureKeys()
124{
125 KKeyDialog::configure( actionCollection(), this );
126}
127
128void MobileMain::optionsConfigureToolbars()
129{
130 // use the standard toolbar editor
131 saveMainWindowSettings( TDEGlobal::config(), autoSaveGroup() );
132 KEditToolbar dlg(actionCollection());
133 connect(&dlg, TQ_SIGNAL(newToolbarConfig()), this, TQ_SLOT(newToolbarConfig()));
134 dlg.exec();
135}
136
137void MobileMain::newToolbarConfig()
138{
139 // recreate our GUI
140 createGUI("kandymobileui.rc");
141 applyMainWindowSettings( TDEGlobal::config(), autoSaveGroup() );
142}
143
144void MobileMain::optionsPreferences()
145{
146 emit showPreferencesWin();
147}
148
149void MobileMain::showStatusMessage(const TQString& text)
150{
151 // display the text on the statusbar
152 statusBar()->message(text);
153}
154
155void MobileMain::showTransienStatusMessage(const TQString& text)
156{
157 // display the text on the statusbar for 2 s.
158 statusBar()->message(text,2000);
159}
160
161void MobileMain::changeCaption(const TQString& text)
162{
163 // display the text on the caption
164 setCaption(text);
165}
166
167bool MobileMain::queryClose()
168{
169#if 0
170 if (m_view->isModified()) {
171 switch (KMessageBox::warningYesNoCancel(this,
172 i18n("Save changes to profile %1?").arg(mFilename))) {
173 case KMessageBox::Yes :
174 fileSave();
175 return true;
176 case KMessageBox::No :
177 return true;
178 default: // cancel
179 return false;
180 }
181 } else {
182 return true;
183 }
184#endif
185 return true;
186}
187
188void MobileMain::showTerminal()
189{
190 emit showTerminalWin();
191}
virtual ~MobileMain()
Default Destructor.
Definition: mobilemain.cpp:68
void saveProperties(TDEConfig *)
This function is called when it is time for the app to save its properties for session management pur...
Definition: mobilemain.cpp:89
void readProperties(TDEConfig *)
This function is called when this app is restored.
Definition: mobilemain.cpp:96
MobileMain(CommandScheduler *, KandyPrefs *prefs)
Default Constructor.
Definition: mobilemain.cpp:50
virtual void dragEnterEvent(TQDragEnterEvent *event)
Overridden virtuals for TQt drag 'n drop (XDND)
Definition: mobilemain.cpp:104