| 1 |
/****************************************************************************** |
| 2 |
|
| 3 |
This source file is part of the Avogadro project. |
| 4 |
|
| 5 |
Copyright 2016 Barry E Moore II |
| 6 |
|
| 7 |
This source code is released under the New BSD License, (the "License"). |
| 8 |
|
| 9 |
Unless required by applicable law or agreed to in writing, software |
| 10 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
See the License for the specific language governing permissions and |
| 13 |
limitations under the License. |
| 14 |
|
| 15 |
******************************************************************************/ |
| 16 |
|
| 17 |
#include "3dmol.h" |
| 18 |
|
| 19 |
#include "3dmoldialog.h" |
| 20 |
|
| 21 |
#include <QAction> |
| 22 |
#include <QStringList> |
| 23 |
|
| 24 |
namespace Avogadro::QtPlugins { |
| 25 |
|
| 26 |
ThreeDMol::ThreeDMol(QObject* parent_) |
| 27 |
: Avogadro::QtGui::ExtensionPlugin(parent_), m_action(new QAction(this)), |
| 28 |
m_dialog(nullptr), m_molecule(nullptr) |
| 29 |
{ |
| 30 |
m_action->setEnabled(true); |
| 31 |
m_action->setText("&3DMol HTML Snippet…"); |
| 32 |
connect(m_action, SIGNAL(triggered()), SLOT(showDialog())); |
| 33 |
} |
| 34 |
|
| 35 |
QString ThreeDMol::description() const |
| 36 |
{ |
| 37 |
return tr("3DMol HTML Block."); |
| 38 |
} |
| 39 |
|
| 40 |
QList<QAction*> ThreeDMol::actions() const |
| 41 |
{ |
| 42 |
return QList<QAction*>() << m_action; |
| 43 |
} |
| 44 |
|
| 45 |
QStringList ThreeDMol::menuPath(QAction*) const |
| 46 |
{ |
| 47 |
return QStringList() << tr("&File") << tr("&Export"); |
| 48 |
} |
| 49 |
|
| 50 |
void ThreeDMol::setMolecule(QtGui::Molecule* mol) |
| 51 |
{ |
| 52 |
if (mol == m_molecule) |
| 53 |
return; |
| 54 |
|
| 55 |
m_molecule = mol; |
| 56 |
if (m_dialog) |
| 57 |
m_dialog->setMolecule(m_molecule); |
| 58 |
} |
| 59 |
|
| 60 |
void ThreeDMol::showDialog() |
| 61 |
{ |
| 62 |
if (!m_dialog) { |
| 63 |
m_dialog = |
| 64 |
new ThreeDMolDialog(m_molecule, qobject_cast<QWidget*>(this->parent())); |
| 65 |
} |
| 66 |
m_dialog->show(); |
| 67 |
m_dialog->raise(); |
| 68 |
m_dialog->activateWindow(); |
| 69 |
} |
| 70 |
|
| 71 |
} // namespace Avogadro::QtPlugins |