...
 
Commits (8)
......@@ -273,7 +273,7 @@ BEGIN_METHOD(Dialog_OpenFile, GB_BOOLEAN multi)
}
}
dialog_title = QString::null;
dialog_title = QString();
END_METHOD
......@@ -292,7 +292,7 @@ BEGIN_METHOD_VOID(Dialog_SaveFile)
GB.ReturnBoolean(false);
}
dialog_title = QString::null;
dialog_title = QString();
END_METHOD
......@@ -311,7 +311,7 @@ BEGIN_METHOD_VOID(Dialog_SelectDirectory)
GB.ReturnBoolean(false);
}
dialog_title = QString::null;
dialog_title = QString();
END_METHOD
......
......@@ -124,7 +124,11 @@ static int get_text_width(QPainter *dp, QString &s)
for (i = 0; i < (int)text_sl.count(); i++)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
w = dp->fontMetrics().horizontalAdvance(text_sl[i]);
#else
w = dp->fontMetrics().width(text_sl[i]);
#endif
if (w > width) width = w;
text_w[i] = w;
}
......
......@@ -218,7 +218,7 @@ void MyDrawingArea::redraw(QRect &r, bool frame)
{
QPainter pf(this);
pf.setClipping(false);
pf.initFrom(this);
//pf.begin(this); // Qt 5.x: avoid message "QPainter::begin: Painter already active"
pf.setRenderHint(QPainter::Antialiasing, false);
drawFrame(&pf);
}
......
......@@ -23,6 +23,7 @@
#define __CSCREEN_CPP
#include <QScreen>
#include <QApplication>
#include <QDesktopWidget>
#include <QToolTip>
......@@ -44,11 +45,21 @@
#include "x11.h"
#include "desktop.h"
#ifdef QT5
#define DESKTOP_INFO() (QGuiApplication::screens().front()->availableGeometry())
#define SCREEN_INFO(_id) (QGuiApplication::screens().at(_id)->geometry())
#define SCREEN_AVAILABLE_SIZE(_id) (QGuiApplication::screens().at(_id)->availableGeometry())
#define NUM_SCREENS() (QGuiApplication::screens().count())
#else
#define DESKTOP_INFO() (QApplication::desktop()->availableGeometry())
#define SCREEN_INFO(_id) (QApplication::desktop()->screenGeometry(_id))
#define SCREEN_AVAILABLE_SIZE(_id) (QApplication::desktop()->availableGeometry(_id))
#if QT_VERSION >= 0x040600
#define NUM_SCREENS() (QApplication::desktop()->screenCount())
#else
#define NUM_SCREENS() (QApplication::desktop()->numScreens())
#endif
#endif
#define MAX_SCREEN 16
......@@ -94,29 +105,28 @@ static void free_screens(void)
BEGIN_PROPERTY(Desktop_X)
GB.ReturnInteger(QApplication::desktop()->availableGeometry().x());
GB.ReturnInteger(DESKTOP_INFO().x());
END_PROPERTY
BEGIN_PROPERTY(Desktop_Y)
GB.ReturnInteger(QApplication::desktop()->availableGeometry().y());
GB.ReturnInteger(DESKTOP_INFO().y());
END_PROPERTY
BEGIN_PROPERTY(Desktop_Width)
GB.ReturnInteger(QApplication::desktop()->availableGeometry().width());
GB.ReturnInteger(DESKTOP_INFO().width());
END_PROPERTY
BEGIN_PROPERTY(Desktop_Height)
GB.ReturnInteger(QApplication::desktop()->availableGeometry().height());
GB.ReturnInteger(DESKTOP_INFO().height());
END_PROPERTY
BEGIN_PROPERTY(Desktop_Resolution)
#ifdef NO_X_WINDOW
......@@ -182,7 +192,6 @@ BEGIN_PROPERTY(Application_Font)
END_PROPERTY
BEGIN_PROPERTY(Application_ActiveWindow)
//GB.ReturnObject(CWidget::get(qApp->activeWindow()));
......@@ -190,21 +199,18 @@ BEGIN_PROPERTY(Application_ActiveWindow)
END_PROPERTY
BEGIN_PROPERTY(Application_ActiveControl)
GB.ReturnObject(CWIDGET_active_control);
END_PROPERTY
BEGIN_PROPERTY(Application_PreviousControl)
GB.ReturnObject(CWIDGET_previous_control);
END_PROPERTY
BEGIN_PROPERTY(Application_Busy)
int busy;
......@@ -227,7 +233,6 @@ BEGIN_PROPERTY(Application_Busy)
END_PROPERTY
BEGIN_PROPERTY(Application_ShowTooltips)
if (READ_PROPERTY)
......@@ -237,7 +242,6 @@ BEGIN_PROPERTY(Application_ShowTooltips)
END_PROPERTY
BEGIN_PROPERTY(Application_Animations)
if (READ_PROPERTY)
......@@ -250,7 +254,6 @@ BEGIN_PROPERTY(Application_Animations)
END_PROPERTY
BEGIN_PROPERTY(Application_Shadows)
if (READ_PROPERTY)
......@@ -263,7 +266,6 @@ BEGIN_PROPERTY(Application_Shadows)
END_PROPERTY
BEGIN_PROPERTY(Application_MainWindow)
if (READ_PROPERTY)
......@@ -281,7 +283,6 @@ BEGIN_PROPERTY(Application_MainWindow)
END_PROPERTY
BEGIN_PROPERTY(Application_Embedder)
#ifdef QT5
......@@ -316,7 +317,6 @@ BEGIN_PROPERTY(Application_Theme)
END_PROPERTY
BEGIN_PROPERTY(Application_Restart)
if (READ_PROPERTY)
......@@ -340,21 +340,18 @@ BEGIN_PROPERTY(Screens_Count)
END_PROPERTY
/*BEGIN_PROPERTY(Screens_Primary)
GB.ReturnInteger(QApplication::desktop()->primaryScreen());
END_PROPERTY*/
BEGIN_METHOD(Screens_get, GB_INTEGER screen)
GB.ReturnObject(get_screen(VARG(screen)));
END_METHOD
BEGIN_METHOD_VOID(Screens_next)
int *index = (int *)GB.GetEnum();
......@@ -369,53 +366,52 @@ BEGIN_METHOD_VOID(Screens_next)
END_METHOD
BEGIN_PROPERTY(Screen_X)
GB.ReturnInteger(QApplication::desktop()->screenGeometry(SCREEN->index).x());
GB.ReturnInteger(SCREEN_INFO(SCREEN->index).x());
END_PROPERTY
BEGIN_PROPERTY(Screen_Y)
GB.ReturnInteger(QApplication::desktop()->screenGeometry(SCREEN->index).y());
GB.ReturnInteger(SCREEN_INFO(SCREEN->index).y());
END_PROPERTY
BEGIN_PROPERTY(Screen_Width)
GB.ReturnInteger(QApplication::desktop()->screenGeometry(SCREEN->index).width());
GB.ReturnInteger(SCREEN_INFO(SCREEN->index).width());
END_PROPERTY
BEGIN_PROPERTY(Screen_Height)
GB.ReturnInteger(QApplication::desktop()->screenGeometry(SCREEN->index).height());
GB.ReturnInteger(SCREEN_INFO(SCREEN->index).height());
END_PROPERTY
BEGIN_PROPERTY(Screen_AvailableX)
GB.ReturnInteger(QApplication::desktop()->availableGeometry(SCREEN->index).x());
GB.ReturnInteger(SCREEN_AVAILABLE_SIZE(SCREEN->index).x());
END_PROPERTY
BEGIN_PROPERTY(Screen_AvailableY)
GB.ReturnInteger(QApplication::desktop()->availableGeometry(SCREEN->index).y());
GB.ReturnInteger(SCREEN_AVAILABLE_SIZE(SCREEN->index).y());
END_PROPERTY
BEGIN_PROPERTY(Screen_AvailableWidth)
GB.ReturnInteger(QApplication::desktop()->availableGeometry(SCREEN->index).width());
GB.ReturnInteger(SCREEN_AVAILABLE_SIZE(SCREEN->index).width());
END_PROPERTY
BEGIN_PROPERTY(Screen_AvailableHeight)
GB.ReturnInteger(QApplication::desktop()->availableGeometry(SCREEN->index).height());
GB.ReturnInteger(SCREEN_AVAILABLE_SIZE(SCREEN->index).height());
END_PROPERTY
......
......@@ -274,7 +274,7 @@ static void style_box(QPainter *p, int x, int y, int w, int h, int state, GB_COL
QStyleOptionFrame opt;
//if (GB.Is(d->device, CLASS_DrawingArea))
// opt.initFrom(QWIDGET(d->device));
// opt.begin(QWIDGET(d->device));
init_option(opt, x, y, w, h, state, color, QPalette::Base);
......
......@@ -363,7 +363,7 @@ static bool set_tab_count(void *_object, int new_count)
{
tab = new CTab(THIS, new MyContainer(WIDGET));
label.sprintf("Tab %d", i);
label = QString("Tab %1").arg(i);
WIDGET->addTab(tab->widget, label);
WIDGET->stack.append(tab);
......
......@@ -83,7 +83,7 @@ typedef
char *name;
void *font;
}
PACKED
// PACKED
CWIDGET; // BEWARE: gb.qt.h MUST be updated accordingly!
typedef
......
......@@ -23,6 +23,8 @@
#define __CWINDOW_CPP
#include <QScreen>
#include <qnamespace.h>
#include <qapplication.h>
#include <qmenubar.h>
......@@ -2481,6 +2483,11 @@ void MyMainWindow::doReparent(QWidget *parent, const QPoint &pos)
int MyMainWindow::currentScreen() const
{
#ifdef QT5
QList<QScreen*> screenList;
QScreen* primaryScreen;
#endif
if (_screen >= 0)
return _screen;
......@@ -2489,7 +2496,15 @@ int MyMainWindow::currentScreen() const
else if (CWINDOW_Main)
return QApplication::desktop()->screenNumber(CWINDOW_Main->widget.widget);
else
#ifndef QT5
return QApplication::desktop()->primaryScreen();
#else
{
primaryScreen = QGuiApplication::primaryScreen();
screenList = QGuiApplication::screens();
return screenList.indexOf(primaryScreen);
}
#endif
}
void MyMainWindow::center()
......@@ -2498,7 +2513,11 @@ void MyMainWindow::center()
QPoint p;
QRect r;
#ifdef QT5
r = QGuiApplication::screens().at(currentScreen())->availableGeometry();
#else
r = QApplication::desktop()->availableGeometry(currentScreen());
#endif
CWIDGET_move(THIS, r.x() + (r.width() - width()) / 2, r.y() + (r.height() - height()) / 2);
}
......
......@@ -238,7 +238,7 @@ static int Begin(GB_PAINT *d)
return TRUE;
if (wid->isCached())
PAINTER(d)->initFrom(wid);
PAINTER(d)->begin(wid);
d->area.width = wid->width();
d->area.height = wid->height();
......@@ -932,7 +932,11 @@ static int get_text_width(QPainter *dp, QString &s)
for (i = 0; i < (int)text_sl.count(); i++)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
w = dp->fontMetrics().horizontalAdvance(text_sl[i]);
#else
w = dp->fontMetrics().width(text_sl[i]);
#endif
if (w > width) width = w;
text_w[i] = w;
}
......