Clean up overuse of literals for GUI constants.

Add CalamaresStyle for colors and other style constants and helpers.
Add static functions for font size.
This commit is contained in:
Teo Mrnjavac 2014-07-08 13:22:09 +02:00
parent f10f2026ad
commit 52028d95f9
7 changed files with 125 additions and 15 deletions

View file

@ -18,11 +18,17 @@
#include "CalamaresUtilsGui.h"
#include <QFont>
#include <QFontMetrics>
#include <QLayout>
namespace CalamaresUtils
{
static int s_defaultFontSize = 0;
static int s_defaultFontHeight = 0;
void
unmarginLayout( QLayout* layout )
{
@ -38,4 +44,41 @@ unmarginLayout( QLayout* layout )
}
}
int
defaultFontSize()
{
return s_defaultFontSize;
}
int
defaultFontHeight()
{
if ( s_defaultFontHeight <= 0 )
{
QFont f;
f.setPointSize( defaultFontSize() );
s_defaultFontHeight = QFontMetrics( f ).height();
}
return s_defaultFontHeight;
}
void
setDefaultFontSize( int points )
{
s_defaultFontSize = points;
}
QSize
defaultIconSize()
{
const int w = defaultFontHeight() * 1.6;
return QSize( w, w );
}
}