Mercurial > hg > orthanc-stone
annotate Applications/Samples/Qt/SampleMainWindow.cpp @ 320:10d188d6e5cc am-2
compatibility with Qt4
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 12 Oct 2018 14:38:48 +0200 |
parents | 87376a645ee1 |
children | 612238b3f3e8 |
rev | line source |
---|---|
285 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 #include "SampleMainWindow.h" | |
22 | |
23 /** | |
24 * Don't use "ui_MainWindow.h" instead of <ui_MainWindow.h> below, as | |
25 * this makes CMake unable to detect when the UI file changes. | |
26 **/ | |
27 #include <ui_SampleMainWindow.h> | |
28 #include "../../Applications/Samples/SampleApplicationBase.h" | |
29 | |
30 namespace OrthancStone | |
31 { | |
32 namespace Samples | |
33 { | |
34 | |
291 | 35 SampleMainWindow::SampleMainWindow(OrthancStone::NativeStoneApplicationContext& context, OrthancStone::Samples::SampleApplicationBase& stoneSampleApplication, QWidget *parent) : |
285 | 36 QStoneMainWindow(context, parent), |
37 ui_(new Ui::SampleMainWindow), | |
38 stoneSampleApplication_(stoneSampleApplication) | |
39 { | |
40 ui_->setupUi(this); | |
41 SetCentralStoneWidget(ui_->cairoCentralWidget); | |
42 | |
320
10d188d6e5cc
compatibility with Qt4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
43 #if QT_VERSION >= 0x050000 |
285 | 44 connect(ui_->toolButton1, &QToolButton::clicked, this, &SampleMainWindow::tool1Clicked); |
45 connect(ui_->toolButton2, &QToolButton::clicked, this, &SampleMainWindow::tool2Clicked); | |
46 connect(ui_->pushButton1, &QPushButton::clicked, this, &SampleMainWindow::pushButton1Clicked); | |
47 connect(ui_->pushButton1, &QPushButton::clicked, this, &SampleMainWindow::pushButton2Clicked); | |
320
10d188d6e5cc
compatibility with Qt4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
48 #else |
10d188d6e5cc
compatibility with Qt4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
49 connect(ui_->toolButton1, SIGNAL(clicked()), this, SLOT(tool1Clicked())); |
10d188d6e5cc
compatibility with Qt4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
50 connect(ui_->toolButton2, SIGNAL(clicked()), this, SLOT(tool2Clicked())); |
10d188d6e5cc
compatibility with Qt4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
51 connect(ui_->pushButton1, SIGNAL(clicked()), this, SLOT(pushButton1Clicked())); |
10d188d6e5cc
compatibility with Qt4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
52 connect(ui_->pushButton1, SIGNAL(clicked()), this, SLOT(pushButton2Clicked())); |
10d188d6e5cc
compatibility with Qt4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
291
diff
changeset
|
53 #endif |
286 | 54 |
55 std::string pushButton1Name; | |
56 std::string pushButton2Name; | |
57 std::string tool1Name; | |
58 std::string tool2Name; | |
59 stoneSampleApplication_.GetButtonNames(pushButton1Name, pushButton2Name, tool1Name, tool2Name); | |
60 | |
61 ui_->toolButton1->setText(QString::fromStdString(tool1Name)); | |
62 ui_->toolButton2->setText(QString::fromStdString(tool2Name)); | |
63 ui_->pushButton1->setText(QString::fromStdString(pushButton1Name)); | |
64 ui_->pushButton2->setText(QString::fromStdString(pushButton2Name)); | |
285 | 65 } |
66 | |
67 SampleMainWindow::~SampleMainWindow() | |
68 { | |
69 delete ui_; | |
70 } | |
71 | |
72 void SampleMainWindow::tool1Clicked() | |
73 { | |
74 stoneSampleApplication_.OnTool1Clicked(); | |
75 } | |
76 | |
77 void SampleMainWindow::tool2Clicked() | |
78 { | |
79 stoneSampleApplication_.OnTool2Clicked(); | |
80 } | |
81 | |
82 void SampleMainWindow::pushButton1Clicked() | |
83 { | |
84 stoneSampleApplication_.OnPushButton1Clicked(); | |
85 } | |
86 | |
87 void SampleMainWindow::pushButton2Clicked() | |
88 { | |
89 stoneSampleApplication_.OnPushButton2Clicked(); | |
90 } | |
91 | |
92 } | |
93 } |