add parameter dcerpc_info to PIDL_dissect_ipv?address()
[wireshark-wip.git] / ui / qt / qt_ui_utils.cpp
blob84467cbbd54f3bb148b7b354e76d5f216b07f950
1 /* qt_ui_utils.cpp
3 * $Id$
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include <string.h>
25 #include <stdlib.h>
27 #include "qt_ui_utils.h"
29 #include <ui/recent.h>
30 #include <ui/ui_util.h>
32 #include <wsutil/str_util.h>
34 #include <QFontDatabase>
36 /* Make the format_size_flags_e enum usable in C++ */
37 format_size_flags_e operator|(format_size_flags_e lhs, format_size_flags_e rhs) {
38 return (format_size_flags_e) ((int)lhs| (int)rhs);
43 * We might want to create our own "wsstring" class with convenience
44 * methods for handling g_malloc()ed strings, GStrings, and a shortcut
45 * to .toUtf8().constData().
48 gchar *qstring_strdup(QString q_string) {
49 return g_strdup(q_string.toUtf8().constData());
52 QString gchar_free_to_qstring(gchar *glib_string) {
53 QString *qt_string = new QString(glib_string);
54 g_free(glib_string);
55 return *qt_string;
58 void smooth_font_size(QFont &font) {
59 QFontDatabase fdb;
60 QList<int> size_list = fdb.smoothSizes(font.family(), font.styleName());
62 if (size_list.size() < 2) return;
64 int last_size = size_list.takeFirst();
65 foreach (int cur_size, size_list) {
66 if (font.pointSize() > last_size && font.pointSize() <= cur_size) {
67 font.setPointSize(cur_size);
68 return;
70 last_size = cur_size;
75 * Editor modelines
77 * Local Variables:
78 * c-basic-offset: 4
79 * tab-width: 8
80 * indent-tabs-mode: nil
81 * End:
83 * ex: set shiftwidth=4 tabstop=8 expandtab:
84 * :indentSize=4:tabSize=8:noTabs=true: