Warning, file /office/calligra/gemini/Constants.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2012 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "Constants.h" 0008 0009 #include <QApplication> 0010 #include <QWidget> 0011 0012 Constants::Constants(QObject* parent) 0013 : QObject(parent) 0014 { 0015 m_gridWidth = qApp->activeWindow()->width() / gridColumns(); 0016 m_gridHeight = qApp->activeWindow()->height() / gridRows(); 0017 m_toolbarButtonSize = m_gridHeight; 0018 m_toolbarHeight = (m_gridHeight * gridRows()) / 12.55814; // magic number which /should/ yield a nice, solid 84 if we're running at 1080p 0019 } 0020 0021 int Constants::animationDuration() const 0022 { 0023 return 150; 0024 } 0025 0026 qreal Constants::gridHeight() const 0027 { 0028 return m_gridHeight; 0029 } 0030 0031 void Constants::setGridHeight( qreal height ) 0032 { 0033 m_gridHeight = height; 0034 m_toolbarButtonSize = m_gridHeight; 0035 m_toolbarHeight = (m_gridHeight * gridRows()) / 12.55814; // magic number which /should/ yield a nice, solid 84 if we're running at 1080p 0036 emit gridSizeChanged(); 0037 } 0038 0039 qreal Constants::gridWidth() const 0040 { 0041 return m_gridWidth; 0042 } 0043 0044 void Constants::setGridWidth( qreal width ) 0045 { 0046 m_gridWidth = width; 0047 m_toolbarButtonSize = m_gridHeight; 0048 m_toolbarHeight = (m_gridHeight * gridRows()) / 12.55814; // magic number which /should/ yield a nice, solid 84 if we're running at 1080p 0049 emit gridSizeChanged(); 0050 } 0051 0052 qreal Constants::toolbarButtonSize() const 0053 { 0054 return m_toolbarButtonSize; 0055 } 0056 0057 qreal Constants::toolbarHeight() const 0058 { 0059 return m_toolbarHeight; 0060 } 0061 0062 int Constants::gridRows() const 0063 { 0064 if (isLandscape()) 0065 return 12; 0066 return 18; 0067 } 0068 0069 int Constants::gridColumns() const 0070 { 0071 return 12; 0072 } 0073 0074 qreal Constants::defaultMargin() const 0075 { 0076 return 0.1 * m_gridHeight; 0077 } 0078 0079 qreal Constants::smallFontSize() const 0080 { 0081 return 0.2 * m_gridHeight; 0082 } 0083 0084 qreal Constants::defaultFontSize() const 0085 { 0086 return 0.3 * m_gridHeight; 0087 } 0088 0089 qreal Constants::largeFontSize() const 0090 { 0091 return 0.4 * m_gridHeight; 0092 } 0093 0094 qreal Constants::hugeFontSize() const 0095 { 0096 return 0.9 * m_gridHeight; 0097 } 0098 0099 bool Constants::isLandscape() const 0100 { 0101 // If user switches certain settings in windows, activeWindow can become null. 0102 if(qApp->activeWindow()) 0103 return qApp->activeWindow()->height() < qApp->activeWindow()->width(); 0104 return true; 0105 }