Use pixels to specify the font sizes

Basically reverts the last font related commits since pointSize isn't
as reliable as pixelSize.

Also some layout values (margins, spacings) have been moved out to Config.h.
This commit is contained in:
Konstantinos Sideris 2017-07-15 17:11:46 +03:00
parent 847ae37df2
commit 30fb46e25b
19 changed files with 156 additions and 92 deletions

63
include/Config.h Normal file
View file

@ -0,0 +1,63 @@
#pragma once
// Non-theme app configuration. Layouts, fonts spacing etc.
//
// Font sizes are in pixels.
namespace conf
{
// Global settings.
static const int fontSize = 12;
static const int emojiSize = 14;
static const int headerFontSize = 21;
// Button settings.
namespace btn
{
static const int fontSize = 20;
static const int cornerRadius = 3;
}
// RoomList specific.
namespace roomlist
{
namespace fonts
{
static const int heading = 13;
static const int badge = 10;
static const int bubble = 20;
} // namespace fonts
} // namespace roomlist
namespace userInfoWidget
{
namespace fonts
{
static const int displayName = 16;
static const int userid = 14;
} // namespace fonts
} // namespace userInfoWidget
namespace topRoomBar
{
namespace fonts
{
static const int roomName = 15;
static const int roomDescription = 13;
} // namespace fonts
} // namespace topRoomBar
namespace timeline
{
static const int msgMargin = 11;
static const int avatarSize = 36;
static const int headerSpacing = 5;
static const int headerLeftMargin = 12;
namespace fonts
{
static const int timestamp = 9;
}
}
} // namespace conf

View file

@ -75,12 +75,6 @@ private:
QPixmap roomAvatar_;
// Sizes are relative to the default font size of the Widget.
static const float UnreadCountFontRatio;
static const float RoomNameFontRatio;
static const float RoomDescriptionFontRatio;
static const float RoomAvatarLetterFontRatio;
Menu *menu_;
QAction *toggleNotifications_;

View file

@ -63,7 +63,4 @@ private:
FlatButton *send_file_button_;
FlatButton *send_message_button_;
EmojiPickButton *emoji_button_;
const float TextFontRatio = 1.1;
const float EmojiFontRatio = 1.3;
};

View file

@ -69,16 +69,10 @@ private:
QHBoxLayout *headerLayout_; // Username (&) Timestamp
int MessageMargin;
const int AvatarSize = 36;
const float TimestampFontRatio = 0.8;
const float EmojiFontRatio = 1.4;
float EmojiSize = 13;
Avatar *userAvatar_;
QFont font_;
QLabel *timestamp_;
QLabel *userName_;
QLabel *body_;

View file

@ -68,9 +68,6 @@ private:
Avatar *avatar_;
int buttonSize_;
const float RoomNameFontRatio = 1.2;
const float RoomDescriptionFontRatio = 1;
};
inline void TopRoomBar::updateRoomAvatar(const QImage &avatar_image)

View file

@ -72,7 +72,4 @@ private:
LogoutDialog *logoutDialog_;
int logoutButtonSize_;
const float DisplayNameFontRatio = 1.3;
const float UserIdFontRatio = 1.1;
};

View file

@ -2,13 +2,18 @@
#include <QMenu>
#include "Config.h"
class Menu : public QMenu
{
public:
Menu(QWidget *parent = nullptr)
: QMenu(parent)
{
setFont(QFont("Open Sans", 10));
QFont font;
font.setPixelSize(conf::fontSize);
setFont(font);
setStyleSheet(
"QMenu { color: black; background-color: white; margin: 0px;}"
"QMenu::item { color: black; padding: 7px 20px; border: 1px solid transparent; margin: 2px 0px; }"