[app] Better guess at screen DPI
This commit is contained in:
parent
3ebb82b208
commit
ef19a5c2e7
2 changed files with 15 additions and 8 deletions
|
@ -56,12 +56,7 @@
|
||||||
|
|
||||||
#define BOOKS_STATE_FILE_SUFFIX ".state"
|
#define BOOKS_STATE_FILE_SUFFIX ".state"
|
||||||
|
|
||||||
#if defined(__i386__)
|
extern int booksPPI;
|
||||||
# define BOOKS_PPI (330) // Tablet 1536x2048
|
#define BOOKS_PPI booksPPI
|
||||||
#elif defined(__arm__)
|
|
||||||
# define BOOKS_PPI (245) // Jolla1 540x960
|
|
||||||
#else
|
|
||||||
# error Unexpected architechture
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // BOOKS_DEFS_H
|
#endif // BOOKS_DEFS_H
|
||||||
|
|
|
@ -74,6 +74,8 @@ const std::string ZLibrary::PathDelimiter(":");
|
||||||
const std::string ZLibrary::EndOfLine("\n");
|
const std::string ZLibrary::EndOfLine("\n");
|
||||||
const std::string ZLibrary::BaseDirectory;
|
const std::string ZLibrary::BaseDirectory;
|
||||||
|
|
||||||
|
int booksPPI = 300;
|
||||||
|
|
||||||
void ZLibrary::initLocale()
|
void ZLibrary::initLocale()
|
||||||
{
|
{
|
||||||
const char* locale = setlocale(LC_MESSAGES, "");
|
const char* locale = setlocale(LC_MESSAGES, "");
|
||||||
|
@ -167,7 +169,17 @@ void ZLibrary::run(ZLApplication* aApp)
|
||||||
|
|
||||||
QQuickView* view = SailfishApp::createView();
|
QQuickView* view = SailfishApp::createView();
|
||||||
QQmlContext* root = view->rootContext();
|
QQmlContext* root = view->rootContext();
|
||||||
root->setContextProperty("PointsPerInch", BOOKS_PPI);
|
QSize screenSize(view->screen()->size());
|
||||||
|
booksPPI =
|
||||||
|
#if defined(__i386__)
|
||||||
|
(screenSize == QSize(1536,2048)) ? 330 : 300;
|
||||||
|
#elif defined(__arm__)
|
||||||
|
(screenSize == QSize(540,960)) ? 245 : 290;
|
||||||
|
#else
|
||||||
|
# error Unexpected architechture
|
||||||
|
#endif
|
||||||
|
HDEBUG("screen" << screenSize << booksPPI << "dpi");
|
||||||
|
root->setContextProperty("PointsPerInch", booksPPI);
|
||||||
root->setContextProperty("MaximumHintCount", 1);
|
root->setContextProperty("MaximumHintCount", 1);
|
||||||
|
|
||||||
view->setTitle(qtTrId("books-app-name"));
|
view->setTitle(qtTrId("books-app-name"));
|
||||||
|
|
Loading…
Reference in a new issue