File: main.cpp

package info (click to toggle)
fqterm 0.9.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,108 kB
  • sloc: cpp: 49,385; ansic: 2,183; javascript: 1,026; python: 348; sh: 29; makefile: 19
file content (128 lines) | stat: -rw-r--r-- 4,439 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/***************************************************************************
 *   fqterm, a terminal emulator for both BBS and *nix.                    *
 *   Copyright (C) 2008 fqterm development group.                          *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.               *
 ***************************************************************************/

#include <stdlib.h>

#if defined(WIN32)
#include <windows.h>
#include <shellapi.h>
#else
#include <sys/stat.h>
#include <errno.h>
#include <locale.h>
#endif

#if defined(FQTERM_USE_STATIC_QT)
  // You can change the definition of FQTERM_USE_STATIC_QT in 
  // fqterm/CMakeLists.txt.{linux, macos, win32}.

  // static link Qt4 plugins.
  void loadNecessaryQtPlugins() {}
  #include <QtPlugin>
  Q_IMPORT_PLUGIN(qkrcodecs)
  Q_IMPORT_PLUGIN(qcncodecs)
  Q_IMPORT_PLUGIN(qjpcodecs)
  Q_IMPORT_PLUGIN(qtwcodecs)
#if QT_VERSION < QT_VERSION_CHECK(4,8,5)
  Q_IMPORT_PLUGIN(qjpeg)
  Q_IMPORT_PLUGIN(qgif)
  Q_IMPORT_PLUGIN(qmng)
#endif
#else
  // dynamic link Qt4 plugins.
  #include <QPluginLoader>
  void loadNecessaryQtPlugins() {
    static QPluginLoader qkrcodecsLoader( "qkrcodecs" );
    static QPluginLoader qcncodecsLoader( "qcncodecs" );
    static QPluginLoader qjpcodecsLoader( "qjpcodecs" );
    static QPluginLoader qtwcodecsLoader( "qtwcodecs" );
    static QPluginLoader qjpegLoader("qjpeg");
    static QPluginLoader qgifLoader("qgif");
    static QPluginLoader qmngLoader("qmng");
   
    qkrcodecsLoader.load();
    qcncodecsLoader.load();
    qjpcodecsLoader.load();
    qtwcodecsLoader.load();
    qjpegLoader.load();
    qgifLoader.load();
    qmngLoader.load();
  }
#endif

#include <QApplication>
#include <QFontDatabase>
#include <QTextCodec>

#include "fqterm.h"
#include "fqterm_frame.h"
#include "fqterm_path.h"
#include "fqterm_trace.h"
#include "fqterm_config.h"
#include "fqterm_param.h"
#include "fqterm_text_line.h"



int main(int argc, char **argv) {
  QApplication a(argc, argv);
  a.setApplicationName("FQTerm");
  a.setApplicationVersion(FQTERM_VERSION_STRING);
  // Set trace categories and level.
  FQTerm::setMaxTraceLevel(1);
  for (int i = 1; i < argc; ++i) {
    QString str(argv[i]);
    bool ok;
    int max_level = str.toInt(&ok, 0); 

    if (ok) {
      FQTerm::setMaxTraceLevel(max_level);
    } else {
      FQTerm::addAllowedCategory(argv[i]);
    }
  }

  using namespace FQTerm;

  loadNecessaryQtPlugins();

  // char buf[] = "\xc8\xb8";
  // QString ucs2 = QTextCodec::codecForName("Big5")->toUnicode(buf);
  // QVector<uint> ucs4 = ucs2.toUcs4(); 
  // QByteArray utf8 = ucs2.toUtf8();
  // const char *utf8c = utf8.constData();

  // FQ_TRACE("text", 0) << "\n" << dumpHexString << std::string(buf, sizeof(buf) - 1)
  //                     << dumpNormalString << " \n-->"
  //                     << dumpNormalString << "\nucs4 " << ucs4.size() << " " << ucs4[0]
  //                     << dumpNormalString << "\nucs2 " << ucs2.size() << " " << ucs2.at(0).unicode()
  //                     << dumpNormalString << "\nutf8   " << dumpHexString << utf8c;
  //return 0;

  if (!iniSettings()) {
    return -1;
  }

  FQTermFrame *mw = new FQTermFrame();
  mw->setWindowTitle("FQTerm " + QString(FQTERM_VERSION_STRING));
  mw->setWindowIcon(QPixmap(getPath(RESOURCE) + "pic/fqterm.png"));
  mw->show();
  return a.exec();
}