7 #include <QApplication>
10 #include <QDockWidget>
30 return QMessageBox::question(
this, tr(
"Really Close?"),
31 tr(
"Do you really want to close the window?"),
32 QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok;
37 if (QThread::currentThread()==thread()) {
41 f.setPointSize(fontSize);
45 QFont f = QApplication::font(
this);
52 Q_ARG(
int, fontSize)));
58 if (QThread::currentThread()==thread()) {
64 Q_ARG(
int, spacing)));
70 QLayout *ly = qobject_cast<QLayout*>(obj);
73 ly->setContentsMargins(spacing, spacing, spacing, spacing);
75 QGridLayout *gl = qobject_cast<QGridLayout*>(ly);
78 gl->setHorizontalSpacing(spacing);
79 gl->setVerticalSpacing(spacing);
88 foreach(QObject* chobj, obj->children()) {
120 QWidget *wid = qobject_cast<QWidget*>(obj);
122 QVariant fsz = obj->property(
"defaultFontSize");
123 QVariant mrga = obj->property(
"defaultAMargins");
124 QVariant mrgb = obj->property(
"defaultBMargins");
127 printMessage(tr(
"QxrdWindow::shrinkObject(\"%1\",%2)").arg(obj->objectName()).
HEXARG(obj));
128 printMessage(tr(
"Default Font Size %1, Margins A [%2,%3], B [%4,%5]").arg(fsz.toInt())
129 .arg(mrga.toPoint().x()).arg(mrga.toPoint().y())
130 .arg(mrgb.toPoint().x()).arg(mrgb.toPoint().y()));
134 int sz = wid->font().pointSize();
136 int left, top, right, bottom;
137 wid->getContentsMargins(&left, &top, &right, &bottom);
140 printMessage(tr(
"Existing Font Size %1, Margins A [%2,%3], B [%4,%5]").arg(sz).arg(left).arg(top).arg(right).arg(bottom));
143 if (!fsz.isValid()) {
144 wid->setProperty(
"defaultFontSize", sz);
145 fsz = wid->property(
"defaultFontSize");
148 if (!mrga.isValid()) {
149 wid->setProperty(
"defaultAMargins", QPoint(left, top));
150 mrga = wid->property(
"defaultAMargins");
153 if (!mrgb.isValid()) {
154 wid->setProperty(
"defaultBMargins", QPoint(right, bottom));
155 mrgb = wid->property(
"defaultBMargins");
159 QFont f = wid->font();
160 f.setPointSize(fontSize);
163 QFont f = wid->font();
164 f.setPointSize(fsz.toInt());
169 wid->setContentsMargins(spacing, spacing, spacing, spacing);
171 QPoint ma = mrga.toPoint();
172 QPoint mb = mrgb.toPoint();
174 if (!ma.isNull() && !mb.isNull()) {
175 wid->setContentsMargins(ma.x(), ma.y(), mb.x(), mb.y());
181 printMessage(tr(
"Default Font Size %1, Margins A [%2,%3], B [%4,%5]").arg(fsz.toInt())
182 .arg(mrga.toPoint().x()).arg(mrga.toPoint().y())
183 .arg(mrgb.toPoint().x()).arg(mrgb.toPoint().y()));
186 QLayout *ly = qobject_cast<QLayout*>(obj);
190 ly->setContentsMargins(spacing, spacing, spacing, spacing);
192 QPoint ma = mrga.toPoint();
193 QPoint mb = mrgb.toPoint();
195 if (!ma.isNull() && !mb.isNull()) {
196 ly->setContentsMargins(ma.x(), ma.y(), mb.x(), mb.y());
200 QGridLayout *gl = qobject_cast<QGridLayout*>(ly);
204 QVariant spc = gl->property(
"defaultSpacing");
207 printMessage(tr(
"Default spacing [%1,%2]").arg(spc.toPoint().x()).arg(spc.toPoint().y()));
210 if (!spc.isValid()) {
211 int hs = gl->horizontalSpacing();
212 int vs = gl->verticalSpacing();
215 printMessage(tr(
"Existing spacing [%1,%2]").arg(hs).arg(vs));
218 gl->setProperty(
"defaultSpacing", QPoint(hs,vs));
219 spc = gl->property(
"defaultSpacing");
223 gl->setHorizontalSpacing(spacing);
224 gl->setVerticalSpacing(spacing);
226 QPoint sp = spc.toPoint();
228 gl->setHorizontalSpacing(sp.x());
229 gl->setVerticalSpacing(sp.y());
234 printMessage(tr(
"Default spacing [%1,%2]").arg(spc.toPoint().x()).arg(spc.toPoint().y()));
239 foreach(QObject* chobj, obj->children()) {
void shrinkDockWidget(QDockWidget *dockWidget, int fontSize, int spacing)
QcepMainWindow(QWidget *parent=0)
qint64 qcepDebug(int cond)
void shrinkObject(QObject *obj, int fontSize, int spacing)
#define INVOKE_CHECK(res)
void shrinkPanels(int fontSize, int spacing)
void setObjectSpacing(QObject *obj, int spacing)
void setSpacing(int spacing)
void setFontSize(int fontSize)
virtual void printMessage(QString msg, QDateTime ts=QDateTime::currentDateTime())=0