File indexing completed on 2024-04-28 04:56:39

0001 /* ============================================================
0002 * Falkon - Qt web browser
0003 * Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
0004 *
0005 * This program is free software: you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation, either version 3 of the License, or
0008 * (at your option) any later version.
0009 *
0010 * This program is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017 * ============================================================ */
0018 #include "mainapplication.h"
0019 #include "proxystyle.h"
0020 
0021 #include <iostream>
0022 
0023 #ifndef Q_OS_WIN
0024 void msgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
0025 {
0026     if (msg.startsWith(QL1S("QSslSocket: cannot resolve SSL")))
0027         return;
0028     if (msg.startsWith(QL1S("Remote debugging server started successfully.")))
0029         return;
0030 
0031     switch (type) {
0032     case QtDebugMsg:
0033     case QtInfoMsg:
0034     case QtWarningMsg:
0035     case QtCriticalMsg:
0036         std::cerr << qPrintable(qFormatLogMessage(type, context, msg)) << std::endl;
0037         break;
0038 
0039     case QtFatalMsg:
0040         std::cerr << "Fatal: " << qPrintable(qFormatLogMessage(type, context, msg)) << std::endl;
0041         abort();
0042 
0043     default:
0044         break;
0045     }
0046 }
0047 #endif
0048 
0049 int main(int argc, char* argv[])
0050 {
0051 #ifndef Q_OS_WIN
0052     qInstallMessageHandler(&msgHandler);
0053 #endif
0054 
0055     // Hack to fix QT_STYLE_OVERRIDE with QProxyStyle
0056     const QByteArray style = qgetenv("QT_STYLE_OVERRIDE");
0057     if (!style.isEmpty()) {
0058         char** args = (char**) malloc(sizeof(char*) * (argc + 1));
0059         for (int i = 0; i < argc; ++i)
0060             args[i] = argv[i];
0061 
0062         QString stylecmd = QL1S("-style=") + QString::fromUtf8(style);
0063         args[argc++] = qstrdup(stylecmd.toUtf8().constData());
0064         argv = args;
0065     }
0066 
0067     MainApplication app(argc, argv);
0068 
0069     if (app.isClosing())
0070         return 0;
0071 
0072     app.setProxyStyle(new ProxyStyle);
0073 
0074     return app.exec();
0075 }