diff --git a/avogadro/mainwindow.cpp b/avogadro/mainwindow.cpp index 4118820d..54705154 100644 --- a/avogadro/mainwindow.cpp +++ b/avogadro/mainwindow.cpp @@ -4,7 +4,7 @@ ******************************************************************************/ #include "mainwindow.h" - +#include "preferencesdialog.h" #include "aboutdialog.h" #include "avogadroappconfig.h" #include "backgroundfileformat.h" @@ -300,7 +300,7 @@ MainWindow::MainWindow(const QStringList& fileNames, bool disableSettings) // Now set up the interface. setupInterface(); - +initializeActions(); // Build up the standard menus, incorporate dynamic menus. buildMenu(); updateRecentFiles(); @@ -356,7 +356,23 @@ MainWindow::~MainWindow() delete m_menuBuilder; delete m_viewFactory; } +void MainWindow::initializeActions() +{ + // Example initialization, adjust according to your needs + m_actionPreferences = new QAction(tr("&Preferences"), this); + connect(m_actionPreferences, &QAction::triggered, this, &MainWindow::showPreferencesDialog); + // Add m_actionPreferences to the appropriate menu or toolbar +} +void MainWindow::showPreferencesDialog() +{ + PreferencesDialog dialog(this); + dialog.loadSettings(); + + if (dialog.exec() == QDialog::Accepted) { + dialog.applySettings(); // Apply and save settings + } +} void MainWindow::setupInterface() { // We take care of setting up the main interface here, along with any custom diff --git a/avogadro/mainwindow.h b/avogadro/mainwindow.h index 3dadf613..02dc41e4 100644 --- a/avogadro/mainwindow.h +++ b/avogadro/mainwindow.h @@ -9,7 +9,7 @@ #include #include #include - +#include "preferencesdialog.h" #ifdef QTTESTING class pqTestUtility; #endif @@ -19,9 +19,9 @@ class QThread; class QTreeView; class QNetworkAccessManager; class QNetworkReply; - +class QAction; namespace Ui { -class AboutDialog; +class AboutDialog; } namespace Avogadro { @@ -74,7 +74,8 @@ public slots: * Update internal state to reflect that the molecule has been modified. */ void markMoleculeDirty(); - + void showPreferencesDialog(); + void initializeActions(); /** * Update internal state to reflect that the molecule is not modified. */ @@ -442,7 +443,7 @@ private slots: QAction* m_copyImage; QAction* m_viewPerspective; QAction* m_viewOrthographic; - + QAction* m_actionPreferences; ViewFactory* m_viewFactory; QNetworkAccessManager* m_network = nullptr; diff --git a/avogadro/mainwindow.ui b/avogadro/mainwindow.ui index 1ef7163a..d3932646 100644 --- a/avogadro/mainwindow.ui +++ b/avogadro/mainwindow.ui @@ -65,17 +65,14 @@ - - - - &Select - - - + + + + @@ -323,6 +320,35 @@ &Import + + + Preferences… + + + + :icons/preferences-icon.png:icons/preferences-icon.png + + + + Ctrl+P + + + + + + + + Preferences… + + + + :icons/preferences-icon.png:icons/preferences-icon.png + + --> + + Preferences… + + &Export @@ -337,6 +363,7 @@ actionClose triggered() MainWindow + showPreferencesDialog() close() @@ -350,10 +377,20 @@ - actionQuit - triggered() - MainWindow - close() + actionQuit + triggered() + MainWindow + close() + + + + actionPreferences + triggered() + MainWindow + showPreferencesDialog() + + + -1