|
1 | | -// |
2 | | -// Created by fuga on 08 nov 2024. |
3 | | -// |
4 | | - |
5 | 1 | #ifndef QTADS_MYDOCKAREATITLEBAR_H |
6 | 2 | #define QTADS_MYDOCKAREATITLEBAR_H |
| 3 | +/******************************************************************************* |
| 4 | +** Qt Advanced Docking System |
| 5 | +** Copyright (C) 2017 Uwe Kindler |
| 6 | +** |
| 7 | +** This library is free software; you can redistribute it and/or |
| 8 | +** modify it under the terms of the GNU Lesser General Public |
| 9 | +** License as published by the Free Software Foundation; either |
| 10 | +** version 2.1 of the License, or (at your option) any later version. |
| 11 | +** |
| 12 | +** This library is distributed in the hope that it will be useful, |
| 13 | +** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | +** Lesser General Public License for more details. |
| 16 | +** |
| 17 | +** You should have received a copy of the GNU Lesser General Public |
| 18 | +** License along with this library; If not, see <http://www.gnu.org/licenses/>. |
| 19 | +******************************************************************************/ |
| 20 | + |
7 | 21 |
|
| 22 | +//============================================================================ |
| 23 | +// INCLUDES |
| 24 | +//============================================================================ |
8 | 25 | #include <DockAreaTitleBar.h> |
9 | 26 |
|
10 | | -class MyDockAreaTitleBar : public ads::CDockAreaTitleBar { |
| 27 | + |
| 28 | +/** |
| 29 | + * Custom DockAreaTitleBar that adds a custom context menu |
| 30 | + */ |
| 31 | +class MyDockAreaTitleBar : public ads::CDockAreaTitleBar |
| 32 | +{ |
11 | 33 | public: |
12 | | - explicit MyDockAreaTitleBar(ads::CDockAreaWidget* parent) |
13 | | - : CDockAreaTitleBar(parent) |
14 | | - {} |
15 | | - |
16 | | - QMenu* buildContextMenu(QMenu*) override |
17 | | - { |
18 | | - auto menu = ads::CDockAreaTitleBar::buildContextMenu(nullptr); |
19 | | - menu->addSeparator(); |
20 | | - auto action = menu->addAction(tr("Format HardDrive")); |
21 | | - |
22 | | - connect(action, &QAction::triggered, this, [this](){ |
23 | | - QMessageBox msgBox; |
24 | | - msgBox.setText("No, just kidding"); |
25 | | - msgBox.setStandardButtons(QMessageBox::Abort); |
26 | | - msgBox.setDefaultButton(QMessageBox::Abort); |
27 | | - msgBox.exec(); |
28 | | - }); |
29 | | - |
30 | | - return menu; |
31 | | - } |
| 34 | + explicit MyDockAreaTitleBar(ads::CDockAreaWidget *parent) : |
| 35 | + CDockAreaTitleBar(parent) |
| 36 | + { |
| 37 | + } |
| 38 | + |
| 39 | + QMenu* buildContextMenu(QMenu*) override |
| 40 | + { |
| 41 | + auto menu = ads::CDockAreaTitleBar::buildContextMenu(nullptr); |
| 42 | + menu->addSeparator(); |
| 43 | + auto action = menu->addAction(tr("Format HardDrive")); |
| 44 | + |
| 45 | + connect(action, &QAction::triggered, this, [this]() |
| 46 | + { |
| 47 | + QMessageBox msgBox; |
| 48 | + msgBox.setText("No, just kidding"); |
| 49 | + msgBox.setStandardButtons(QMessageBox::Abort); |
| 50 | + msgBox.setDefaultButton(QMessageBox::Abort); |
| 51 | + msgBox.exec(); |
| 52 | + }); |
| 53 | + |
| 54 | + return menu; |
| 55 | + } |
32 | 56 | }; |
33 | 57 |
|
34 | 58 | #endif // QTADS_MYDOCKAREATITLEBAR_H |
0 commit comments