Skip to content
Snippets Groups Projects
Commit bd46edae authored by SeeLook's avatar SeeLook
Browse files

Using android style for sliders and radio buttons. Single, another style...

Using android style for sliders and radio buttons. Single, another style instance is created during core lib initialization and accessible through static Tcore::androidStyle
parent 2d6834cf
No related branches found
No related tags found
No related merge requests found
...@@ -32,17 +32,27 @@ ...@@ -32,17 +32,27 @@
#include <QtCore/qdir.h> #include <QtCore/qdir.h>
#if defined (Q_OS_ANDROID) #if defined (Q_OS_ANDROID)
#include "Android/tandroid.h" #include "Android/tandroid.h"
#include <QtWidgets/qstylefactory.h>
#endif #endif
Tglobals* Tcore::m_gl = 0; Tglobals* Tcore::m_gl = 0;
#if defined (Q_OS_ANDROID)
QStyle* Tcore::androidStyle = nullptr;
#endif
bool initCoreLibrary() { bool initCoreLibrary() {
if (Tcore::gl() == 0) { if (Tcore::gl() == 0) {
qDebug() << "Tglobals was not created. Construct it first!"; qDebug() << "Tglobals was not created. Construct it first!";
return false; return false;
} }
#if defined (Q_OS_ANDROID)
if (Tcore::androidStyle == nullptr)
Tcore::androidStyle = QStyleFactory::create(QStringLiteral("android"));
#endif
Tcolor::setShadow(qApp->palette()); Tcolor::setShadow(qApp->palette());
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
TpushButton::setCheckColor(Tcore::gl()->S->pointerColor, qApp->palette().base().color()); TpushButton::setCheckColor(Tcore::gl()->S->pointerColor, qApp->palette().base().color());
......
/*************************************************************************** /***************************************************************************
* Copyright (C) 2014-2015 by Tomasz Bojczuk * * Copyright (C) 2014-2016 by Tomasz Bojczuk *
* seelook@gmail.com * * seelook@gmail.com *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
...@@ -22,8 +22,10 @@ ...@@ -22,8 +22,10 @@
#include "nootkacoreglobal.h" #include "nootkacoreglobal.h"
#include "tglobals.h" #include "tglobals.h"
class QTranslator; class QTranslator;
class QApplication; class QApplication;
class QStyle;
/** /**
* Internal instance of Tglobals pointer used by in initCoreLibrary. * * Internal instance of Tglobals pointer used by in initCoreLibrary. *
...@@ -36,6 +38,9 @@ class NOOTKACORE_EXPORT Tcore ...@@ -36,6 +38,9 @@ class NOOTKACORE_EXPORT Tcore
public: public:
static Tglobals* gl() { return m_gl; } /** static global pointer to Tglobals */ static Tglobals* gl() { return m_gl; } /** static global pointer to Tglobals */
#if defined (Q_OS_ANDROID)
static QStyle* androidStyle;
#endif
protected: protected:
static void setGlobals(Tglobals *g) { m_gl = g; } static void setGlobals(Tglobals *g) { m_gl = g; }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <tmenuwidget.h> #include <tmenuwidget.h>
#include <graphics/tdropshadoweffect.h> #include <graphics/tdropshadoweffect.h>
#include <ttouchmenu.h> #include <ttouchmenu.h>
#include <tinitcorelib.h>
#endif #endif
#include <QtWidgets/QtWidgets> #include <QtWidgets/QtWidgets>
...@@ -214,17 +215,19 @@ void TsettingsDialogBase::closeEvent(QCloseEvent *event) { ...@@ -214,17 +215,19 @@ void TsettingsDialogBase::closeEvent(QCloseEvent *event) {
void TsettingsDialogBase::markChanges(QWidget *container) { void TsettingsDialogBase::markChanges(QWidget *container) {
foreach(QCheckBox *chB, container->findChildren<QCheckBox*>()) for(QCheckBox *chB : container->findChildren<QCheckBox*>())
connect(chB, &QCheckBox::clicked, menuButton, &TmenuWidget::animate); connect(chB, &QCheckBox::clicked, menuButton, &TmenuWidget::animate);
foreach(QGroupBox *grB, container->findChildren<QGroupBox*>()) for(QGroupBox *grB : container->findChildren<QGroupBox*>())
connect(grB, &QGroupBox::clicked, menuButton, &TmenuWidget::animate); connect(grB, &QGroupBox::clicked, menuButton, &TmenuWidget::animate);
foreach(QPushButton *butt, container->findChildren<QPushButton*>()) for(QPushButton *butt : container->findChildren<QPushButton*>())
connect(butt, &QPushButton::clicked, menuButton, &TmenuWidget::animate); connect(butt, &QPushButton::clicked, menuButton, &TmenuWidget::animate);
foreach(QRadioButton *radio, container->findChildren<QRadioButton*>()) for(QRadioButton *radio : container->findChildren<QRadioButton*>()) {
connect(radio, &QCheckBox::clicked, menuButton, &TmenuWidget::animate); connect(radio, &QCheckBox::clicked, menuButton, &TmenuWidget::animate);
foreach(QComboBox *combo, container->findChildren<QComboBox*>()) radio->setStyle(Tcore::androidStyle);
}
for(QComboBox *combo : container->findChildren<QComboBox*>())
connect(combo, SIGNAL(currentIndexChanged(int)), menuButton, SLOT(animate())); connect(combo, SIGNAL(currentIndexChanged(int)), menuButton, SLOT(animate()));
foreach(QSpinBox *spin, container->findChildren<QSpinBox*>()) for(QSpinBox *spin : container->findChildren<QSpinBox*>())
connect(spin, SIGNAL(valueChanged(int)), menuButton, SLOT(animate())); connect(spin, SIGNAL(valueChanged(int)), menuButton, SLOT(animate()));
} }
......
...@@ -137,6 +137,10 @@ int main(int argc, char *argv[]) ...@@ -137,6 +137,10 @@ int main(int argc, char *argv[])
qApp->quit(); // HACK: calling QApplication::quick() solves hang on x86 when Qt uses native (usually obsolete) SSL libraries qApp->quit(); // HACK: calling QApplication::quick() solves hang on x86 when Qt uses native (usually obsolete) SSL libraries
#endif #endif
} while (resetConfig); } while (resetConfig);
#if defined (Q_OS_ANDROID)
Tcore::androidStyle->deleteLater();
#endif
delete a; delete a;
return exitCode; return exitCode;
} }
...@@ -61,11 +61,11 @@ int TtouchStyle::styleHint(QStyle::StyleHint hint, const QStyleOption* option, ...@@ -61,11 +61,11 @@ int TtouchStyle::styleHint(QStyle::StyleHint hint, const QStyleOption* option,
int TtouchStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption* option, const QWidget* widget) const { int TtouchStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption* option, const QWidget* widget) const {
switch (metric) { switch (metric) {
case PM_SmallIconSize: case PM_SmallIconSize:
return Tmtr::fingerPixels() * 0.7; // small icon size return qRound(Tmtr::fingerPixels() * 0.7); // small icon size
case PM_IndicatorHeight: // check box size case PM_IndicatorHeight: // check box size
case PM_IndicatorWidth: case PM_IndicatorWidth:
return Tmtr::fingerPixels() * 0.5; return qRound(Tmtr::fingerPixels() * 0.5);
case PM_LayoutLeftMargin: case PM_LayoutLeftMargin:
case PM_LayoutRightMargin: case PM_LayoutRightMargin:
case PM_LayoutBottomMargin: case PM_LayoutBottomMargin:
...@@ -77,7 +77,7 @@ int TtouchStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption* opt ...@@ -77,7 +77,7 @@ int TtouchStyle::pixelMetric(QStyle::PixelMetric metric, const QStyleOption* opt
case PM_ExclusiveIndicatorHeight: // radio button ellipse size case PM_ExclusiveIndicatorHeight: // radio button ellipse size
case PM_ExclusiveIndicatorWidth: case PM_ExclusiveIndicatorWidth:
return Tmtr::fingerPixels() * 0.4; return qRound(Tmtr::fingerPixels() * 0.4);
// case PM_MenuTearoffHeight: // case PM_MenuTearoffHeight:
// return Tmtr::fingerPixels(); // return Tmtr::fingerPixels();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment