From fb824c92617e1df1084856782442ab69358bb2ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Sat, 30 May 2015 18:03:29 +0000 Subject: [PATCH] [GB.FORM] * NEW: SliderBox: The slider has always a space for the possible minus sign. [GB.GUI.QT] * NEW: Print a warning message if GB_GUI contains an unsupported component. [GB.QT5] * NEW: Desktop.Screenshot does not use the deprecated API anymore. git-svn-id: svn://localhost/gambas/trunk@7107 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- comp/src/gb.form/.src/SliderBox.class | 4 +- gb.qt4/src/CPicture.cpp | 56 ++++++++++++++------------- gb.qt4/src/CPicture.h | 2 +- gb.qt4/src/CScreen.cpp | 2 +- gb.qt4/src/CWidget.cpp | 1 - main/lib/gui.qt/main.c | 4 +- 6 files changed, 37 insertions(+), 32 deletions(-) diff --git a/comp/src/gb.form/.src/SliderBox.class b/comp/src/gb.form/.src/SliderBox.class index 45d8f213f..a8a26bfee 100644 --- a/comp/src/gb.form/.src/SliderBox.class +++ b/comp/src/gb.form/.src/SliderBox.class @@ -60,9 +60,9 @@ Private Sub UpdateSpinBoxWidth() Dim N As Integer N = Max(Abs($hSpinBox.MinValue), Abs($hSpinBox.MaxValue)) - If $hSpinBox.MinValue < 0 Then N *= 10 + 'If $hSpinBox.MinValue < 0 Then N *= 10 - $hSpinBox.W = Max(Desktop.Scale * 8, (2 + Len(CStr(N))) * $hSpinBox.Font.TextWidth("0") + Desktop.Scale * 2) + $hSpinBox.W = Max(Desktop.Scale * 8, (2 + Len(CStr(N))) * $hSpinBox.Font.TextWidth("0") + $hSpinBox.Font.TextWidth("-") + Desktop.Scale * 2) End diff --git a/gb.qt4/src/CPicture.cpp b/gb.qt4/src/CPicture.cpp index 57aa3849b..359ce7490 100644 --- a/gb.qt4/src/CPicture.cpp +++ b/gb.qt4/src/CPicture.cpp @@ -42,10 +42,13 @@ #include "CImage.h" #include "CPicture.h" -#ifndef NO_X_WINDOW +#ifdef QT5 +#include +#include +#endif + #include #include -#endif static QHash dict; @@ -131,34 +134,35 @@ static void flush_picture() } -CPICTURE *CPICTURE_grab(QWidget *wid, int x, int y, int w, int h) +CPICTURE *CPICTURE_grab(QWidget *wid, int screen, int x, int y, int w, int h) { - CPICTURE *pict; - int id; + CPICTURE *pict; - pict = create(); + pict = create(); - if (!wid) - { - #ifdef NO_X_WINDOW - qDebug("Qt/Embedded: Full screen grab not implemented"); - #else - id = QX11Info::appRootWindow(); - - if (w <= 0 || h <= 0) - { - x = 0; y = 0; w = -1; h = -1; - } - - *pict->pixmap = QPixmap::grabWindow(id, x, y, w, h); - #endif - } - else - { - *pict->pixmap = QPixmap::grabWindow(wid->winId()); - } + if (!wid) + { + if (w <= 0 || h <= 0) + { + x = 0; y = 0; w = -1; h = -1; + } + +#ifdef QT5 + *pict->pixmap = QGuiApplication::primaryScreen()->grabWindow(QX11Info::appRootWindow(), x, y, w, h); +#else + *pict->pixmap = QPixmap::grabWindow(QX11Info::appRootWindow(), x, y, w, h); +#endif + } + else + { +#ifdef QT5 + *pict->pixmap = QGuiApplication::screens().at(QApplication::desktop()->screenNumber(wid))->grabWindow(wid->winId()); +#else + *pict->pixmap = QPixmap::grabWindow(wid->winId()); +#endif + } - return pict; + return pict; } diff --git a/gb.qt4/src/CPicture.h b/gb.qt4/src/CPicture.h index 1adee53d2..040996c5f 100644 --- a/gb.qt4/src/CPicture.h +++ b/gb.qt4/src/CPicture.h @@ -69,7 +69,7 @@ extern GB_DESC CPictureDesc[]; #define CLEAR_PICTURE(_store) GB.StoreObject(NULL, (void **)(void *)_store) -CPICTURE *CPICTURE_grab(QWidget *wid, int x = 0, int y = 0, int w = -1, int h = -1); +CPICTURE *CPICTURE_grab(QWidget *wid, int screen = -1, int x = 0, int y = 0, int w = -1, int h = -1); CPICTURE *CPICTURE_get_picture(const char *path); bool CPICTURE_load_image(QImage **p, const char *path, int lenp); CPICTURE *CPICTURE_create(const QPixmap *pixmap); diff --git a/gb.qt4/src/CScreen.cpp b/gb.qt4/src/CScreen.cpp index f62f4ef8b..3a3649ee6 100644 --- a/gb.qt4/src/CScreen.cpp +++ b/gb.qt4/src/CScreen.cpp @@ -132,7 +132,7 @@ END_PROPERTY BEGIN_METHOD(Desktop_Screenshot, GB_INTEGER x; GB_INTEGER y; GB_INTEGER w; GB_INTEGER h) - GB.ReturnObject(CPICTURE_grab(0, VARGOPT(x, 0), VARGOPT(y, 0), VARGOPT(w, 0), VARGOPT(h, 0))); + GB.ReturnObject(CPICTURE_grab(0, -1, VARGOPT(x, 0), VARGOPT(y, 0), VARGOPT(w, 0), VARGOPT(h, 0))); END_METHOD diff --git a/gb.qt4/src/CWidget.cpp b/gb.qt4/src/CWidget.cpp index 30fabb9a4..0cfd75461 100644 --- a/gb.qt4/src/CWidget.cpp +++ b/gb.qt4/src/CWidget.cpp @@ -3202,7 +3202,6 @@ GB_DESC CControlDesc[] = GB_METHOD("SetFocus", NULL, Control_SetFocus, NULL), GB_METHOD("Refresh", NULL, Control_Refresh, NULL), - //GB_METHOD("Screenshot", "Picture", Control_Screenshot, NULL), GB_METHOD("Drag", "Control", Control_Drag, "(Data)v[(Format)s]"), GB_METHOD("Grab", NULL, Control_Grab, NULL), diff --git a/main/lib/gui.qt/main.c b/main/lib/gui.qt/main.c index 6e85964ba..4bf6ba4b9 100644 --- a/main/lib/gui.qt/main.c +++ b/main/lib/gui.qt/main.c @@ -46,12 +46,14 @@ int EXPORT GB_INIT(void) const char *comp2; env = getenv("GB_GUI"); - if (env) + if (env && *env) { if (strcmp(env, "gb.qt4") == 0) use = USE_GB_QT4; else if (strcmp(env, "gb.qt5") == 0) use = USE_GB_QT5; + else + fprintf(stderr, "gb.gui: warning: '%s' component not supported\n", env); } if (use == USE_NOTHING)