26 #include <QFileDialog> 41 , dirGroup(new QGroupBox)
43 , buttons(new QGroupBox)
44 , settingsDirEdit(new QLineEdit(dirGroup))
45 , dataDirEdit(new QLineEdit(dirGroup))
46 , HDFBufferEdit(new QLineEdit(HDF))
49 const QSettings user_preferences;
50 QSettings::setPath(QSettings::NativeFormat,
51 QSettings::SystemScope,
52 "/usr/local/share/rtxi/");
55 auto* box_layout =
new QVBoxLayout;
58 auto* dirLayout =
new QGridLayout;
61 const QString env_var = QString::fromLocal8Bit(qgetenv(
"HOME"));
62 settingsDirEdit->setText(
63 user_preferences.value(
"/dirs/setfiles", env_var).toString());
65 new QLabel(tr(
"Default settings directory:")), 0, 0, 1, 1);
66 dirLayout->addWidget(settingsDirEdit, 0, 1, 1, 1);
67 auto* chooseSettingsDirButton =
new QPushButton(
"Browse",
this);
68 dirLayout->addWidget(chooseSettingsDirButton, 0, 2, 1, 2);
69 QObject::connect(chooseSettingsDirButton,
75 user_preferences.value(
"/dirs/data", env_var).toString());
77 new QLabel(tr(
"Default HDF5 data directory:")), 1, 0, 1, 1);
78 dirLayout->addWidget(dataDirEdit, 1, 1, 1, 1);
79 auto* chooseDataDirButton =
new QPushButton(
"Browse",
this);
80 dirLayout->addWidget(chooseDataDirButton, 1, 2, 1, 2);
82 chooseDataDirButton, SIGNAL(released()),
this, SLOT(
chooseDataDir()));
85 dirGroup->setLayout(dirLayout);
88 auto* hdfLayout =
new QGridLayout;
92 new QLabel(tr(
"HDF Data Recorder Buffer Size (MB):")), 0, 0, 1, 1);
93 hdfLayout->addWidget(HDFBufferEdit, 0, 1, 1, 1);
94 HDFBufferEdit->setText(
95 QString::number(user_preferences.value(
"/system/HDFbuffer", 10).toInt()));
98 HDF->setLayout(hdfLayout);
101 auto* buttonLayout =
new QHBoxLayout;
104 auto* resetButton =
new QPushButton(
"Reset");
105 QObject::connect(resetButton, SIGNAL(released()),
this, SLOT(
reset()));
106 auto* applyButton =
new QPushButton(
"Save");
107 QObject::connect(applyButton, SIGNAL(released()),
this, SLOT(
apply()));
108 auto* cancelButton =
new QPushButton(
"Close");
110 cancelButton, SIGNAL(released()), parentWidget(), SLOT(close()));
112 status->setText(
"Defaults \nloaded");
114 status->setFrameStyle(QFrame::Panel | QFrame::Sunken);
115 status->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
118 buttonLayout->addWidget(resetButton);
119 buttonLayout->addWidget(applyButton);
120 buttonLayout->addWidget(cancelButton);
121 buttonLayout->addWidget(status);
124 buttons->setLayout(buttonLayout);
127 box_layout->addWidget(dirGroup);
128 box_layout->addWidget(HDF);
129 box_layout->addWidget(buttons);
132 setLayout(box_layout);
133 setWindowTitle(QString(this->
getName().c_str()));
136 this->
getMdiWindow()->setFixedSize(500, this->sizeHint().height() + 50);
141 const QString env_var = QString::fromLocal8Bit(qgetenv(
"HOME"));
142 settingsDirEdit->setText(env_var);
143 dataDirEdit->setText(env_var);
144 HDFBufferEdit->setText(QString::number(10));
145 userprefs.setValue(
"/dirs/setfiles", settingsDirEdit->text());
146 userprefs.setValue(
"/dirs/data", dataDirEdit->text());
148 const QString buffer = HDFBufferEdit->text();
149 userprefs.setValue(
"/system/HDFbuffer", buffer.toInt(&ok));
150 status->setText(
"Preferences \nreset");
155 userprefs.setValue(
"/dirs/setfiles", settingsDirEdit->text());
156 userprefs.setValue(
"/dirs/data", dataDirEdit->text());
158 const QString buffer = HDFBufferEdit->text();
159 userprefs.setValue(
"/system/HDFbuffer", buffer.toInt(&ok));
160 status->setText(
"Preferences \napplied");
165 const QString env_var = QString::fromLocal8Bit(qgetenv(
"HOME"));
166 const QString dir_name = QFileDialog::getExistingDirectory(
168 tr(
"Choose default directory for settings files"),
169 userprefs.value(
"/dirs/setfiles", env_var).toString(),
170 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
171 settingsDirEdit->setText(dir_name);
176 const QString env_var = QString::fromLocal8Bit(qgetenv(
"HOME"));
177 const QString dir_name = QFileDialog::getExistingDirectory(
179 tr(
"Choose default directory for HDF5 data files"),
180 userprefs.value(
"/dirs/data", env_var).toString(),
181 QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
182 dataDirEdit->setText(dir_name);
188 return std::make_unique<UserPrefs::Plugin>(ev_manager);
Panel(QMainWindow *mwindow, Event::Manager *ev_manager)
Plugin(Event::Manager *ev_manager)
constexpr std::string_view MODULE_NAME
std::unique_ptr< Widgets::Component > createRTXIComponent(Widgets::Plugin *host_plugin)
Widgets::Panel * createRTXIPanel(QMainWindow *main_window, Event::Manager *ev_manager)
Widgets::FactoryMethods getFactories()
std::unique_ptr< Widgets::Plugin > createRTXIPlugin(Event::Manager *ev_manager)
constexpr std::string_view MODULE_NAME