3
* q G o a Go Program using Trolltech's Qt
5
* (C) by Peter Strempel, Johannes Mesa, Emmanuel Beranger 2001-2003
9
#include "gui_dialog.h"
12
#include "msg_handler.h"
15
#include <qtranslator.h>
16
#include <qtextcodec.h>
18
#include <qapplication.h>
20
#include <qpushbutton.h>
21
#include <qmessagebox.h>
22
#include <qfiledialog.h>
24
#include <qlistview.h>
25
#include <qcheckbox.h>
26
#include <qtextstream.h>
27
#include <qtextview.h>
31
#include <qmainwindow.h>
33
#include <qdragobject.h>
47
int main(int argc, char **argv)
50
qInstallMsgHandler(myMessageHandler);
53
bool found_debug = false;
54
bool found_sgf = false;
55
bool found_sgf_file = false;
57
bool found_menu = false;
63
if (argv[ac] == QString("-debug"))
68
else if (argv[ac] == QString("-sgf"))
73
else if (argv[ac] == QString("-sgf19"))
75
// set up board 19x19 immediately
77
found_sgf_file = true;
78
sgf_file = QString("/19/");
80
else if (argv[ac] == QString("-desktop"))
82
// set standard options
83
qApp->setDesktopSettingsAware(true);
85
else if (ac && argv[ac][0] != '-')
89
found_sgf_file = true;
90
sgf_file = QString(argv[ac]);
94
QApplication myapp(argc, argv);
96
QString style = myapp.style().name();
99
Debug_Dialog *nonModal = new Debug_Dialog();
100
view = nonModal->TextView1;
103
// get application path
104
QFileInfo program(argv[0]);
105
QString program_dir = program.dirPath(true);
106
qDebug("main:qt->PROGRAM.DIRPATH = " + program_dir);
107
qDebug("style = " + style);
108
// restore last setting
109
setting = new Setting();
111
setting->program_dir = program_dir;
112
// load values from file
113
setting->loadSettings();
117
QTranslator trans(0);
118
const char *lang = setting->getLanguage();
119
qDebug(QString("Checking for language settings...") + lang);
120
QString tr_dir = setting->getTranslationsDirectory(), loc;
123
qDebug("No language settings found, using system locale %s", QTextCodec::locale());
124
loc = QString("qgo_") + QTextCodec::locale();
125
lang = QTextCodec::locale();
129
qDebug("Language settings found: %s", lang);
130
loc = QString("qgo_") + lang;
133
if (trans.load(loc, tr_dir))
135
qDebug("Translation loaded.");
136
myapp.installTranslator(&trans);
138
else if (strcmp(lang, "en") && strcmp(lang, "C")) // Skip warning for en and C default.
139
qWarning("Failed to find translation file for %s", lang);
141
ClientWindow *mainWindow = new ClientWindow(0, 0, 1);
143
#ifdef OWN_DEBUG_MODE
144
// restore size and pos
145
if (mainWindow->getViewSize().width() > 0)
147
nonModal->resize(mainWindow->getViewSize());
148
nonModal->move(mainWindow->getViewPos());
157
mainWindow->setDebugDialog(nonModal);
160
// if debugging allow enhanced output
162
mainWindow->DODEBUG = true;
166
// show only board, hide client
169
qDebug("file to open: " + sgf_file);
170
mainWindow->openLocalBoard(sgf_file);
173
mainWindow->openLocalBoard();
178
myapp.setMainWidget(mainWindow);
180
QObject::connect(&myapp, SIGNAL(lastWindowClosed()), mainWindow, SLOT(quit()));
182
if (!found_sgf && !found_menu)
184
mainWindow->setCaption(PACKAGE1 + QString(" V") + VERSION);