forked from telegramdesktop/tdesktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_qt_5_5_0_patch.diff
11766 lines (11723 loc) · 576 KB
/
_qt_5_5_0_patch.diff
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/qtbase/mkspecs/common/msvc-desktop.conf b/qtbase/mkspecs/common/msvc-desktop.conf
index e638af6..e44ee5e 100644
--- a/qtbase/mkspecs/common/msvc-desktop.conf
+++ b/qtbase/mkspecs/common/msvc-desktop.conf
@@ -28,9 +28,9 @@ QMAKE_YACCFLAGS = -d
QMAKE_CFLAGS = -nologo -Zc:wchar_t
QMAKE_CFLAGS_WARN_ON = -W3
QMAKE_CFLAGS_WARN_OFF = -W0
-QMAKE_CFLAGS_RELEASE = -O2 -MD
-QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
-QMAKE_CFLAGS_DEBUG = -Zi -MDd
+QMAKE_CFLAGS_RELEASE = -O2 -MT
+QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
+QMAKE_CFLAGS_DEBUG = -Zi -MTd
QMAKE_CFLAGS_YACC =
QMAKE_CFLAGS_LTCG = -GL
QMAKE_CFLAGS_SSE2 = -arch:SSE2
diff --git a/qtbase/qmake/generators/mac/pbuilder_pbx.cpp b/qtbase/qmake/generators/mac/pbuilder_pbx.cpp
index 81bb068..a0fe016 100644
--- a/qtbase/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qtbase/qmake/generators/mac/pbuilder_pbx.cpp
@@ -1500,11 +1500,15 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
plist_in_text.replace("@TYPEINFO@",
(project->isEmpty("QMAKE_PKGINFO_TYPEINFO")
? QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4).toQString()));
- QFile plist_out_file(Option::output_dir + "/Info.plist");
- if (plist_out_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ QString plist_dir;
+ if (!project->isEmpty("PLIST_DIR"))
+ plist_dir = project->first("PLIST_DIR").toQString();
+ QString plist_in_filename = QFileInfo(plist_in_file).fileName();
+ QFile plist_out_file(Option::output_dir + "/" + plist_dir + plist_in_filename);
+ if (plist_out_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QTextStream plist_out(&plist_out_file);
plist_out << plist_in_text;
- t << "\t\t\t\t" << writeSettings("INFOPLIST_FILE", "Info.plist") << ";\n";
+ t << "\t\t\t\t" << writeSettings("INFOPLIST_FILE", fixForOutput(plist_dir + plist_in_filename)) << ";\n";
}
}
}
diff --git a/qtbase/qmake/generators/makefile.cpp b/qtbase/qmake/generators/makefile.cpp
index 4a03faf..2c18c48 100644
--- a/qtbase/qmake/generators/makefile.cpp
+++ b/qtbase/qmake/generators/makefile.cpp
@@ -167,7 +167,7 @@ MakefileGenerator::initOutPaths()
v["PRECOMPILED_DIR"] = v["OBJECTS_DIR"];
static const char * const dirs[] = { "OBJECTS_DIR", "DESTDIR",
"SUBLIBS_DIR", "DLLDESTDIR",
- "PRECOMPILED_DIR", 0 };
+ "PRECOMPILED_DIR", "PLIST_DIR", 0 };
for (int x = 0; dirs[x]; x++) {
const ProKey dkey(dirs[x]);
if (v[dkey].isEmpty())
diff --git a/qtbase/src/3rdparty/pcre/pcre16_valid_utf16.c b/qtbase/src/3rdparty/pcre/pcre16_valid_utf16.c
index 0907653..96f6e19 100644
--- a/qtbase/src/3rdparty/pcre/pcre16_valid_utf16.c
+++ b/qtbase/src/3rdparty/pcre/pcre16_valid_utf16.c
@@ -101,7 +101,7 @@ for (p = string; length-- > 0; p++)
{
/* Normal UTF-16 code point. Neither high nor low surrogate. */
}
- else if ((c & 0x0400) == 0)
+ else if ((c & 0xfc00) == 0xd800)
{
/* High surrogate. Must be a followed by a low surrogate. */
if (length == 0)
diff --git a/qtbase/src/corelib/kernel/qobjectdefs.h b/qtbase/src/corelib/kernel/qobjectdefs.h
index 4d01264..9bee473 100644
--- a/qtbase/src/corelib/kernel/qobjectdefs.h
+++ b/qtbase/src/corelib/kernel/qobjectdefs.h
@@ -142,7 +142,7 @@ inline void qYouForgotTheQ_OBJECT_Macro(T1, T2) {}
# define Q_DECL_HIDDEN_STATIC_METACALL Q_DECL_HIDDEN
#endif
-#if defined(Q_CC_CLANG) && Q_CC_CLANG >= 306
+#if defined(Q_CC_CLANG) && (Q_CC_CLANG >= 306) && 0
# define Q_OBJECT_NO_OVERRIDE_WARNING QT_WARNING_DISABLE_CLANG("-Winconsistent-missing-override")
#else
# define Q_OBJECT_NO_OVERRIDE_WARNING
diff --git a/qtbase/src/corelib/tools/qunicodetables.cpp b/qtbase/src/corelib/tools/qunicodetables.cpp
index 73dce81..76c6933 100644
--- a/qtbase/src/corelib/tools/qunicodetables.cpp
+++ b/qtbase/src/corelib/tools/qunicodetables.cpp
@@ -5839,7 +5839,7 @@ static const Properties uc_properties[] = {
{ 1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 7, 4, 4, 21, 11 },
{ 0, 17, 230, 5, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 4, 4, 4, 21, 11 },
{ 18, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 85, 0, 8, 8, 12, 11 },
- { 25, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 17, 2 },
+ { 25, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 17, 11 },
{ 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 14, 9, 11, 11 },
{ 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 14, 9, 11, 11 },
{ 3, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 14, 9, 11, 11 },
diff --git a/qtbase/src/gui/image/qbmphandler.cpp b/qtbase/src/gui/image/qbmphandler.cpp
index f124ced..eb78a13 100644
--- a/qtbase/src/gui/image/qbmphandler.cpp
+++ b/qtbase/src/gui/image/qbmphandler.cpp
@@ -212,6 +212,9 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
int blue_scale = 0;
int alpha_scale = 0;
+ if (!d->isSequential())
+ d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4 ? BMP_WIN : bi.biSize)); // goto start of colormap
+
if (bi.biSize >= BMP_WIN4 || (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32))) {
if (d->read((char *)&red_mask, sizeof(red_mask)) != sizeof(red_mask))
return false;
@@ -299,9 +302,6 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
image.setDotsPerMeterX(bi.biXPelsPerMeter);
image.setDotsPerMeterY(bi.biYPelsPerMeter);
- if (!d->isSequential())
- d->seek(startpos + BMP_FILEHDR_SIZE + (bi.biSize >= BMP_WIN4? BMP_WIN : bi.biSize)); // goto start of colormap
-
if (ncols > 0) { // read color table
uchar rgb[4];
int rgb_len = t == BMP_OLD ? 3 : 4;
diff --git a/qtbase/src/gui/kernel/qplatformdialoghelper.h b/qtbase/src/gui/kernel/qplatformdialoghelper.h
index 8b2b988..2d1cdd9 100644
--- a/qtbase/src/gui/kernel/qplatformdialoghelper.h
+++ b/qtbase/src/gui/kernel/qplatformdialoghelper.h
@@ -363,6 +363,7 @@ public:
virtual QUrl directory() const = 0;
virtual void selectFile(const QUrl &filename) = 0;
virtual QList<QUrl> selectedFiles() const = 0;
+ virtual QByteArray selectedRemoteContent() const { return QByteArray(); }
virtual void setFilter() = 0;
virtual void selectNameFilter(const QString &filter) = 0;
virtual QString selectedNameFilter() const = 0;
diff --git a/qtbase/src/gui/painting/qimagescale.cpp b/qtbase/src/gui/painting/qimagescale.cpp
index 9b4eabc..a3e0e04 100644
--- a/qtbase/src/gui/painting/qimagescale.cpp
+++ b/qtbase/src/gui/painting/qimagescale.cpp
@@ -313,7 +313,10 @@ static void qt_qimageScaleAARGBA_up_xy(QImageScaleInfo *isi, unsigned int *dest,
for (int x = dxx; x < end; x++) {
const unsigned int *pix = sptr + xpoints[x];
const int xap = xapoints[x];
- *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap);
+ if (xap > 0)
+ *dptr = INTERPOLATE_PIXEL_256(pix[0], 256 - xap, pix[1], xap);
+ else
+ *dptr = pix[0];
dptr++;
}
}
diff --git a/qtbase/src/gui/painting/qpaintengine_p.h b/qtbase/src/gui/painting/qpaintengine_p.h
index c58662e..468d671 100644
--- a/qtbase/src/gui/painting/qpaintengine_p.h
+++ b/qtbase/src/gui/painting/qpaintengine_p.h
@@ -79,8 +79,18 @@ public:
if (hasSystemTransform) {
if (systemTransform.type() <= QTransform::TxTranslate)
systemClip.translate(qRound(systemTransform.dx()), qRound(systemTransform.dy()));
- else
- systemClip = systemTransform.map(systemClip);
+ else {
+// Transform the system clip region back from device pixels to device-independent pixels before
+// applying systemTransform, which already has transform from device-independent pixels to device pixels
+#ifdef Q_OS_MAC
+ QTransform scaleTransform;
+ const qreal invDevicePixelRatio = 1. / pdev->devicePixelRatio();
+ scaleTransform.scale(invDevicePixelRatio, invDevicePixelRatio);
+ systemClip = systemTransform.map(scaleTransform.map(systemClip));
+#else
+ systemClip = systemTransform.map(systemClip);
+#endif
+ }
}
// Make sure we're inside the viewport.
diff --git a/qtbase/src/gui/text/qtextlayout.cpp b/qtbase/src/gui/text/qtextlayout.cpp
index 7da3e84..0829250 100644
--- a/qtbase/src/gui/text/qtextlayout.cpp
+++ b/qtbase/src/gui/text/qtextlayout.cpp
@@ -643,6 +643,9 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const
while (oldPos < len && !attributes[oldPos].graphemeBoundary)
oldPos++;
} else {
+ while (oldPos < len && attributes[oldPos].whiteSpace)
+ oldPos++;
+
if (oldPos < len && d->atWordSeparator(oldPos)) {
oldPos++;
while (oldPos < len && d->atWordSeparator(oldPos))
@@ -651,8 +654,6 @@ int QTextLayout::nextCursorPosition(int oldPos, CursorMode mode) const
while (oldPos < len && !attributes[oldPos].whiteSpace && !d->atWordSeparator(oldPos))
oldPos++;
}
- while (oldPos < len && attributes[oldPos].whiteSpace)
- oldPos++;
}
return oldPos;
diff --git a/qtbase/src/gui/text/qtextlayout.h b/qtbase/src/gui/text/qtextlayout.h
index 47dcd38..64c3810 100644
--- a/qtbase/src/gui/text/qtextlayout.h
+++ b/qtbase/src/gui/text/qtextlayout.h
@@ -186,6 +186,8 @@ private:
QRectF *brect, int tabstops, int* tabarray, int tabarraylen,
QPainter *painter);
QTextEngine *d;
+
+ friend class TextBlock;
};
diff --git a/qtbase/src/network/socket/qnativesocketengine_win.cpp b/qtbase/src/network/socket/qnativesocketengine_win.cpp
index 72f85c8..a1c2e08 100644
--- a/qtbase/src/network/socket/qnativesocketengine_win.cpp
+++ b/qtbase/src/network/socket/qnativesocketengine_win.cpp
@@ -685,7 +685,13 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin
errorDetected = true;
break;
}
- if (value == WSAEADDRNOTAVAIL) {
+ if (value == WSAENETUNREACH) {
+ setError(QAbstractSocket::NetworkError, NetworkUnreachableErrorString);
+ socketState = QAbstractSocket::UnconnectedState;
+ errorDetected = true;
+ break;
+ }
+ if (value == WSAEADDRNOTAVAIL) {
setError(QAbstractSocket::NetworkError, AddressNotAvailableErrorString);
socketState = QAbstractSocket::UnconnectedState;
errorDetected = true;
diff --git a/qtbase/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
index 65cdabd..190683e 100644
--- a/qtbase/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
+++ b/qtbase/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
@@ -198,6 +198,78 @@ void QBasicFontDatabase::releaseHandle(void *handle)
extern FT_Library qt_getFreetype();
+// copied from freetype with some modifications
+
+#ifndef FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY
+#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG('i', 'g', 'p', 'f')
+#endif
+
+#ifndef FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY
+#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG('i', 'g', 'p', 's')
+#endif
+
+/* there's a Mac-specific extended implementation of FT_New_Face() */
+/* in src/base/ftmac.c */
+
+#if !defined( FT_MACINTOSH ) || defined( DARWIN_NO_CARBON )
+
+/* documentation is in freetype.h */
+
+FT_Error __ft_New_Face(FT_Library library, const char* pathname, FT_Long face_index, FT_Face *aface) {
+ FT_Open_Args args;
+
+ /* test for valid `library' and `aface' delayed to FT_Open_Face() */
+ if (!pathname)
+ return FT_Err_Invalid_Argument;
+
+ FT_Parameter params[2];
+ params[0].tag = FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY;
+ params[0].data = 0;
+ params[1].tag = FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY;
+ params[1].data = 0;
+ args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
+ args.pathname = (char*)pathname;
+ args.stream = NULL;
+ args.num_params = 2;
+ args.params = params;
+
+ return FT_Open_Face(library, &args, face_index, aface);
+}
+
+#else
+
+FT_Error __ft_New_Face(FT_Library library, const char* pathname, FT_Long face_index, FT_Face *aface) {
+ return FT_New_Face(library, pathname, face_index, aface);
+}
+
+#endif /* defined( FT_MACINTOSH ) && !defined( DARWIN_NO_CARBON ) */
+
+/* documentation is in freetype.h */
+
+FT_Error __ft_New_Memory_Face(FT_Library library, const FT_Byte* file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface) {
+ FT_Open_Args args;
+
+ /* test for valid `library' and `face' delayed to FT_Open_Face() */
+ if (!file_base)
+ return FT_Err_Invalid_Argument;
+
+ FT_Parameter params[2];
+ params[0].tag = FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY;
+ params[0].data = 0;
+ params[1].tag = FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY;
+ params[1].data = 0;
+ args.flags = FT_OPEN_MEMORY | FT_OPEN_PARAMS;
+ args.memory_base = file_base;
+ args.memory_size = file_size;
+ args.stream = NULL;
+ args.num_params = 2;
+ args.params = params;
+
+ return FT_Open_Face(library, &args, face_index, aface);
+}
+
+// end
+
QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByteArray &file, QSupportedWritingSystems *supportedWritingSystems)
{
FT_Library library = qt_getFreetype();
@@ -209,9 +281,9 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt
FT_Face face;
FT_Error error;
if (!fontData.isEmpty()) {
- error = FT_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
+ error = __ft_New_Memory_Face(library, (const FT_Byte *)fontData.constData(), fontData.size(), index, &face);
} else {
- error = FT_New_Face(library, file.constData(), index, &face);
+ error = __ft_New_Face(library, file.constData(), index, &face);
}
if (error != FT_Err_Ok) {
qDebug() << "FT_New_Face failed with index" << index << ":" << hex << error;
diff --git a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 112bb8e..9f1df70 100644
--- a/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -373,6 +373,15 @@ static void populateFromPattern(FcPattern *pattern)
return;
familyName = QString::fromUtf8((const char *)value);
+ if (familyName == QLatin1String("Open Sans")) {
+ FcChar8 *styl = 0;
+ if (FcPatternGetString(pattern, FC_STYLE, 0, &styl) == FcResultMatch) {
+ QString style = QString::fromUtf8(reinterpret_cast<const char *>(styl));
+ if (style == QLatin1String("Semibold")) {
+ familyName.append(QChar(QChar::Space)).append(style);
+ }
+ }
+ }
slant_value = FC_SLANT_ROMAN;
weight_value = FC_WEIGHT_REGULAR;
@@ -781,6 +790,15 @@ QStringList QFontconfigDatabase::addApplicationFont(const QByteArray &fontData,
FcChar8 *fam = 0;
if (FcPatternGetString(pattern, FC_FAMILY, 0, &fam) == FcResultMatch) {
QString family = QString::fromUtf8(reinterpret_cast<const char *>(fam));
+ if (family == QLatin1String("Open Sans")) {
+ FcChar8 *styl = 0;
+ if (FcPatternGetString(pattern, FC_STYLE, 0, &styl) == FcResultMatch) {
+ QString style = QString::fromUtf8(reinterpret_cast<const char *>(styl));
+ if (style == QLatin1String("Semibold")) {
+ family.append(QChar(QChar::Space)).append(style);
+ }
+ }
+ }
families << family;
}
populateFromPattern(pattern);
diff --git a/qtbase/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/qtbase/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index be70092..1594dac 100644
--- a/qtbase/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/qtbase/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -263,6 +263,10 @@ static void getFontDescription(CTFontDescriptorRef font, FontDescription *fd)
fd->foundryName = QStringLiteral("CoreText");
fd->familyName = (CFStringRef) CTFontDescriptorCopyAttribute(font, kCTFontFamilyNameAttribute);
+ QCFString _displayName = (CFStringRef) CTFontDescriptorCopyAttribute(font, kCTFontDisplayNameAttribute);
+ if (_displayName == QStringLiteral("Open Sans Semibold")) {
+ fd->familyName = _displayName;
+ }
fd->styleName = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontStyleNameAttribute);
fd->weight = QFont::Normal;
fd->style = QFont::StyleNormal;
diff --git a/qtbase/src/plugins/platforminputcontexts/compose/compose.pro b/qtbase/src/plugins/platforminputcontexts/compose/compose.pro
index a9da36c..65183b6 100644
--- a/qtbase/src/plugins/platforminputcontexts/compose/compose.pro
+++ b/qtbase/src/plugins/platforminputcontexts/compose/compose.pro
@@ -20,7 +20,7 @@ HEADERS += $$PWD/qcomposeplatforminputcontext.h \
contains(QT_CONFIG, xkbcommon-qt): {
# dont't need x11 dependency for compose key plugin
QT_CONFIG -= use-xkbcommon-x11support
- include(../../../3rdparty/xkbcommon.pri)
+# include(../../../3rdparty/xkbcommon.pri)
} else {
LIBS += $$QMAKE_LIBS_XKBCOMMON
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XKBCOMMON
diff --git a/qtbase/src/plugins/platforminputcontexts/fcitx/fcitx.json b/qtbase/src/plugins/platforminputcontexts/fcitx/fcitx.json
new file mode 100644
index 0000000..6d2b389
--- /dev/null
+++ b/qtbase/src/plugins/platforminputcontexts/fcitx/fcitx.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "fcitx" ]
+}
\ No newline at end of file
diff --git a/qtbase/src/plugins/platforminputcontexts/fcitx/fcitx.pro b/qtbase/src/plugins/platforminputcontexts/fcitx/fcitx.pro
new file mode 100644
index 0000000..cbd3ab7
--- /dev/null
+++ b/qtbase/src/plugins/platforminputcontexts/fcitx/fcitx.pro
@@ -0,0 +1,38 @@
+TARGET = fcitxplatforminputcontextplugin
+
+PLUGIN_TYPE = platforminputcontexts
+PLUGIN_EXTENDS = -
+PLUGIN_CLASS_NAME = QFcitxPlatformInputContextPlugin
+load(qt_plugin)
+
+QT += dbus gui-private
+SOURCES += $$PWD/fcitxqtconnection.cpp \
+ $$PWD/fcitxqtformattedpreedit.cpp \
+ $$PWD/fcitxqtinputcontextproxy.cpp \
+ $$PWD/fcitxqtinputmethoditem.cpp \
+ $$PWD/fcitxqtinputmethodproxy.cpp \
+ $$PWD/fcitxqtkeyboardlayout.cpp \
+ $$PWD/fcitxqtkeyboardproxy.cpp \
+ $$PWD/keyuni.cpp \
+ $$PWD/main.cpp \
+ $$PWD/qfcitxplatforminputcontext.cpp \
+ $$PWD/utils.cpp
+
+HEADERS += $$PWD/fcitxqtconnection.h \
+ $$PWD/fcitxqtconnection_p.h \
+ $$PWD/fcitxqtdbusaddons_export.h \
+ $$PWD/fcitxqtdbusaddons_version.h \
+ $$PWD/fcitxqtformattedpreedit.h \
+ $$PWD/fcitxqtinputcontextproxy.h \
+ $$PWD/fcitxqtinputmethoditem.h \
+ $$PWD/fcitxqtinputmethodproxy.h \
+ $$PWD/fcitxqtkeyboardlayout.h \
+ $$PWD/fcitxqtkeyboardproxy.h \
+ $$PWD/keydata.h \
+ $$PWD/keyserver_x11.h \
+ $$PWD/keyuni.h \
+ $$PWD/main.h \
+ $$PWD/qfcitxplatforminputcontext.h \
+ $$PWD/utils.h
+
+OTHER_FILES += $$PWD/fcitx.json
diff --git a/qtbase/src/plugins/platforminputcontexts/fcitx/fcitxqtconnection.cpp b/qtbase/src/plugins/platforminputcontexts/fcitx/fcitxqtconnection.cpp
new file mode 100644
index 0000000..a50178a
--- /dev/null
+++ b/qtbase/src/plugins/platforminputcontexts/fcitx/fcitxqtconnection.cpp
@@ -0,0 +1,369 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * *
+ * 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 "fcitxqtconnection_p.h"
+#include <QDBusConnection>
+#include <QDBusServiceWatcher>
+#include <QDBusReply>
+#include <QDBusConnectionInterface>
+#include <QDebug>
+#include <QFile>
+#include <QTimer>
+#include <QDir>
+
+#include <signal.h>
+#include <errno.h>
+
+// utils function in fcitx-utils and fcitx-config
+bool _pid_exists(pid_t pid) {
+ if (pid <= 0)
+ return 0;
+ return !(kill(pid, 0) && (errno == ESRCH));
+}
+
+
+FcitxQtConnection::FcitxQtConnection(QObject* parent): QObject(parent)
+ ,d_ptr(new FcitxQtConnectionPrivate(this))
+{
+}
+
+void FcitxQtConnection::startConnection()
+{
+ Q_D(FcitxQtConnection);
+ if (!d->m_initialized) {
+ d->initialize();
+ d->createConnection();
+ }
+}
+
+void FcitxQtConnection::endConnection()
+{
+ Q_D(FcitxQtConnection);
+ d->cleanUp();
+ d->finalize();
+ d->m_connectedOnce = false;
+}
+
+bool FcitxQtConnection::autoReconnect()
+{
+ Q_D(FcitxQtConnection);
+ return d->m_autoReconnect;
+}
+
+void FcitxQtConnection::setAutoReconnect(bool a)
+{
+ Q_D(FcitxQtConnection);
+ d->m_autoReconnect = a;
+}
+
+QDBusConnection* FcitxQtConnection::connection()
+{
+ Q_D(FcitxQtConnection);
+ return d->m_connection;
+}
+
+const QString& FcitxQtConnection::serviceName()
+{
+ Q_D(FcitxQtConnection);
+ return d->m_serviceName;
+}
+
+bool FcitxQtConnection::isConnected()
+{
+ Q_D(FcitxQtConnection);
+ return d->isConnected();
+}
+
+
+
+FcitxQtConnection::~FcitxQtConnection()
+{
+}
+
+FcitxQtConnectionPrivate::FcitxQtConnectionPrivate(FcitxQtConnection* conn) : QObject(conn)
+ ,q_ptr(conn)
+ ,m_displayNumber(-1)
+ ,m_serviceName(QString("%1-%2").arg("org.fcitx.Fcitx").arg(displayNumber()))
+ ,m_connection(0)
+ ,m_serviceWatcher(new QDBusServiceWatcher(conn))
+ ,m_watcher(new QFileSystemWatcher(this))
+ ,m_autoReconnect(true)
+ ,m_connectedOnce(false)
+ ,m_initialized(false)
+{
+}
+
+FcitxQtConnectionPrivate::~FcitxQtConnectionPrivate()
+{
+ if (m_connection)
+ delete m_connection;
+}
+
+void FcitxQtConnectionPrivate::initialize() {
+ m_serviceWatcher->setConnection(QDBusConnection::sessionBus());
+ m_serviceWatcher->addWatchedService(m_serviceName);
+
+ QFileInfo info(socketFile());
+ QDir dir(info.path());
+ if (!dir.exists()) {
+ QDir rt(QDir::root());
+ rt.mkpath(info.path());
+ }
+ m_watcher->addPath(info.path());
+ if (info.exists()) {
+ m_watcher->addPath(info.filePath());
+ }
+
+ connect(m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(socketFileChanged()));
+ connect(m_watcher, SIGNAL(directoryChanged(QString)), this, SLOT(socketFileChanged()));
+ m_initialized = true;
+}
+
+void FcitxQtConnectionPrivate::finalize() {
+ m_serviceWatcher->removeWatchedService(m_serviceName);
+ m_watcher->removePaths(m_watcher->files());
+ m_watcher->removePaths(m_watcher->directories());
+ m_watcher->disconnect(SIGNAL(fileChanged(QString)));
+ m_watcher->disconnect(SIGNAL(directoryChanged(QString)));
+ m_initialized = false;
+}
+
+void FcitxQtConnectionPrivate::socketFileChanged() {
+ QFileInfo info(socketFile());
+ if (info.exists()) {
+ if (m_watcher->files().indexOf(info.filePath()) == -1)
+ m_watcher->addPath(info.filePath());
+ }
+
+ QString addr = address();
+ if (addr.isNull())
+ return;
+
+ cleanUp();
+ createConnection();
+}
+
+QByteArray FcitxQtConnectionPrivate::localMachineId()
+{
+#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
+ return QDBusConnection::localMachineId();
+#else
+ QFile file1("/var/lib/dbus/machine-id");
+ QFile file2("/etc/machine-id");
+ QFile* fileToRead = NULL;
+ if (file1.open(QIODevice::ReadOnly)) {
+ fileToRead = &file1;
+ }
+ else if (file2.open(QIODevice::ReadOnly)) {
+ fileToRead = &file2;
+ }
+ if (fileToRead) {
+ QByteArray result = fileToRead->readLine(1024);
+ fileToRead->close();
+ result = result.trimmed();
+ if (!result.isEmpty())
+ return result;
+ }
+ return "machine-id";
+#endif
+}
+
+int FcitxQtConnectionPrivate::displayNumber() {
+ if (m_displayNumber < 0) {
+ QByteArray displayNumber("0");
+ QByteArray display(qgetenv("DISPLAY"));
+ int pos = display.indexOf(':');
+
+ if (pos >= 0) {
+ ++pos;
+ int pos2 = display.indexOf('.', pos);
+ if (pos2 > 0) {
+ displayNumber = display.mid(pos, pos2 - pos);
+ } else {
+ displayNumber = display.mid(pos);
+ }
+ }
+
+ bool ok;
+ int d = displayNumber.toInt(&ok);
+ if (ok) {
+ m_displayNumber = d;
+ } else {
+ m_displayNumber = 0;
+ }
+ }
+
+ return m_displayNumber;
+}
+
+const QString& FcitxQtConnectionPrivate::socketFile()
+{
+ if (!m_socketFile.isEmpty())
+ return m_socketFile;
+
+ QString filename = QString("%1-%2").arg(QString::fromLatin1(QDBusConnection::localMachineId())).arg(displayNumber());
+
+ QString home = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_HOME"));
+ if (home.isEmpty()) {
+ home = QDir::homePath().append(QLatin1Literal("/.config"));
+ }
+ m_socketFile = QString("%1/fcitx/dbus/%2").arg(home).arg(filename);
+
+ return m_socketFile;
+}
+
+QString FcitxQtConnectionPrivate::address()
+{
+ QString addr;
+ QByteArray addrVar = qgetenv("FCITX_DBUS_ADDRESS");
+ if (!addrVar.isNull())
+ return QString::fromLocal8Bit(addrVar);
+
+ QFile file(socketFile());
+ if (!file.open(QIODevice::ReadOnly))
+ return QString();
+
+ const int BUFSIZE = 1024;
+
+ char buffer[BUFSIZE];
+ size_t sz = file.read(buffer, BUFSIZE);
+ file.close();
+ if (sz == 0)
+ return QString();
+ char* p = buffer;
+ while(*p)
+ p++;
+ size_t addrlen = p - buffer;
+ if (sz != addrlen + 2 * sizeof(pid_t) + 1)
+ return QString();
+
+ /* skip '\0' */
+ p++;
+ pid_t *ppid = (pid_t*) p;
+ pid_t daemonpid = ppid[0];
+ pid_t fcitxpid = ppid[1];
+
+ if (!_pid_exists(daemonpid)
+ || !_pid_exists(fcitxpid))
+ return QString();
+
+ addr = QLatin1String(buffer);
+
+ return addr;
+}
+
+void FcitxQtConnectionPrivate::createConnection() {
+ if (m_connectedOnce && !m_autoReconnect) {
+ return;
+ }
+
+ m_serviceWatcher->disconnect(SIGNAL(serviceOwnerChanged(QString,QString,QString)));
+ QString addr = address();
+ if (!addr.isNull()) {
+ QDBusConnection connection(QDBusConnection::connectToBus(addr, "fcitx"));
+ if (connection.isConnected()) {
+ // qDebug() << "create private";
+ m_connection = new QDBusConnection(connection);
+ }
+ else
+ QDBusConnection::disconnectFromBus("fcitx");
+ }
+
+ if (!m_connection) {
+ QDBusConnection* connection = new QDBusConnection(QDBusConnection::sessionBus());
+ connect(m_serviceWatcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)), this, SLOT(imChanged(QString,QString,QString)));
+ QDBusReply<bool> registered = connection->interface()->isServiceRegistered(m_serviceName);
+ if (!registered.isValid() || !registered.value()) {
+ delete connection;
+ }
+ else {
+ m_connection = connection;
+ }
+ }
+
+ Q_Q(FcitxQtConnection);
+ if (m_connection) {
+
+ m_connection->connect ("org.freedesktop.DBus.Local",
+ "/org/freedesktop/DBus/Local",
+ "org.freedesktop.DBus.Local",
+ "Disconnected",
+ this,
+ SLOT (dbusDisconnected ()));
+ m_connectedOnce = true;
+ emit q->connected();
+ }
+}
+
+
+void FcitxQtConnectionPrivate::dbusDisconnected()
+{
+ cleanUp();
+
+ createConnection();
+}
+
+void FcitxQtConnectionPrivate::imChanged(const QString& service, const QString& oldowner, const QString& newowner)
+{
+ if (service == m_serviceName) {
+ /* old die */
+ if (oldowner.length() > 0 || newowner.length() > 0)
+ cleanUp();
+
+ /* new rise */
+ if (newowner.length() > 0) {
+ QTimer::singleShot(100, this, SLOT(newServiceAppear()));
+ }
+ }
+}
+
+void FcitxQtConnectionPrivate::cleanUp()
+{
+ Q_Q(FcitxQtConnection);
+ bool doemit = false;
+ QDBusConnection::disconnectFromBus("fcitx");
+ if (m_connection) {
+ delete m_connection;
+ m_connection = 0;
+ doemit = true;
+ }
+
+ if (!m_autoReconnect && m_connectedOnce)
+ finalize();
+
+ /* we want m_connection and finalize being called before the signal
+ * thus isConnected will return false in slot
+ * and startConnection can be called in slot
+ */
+ if (doemit)
+ emit q->disconnected();
+}
+
+bool FcitxQtConnectionPrivate::isConnected()
+{
+ return m_connection && m_connection->isConnected();
+}
+
+void FcitxQtConnectionPrivate::newServiceAppear() {
+ if (!isConnected()) {
+ cleanUp();
+
+ createConnection();
+ }
+}
diff --git a/qtbase/src/plugins/platforminputcontexts/fcitx/fcitxqtconnection.h b/qtbase/src/plugins/platforminputcontexts/fcitx/fcitxqtconnection.h
new file mode 100644
index 0000000..efe255f
--- /dev/null
+++ b/qtbase/src/plugins/platforminputcontexts/fcitx/fcitxqtconnection.h
@@ -0,0 +1,111 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * *
+ * 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. *
+ ***************************************************************************/
+
+#ifndef FCITXQTCONNECTION_H
+#define FCITXQTCONNECTION_H
+
+#include "fcitxqtdbusaddons_export.h"
+
+#include <QtCore/QObject>
+
+class QDBusConnection;
+
+class FcitxQtConnectionPrivate;
+
+
+/**
+ * dbus connection to fcitx
+ **/
+class FCITXQTDBUSADDONS_EXPORT FcitxQtConnection : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(bool autoReconnect READ autoReconnect WRITE setAutoReconnect)
+ Q_PROPERTY(bool connected READ isConnected)
+ Q_PROPERTY(QDBusConnection* connection READ connection)
+ Q_PROPERTY(QString serviceName READ serviceName)
+public:
+ /**
+ * create a new connection
+ *
+ * @param parent
+ **/
+ explicit FcitxQtConnection(QObject* parent = 0);
+
+ /**
+ * destroy the connection
+ **/
+ virtual ~FcitxQtConnection();
+
+ /**
+ * the connection will not start to work until you call this function
+ * you may want to connect to the signal before you call this function
+ **/
+ void startConnection();
+ void endConnection();
+ /**
+ * automatically reconnect if fcitx disappeared
+ *
+ * @param a ...
+ * @return void
+ **/
+ void setAutoReconnect(bool a);
+
+ /**
+ * check this connection is doing automatical reconnect or not
+ *
+ * default value is true
+ **/
+ bool autoReconnect();
+
+ /**
+ * return the current dbus connection to fcitx, notice, the object return
+ * by this function might be deteled if fcitx disappear, or might return 0
+ * if fcitx is not running
+ *
+ * @return QDBusConnection*
+ **/
+ QDBusConnection* connection();
+ /**
+ * current fcitx dbus service name, can be used for create DBus proxy
+ *
+ * @return service name
+ **/
+ const QString& serviceName();
+ /**
+ * check its connected or not
+ **/
+ bool isConnected();
+
+Q_SIGNALS:
+ /**
+ * this signal will be emitted upon fcitx appears
+ **/
+ void connected();
+ /**
+ * this signal will be emitted upon fcitx disappears
+ *
+ * it will come with connected in pair
+ **/
+ void disconnected();
+
+private:
+ FcitxQtConnectionPrivate * const d_ptr;
+ Q_DECLARE_PRIVATE(FcitxQtConnection);
+};
+
+#endif // FCITXCONNECTION_H
diff --git a/qtbase/src/plugins/platforminputcontexts/fcitx/fcitxqtconnection_p.h b/qtbase/src/plugins/platforminputcontexts/fcitx/fcitxqtconnection_p.h
new file mode 100644
index 0000000..dda726a
--- /dev/null
+++ b/qtbase/src/plugins/platforminputcontexts/fcitx/fcitxqtconnection_p.h
@@ -0,0 +1,68 @@
+/***************************************************************************
+ * Copyright (C) 2012~2012 by CSSlayer *
+ * *
+ * 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. *
+ ***************************************************************************/
+
+#ifndef FCITXQTCONNECTION_P_H
+#define FCITXQTCONNECTION_P_H
+
+#include "fcitxqtconnection.h"
+#include <QtCore/QWeakPointer>
+#include <QtCore/QFileSystemWatcher>
+
+class QDBusConnection;
+class QDBusServiceWatcher;
+
+class FcitxQtConnectionPrivate : public QObject {
+ Q_OBJECT
+public:
+ FcitxQtConnectionPrivate(FcitxQtConnection* conn);
+ virtual ~FcitxQtConnectionPrivate();
+ FcitxQtConnection * const q_ptr;
+ Q_DECLARE_PUBLIC(FcitxQtConnection);
+
+private Q_SLOTS:
+ void imChanged(const QString& service, const QString& oldowner, const QString& newowner);
+ void dbusDisconnected();
+ void cleanUp();
+ void newServiceAppear();
+ void socketFileChanged();
+
+private:
+ bool isConnected();
+
+ static QByteArray localMachineId();
+ const QString& socketFile();
+ void createConnection();
+ QString address();
+ int displayNumber();
+ void initialize();
+ void finalize();
+
+ int m_displayNumber;
+ QString m_serviceName;
+ QDBusConnection* m_connection;
+ QDBusServiceWatcher* m_serviceWatcher;
+ QFileSystemWatcher* m_watcher;
+ QString m_socketFile;
+ bool m_autoReconnect;
+ bool m_connectedOnce;
+ bool m_initialized;
+};