File indexing completed on 2024-12-22 04:17:24
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2007 The University of Toronto * 0004 * netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 0013 #include "applicationsettingsdialog.h" 0014 0015 #include "applicationsettings.h" 0016 #include "gridtab.h" 0017 #include "generaltab.h" 0018 #include "dialogpage.h" 0019 #include "defaultlabelpropertiestab.h" 0020 #include "layouttab.h" 0021 0022 #include <QDebug> 0023 0024 namespace Kst { 0025 0026 ApplicationSettingsDialog::ApplicationSettingsDialog(QWidget *parent) 0027 : Dialog(parent) { 0028 0029 setWindowTitle(tr("Kst Settings")); 0030 setAttribute(Qt::WA_DeleteOnClose, false); 0031 0032 _generalTab = new GeneralTab(this); 0033 _gridTab = new GridTab(this); 0034 _defaultLabelPropertiesTab = new DefaultLabelPropertiesTab(this); 0035 _layoutTab = new LayoutTab(this); 0036 0037 connect(_generalTab, SIGNAL(apply()), this, SLOT(generalChanged())); 0038 connect(_gridTab, SIGNAL(apply()), this, SLOT(gridChanged())); 0039 connect(_defaultLabelPropertiesTab, SIGNAL(apply()), this, SLOT(defaultLabelPropertiesChanged())); 0040 connect(_layoutTab, SIGNAL(apply()), this, SLOT(layoutChanged())); 0041 0042 DialogPage *general = new DialogPage(this); 0043 general->setPageTitle(tr("General")); 0044 general->addDialogTab(_generalTab); 0045 addDialogPage(general); 0046 0047 DialogPage *defaultLabelProperties = new DialogPage(this); 0048 defaultLabelProperties->setPageTitle(tr("Scaling")); 0049 defaultLabelProperties->addDialogTab(_defaultLabelPropertiesTab); 0050 addDialogPage(defaultLabelProperties); 0051 0052 DialogPage *grid = new DialogPage(this); 0053 grid->setPageTitle(tr("Grid")); 0054 grid->addDialogTab(_gridTab); 0055 addDialogPage(grid); 0056 0057 DialogPage *layout = new DialogPage(this); 0058 layout->setPageTitle(tr("Layout Properties")); 0059 layout->addDialogTab(_layoutTab); 0060 addDialogPage(layout); 0061 0062 setupGeneral(); 0063 setupGrid(); 0064 setupDefaultLabelProperties(); 0065 setupLayout(); 0066 0067 selectDialogPage(general); 0068 } 0069 0070 0071 ApplicationSettingsDialog::~ApplicationSettingsDialog() { 0072 } 0073 0074 0075 void ApplicationSettingsDialog::setupGeneral() { 0076 _generalTab->setUseRaster(ApplicationSettings::self()->useRaster()); 0077 _generalTab->setTransparentDrag(ApplicationSettings::self()->transparentDrag()); 0078 _generalTab->setMinimumUpdatePeriod(ApplicationSettings::self()->minimumUpdatePeriod()); 0079 _generalTab->setAntialiasPlot(ApplicationSettings::self()->antialiasPlots()); 0080 } 0081 0082 0083 void ApplicationSettingsDialog::setupGrid() { 0084 _gridTab->setShowGrid(ApplicationSettings::self()->showGrid()); 0085 _gridTab->setSnapToGrid(ApplicationSettings::self()->snapToGrid()); 0086 _gridTab->setGridHorizontalSpacing(ApplicationSettings::self()->gridHorizontalSpacing()); 0087 _gridTab->setGridVerticalSpacing(ApplicationSettings::self()->gridVerticalSpacing()); 0088 } 0089 0090 0091 void ApplicationSettingsDialog::setupDefaultLabelProperties() { 0092 _defaultLabelPropertiesTab->setReferenceViewWidth(ApplicationSettings::self()->referenceViewWidthCM()); 0093 _defaultLabelPropertiesTab->setReferenceViewHeight(ApplicationSettings::self()->referenceViewHeightCM()); 0094 _defaultLabelPropertiesTab->setMinimumFontSize(ApplicationSettings::self()->minimumFontSize()); 0095 } 0096 0097 0098 void ApplicationSettingsDialog::setupLayout() { 0099 _layoutTab->setHorizontalMargin(ApplicationSettings::self()->layoutMargins().width()); 0100 _layoutTab->setVerticalMargin(ApplicationSettings::self()->layoutMargins().height()); 0101 _layoutTab->setHorizontalSpacing(ApplicationSettings::self()->layoutSpacing().width()); 0102 _layoutTab->setVerticalSpacing(ApplicationSettings::self()->layoutSpacing().height()); 0103 } 0104 0105 0106 void ApplicationSettingsDialog::generalChanged() { 0107 //Need to block the signals so that the modified signal only goes out once... 0108 ApplicationSettings::self()->blockSignals(true); 0109 ApplicationSettings::self()->setTransparentDrag(_generalTab->transparentDrag()); 0110 ApplicationSettings::self()->setUseRaster(_generalTab->useRaster()); 0111 ApplicationSettings::self()->setMinimumUpdatePeriod(_generalTab->minimumUpdatePeriod()); 0112 ApplicationSettings::self()->setAntialiasPlots(_generalTab->antialiasPlot()); 0113 ApplicationSettings::self()->blockSignals(false); 0114 0115 emit ApplicationSettings::self()->modified(); 0116 } 0117 0118 0119 void ApplicationSettingsDialog::gridChanged() { 0120 //Need to block the signals so that the modified signal only goes out once... 0121 ApplicationSettings::self()->blockSignals(true); 0122 ApplicationSettings::self()->setShowGrid(_gridTab->showGrid()); 0123 ApplicationSettings::self()->setSnapToGrid(_gridTab->snapToGrid()); 0124 ApplicationSettings::self()->setGridHorizontalSpacing(_gridTab->gridHorizontalSpacing()); 0125 ApplicationSettings::self()->setGridVerticalSpacing(_gridTab->gridVerticalSpacing()); 0126 ApplicationSettings::self()->blockSignals(false); 0127 0128 emit ApplicationSettings::self()->modified(); 0129 } 0130 0131 0132 void ApplicationSettingsDialog::defaultLabelPropertiesChanged() { 0133 //Need to block the signals so that the modified signal only goes out once... 0134 ApplicationSettings::self()->blockSignals(true); 0135 0136 ApplicationSettings::self()->blockSignals(false); 0137 ApplicationSettings::self()->setReferenceViewWidthCM(_defaultLabelPropertiesTab->referenceViewWidth()); 0138 ApplicationSettings::self()->setReferenceViewHeightCM(_defaultLabelPropertiesTab->referenceViewHeight()); 0139 ApplicationSettings::self()->setMinimumFontSize(_defaultLabelPropertiesTab->minimumFontSize()); 0140 0141 emit ApplicationSettings::self()->modified(); 0142 } 0143 0144 0145 void ApplicationSettingsDialog::layoutChanged() { 0146 //Need to block the signals so that the modified signal only goes out once... 0147 ApplicationSettings::self()->blockSignals(true); 0148 ApplicationSettings::self()->setLayoutMargins(QSizeF(_layoutTab->horizontalMargin(), _layoutTab->verticalMargin())); 0149 ApplicationSettings::self()->setLayoutSpacing(QSizeF(_layoutTab->horizontalSpacing(), _layoutTab->verticalSpacing())); 0150 ApplicationSettings::self()->blockSignals(false); 0151 0152 emit ApplicationSettings::self()->modified(); 0153 } 0154 0155 0156 } 0157 0158 // vim: ts=2 sw=2 et