1 /*
2 
3  Copyright (c) 2003-2013 uim Project https://github.com/uim/uim
4 
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without
8  modification, are permitted provided that the following conditions
9  are met:
10 
11  1. Redistributions of source code must retain the above copyright
12     notice, this list of conditions and the following disclaimer.
13  2. Redistributions in binary form must reproduce the above copyright
14     notice, this list of conditions and the following disclaimer in the
15     documentation and/or other materials provided with the distribution.
16  3. Neither the name of authors nor the names of its contributors
17     may be used to endorse or promote products derived from this software
18     without specific prior written permission.
19 
20  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
21  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
24  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  SUCH DAMAGE.
31 
32 */
33 #include <config.h>
34 
35 #include <clocale>
36 #include <cstdio>
37 #include <cstdlib>
38 #include <cstring>
39 #include <unistd.h>
40 
41 #include <QtCore/QSocketNotifier>
42 #include <QtCore/QStringList>
43 #include <QtCore/QTextCodec>
44 #if QT_VERSION < 0x050000
45 # include <QtGui/QApplication>
46 # include <QtGui/QDesktopWidget>
47 # include <QtGui/QHeaderView>
48 # include <QtGui/QLabel>
49 # include <QtGui/QTableWidget>
50 # include <QtGui/QVBoxLayout>
51 #else
52 # include <QtWidgets/QApplication>
53 # include <QtWidgets/QDesktopWidget>
54 # include <QtWidgets/QHeaderView>
55 # include <QtWidgets/QLabel>
56 # include <QtWidgets/QTableWidget>
57 # include <QtWidgets/QVBoxLayout>
58 #endif
59 
60 #include "candidatewindow.h"
61 #include "candidatetablewindow.h"
62 #include "ximcandidatewindow.h"
63 
64 #include "qtgettext.h"
65 
66 class Window
67 {
68     public:
69         Window(int argc, char *argv[]);
70         ~Window();
71 
72     private:
73         QWidget *widget;
74 };
75 
Window(int argc,char * argv[])76 Window::Window(int argc, char *argv[])
77 {
78     uim_init();
79     if (argc > 1) {
80         // vertical
81         if (!strcmp(argv[1], "-v")) {
82             widget = new CandidateWindow(0, true);
83         // horizontal
84         } else if (!strcmp(argv[1], "-h")) {
85             widget = new CandidateWindow(0, false);
86         // table
87         } else if (!strcmp(argv[1], "-t")) {
88             widget = new CandidateTableWindow(0);
89         } else {
90             widget = new XimCandidateWindow;
91         }
92     } else {
93         widget = new XimCandidateWindow;
94     }
95 }
96 
~Window()97 Window::~Window()
98 {
99     delete widget;
100     uim_quit();
101 }
102 
main(int argc,char * argv[])103 int main(int argc, char *argv[])
104 {
105     setlocale(LC_ALL, "");
106     bindtextdomain(PACKAGE, LOCALEDIR);
107     textdomain(PACKAGE);
108     bind_textdomain_codeset(PACKAGE, "UTF-8"); // ensure code encoding is UTF8-
109 
110     QApplication app(argc, argv);
111 
112     Window window(argc, argv);
113 
114     return app.exec();
115 }
116