• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libkscreensaver
 

libkscreensaver

  • libkscreensaver
main.cpp
1 /* This file is part of the KDE libraries
2 
3  Copyright (c) 2001 Martin R. Jones <mjones@kde.org>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 #include <config.h>
21 
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <signal.h>
25 
26 #include <tqdialog.h>
27 #include <klocale.h>
28 #include <kglobal.h>
29 #include <kdebug.h>
30 #include <kcmdlineargs.h>
31 #include <kapplication.h>
32 #include <kcrash.h>
33 
34 #include "kscreensaver.h"
35 #include "kscreensaver_vroot.h"
36 
37 extern "C"
38 {
39  extern const char *kss_applicationName;
40  extern const char *kss_description;
41  extern const char *kss_version;
42  KScreenSaver *kss_create( WId d );
43  TQDialog *kss_setup();
44 }
45 
46 static const KCmdLineOptions options[] =
47 {
48  { "setup", I18N_NOOP("Setup screen saver"), 0 },
49  { "window-id wid", I18N_NOOP("Run in the specified XWindow"), 0 },
50  { "root", I18N_NOOP("Run in the root XWindow"), 0 },
51  { "demo", I18N_NOOP("Start screen saver in demo mode"), "default"},
52  KCmdLineLastOption
53 };
54 
55 static void crashHandler( int )
56 {
57 #ifdef SIGABRT
58  signal (SIGABRT, SIG_DFL);
59 #endif
60  abort();
61 }
62 
63 //----------------------------------------------------------------------------
64 
65 class DemoWindow : public TQWidget
66 {
67 public:
68  DemoWindow() : TQWidget()
69  {
70  setFixedSize(600, 420);
71  }
72 
73 protected:
74  virtual void keyPressEvent(TQKeyEvent *e)
75  {
76  if (e->ascii() == 'q')
77  {
78  kapp->quit();
79  }
80  }
81 
82  virtual void closeEvent( TQCloseEvent * )
83  {
84  kapp->quit();
85  }
86 };
87 
88 
89 //----------------------------------------------------------------------------
90 #if defined(Q_WS_QWS) || defined(Q_WS_MACX)
91 typedef WId Window;
92 #endif
93 
94 KDE_EXPORT int main(int argc, char *argv[])
95 {
96  KLocale::setMainCatalogue("libkscreensaver");
97  KCmdLineArgs::init(argc, argv, kss_applicationName, kss_description, kss_version);
98 
99  KCmdLineArgs::addCmdLineOptions(options);
100 
101  KApplication app;
102 
103  KCrash::setCrashHandler( crashHandler );
104  KGlobal::locale()->insertCatalogue("klock");
105  KGlobal::locale()->insertCatalogue("kscreensaver");
106 
107  DemoWindow *demoWidget = 0;
108  Window saveWin = 0;
109  KScreenSaver *target;
110 
111  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
112 
113  if (args->isSet("setup"))
114  {
115  TQDialog *dlg = kss_setup();
116  args->clear();
117  dlg->exec();
118  delete dlg;
119  exit(0);
120  }
121 
122  if (args->isSet("window-id"))
123  {
124  saveWin = atol(args->getOption("window-id"));
125  }
126 
127 #ifdef Q_WS_X11 //FIXME
128  if (args->isSet("root"))
129  {
130  saveWin = RootWindow(qt_xdisplay(), qt_xscreen());
131  }
132 #endif
133 
134  if (args->isSet("demo"))
135  {
136  saveWin = 0;
137  }
138 
139  if (saveWin == 0)
140  {
141  demoWidget = new DemoWindow();
142  demoWidget->setBackgroundMode(TQWidget::NoBackground);
143  saveWin = demoWidget->winId();
144  app.setMainWidget(demoWidget);
145  app.processEvents();
146  }
147 
148  target = kss_create( saveWin );
149 
150  if ( demoWidget )
151  {
152  demoWidget->setFixedSize( 600, 420 );
153  demoWidget->show();
154  }
155  args->clear();
156  app.exec();
157 
158  delete target;
159  delete demoWidget;
160 
161  return 0;
162 }
163 

libkscreensaver

Skip menu "libkscreensaver"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members

libkscreensaver

Skip menu "libkscreensaver"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for libkscreensaver by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |