Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to compile-time connect calls #549

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions avogadro/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ AboutDialog::AboutDialog(QWidget* parent_)
"</p></body></html>");

// Add the labels
m_ui->versionLabel->setText(html.arg("20").arg(tr("Version:")));
m_ui->libsLabel->setText(html.arg("10").arg(tr("Avogadro Library Version:")));
m_ui->qtVersionLabel->setText(html.arg("10").arg(tr("Qt Version:")));
m_ui->sslVersionLabel->setText(html.arg("10").arg(tr("SSL Version:")));
m_ui->versionLabel->setText(html.arg("20", tr("Version:")));
m_ui->libsLabel->setText(html.arg("10", tr("Avogadro Library Version:")));
m_ui->qtVersionLabel->setText(html.arg("10", tr("Qt Version:")));
m_ui->sslVersionLabel->setText(html.arg("10", tr("SSL Version:")));

// Add the version numbers
m_ui->version->setText(html.arg("20").arg(AvogadroApp_VERSION));
m_ui->libsVersion->setText(html.arg("10").arg(version()));
m_ui->qtVersion->setText(html.arg("10").arg(qVersion()));
m_ui->version->setText(html.arg("20", AvogadroApp_VERSION));
m_ui->libsVersion->setText(html.arg("10", version()));
m_ui->qtVersion->setText(html.arg("10", qVersion()));
m_ui->sslVersion->setText(
html.arg("10").arg(QSslSocket::sslLibraryVersionString()));
html.arg("10", QSslSocket::sslLibraryVersionString()));

// Add support for a 2x replacement (mainly Mac OS X retina at this point).
if (window()->devicePixelRatio() == 2) {
Expand Down
15 changes: 5 additions & 10 deletions avogadro/avogadro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,32 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext& context,
switch (type) {
case QtInfoMsg:
message = QString("Info: %1 (%2:%3, %4)")
.arg(localMsg.constData())
.arg(file)
.arg(localMsg.constData(), file)
.arg(context.line)
.arg(function);
break;
case QtWarningMsg:
message = QString("Warning: %1 (%2:%3, %4)")
.arg(localMsg.constData())
.arg(file)
.arg(localMsg.constData(), file)
.arg(context.line)
.arg(function);
break;
case QtCriticalMsg:
message = QString("Critical: %1 (%2:%3, %4)")
.arg(localMsg.constData())
.arg(file)
.arg(localMsg.constData(), file)
.arg(context.line)
.arg(function);
break;
case QtFatalMsg:
message = QString("Fatal: %1 (%2:%3, %4)")
.arg(localMsg.constData())
.arg(file)
.arg(localMsg.constData(), file)
.arg(context.line)
.arg(function);
break;
case QtDebugMsg:
default:
message = QString("Debug: %1 (%2:%3, %4)")
.arg(localMsg.constData())
.arg(file)
.arg(localMsg.constData(), file)
.arg(context.line)
.arg(function);
break;
Expand Down
28 changes: 11 additions & 17 deletions avogadro/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,9 +714,8 @@ void MainWindow::updateWindowTitle()
setWindowTitle(tr("%1%2 - Avogadro %3",
"window title: %1 = file name, %2 = • for "
"modified file, %3 = Avogadro version")
.arg(QFileInfo(fileName).fileName())
.arg(m_moleculeDirty ? "•" : "")
.arg(AvogadroApp_VERSION));
.arg(QFileInfo(fileName).fileName(),
m_moleculeDirty ? "•" : "", AvogadroApp_VERSION));
}

#ifdef QTTESTING
Expand Down Expand Up @@ -788,8 +787,7 @@ void MainWindow::openFile()
return;

QString filter(QString("%1 (*.cml);;%2 (*.cjson)")
.arg(tr("Chemical Markup Language"))
.arg(tr("Chemical JSON")));
.arg(tr("Chemical Markup Language"), tr("Chemical JSON")));

