preferences_dialog.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #include <QGroupBox>
31 #include <QCheckBox>
32 #include <QVBoxLayout>
33 #include <QDialogButtonBox>
34 #include <QPushButton>
35 
36 #include "preferences_dialog.h"
37 #include "rviz/preferences.h"
38 
39 namespace rviz
40 {
41 PreferencesDialog::PreferencesDialog(Factory* factory, Preferences* preferences_output, QWidget* parent)
42  : QDialog(parent), factory_(factory), preferences_(preferences_output)
43 {
44  //***** Layout
45 
46  // Display Type group
47  QGroupBox* preferences_box = new QGroupBox("Preferences");
48 
49  QVBoxLayout* preferences_layout = new QVBoxLayout;
50  preferences_layout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
51  prompt_save_on_exit_checkbox_ = new QCheckBox;
53  prompt_save_on_exit_checkbox_->setText(QString("Prompt Save on Exit?"));
54  preferences_layout->addWidget(prompt_save_on_exit_checkbox_);
55  preferences_box->setLayout(preferences_layout);
56 
57  // Buttons
58  button_box_ = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
59 
60  QVBoxLayout* main_layout = new QVBoxLayout;
61  main_layout->addWidget(preferences_box);
62  main_layout->addWidget(button_box_);
63  setLayout(main_layout);
64 
65  //***** Connections
66  connect(button_box_, SIGNAL(accepted()), this, SLOT(accept()));
67  connect(button_box_, SIGNAL(rejected()), this, SLOT(reject()));
68 }
69 
71 {
72  return (QSize(500, 100));
73 }
74 
75 void PreferencesDialog::setError(const QString& error_text)
76 {
77  button_box_->button(QDialogButtonBox::Ok)->setToolTip(error_text);
78 }
79 
81 {
82  setError("");
83  return true;
84 }
85 
87 {
88  if (isValid())
89  {
91  QDialog::accept();
92  }
93 }
94 
95 } // namespace rviz
QSize sizeHint() const override
bool prompt_save_on_exit
Definition: preferences.h:37
PreferencesDialog(Factory *factory, Preferences *preferences_output, QWidget *parent=nullptr)
void setError(const QString &error_text)
Abstract superclass representing the ability to get a list of class IDs and the ability to get name...
Definition: factory.h:42
QCheckBox * prompt_save_on_exit_checkbox_
QDialogButtonBox * button_box_


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:25