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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
/****************************************************************************
**
** Copyright (C) 2011 Christian B. Huebschle & George M. Sheldrick
** All rights reserved.
** Contact: chuebsch@moliso.de
**
** This file is part of the ShelXle
**
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file COPYING included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
**
****************************************************************************/
#include "window.h"
#include <QApplication>
//öß
#if (QT_VERSION >= 0x050000)
void mh(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
printf("mh %X\n",QT_VERSION);
QByteArray localMsg = msg.toLocal8Bit();
QString pth=QDir::homePath()+"/ShelXle_qt6_message.txt";
FILE *er=fopen(pth.toStdString().c_str(),"at");
fprintf(er,"======%s\n%s\n======\n",
QDateTime::currentDateTime().toString().toStdString().c_str(),
localMsg.constData());
fclose(er);
if (strstr(localMsg.constData(),"QOpenGLShader::link:")!=NULL) {
printf("%s\n",localMsg.constData());fflush(stdout);
return; // ignore useless error messages with shitty intel graphic cards reporting \"No error."
}
if (strstr(localMsg.constData(),"QAccessibleWidget")!=NULL) {
printf("%s\n",localMsg.constData());fflush(stdout);
return; // ignore useless error messages on win with touch screens
}
if (strstr(localMsg.constData(),"setGeometry")!=NULL) {
printf("%s\n",localMsg.constData());fflush(stdout);
return; // ignore useless error messages
}
if (strstr(localMsg.constData(),"QOpenGLShader::link:")!=NULL) {
printf("%s\n",localMsg.constData());fflush(stdout);
return; // ignore useless error messages
}
if (strstr(localMsg.constData(),"WM_DESTROY")!=NULL) {
printf("ignore %s\n",localMsg.constData());fflush(stdout);
return; // ignore useless error messages
}
switch (type) {
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
// Q_WS_* was droppen in QT5 in favor of Q_OS_*
#if defined Q_WS_WIN || defined Q_OS_WIN
//QMessageBox::information(0,"information",msg);
#endif
break;
case QtInfoMsg:
fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
#if defined Q_WS_WIN || defined Q_OS_WIN
//QMessageBox::information(0,"information",msg);
#endif
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
#if defined Q_WS_WIN || defined Q_OS_WIN
//QMessageBox::warning(0,"warning",msg);
#endif
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
#if defined Q_WS_WIN || defined Q_OS_WIN
//QMessageBox::critical(0,"critical",msg);
#endif
break;
case QtFatalMsg:
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
#if defined Q_WS_WIN || defined Q_OS_WIN
QMessageBox::critical(0,"fatal",msg);
#endif
abort();
}
}
#else
void mh(QtMsgType type, const char *msg){
QString pth=QDir::homePath()+"/ShelXle_message.txt";
FILE *er=fopen(pth.toStdString().c_str(),"wt");
fprintf(er,"======\n%s\n======\n",msg);
fclose(er);
if (strstr(msg,"QOpenGLShader::link:")!=NULL) {
printf("%s\n",msg);fflush(stdout);
return; // ignore useless error messages with shitty intel graphic cards reporting \"No error."
}
if (strstr(msg,"QAccessibleWidget")!=NULL) {
printf("%s\n",msg);fflush(stdout);
return; // ignore useless error messages on win with touch screens
}
if (strstr(msg,"setGeometry")!=NULL) {
printf("%s\n",msg);fflush(stdout);
return; // ignore useless error messages
}
if (strstr(msg,"QOpenGLShader::link:")!=NULL) {
printf("%s\n",msg);fflush(stdout);
return; // ignore useless error messages
}
if (strstr(msg,"Warning: External WM_DESTROY received for")!=NULL) {
printf("%s\n",msg);fflush(stdout);
return; // ignore useless error messages
}
switch (type){
case QtDebugMsg:
printf("%s\n",msg);fflush(stdout);
#if defined Q_WS_WIN
QMessageBox::information(0,"information",msg);
#endif
break;
case QtWarningMsg:
printf("%s\n",msg);fflush(stdout);
#if defined Q_WS_WIN
QMessageBox::warning(0,"warning",msg);
#endif
break;
case QtCriticalMsg:
printf("%s\n",msg);fflush(stdout);
#if defined Q_WS_WIN
QMessageBox::critical(0,"critical",msg);
#endif
break;
case QtFatalMsg:
printf("%s\n",msg);fflush(stdout);
#if defined Q_WS_WIN
QMessageBox::critical(0,"fatal",msg);
#endif
abort();
}
}
#endif
/*
void printicon(){
#if defined Q_WS_WIN || defined Q_OS_WIN
#define DEFINE_CONSOLEV2_PROPERTIES
#endif
QImage II=QImage(":xle-icons/SHELxLE.png" );
// QImage II=QPixmap(":xle-icons/cbh.png" ).toImage();
int r, g, b, c216,gray,k=0;
double alpha;
char x[9]="@ShelXle";
for (int j=0; j<II.height(); j++){
for (int i=0; i<II.width(); i++){
//printf("%2x",qGray(II.pixel(i,j)));a
alpha=qAlpha(II.pixel(i,j))/256.0;
r=(int) (qRed(II.pixel(i,j))/48.0*alpha);
g=(int) (qGreen(II.pixel(i,j))/48.0*alpha);
b=(int) (qBlue(II.pixel(i,j))/48.0*alpha);
c216 = 16 + 36 * r + 6 * g + b;
gray =qGray(II.pixel(i,j))/11+232;
gray= (int)(alpha*gray +(235*(1.0-alpha)));
#if defined Q_WS_WIN || defined Q_OS_WIN
wprintf(L"\x1b[48;5;%dm\x1b[38;5;%dm%c",c216,gray,x[k%8]);
#else
printf("\e[48;5;%dm\e[38;5;%dm%c",c216,gray,x[k%8]);
#endif
//printf("\e[48;5;%dm\e[38;5;%dm%c",gray,c216,x[k%8]);
k++;
}
#if defined Q_WS_WIN || defined Q_OS_WIN
wprintf(L"\x1b[0;0;0m\n");j++;
#else
printf("\e[0;0;0m\n");j++;
#endif
}
}
*/
int main(int argv, char *args[]){
char *ENUS=setlocale(LC_ALL,"C");
if (!ENUS)ENUS=setlocale(LC_ALL,"en_US.UTF-8");
//printf("%s\n",ENUS);
#if (QT_VERSION >= 0x050000)
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
//printf("AA_UseDesktopOpenGL %d \n",QCoreApplication::testAttribute(Qt::AA_UseDesktopOpenGL));
QApplication app(argv, args);
/*QSurfaceFormat f = QSurfaceFormat::defaultFormat();
//printf("??\n");
f.setSampleBuffers(true);
QOpenGLFormat::setDefaultFormat(f);
if (!QOpenGLFormat::hasOpenGL()) {
QMessageBox::information(0, "OpenGL samplebuffers",
"This system does not support OpenGL.");
return 0;
}*/
#else
QApplication app(argv, args);
#endif
app.setOrganizationName("shelxle");
app.setWindowIcon(QIcon(":xle-icons/SHELxLE.png"));
//printicon();
#if (QT_VERSION >= 0x050000)
qInstallMessageHandler(mh);
#else
qInstallMsgHandler(mh);
#endif
//printf("??1\n");
ChGL *chgl = new ChGL(0);
//printf("??2 %p\n",chgl);
Window *window = new Window(chgl);
window->chgl->setMainWindow(window);
//printf("??3\n");
window->show();
int istat = app.exec();
//printf("delete the main window now...\n");
delete window;
//printf("%d bye bye! Thanks for using!\n",istat);
return istat;
}
|