Mercurial > hg > svcore
comparison system/Init.cpp @ 150:4b2ea82fd0ed
* Reorganising code base. This revision probably should compile once more.
author | Chris Cannam |
---|---|
date | Mon, 31 Jul 2006 14:05:22 +0000 |
parents | |
children | f8cf055dbf34 |
comparison
equal
deleted
inserted
replaced
149:3e4c384f518e | 150:4b2ea82fd0ed |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Chris Cannam. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #include <QApplication> | |
17 #include <QFont> | |
18 | |
19 #include <iostream> | |
20 | |
21 #ifdef Q_WS_X11 | |
22 #include <X11/Xlib.h> | |
23 #include <X11/Xutil.h> | |
24 #include <X11/Xatom.h> | |
25 #include <X11/SM/SMlib.h> | |
26 | |
27 static int handle_x11_error(Display *dpy, XErrorEvent *err) | |
28 { | |
29 char errstr[256]; | |
30 XGetErrorText(dpy, err->error_code, errstr, 256); | |
31 if (err->error_code != BadWindow) { | |
32 std::cerr << "waveform: X Error: " | |
33 << errstr << " " << int(err->error_code) | |
34 << "\nin major opcode: " | |
35 << int(err->request_code) << std::endl; | |
36 } | |
37 return 0; | |
38 } | |
39 #endif | |
40 | |
41 #ifdef Q_WS_WIN32 | |
42 | |
43 #include <fcntl.h> | |
44 | |
45 // Set default file open mode to binary | |
46 #undef _fmode | |
47 int _fmode = _O_BINARY; | |
48 | |
49 void redirectStderr() | |
50 { | |
51 HANDLE stderrHandle = GetStdHandle(STD_ERROR_HANDLE); | |
52 if (!stderrHandle) return; | |
53 | |
54 AllocConsole(); | |
55 | |
56 CONSOLE_SCREEN_BUFFER_INFO info; | |
57 GetConsoleScreenBufferInfo(stderrHandle, &info); | |
58 info.dwSize.Y = 1000; | |
59 SetConsoleScreenBufferSize(stderrHandle, info.dwSize); | |
60 | |
61 int h = _open_osfhandle((long)stderrHandle, _O_TEXT); | |
62 if (h) { | |
63 FILE *fd = _fdopen(h, "w"); | |
64 if (fd) { | |
65 *stderr = *fd; | |
66 setvbuf(stderr, NULL, _IONBF, 0); | |
67 } | |
68 } | |
69 } | |
70 | |
71 #endif | |
72 | |
73 extern void svSystemSpecificInitialisation() | |
74 { | |
75 #ifdef Q_WS_X11 | |
76 XSetErrorHandler(handle_x11_error); | |
77 #endif | |
78 | |
79 #ifdef Q_WS_WIN32 | |
80 redirectStderr(); | |
81 QFont fn = qApp->font(); | |
82 fn.setFamily("Tahoma"); | |
83 qApp->setFont(fn); | |
84 #else | |
85 #ifdef Q_WS_X11 | |
86 QFont fn = qApp->font(); | |
87 fn.setPointSize(fn.pointSize() + 2); | |
88 qApp->setFont(fn); | |
89 #endif | |
90 #endif | |
91 } | |
92 |