QSettings settings;
QString dir = settings.value("MainWindow/lastOpenDir").toString();
Expand Down Expand Up @@ -963,7 +961,7 @@ bool MainWindow::openFile(const QString& fileName, Io::FileFormat* reader)
m_progressDialog->setMinimumDuration(750);
m_progressDialog->setWindowTitle(tr("Reading File"));
m_progressDialog->setLabelText(
tr("Opening file '%1'\nwith '%2'").arg(fileName).arg(ident));
tr("Opening file '%1'\nwith '%2'").arg(fileName, ident));
/// @todo Add API to abort file ops
m_progressDialog->setCancelButton(nullptr);
connect(m_fileReadThread, &QThread::started, m_threadedReader,
Expand Down Expand Up @@ -1030,8 +1028,7 @@ void MainWindow::backgroundReaderFinished()
} else {
MESSAGEBOX::critical(this, tr("File error"),
tr("Error while reading file '%1':\n%2")
.arg(fileName)
.arg(m_threadedReader->error()));
.arg(fileName, m_threadedReader->error()));
delete m_fileReadMolecule;
}
m_fileReadThread->deleteLater();
Expand Down Expand Up @@ -1065,8 +1062,7 @@ bool MainWindow::backgroundWriterFinished()
MESSAGEBOX::critical(
this, tr("Error saving file"),
tr("Error while saving '%1':\n%2", "%1 = file name, %2 = error message")
.arg(fileName)
.arg(m_threadedWriter->error()));
.arg(fileName, m_threadedWriter->error()));
}
}
m_fileWriteThread->deleteLater();
Expand Down Expand Up @@ -1531,8 +1527,7 @@ bool MainWindow::saveFile(bool async)
bool MainWindow::saveFileAs(bool async)
{
QString filter(QString("%1 (*.cjson);;%2 (*.cml)")
.arg(tr("Chemical JSON"))
.arg(tr("Chemical Markup Language")));
.arg(tr("Chemical JSON"), tr("Chemical Markup Language")));

