annotate widgets/MenuTitle.h @ 1605:ae2d5f8ff005

When asked to render the whole view width, we need to wait for the layers to be ready before we can determine what the width is
author Chris Cannam
date Thu, 30 Apr 2020 14:47:13 +0100
parents e660a00bc3b9
children
rev   line source
Chris@1583 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1583 2
Chris@1583 3 /*
Chris@1583 4 Sonic Visualiser
Chris@1583 5 An audio file viewer and annotation editor.
Chris@1583 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1583 7
Chris@1583 8 This program is free software; you can redistribute it and/or
Chris@1583 9 modify it under the terms of the GNU General Public License as
Chris@1583 10 published by the Free Software Foundation; either version 2 of the
Chris@1583 11 License, or (at your option) any later version. See the file
Chris@1583 12 COPYING included with this distribution for more information.
Chris@1583 13 */
Chris@1583 14
Chris@1583 15 #ifndef SV_MENU_TITLE_H
Chris@1583 16 #define SV_MENU_TITLE_H
Chris@1583 17
Chris@1583 18 #include "view/ViewManager.h"
Chris@1583 19
Chris@1583 20 #include <QStyle>
Chris@1583 21 #include <QWidgetAction>
Chris@1583 22 #include <QLabel>
Chris@1583 23 #include <QApplication>
Chris@1587 24 #include <QMenu>
Chris@1583 25
Chris@1583 26 class MenuTitle
Chris@1583 27 {
Chris@1583 28 public:
Chris@1583 29 static void addTitle(QMenu *m, QString text) {
Chris@1583 30
Chris@1583 31 #ifdef Q_OS_LINUX
Chris@1583 32 static int leftIndent =
Chris@1590 33 (ViewManager::scalePixelSize(8) +
Chris@1590 34 qApp->style()->pixelMetric(QStyle::PM_SmallIconSize));
Chris@1583 35 #else
Chris@1583 36 #ifdef Q_OS_WIN
Chris@1583 37 static int leftIndent =
Chris@1583 38 (9 + qApp->style()->pixelMetric(QStyle::PM_SmallIconSize));
Chris@1583 39 #else
Chris@1583 40 static int leftIndent = 16;
Chris@1583 41 #endif
Chris@1583 42 #endif
Chris@1583 43
Chris@1583 44 QWidgetAction *wa = new QWidgetAction(m);
Chris@1583 45 QLabel *title = new QLabel;
Chris@1583 46 title->setText(QObject::tr("<b>%1</b>")
Chris@1583 47 .arg(XmlExportable::encodeEntities(text)));
Chris@1583 48 title->setMargin(ViewManager::scalePixelSize(3));
Chris@1583 49 title->setIndent(leftIndent);
Chris@1583 50 wa->setDefaultWidget(title);
Chris@1583 51 m->addAction(wa);
Chris@1583 52 m->addSeparator();
Chris@1583 53 }
Chris@1583 54 };
Chris@1583 55
Chris@1583 56 #endif