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

arts

  • arts
  • message
artsmessage.cc
1 /*
2  Copyright (C) 2001 Jeff Tranter
3  tranter@kde.org
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program 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
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 
19 
20 ------------------------------------------------------------------------
21 
22 This application displays an error, warning, or informational message
23 in a dialog. It is normally used by artsd in conjunction with the -m
24 option. By abstracting this out of artsd, we keep it independent of
25 any particular graphics toolkit.
26 
27 This version uses KDE. Equivalent versions could be written using Qt,
28 Gnome, etc. and used instead.
29 
30 */
31 
32 #include <tqregexp.h>
33 
34 #include <klocale.h>
35 #include <kglobal.h>
36 #include <kapplication.h>
37 #include <kaboutdata.h>
38 #include <kmessagebox.h>
39 #include <kcmdlineargs.h>
40 
41 // command line options
42 static KCmdLineOptions options[] =
43  {
44  { "e", 0,0 },
45  { "error", I18N_NOOP("Display error message (default)"), 0 },
46  { "w", 0, 0},
47  { "warning", I18N_NOOP("Display warning message"), 0 },
48  { "i", 0, 0 },
49  { "info", I18N_NOOP("Display informational message"), 0 },
50  { "+message", I18N_NOOP("Message string to be displayed"), 0 },
51  KCmdLineLastOption // End of options.
52  };
53 
54 KAboutData aboutData("artsmessage", I18N_NOOP("artsmessage"), "0.1",
55  I18N_NOOP("Utility to display aRts error messages"),
56  KAboutData::License_GPL, "(c) 2001, Jeff Tranter", 0, 0, "tranter@kde.org");
57 
58 int main(int argc, char **argv) {
59  aboutData.addAuthor("Jeff Tranter", 0, "tranter@kde.org");
60  KGlobal::locale()->setMainCatalogue("kdelibs");
61  KCmdLineArgs::init(argc, argv, &aboutData);
62  KCmdLineArgs::addCmdLineOptions(options);
63  KApplication app;
64 
65  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
66  TQString msg;
67 
68  // must be at least one argument
69  if (args->count() == 0) {
70  args->usage();
71  }
72 
73  // build up message string from remaining arguments
74  for (int i = 0; i < args->count(); i++) {
75  if (i == 0)
76  msg = args->arg(i);
77  else
78  msg += TQString(" ") + args->arg(i);
79  }
80 
81  const int notifyOptions = 0; // never activate KNotify
82  if (args->isSet("w")) {
83  KMessageBox::sorry(0, msg, i18n("Warning"), notifyOptions);
84  } else if (args->isSet("i")) {
85  TQString id = msg;
86  id.replace(TQRegExp("[\\[\\]\\s=]"), "_");
87  KMessageBox::information(0, msg, i18n("Informational"), id, notifyOptions);
88  } else {
89  KMessageBox::error(0, msg, i18n("Error"), notifyOptions);
90  }
91 
92  return 0;
93 }
KMessageBox::error
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
KApplication
KGlobal::locale
static KLocale * locale()
KCmdLineArgs::usage
static void usage(const char *id=0)
KCmdLineArgs
KCmdLineArgs::parsedArgs
static KCmdLineArgs * parsedArgs(const char *id=0)
KMessageBox::sorry
static void sorry(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
klocale.h
KCmdLineArgs::count
int count() const
KCmdLineOptions
KCmdLineArgs::isSet
bool isSet(const char *option) const
KMessageBox::information
static void information(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const TQString &dontShowAgainName=TQString::null, int options=Notify)
I18N_NOOP
#define I18N_NOOP(x)
KAboutData
KAboutData::addAuthor
void addAuthor(const char *name, const char *task=0, const char *emailAddress=0, const char *webAddress=0)
KCmdLineArgs::init
static void init(int _argc, char **_argv, const char *_appname, const char *programName, const char *_description, const char *_version, bool noKApp=false)
KLocale::setMainCatalogue
static void setMainCatalogue(const char *catalog)
KCmdLineArgs::addCmdLineOptions
static void addCmdLineOptions(const KCmdLineOptions *options, const char *name=0, const char *id=0, const char *afterId=0)
KCmdLineArgs::arg
const char * arg(int n) const

arts

Skip menu "arts"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

arts

Skip menu "arts"
  • 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 arts by doxygen 1.8.8
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |