swift
modelconverterxsetupcomponent.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #include <QFileDialog>
7 
8 #include "ui_modelconverterxsetupcomponent.h"
9 
10 #include "misc/logmessage.h"
11 #include "misc/statusmessage.h"
12 
13 using namespace swift::misc;
14 
15 namespace swift::gui::components
16 {
17  CModelConverterXSetupComponent::CModelConverterXSetupComponent(QWidget *parent)
18  : QFrame(parent), ui(new Ui::CModelConverterXSetupComponent)
19  {
20  ui->setupUi(this);
21  connect(ui->pb_DirBrowser, &QPushButton::clicked, this, &CModelConverterXSetupComponent::selectBinary);
22  connect(ui->le_McxBinary, &QLineEdit::returnPressed, this, &CModelConverterXSetupComponent::saveSettings);
23  ui->le_McxBinary->setText(m_setting.get());
24  }
25 
27 
28  void CModelConverterXSetupComponent::selectBinary()
29  {
30  QString defaultValue = m_setting.get();
31  if (defaultValue.isEmpty()) { defaultValue = QDir::currentPath(); }
32  const QString fileName =
33  QFileDialog::getOpenFileName(nullptr, tr("ModelConverterX binary"), defaultValue, "*.exe");
34  ui->le_McxBinary->setText(fileName);
35  this->saveSettings();
36  }
37 
38  void CModelConverterXSetupComponent::saveSettings()
39  {
40  const QString t = ui->le_McxBinary->text();
41  const CStatusMessage msg = m_setting.setAndSave(t);
42  CLogMessage::preformatted(msg);
43  }
44 } // namespace swift::gui::components
CStatusMessage setAndSave(const T &value, qint64 timestamp=0)
Write and save in the same step. Must be called from the thread in which the owner lives.
Definition: valuecache.h:417
T get() const
Get a copy of the current value.
Definition: valuecache.h:408
Streamable status message, e.g.
High level reusable GUI components.
Definition: aboutdialog.cpp:13
Free functions in swift::misc.