QSettings settings;
QString dir = settings.value("MainWindow/lastSaveDir").toString();
Expand Down Expand Up @@ -1683,8 +1678,7 @@ bool MainWindow::saveFileAs(const QString& fileName, Io::FileFormat* writer,
m_progressDialog->setWindowTitle(tr("Saving File in Progress…"));
m_progressDialog->setLabelText(
tr("Saving file “%1”\nwith “%2”", "%1 = file name, %2 = format")
.arg(fileName)
.arg(ident));
.arg(fileName, ident));
/// @todo Add API to abort file ops
m_progressDialog->setCancelButton(nullptr);
connect(m_fileWriteThread, &QThread::started, m_threadedWriter,
Expand Down Expand Up @@ -2441,8 +2435,8 @@ void MainWindow::checkUpdate()
{
if (m_network == nullptr) {
m_network = new QNetworkAccessManager(this);
connect(m_network, SIGNAL(finished(QNetworkReply*)), this,
SLOT(finishUpdateRequest(QNetworkReply*)));
connect(m_network, &QNetworkAccessManager::finished, this,
&MainWindow::finishUpdateRequest);
}

m_network->get(
Expand Down Expand Up @@ -2650,7 +2644,7 @@ bool MainWindow::handleCommand(const QString& command,
enableTypes = options.value("types").toStringList();
} else {
// list of true / false types
for (auto key : options.keys()) {
for (const auto& key : options.keys()) {
if (options.value(key).toBool())
enableTypes << key;
else
Expand Down
7 changes: 4 additions & 3 deletions avogadro/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public slots:
* Use the FileFormat @a reader to load @a fileName. This method
* takes ownership of @a reader and will delete it before returning.
*/
bool openFile(const QString& fileName, Io::FileFormat* reader = nullptr);
bool openFile(const QString& fileName,
Avogadro::Io::FileFormat* reader = nullptr);

void exportGraphics(QString fileName);

Expand Down Expand Up @@ -158,7 +159,7 @@ public slots:
/**
* Emitted when the active molecule in the application has changed.
*/
void moleculeChanged(QtGui::Molecule* molecue);
void moleculeChanged(Avogadro::QtGui::Molecule* molecue);

protected:
void closeEvent(QCloseEvent* event);
Expand Down Expand Up @@ -248,7 +249,7 @@ protected slots:
* false, the return value indicates whether or not the file was written
* successfully.
*/
bool saveFileAs(const QString& fileName, Io::FileFormat* writer,
bool saveFileAs(const QString& fileName, Avogadro::Io::FileFormat* writer,
bool async = true);

/**
Expand Down
53 changes: 28 additions & 25 deletions avogadro/renderingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@

namespace Avogadro {

RenderingDialog::RenderingDialog(QWidget *parent_, SolidPipeline &pipeline)
: QDialog(parent_), m_ui(new Ui::RenderingDialog), m_solidPipeline(pipeline)
RenderingDialog::RenderingDialog(QWidget* parent_, SolidPipeline& pipeline)
: QDialog(parent_)
, m_ui(new Ui::RenderingDialog)
, m_solidPipeline(pipeline)
{
m_ui->setupUi(this);

m_ui->aoEnableCheckBox->setCheckState(pipeline.getAoEnabled()? Qt::Checked : Qt::Unchecked);
m_ui->dofEnableCheckBox->setCheckState(pipeline.getDofEnabled()? Qt::Checked : Qt::Unchecked);
m_ui->fogEnableCheckBox->setCheckState(pipeline.getFogEnabled()? Qt::Checked : Qt::Unchecked);
m_ui->aoEnableCheckBox->setCheckState(
pipeline.getAoEnabled() ? Qt::Checked : Qt::Unchecked);
m_ui->dofEnableCheckBox->setCheckState(
pipeline.getDofEnabled() ? Qt::Checked : Qt::Unchecked);
m_ui->fogEnableCheckBox->setCheckState(
pipeline.getFogEnabled() ? Qt::Checked : Qt::Unchecked);
m_ui->aoStrengthDoubleSpinBox->setMinimum(0.0);
m_ui->aoStrengthDoubleSpinBox->setValue(pipeline.getAoStrength());
m_ui->aoStrengthDoubleSpinBox->setMaximum(2.0);
Expand All @@ -28,7 +33,7 @@ RenderingDialog::RenderingDialog(QWidget *parent_, SolidPipeline &pipeline)
m_ui->dofStrengthDoubleSpinBox->setSingleStep(0.1);
m_ui->dofPositionDoubleSpinBox->setMinimum(0.0);
m_ui->dofPositionDoubleSpinBox->setValue(pipeline.getDofPosition());
// We can adjust the max and min value
// We can adjust the max and min value
// after testing with several molecules
m_ui->dofPositionDoubleSpinBox->setMaximum(20.0);
m_ui->dofPositionDoubleSpinBox->setDecimals(1);
Expand All @@ -43,18 +48,19 @@ RenderingDialog::RenderingDialog(QWidget *parent_, SolidPipeline &pipeline)
m_ui->fogPositionDoubleSpinBox->setMaximum(20.0);
m_ui->fogPositionDoubleSpinBox->setDecimals(1);
m_ui->fogPositionDoubleSpinBox->setSingleStep(0.1);
m_ui->edEnableCheckBox->setCheckState(pipeline.getEdEnabled()? Qt::Checked : Qt::Unchecked);

connect(m_ui->aoEnableCheckBox, SIGNAL(stateChanged(int)),
SLOT(aoEnableCheckBoxChanged(int)));
connect(m_ui->dofEnableCheckBox, SIGNAL(stateChanged(int)),
SLOT(dofEnableCheckBoxChanged(int)));
connect(m_ui->fogEnableCheckBox, SIGNAL(stateChanged(int)),
SLOT(fogEnableCheckBoxChanged(int)));
connect(m_ui->saveButton, SIGNAL(clicked()),
SLOT(saveButtonClicked()));
connect(m_ui->closeButton, SIGNAL(clicked()),
SLOT(closeButtonClicked()));
m_ui->edEnableCheckBox->setCheckState(
pipeline.getEdEnabled() ? Qt::Checked : Qt::Unchecked);

connect(m_ui->aoEnableCheckBox, &QCheckBox::stateChanged, this,
&RenderingDialog::aoEnableCheckBoxChanged);
connect(m_ui->dofEnableCheckBox, &QCheckBox::stateChanged, this,
&RenderingDialog::dofEnableCheckBoxChanged);
connect(m_ui->fogEnableCheckBox, &QCheckBox::stateChanged, this,
&RenderingDialog::fogEnableCheckBoxChanged);
connect(m_ui->saveButton, &QAbstractButton::clicked, this,
&RenderingDialog::saveButtonClicked);
connect(m_ui->closeButton, &QAbstractButton::clicked, this,
&RenderingDialog::closeButtonClicked);
}

RenderingDialog::~RenderingDialog()
Expand Down Expand Up @@ -105,26 +111,23 @@ bool RenderingDialog::edEnabled()
return m_ui->edEnableCheckBox->checkState() == Qt::Checked;
}


void RenderingDialog::dofEnableCheckBoxChanged(int state)
{
if (state == Qt::Unchecked){
if (state == Qt::Unchecked) {
m_ui->dofStrengthDoubleSpinBox->setEnabled(false);
m_ui->dofPositionDoubleSpinBox->setEnabled(false);
}
else{
} else {
m_ui->dofStrengthDoubleSpinBox->setEnabled(true);
m_ui->dofPositionDoubleSpinBox->setEnabled(true);
}
}

void RenderingDialog::fogEnableCheckBoxChanged(int state)
{
if (state == Qt::Unchecked){
if (state == Qt::Unchecked) {
m_ui->fogPositionDoubleSpinBox->setEnabled(false);
m_ui->fogStrengthDoubleSpinBox->setEnabled(false);
}
else{
} else {
m_ui->fogStrengthDoubleSpinBox->setEnabled(true);
m_ui->fogPositionDoubleSpinBox->setEnabled(true);
}
Expand Down
Loading