• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Stellarium / stellarium / 6685397774

29 Oct 2023 07:37PM UTC coverage: 11.735% (-0.002%) from 11.737%
6685397774

push

github

10110111
Deduplicate title bar implementation

131 of 131 new or added lines in 56 files covered. (100.0%)

14842 of 126472 relevant lines covered (11.74%)

21617.74 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/gui/Dialog.hpp
1
/*
2
 * Stellarium
3
 * Copyright (C) 2008 Guillaume Chereau
4
 * 
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 * 
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 * 
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA  02110-1335, USA.
18
 */
19

20

21
#ifndef DIALOG_HPP
22
#define DIALOG_HPP
23

24
#include <QWidget>
25
#include <QFrame>
26
#include <QLabel>
27
#include <QMouseEvent>
28

29
//! \class TitleBar
30
//! A title bar control used in windows derived from StelDialog.
31
//! 
32
//! As window classes derived from StelDialog are basic QWidgets, they have no
33
//! title bar. A TitleBar control needs to be used in each window's design
34
//! to allow the user to move them.
35
//! 
36
//! Typically, the frame should contain a centered label displaying the window's
37
//! title and a button for closing the window (connected to the 
38
//! StelDialog::close() slot).
39

40
class TitleBar : public QFrame
41
{
42
        Q_OBJECT
43
        Q_PROPERTY(QString title READ title WRITE setTitle)
44
public:
45
        QPoint mousePos;
46

47
        TitleBar(QWidget* parent = nullptr);
48
        void setTitle(const QString& title) { label->setText(title); }
×
49
        QString title() const { return label->text(); }
×
50
protected:
51
        void mousePressEvent(QMouseEvent *event) override;
52
        void mouseReleaseEvent(QMouseEvent *event) override;
53
        void mouseMoveEvent(QMouseEvent *event) override;
54
signals:
55
        void closeClicked();
56
        // should be connected to the StelDialog in createDialogContents()
57
        void movedTo(QPoint newPosition);
58
protected:
59
        bool moving = false;
60
        QLabel* label;
61
};
62

63
class ResizeFrame : public QFrame
64
{
65
Q_OBJECT
66
public:
67
        QPoint mousePos;
68
  
69
        ResizeFrame(QWidget* parent) : QFrame(parent) {}
×
70
  
71
        virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE {
×
72
                mousePos = event->pos();
×
73
        }
×
74
        virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
75
};
76

77
#endif // DIALOG_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc