Debian Codegraph @

src/ApvlvEditor.cc

raw
1 /*
2 * This file is part of the apvlv package
3 *
4 * Copyright (C) 2008 Alf.
5 *
6 * Contact: Alf <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2.0 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 */
23 /* @CPPFILE ApvlvEditor.cc
24 *
25 * Author: Alf <[email protected]>
26 */
27
28 #include "ApvlvEditor.h"
29
30 namespace apvlv
31 {
32
33 Editor::Editor (QWidget *parent) : QTextEdit (parent)
34 {
35 auto font = currentFont ();
36 mFontFamily = font.family ();
37 mFontPointSize = font.pointSizeF ();
38 mFontWeight = font.weight ();
39 mFontPixelSize = font.pixelSize ();
40 }
41
42 void
43 Editor::setZoomrate (double zm)
44 {
45 auto font = currentFont ();
46 auto updated = false;
47 if (mFontPointSize != -1)
48 {
49 auto pointsize = mFontPointSize * zm;
50 font.setPointSizeF (pointsize);
51 updated = true;
52 }
53 else if (mFontPixelSize != -1)
54 {
55 auto pixelsize = mFontPixelSize * zm;
56 font.setPixelSize (static_cast<int> (pixelsize));
57 updated = true;
58 }
59 if (updated)
60 {
61 setFont (font);
62 update ();
63 }
64 }
65
66 }