1 //=============================================================================
2 //  MuseScore
3 //  Music Composition & Notation
4 //
5 //  Copyright (C) 2017 Werner Schweer and others
6 //
7 //  This program is free software; you can redistribute it and/or modify
8 //  it under the terms of the GNU General Public License version 2
9 //  as published by the Free Software Foundation and appearing in
10 //  the file LICENSE.GPL
11 //=============================================================================
12 
13 #include "fontStyleSelect.h"
14 #include "icons.h"
15 
16 namespace Ms {
17 
18 //---------------------------------------------------------
19 //    FontStyleSelect
20 //---------------------------------------------------------
21 
FontStyleSelect(QWidget * parent)22 FontStyleSelect::FontStyleSelect(QWidget* parent)
23    : QWidget(parent)
24       {
25       setupUi(this);
26 
27       bold->setIcon(*icons[int(Icons::textBold_ICON)]);
28       italic->setIcon(*icons[int(Icons::textItalic_ICON)]);
29       underline->setIcon(*icons[int(Icons::textUnderline_ICON)]);
30 
31       connect(bold, SIGNAL(toggled(bool)), SLOT(_fontStyleChanged()));
32       connect(italic, SIGNAL(toggled(bool)), SLOT(_fontStyleChanged()));
33       connect(underline, SIGNAL(toggled(bool)), SLOT(_fontStyleChanged()));
34       }
35 
36 //---------------------------------------------------------
37 //   _fontStyleChanged
38 //---------------------------------------------------------
39 
_fontStyleChanged()40 void FontStyleSelect::_fontStyleChanged()
41       {
42       emit fontStyleChanged(fontStyle());
43       }
44 
45 //---------------------------------------------------------
46 //   fontStyle
47 //---------------------------------------------------------
48 
fontStyle() const49 FontStyle FontStyleSelect::fontStyle() const
50       {
51       FontStyle fs = FontStyle::Normal;
52 
53       if (bold->isChecked())
54             fs = fs + FontStyle::Bold;
55       if (italic->isChecked())
56             fs = fs + FontStyle::Italic;
57       if (underline->isChecked())
58             fs = fs + FontStyle::Underline;
59 
60       return fs;
61       }
62 
63 //---------------------------------------------------------
64 //   setFontStyle
65 //---------------------------------------------------------
66 
setFontStyle(FontStyle fs)67 void FontStyleSelect::setFontStyle(FontStyle fs)
68       {
69       bold->setChecked(fs & FontStyle::Bold);
70       italic->setChecked(fs & FontStyle::Italic);
71       underline->setChecked(fs & FontStyle::Underline);
72       }
73 
74 }
75 
76