File: main.cpp

package info (click to toggle)
shelxle 1.0.952-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,584 kB
  • sloc: cpp: 33,439; ansic: 560; makefile: 3
file content (168 lines) | stat: -rw-r--r-- 5,562 bytes parent folder | download
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

/****************************************************************************
**
** 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) {
  QByteArray localMsg = msg.toLocal8Bit();
    QString pth=QDir::homePath()+"/ShelXle_message.txt";
    FILE *er=fopen(pth.toStdString().c_str(),"wt");
    fprintf(er,"======\n%s\n======\n",localMsg.constData());
    fclose(er);
    if (strstr(localMsg.constData(),"QGLShader::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(),"QGLShader::link:")!=NULL) {
    printf("%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);
#if defined Q_WS_WIN  ||  defined Q_WS_MAC
    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_WS_MAC
    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_WS_MAC
    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_WS_MAC
    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_WS_MAC
    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,"QGLShader::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,"QGLShader::link:")!=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  ||  defined Q_WS_MAC
    QMessageBox::information(0,"information",msg);
#endif
    break;
  case QtWarningMsg:
    printf("%s\n",msg);fflush(stdout);
#if defined Q_WS_WIN  ||  defined Q_WS_MAC
    QMessageBox::warning(0,"warning",msg);
#endif
    break;
  case QtCriticalMsg:
    printf("%s\n",msg);fflush(stdout);
#if defined Q_WS_WIN  || defined Q_WS_MAC
    QMessageBox::critical(0,"critical",msg);
#endif
    break;
  case QtFatalMsg:
    printf("%s\n",msg);fflush(stdout);
#if defined Q_WS_WIN  || defined Q_WS_MAC
    QMessageBox::critical(0,"fatal",msg);
#endif
    abort();
  }
}

#endif

void printicon(){
  QImage II=QImage(":/icons/SHELxLE.png" );
//  QImage II=QPixmap(":/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)));
    printf("\e[48;5;%dm\e[38;5;%dm%c",c216,gray,x[k%8]);
    //printf("\e[48;5;%dm\e[38;5;%dm%c",gray,c216,x[k%8]);
    k++;
  }
  printf("\e[0;0;0m\n");j++;
  }


}

int main(int argv, char *args[]){
  QApplication app(argv, args);
  
  app.setOrganizationName("shelxle");
  app.setWindowIcon(QIcon(":/icons/SHELxLE.png"));
  //printicon();
#if (QT_VERSION >= 0x050000)
  qInstallMessageHandler(mh);
#else
  qInstallMsgHandler(mh);
#endif
  Window *window = new Window();
  window->show();
  int istat = app.exec();
  delete window;
  return istat;
}