Mercurial > hg > svgui
comparison widgets/MenuTitle.h @ 1583:2e720fdcab0a
Factor out the menu titling code formerly in MainWindow
author | Chris Cannam |
---|---|
date | Thu, 26 Mar 2020 11:16:47 +0000 |
parents | |
children | 2108af725460 |
comparison
equal
deleted
inserted
replaced
1582:01a41a37bd26 | 1583:2e720fdcab0a |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
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 as | |
10 published by the Free Software Foundation; either version 2 of the | |
11 License, or (at your option) any later version. See the file | |
12 COPYING included with this distribution for more information. | |
13 */ | |
14 | |
15 #ifndef SV_MENU_TITLE_H | |
16 #define SV_MENU_TITLE_H | |
17 | |
18 #include "view/ViewManager.h" | |
19 | |
20 #include <QStyle> | |
21 #include <QWidgetAction> | |
22 #include <QLabel> | |
23 #include <QApplication> | |
24 | |
25 class MenuTitle | |
26 { | |
27 public: | |
28 static void addTitle(QMenu *m, QString text) { | |
29 | |
30 #ifdef Q_OS_LINUX | |
31 static int leftIndent = | |
32 (ViewManager::scalePixelSize(5) + | |
33 2 * qApp->style()->pixelMetric(QStyle::PM_SmallIconSize)); | |
34 #else | |
35 #ifdef Q_OS_WIN | |
36 static int leftIndent = | |
37 (9 + qApp->style()->pixelMetric(QStyle::PM_SmallIconSize)); | |
38 #else | |
39 static int leftIndent = 16; | |
40 #endif | |
41 #endif | |
42 | |
43 QWidgetAction *wa = new QWidgetAction(m); | |
44 QLabel *title = new QLabel; | |
45 title->setText(QObject::tr("<b>%1</b>") | |
46 .arg(XmlExportable::encodeEntities(text))); | |
47 title->setMargin(ViewManager::scalePixelSize(3)); | |
48 title->setIndent(leftIndent); | |
49 wa->setDefaultWidget(title); | |
50 m->addAction(wa); | |
51 m->addSeparator(); | |
52 } | |
53 }; | |
54 | |
55 #endif |