git-svn-id: svn://db.shs.com.ru/libs@462 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2018-11-28 14:48:50 +00:00
parent efc185f510
commit 90a1478af6
16 changed files with 83 additions and 25 deletions

View File

@@ -59,7 +59,7 @@ if (LIB)
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local)
else()
if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else()
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr)
endif()

View File

@@ -45,7 +45,7 @@ if(LIB)
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local)
else()
if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else()
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr)
endif()

View File

@@ -44,7 +44,7 @@ else()
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local)
else()
if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
set(CMAKE_INSTALL_PREFIX {ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else()
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr)
endif()

View File

@@ -57,12 +57,12 @@ else()
qt_install(TARGETS ${PROJECT_NAME} DESTINATION QtBin)
else()
if(APPLE)
set(CMAKE_INSTALL_PREFIX /usr/local)
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}$/usr/local)
else()
if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else()
set(CMAKE_INSTALL_PREFIX /usr)
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}$/usr)
endif()
endif()
install(FILES ${out_HDR} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip)

View File

@@ -1,5 +1,6 @@
#include "edockwidget.h"
#include "qad_types.h"
#include <QEvent>
#include <QStyle>
@@ -22,9 +23,17 @@ void EDockWidget::setWindowIcon(const QIcon & icon) {
QDockWidget::setWindowIcon(icon);
if (!icon.isNull()) {
lbl_icon->setScaledContents(true);
lbl_icon->setFixedSize(preferredIconSize(1.5));
lbl_icon->setFixedSize(preferredIconSize(1.5, this));
}
//#endif
//#endif
}
bool EDockWidget::event(QEvent * e) {
if (e->type() == QEvent::FontChange || e->type() == QEvent::Polish) {
lbl_icon->setFixedSize(preferredIconSize(1.5, this));
}
return QDockWidget::event(e);
}

View File

@@ -23,6 +23,7 @@ public:
void setWindowIcon(const QIcon & icon);
private:
bool event(QEvent * e);
void init();
QFrame * header;

View File

@@ -24,9 +24,12 @@ Ribbon::~Ribbon() {
bool Ribbon::eventFilter(QObject * o, QEvent * e) {
//qDebug() << e;
if (o == parent) {
if (e->type() == QEvent::Resize || e->type() == QEvent::WindowActivate)
_resize();
if (e->type() == QEvent::FontChange || e->type() == QEvent::Polish)
_setIconsSize();
return QToolBar::eventFilter(o, e);
}
if (e->type() == QEvent::ActionChanged) {
@@ -57,6 +60,13 @@ void Ribbon::_resize() {
}
void Ribbon::_setIconsSize() {
qDebug() << "resize" << preferredIconSize() << QApplication::font();
setTabIconSize(preferredIconSize(2, this));
setIconSize(preferredIconSize(3, this));
}
void Ribbon::setVisible(bool yes) {
QToolBar::setVisible(yes);
if (parent == 0) return;
@@ -183,8 +193,7 @@ void Ribbon::init() {
parent->addToolBar(Qt::TopToolBarArea, this);
parent->menuBar()->hide();
tab->setAutoFillBackground(false);
setTabIconSize(preferredIconSize(2));
setIconSize(preferredIconSize(3));
_setIconsSize();
}

View File

@@ -36,6 +36,7 @@ private:
bool eventFilter(QObject * o, QEvent * e);
void timerEvent(QTimerEvent * e);
void _resize();
void _setIconsSize();
int hovered, delay;
bool delay_e;

View File

@@ -229,7 +229,7 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom(
widget_props = new QWidget();
ui = new Ui::DrawTools();
ui->setupUi(widget_props);
ui->labelPen->setMinimumSize(preferredIconSize(1.5));
ui->labelPen->setMinimumSize(preferredIconSize(1.5, widget_props));
ui->labelPen->setMaximumSize(ui->labelPen->minimumSize());
ui->labelBrush->setMinimumSize(ui->labelPen->minimumSize());
ui->labelBrush->setMaximumSize(ui->labelBrush->minimumSize());
@@ -350,6 +350,8 @@ void DrawTools::setAlignCompact(bool yes) {
bool DrawTools::eventFilter(QObject * o, QEvent * e) {
QMouseEvent * me = (QMouseEvent*)e;
QPointF sp;
if (e->type() == QEvent::FontChange || e->type() == QEvent::Polish)
ui->labelPen->setMinimumSize(preferredIconSize(1.5, widget_props));
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseMove)
sp = quantize(view_->mapToScene(me->pos()), view_->gridStep());
QRectF mr;

View File

@@ -336,8 +336,8 @@ SQLTableWidget::SQLTableWidget(QWidget * parent): QWidget(parent), filters_group
connection_name = QSqlDatabase::defaultConnection;
filters_active = first_update = true;
table_opened = read_only = false;
ui->labelNew->setFixedSize(preferredIconSize(1.2));
ui->labelFilter->setFixedSize(preferredIconSize(1.2));
ui->labelNew->setFixedSize(preferredIconSize(1.2, this));
ui->labelFilter->setFixedSize(preferredIconSize(1.2, this));
ui->view->installEventFilter(this);
ui->view->viewport()->installEventFilter(this);
ui->view->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder);

View File

@@ -1,6 +1,11 @@
#include "qad_types.h"
#include <QApplication>
#include <QFontMetrics>
#include <QWidget>
#if QT_VERSION >= 0x050000
# include <QWindow>
# include <QScreen>
#endif
__QADTypesRegistrator__ __registrator__;
@@ -125,22 +130,43 @@ QString uniqueName(QString n, const QStringList & names) {
}
int fontHeight() {
int fontHeight(QWidget * w) {
#ifdef Q_OS_ANDROID
static int ret = QApplication::fontMetrics().size(0, "0").height();
return ret;
#else
# if QT_VERSION >= 0x050000
//qDebug() << "fontHeight" << w;
if (w) {
QWidget * pw = w->window();
if (pw) {
/*QWindow * wnd = pw->windowHandle();
//qDebug() << "wnd" << wnd;
if (wnd) {
QScreen * s = wnd->screen();
qDebug() << "s" << s;
if (s) {
qDebug() << "scales:";
qDebug() << QApplication::fontMetrics().size(0, "0").height() << QApplication::fontMetrics().xHeight();
qDebug() << s->logicalDotsPerInch() << s->logicalDotsPerInch()/96.*QApplication::font().pointSizeF();
}
}*/
return QFontMetrics(QApplication::font(), pw).size(0, "0").height();
}
}
# endif
#endif
return QApplication::fontMetrics().size(0, "0").height();
}
int lineThickness() {
return qMax<int>(qRound(fontHeight() / 15.), 1);
int lineThickness(QWidget * w) {
return qMax<int>(qRound(fontHeight(w) / 15.), 1);
}
QSize preferredIconSize(float x) {
int s = qMax<int>(8, qRound(fontHeight() * x));
QSize preferredIconSize(float x, QWidget * w) {
int s = qMax<int>(8, qRound(fontHeight(w) * x));
#ifdef Q_OS_MACOS
s /= 1.25;
#endif
@@ -148,6 +174,6 @@ QSize preferredIconSize(float x) {
}
double appScale() {
return qMax<double>(fontHeight() / 15., 1.);
double appScale(QWidget * w) {
return qMax<double>(fontHeight(w) / 15., 1.);
}

View File

@@ -117,10 +117,11 @@ inline QRectF enlargedRect(const QRectF & r, qreal dx, qreal dy, qreal v) {
QVariant::Type typeFromLetter(const QString & l);
QString uniqueName(QString n, const QStringList & names);
int fontHeight();
int lineThickness();
QSize preferredIconSize(float x = 1.f);
double appScale();
int fontHeight(QWidget * w = 0);
int lineThickness(QWidget * w = 0);
QSize preferredIconSize(float x = 1.f, QWidget * w = 0);
double appScale(QWidget * w = 0);
#endif // QAD_TYPES_H

View File

@@ -38,7 +38,7 @@ EComboBox::EComboBox(QWidget * parent): QComboBox(parent) {
iv.setMinimumHeight(100);
icon.setPixmap(QPixmap(":/icons/edit-find.png"));
icon.setScaledContents(true);
icon.setFixedSize(preferredIconSize(1.2));
icon.setFixedSize(preferredIconSize(1.2, this));
ifont = nfont = font();
ifont.setItalic(true);
#if QT_VERSION >= 0x040700

View File

@@ -24,7 +24,7 @@ public:
explicit IconedLabel(QWidget * parent = 0): QFrame(parent) {
label_.setAlignment(Qt::AlignCenter);
icon_.setAlignment(Qt::AlignCenter);
size_ = preferredIconSize();
size_ = preferredIconSize(-1, this);
setDirection(LeftToRight);
}

View File

@@ -58,6 +58,8 @@ void SessionManager::save() {
sr.setValue(spins[i].first, spins[i].second->value(), false);
for (int i = 0; i < spinsliders.size(); ++i)
sr.setValue(spinsliders[i].first, spinsliders[i].second->value(), false);
for (int i = 0; i < evals.size(); ++i)
sr.setValue(evals[i].first, evals[i].second->expression(), false);
for (int i = 0; i < tabs.size(); ++i)
sr.setValue(tabs[i].first, tabs[i].second->currentIndex(), false);
for (int i = 0; i < buttons.size(); ++i)
@@ -134,6 +136,8 @@ void SessionManager::load(bool onlyMainwindow) {
spins[i].second->setValue(sr.getValue(spins[i].first, spins[i].second->value()));
for (int i = 0; i < spinsliders.size(); ++i)
spinsliders[i].second->setValue(sr.getValue(spinsliders[i].first, spinsliders[i].second->value()));
for (int i = 0; i < evals.size(); ++i)
evals[i].second->setExpression(sr.getValue(evals[i].first, evals[i].second->expression()));
for (int i = 0; i < tabs.size(); ++i) {
QTabWidget * t = tabs[i].second;
int v = sr.getValue(tabs[i].first, t->currentIndex());
@@ -185,6 +189,7 @@ void SessionManager::clear(bool with_filename) {
dspins.clear();
spins.clear();
spinsliders.clear();
evals.clear();
tabs.clear();
buttons.clear();
stacks.clear();

View File

@@ -13,6 +13,7 @@
#include <QSplitter>
#include <QStackedWidget>
#include "spinslider.h"
#include "evalspinbox.h"
#include "qpiconfig.h"
/// for all children widgets of "QMainWindow"s and MainWidgets
@@ -37,6 +38,7 @@ public:
void addEntry(QDoubleSpinBox * e) {dspins.push_back(QPair<QString, QDoubleSpinBox * >(e->objectName(), e));}
void addEntry(QSpinBox * e) {spins.push_back(QPair<QString, QSpinBox * >(e->objectName(), e));}
void addEntry(SpinSlider * e) {spinsliders.push_back(QPair<QString, SpinSlider * >(e->objectName(), e));}
void addEntry(EvalSpinBox * e) {evals.push_back(QPair<QString, EvalSpinBox * >(e->objectName(), e));}
void addEntry(QTabWidget * e) {tabs.push_back(QPair<QString, QTabWidget * >(e->objectName(), e));}
void addEntry(QAction * e) {actions.push_back(QPair<QString, QAction * >(e->objectName(), e));}
void addEntry(QAbstractButton * e) {buttons.push_back(QPair<QString, QAbstractButton * >(e->objectName(), e));}
@@ -51,6 +53,7 @@ public:
void addEntry(const QString & name, QDoubleSpinBox * e) {dspins.push_back(QPair<QString, QDoubleSpinBox * >(name, e));}
void addEntry(const QString & name, QSpinBox * e) {spins.push_back(QPair<QString, QSpinBox * >(name, e));}
void addEntry(const QString & name, SpinSlider * e) {spinsliders.push_back(QPair<QString, SpinSlider * >(name, e));}
void addEntry(const QString & name, EvalSpinBox * e) {evals.push_back(QPair<QString, EvalSpinBox * >(name, e));}
void addEntry(const QString & name, QTabWidget * e) {tabs.push_back(QPair<QString, QTabWidget * >(name, e));}
void addEntry(const QString & name, QAbstractButton * e) {buttons.push_back(QPair<QString, QAbstractButton * >(name, e));}
void addEntry(const QString & name, QStackedWidget * e) {stacks.push_back(QPair<QString, QStackedWidget * >(name, e));}
@@ -78,6 +81,7 @@ private:
QVector<QPair<QString, QDoubleSpinBox * > > dspins;
QVector<QPair<QString, QSpinBox * > > spins;
QVector<QPair<QString, SpinSlider * > > spinsliders;
QVector<QPair<QString, EvalSpinBox * > > evals;
QVector<QPair<QString, QTabWidget * > > tabs;
QVector<QPair<QString, QAbstractButton * > > buttons;
QVector<QPair<QString, QStackedWidget * > > stacks;