[Kst] branches/work/kst/portto4/kst/src/libkstapp

Mike Fenton mike at staikos.net
Mon Mar 17 20:13:34 CET 2008


SVN commit 786698 by fenton:

Convert Reference View Width/Height to be calculated in centimeters and then converted to points before use.
Add trigger of apply signal when ok is clicked as part of Dialog.


 M  +14 -4     applicationsettings.cpp  
 M  +8 -5      applicationsettings.h  
 M  +4 -4      applicationsettingsdialog.cpp  
 M  +1 -0      dialog.cpp  
 M  +8 -8      generaltab.cpp  
 M  +4 -4      generaltab.h  
 M  +4 -4      generaltab.ui  


--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettings.cpp #786697:786698
@@ -42,8 +42,8 @@
   // several seconds delay when opening application on my system.
   _useOpenGL = _settings->value("general/opengl", QVariant(QGLPixelBuffer::hasOpenGLPbuffers())).toBool();
 
-  _refViewWidth = _settings->value("general/referenceviewwidth", QVariant(800)).toInt();
-  _refViewHeight = _settings->value("general/referenceviewheight", QVariant(600)).toInt();
+  _refViewWidth = _settings->value("general/referenceviewwidth", QVariant(16)).toDouble();
+  _refViewHeight = _settings->value("general/referenceviewheight", QVariant(12)).toDouble();
   _refFontSize = _settings->value("general/referencefontsize", QVariant(12)).toInt();
   _minFontSize = _settings->value("general/minimumfontsize", QVariant(5)).toInt();
   _defaultFontFamily = _settings->value("general/defaultfontfamily", "Albany AMT").toString();
@@ -73,11 +73,16 @@
 
 
 int ApplicationSettings::referenceViewWidth() const {
+  return (_refViewWidth * 72.0 * 0.3937008);
+}
+
+
+double ApplicationSettings::referenceViewWidthCM() const {
   return _refViewWidth;
 }
 
 
-void ApplicationSettings::setReferenceViewWidth(const int width) {
+void ApplicationSettings::setReferenceViewWidthCM(const double width) {
   _refViewWidth = width;
   _settings->setValue("general/referenceviewwidth", width);
   emit modified();
@@ -85,11 +90,16 @@
 
 
 int ApplicationSettings::referenceViewHeight() const {
+  return (_refViewHeight * 72.0 * 0.3937008);
+}
+
+
+double ApplicationSettings::referenceViewHeightCM() const {
   return _refViewHeight;
 }
 
 
-void ApplicationSettings::setReferenceViewHeight(const int height) {
+void ApplicationSettings::setReferenceViewHeightCM(const double height) {
   _refViewHeight = height;
   _settings->setValue("general/referenceviewheight", height);
   emit modified();
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettings.h #786697:786698
@@ -30,11 +30,14 @@
     void setUseOpenGL(bool useOpenGL);
 
     int referenceViewWidth() const;
-    void setReferenceViewWidth(const int width);
-
     int referenceViewHeight() const;
-    void setReferenceViewHeight(const int height);
 
+    double referenceViewWidthCM() const;
+    void setReferenceViewWidthCM(const double width);
+
+    double referenceViewHeightCM() const;
+    void setReferenceViewHeightCM(const double height);
+
     int referenceFontSize() const;
     void setReferenceFontSize(const int points);
 
@@ -67,8 +70,8 @@
   private:
     QSettings *_settings;
     bool _useOpenGL;
-    int _refViewWidth;
-    int _refViewHeight;
+    double _refViewWidth;
+    double _refViewHeight;
     int _refFontSize;
     int _minFontSize;
     QString _defaultFontFamily;
--- branches/work/kst/portto4/kst/src/libkstapp/applicationsettingsdialog.cpp #786697:786698
@@ -51,8 +51,8 @@
 
 void ApplicationSettingsDialog::setupGeneral() {
   _generalTab->setUseOpenGL(ApplicationSettings::self()->useOpenGL());
-  _generalTab->setReferenceViewWidth(ApplicationSettings::self()->referenceViewWidth());
-  _generalTab->setReferenceViewHeight(ApplicationSettings::self()->referenceViewHeight());
+  _generalTab->setReferenceViewWidth(ApplicationSettings::self()->referenceViewWidthCM());
+  _generalTab->setReferenceViewHeight(ApplicationSettings::self()->referenceViewHeightCM());
   _generalTab->setReferenceFontSize(ApplicationSettings::self()->referenceFontSize());
   _generalTab->setMinimumFontSize(ApplicationSettings::self()->minimumFontSize());
   _generalTab->setDefaultFontFamily(ApplicationSettings::self()->defaultFontFamily());
@@ -71,8 +71,8 @@
   //Need to block the signals so that the modified signal only goes out once...
   ApplicationSettings::self()->blockSignals(true);
   ApplicationSettings::self()->setUseOpenGL(_generalTab->useOpenGL());
-  ApplicationSettings::self()->setReferenceViewWidth(_generalTab->referenceViewWidth());
-  ApplicationSettings::self()->setReferenceViewHeight(_generalTab->referenceViewHeight());
+  ApplicationSettings::self()->setReferenceViewWidthCM(_generalTab->referenceViewWidth());
+  ApplicationSettings::self()->setReferenceViewHeightCM(_generalTab->referenceViewHeight());
   ApplicationSettings::self()->setReferenceFontSize(_generalTab->referenceFontSize());
   ApplicationSettings::self()->setMinimumFontSize(_generalTab->minimumFontSize());
   ApplicationSettings::self()->setDefaultFontFamily(_generalTab->defaultFontFamily());
--- branches/work/kst/portto4/kst/src/libkstapp/dialog.cpp #786697:786698
@@ -129,6 +129,7 @@
   QDialogButtonBox::StandardButton std = _buttonBox->standardButton(button);
   switch(std) {
   case QDialogButtonBox::Ok:
+    emit apply();
     emit ok();
     break;
   case QDialogButtonBox::Apply:
--- branches/work/kst/portto4/kst/src/libkstapp/generaltab.cpp #786697:786698
@@ -20,8 +20,8 @@
   setTabTitle(tr("General"));
 
   connect(_useOpenGL, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
-  connect(_refViewWidth, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
-  connect(_refViewHeight, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
+  connect(_refViewWidth, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
+  connect(_refViewHeight, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
   connect(_refFontSize, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
   connect(_minFontSize, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
   connect(_defaultFontFamily, SIGNAL(currentFontChanged(const QFont &)), this, SIGNAL(modified()));
@@ -42,22 +42,22 @@
 }
 
 
-int GeneralTab::referenceViewWidth() const {
-  return _refViewWidth->value();
+double GeneralTab::referenceViewWidth() const {
+  return (_refViewWidth->value());
 }
 
 
-void GeneralTab::setReferenceViewWidth(const int width) {
+void GeneralTab::setReferenceViewWidth(const double width) {
   _refViewWidth->setValue(width);
 }
 
 
-int GeneralTab::referenceViewHeight() const {
-  return _refViewHeight->value();
+double GeneralTab::referenceViewHeight() const {
+  return (_refViewHeight->value());
 }
 
 
-void GeneralTab::setReferenceViewHeight(const int height) {
+void GeneralTab::setReferenceViewHeight(const double height) {
   _refViewHeight->setValue(height);
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/generaltab.h #786697:786698
@@ -28,11 +28,11 @@
     bool useOpenGL() const;
     void setUseOpenGL(const bool useOpenGL);
 
-    int referenceViewWidth() const;
-    void setReferenceViewWidth(const int width);
+    double referenceViewWidth() const;
+    void setReferenceViewWidth(const double width);
 
-    int referenceViewHeight() const;
-    void setReferenceViewHeight(const int height);
+    double referenceViewHeight() const;
+    void setReferenceViewHeight(const double height);
 
     int referenceFontSize() const;
     void setReferenceFontSize(const int points);
--- branches/work/kst/portto4/kst/src/libkstapp/generaltab.ui #786697:786698
@@ -23,12 +23,12 @@
    <item row="1" column="0" colspan="3" >
     <widget class="QLabel" name="label" >
      <property name="text" >
-      <string>Reference View Width (points):</string>
+      <string>Reference View Width (cm):</string>
      </property>
     </widget>
    </item>
    <item row="1" column="3" >
-    <widget class="QSpinBox" name="_refViewWidth" >
+    <widget class="QDoubleSpinBox" name="_refViewWidth" >
      <property name="maximum" >
       <number>2000</number>
      </property>
@@ -37,12 +37,12 @@
    <item row="2" column="0" colspan="3" >
     <widget class="QLabel" name="label_2" >
      <property name="text" >
-      <string>Reference View Height (points):</string>
+      <string>Reference View Height (cm):</string>
      </property>
     </widget>
    </item>
    <item row="2" column="3" >
-    <widget class="QSpinBox" name="_refViewHeight" >
+     <widget class="QDoubleSpinBox" name="_refViewHeight" >
      <property name="maximum" >
       <number>2000</number>
      </property>


More information about the Kst mailing list