OSDN Git Service

Ver0.19
[gefu/Gefu.git] / preferencedialog.cpp
index d050b10..e0fb5be 100644 (file)
@@ -45,6 +45,7 @@ PreferenceDialog::PreferenceDialog(QWidget *parent) :
 
     connect(ui->boxClrBg, SIGNAL(clicked()), this, SLOT(selectBoxColor()));
     connect(ui->boxClrFg, SIGNAL(clicked()), this, SLOT(selectBoxColor()));
+    connect(ui->chooseBoxFont, SIGNAL(clicked()), this, SLOT(chooseFont()));
 
     connect(ui->clrBgMark, SIGNAL(clicked()), this, SLOT(selectViewColor()));
     connect(ui->clrBgNormal, SIGNAL(clicked()), this, SLOT(selectViewColor()));
@@ -53,12 +54,13 @@ PreferenceDialog::PreferenceDialog(QWidget *parent) :
     connect(ui->clrFgNormal, SIGNAL(clicked()), this, SLOT(selectViewColor()));
     connect(ui->clrFgReadonly, SIGNAL(clicked()), this, SLOT(selectViewColor()));
     connect(ui->clrFgSystem, SIGNAL(clicked()), this, SLOT(selectViewColor()));
-
-    connect(ui->chooseBoxFont, SIGNAL(clicked()), this, SLOT(chooseFont()));
     connect(ui->chooseViewFont, SIGNAL(clicked()), this, SLOT(chooseFont()));
 
+    connect(ui->enableDarker, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool)));
+
     connect(ui->importAppearance, SIGNAL(clicked()), this, SLOT(importAppearance()));
     connect(ui->exportAppearance, SIGNAL(clicked()), this, SLOT(exportAppearance()));
+
     connect(ui->termBrowse, SIGNAL(clicked()), this, SLOT(browseApp()));
     connect(ui->editorBrowse, SIGNAL(clicked()), this, SLOT(browseApp()));
 
@@ -77,8 +79,6 @@ PreferenceDialog::PreferenceDialog(QWidget *parent) :
     QRadioButton *radioBtn;
 
     //>>>>> 起動と終了
-    // 終了時の確認ダイアログ
-    ui->confirmExit->setChecked(settings.value(IniKey_ConfirmExit).toBool());
     // 起動時のサイズ
     ui->bootSize->setChecked(true);
     strValue = settings.value(IniKey_BootSizeSpec).toString();
@@ -115,9 +115,15 @@ PreferenceDialog::PreferenceDialog(QWidget *parent) :
     ui->relativeTop->setValue(point.y());
     // 起動時の設定削除
     ui->resetOnBoot->setChecked(settings.value(IniKey_ResetOnBoot).toBool());
+    // アップデートの確認
+    ui->checkUpdates->setChecked(settings.value(IniKey_CheckUpdates).toBool());
+    // 終了時の確認ダイアログ
+    ui->confirmExit->setChecked(settings.value(IniKey_ConfirmExit).toBool());
 
     //>>>>> 色とフォント、テキストビューア
     loadAppearance(settings, false);
+    ui->enableDarker->setChecked(settings.value(IniKey_EnableDarker).toBool());
+    ui->dark->setValue(settings.value(IniKey_Darkness).toInt());
 
     //>>>>> ファイル操作
     // 確認ダイアログの表示
@@ -222,6 +228,10 @@ void PreferenceDialog::loadAppearance(QSettings &settings, bool import)
     font = settings.value(IniKey_ViewFont).value<QFont>();
     ui->viewFont->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize()));
     // サンプル表示
+    QHeaderView *header = ui->sampleTable->verticalHeader();
+    header->setDefaultSectionSize(QFontMetrics(font).height() * 1.5);
+    ui->sampleTable->setMinimumHeight(header->sectionSize(0) * 5);
+    ui->sampleTable->setMaximumHeight(ui->sampleTable->minimumHeight() + 2);
     m_model.setFont(font);
     m_model.update();
 
@@ -277,6 +287,10 @@ void PreferenceDialog::chooseFont()
         label = ui->boxFont;
     }
     else if (sender() == ui->chooseViewFont) {
+        QHeaderView *header = ui->sampleTable->verticalHeader();
+        header->setDefaultSectionSize(QFontMetrics(font).height() * 1.5);
+        ui->sampleTable->setMinimumHeight(header->sectionSize(0) * 5);
+        ui->sampleTable->setMaximumHeight(ui->sampleTable->minimumHeight() + 2);
         m_model.setFont(font);
         m_model.update();
         label = ui->viewFont;
@@ -333,10 +347,25 @@ void PreferenceDialog::setControlsEnabled(bool enabled)
     else if (sender() == ui->viewerInherit) {
         ui->viewerClrBg->setEnabled(!enabled);
         ui->viewerClrFg->setEnabled(!enabled);
+        // サンプル表示も更新
+        QPalette pal = ui->viewerSample->palette();
+        if (enabled) {
+            pal.setColor(QPalette::Base, m_colorMap["clrBgNormal"]);
+            pal.setColor(QPalette::Text, m_colorMap["clrFgNormal"]);
+        }
+        else {
+            QSettings settings;
+            pal.setColor(QPalette::Base, settings.value(IniKey_ViewerColorBg).value<QColor>());
+            pal.setColor(QPalette::Text, settings.value(IniKey_ViewerColorFg).value<QColor>());
+        }
+        ui->viewerSample->setPalette(pal);
     }
     else if (sender() == ui->enableViewerIgnoreExt) {
         ui->viewerIgnoreExt->setEnabled(enabled);
     }
+    else if (sender() == ui->enableDarker) {
+        ui->dark->setEnabled(enabled);
+    }
 }
 
 void PreferenceDialog::setIgnoreExtDefault()
@@ -471,8 +500,6 @@ void PreferenceDialog::accept()
     QAbstractButton *selected;
 
     //>>>>> 起動と終了
-    // 終了時の確認ダイアログ
-    settings.setValue(IniKey_ConfirmExit, ui->confirmExit->isChecked());
     // 起動時のサイズ
     if (!ui->bootSize->isChecked()) {
         settings.setValue(IniKey_BootSizeSpec, "");
@@ -505,9 +532,15 @@ void PreferenceDialog::accept()
     }
     // 起動時の設定削除
     settings.setValue(IniKey_ResetOnBoot, ui->resetOnBoot->isChecked());
+    // 終了時の確認ダイアログ
+    settings.setValue(IniKey_ConfirmExit, ui->confirmExit->isChecked());
+    // アップデートのチェック
+    settings.setValue(IniKey_CheckUpdates, ui->checkUpdates->isChecked());
 
     //>>>>> 色とフォント
     saveAppearance(settings);
+    settings.setValue(IniKey_EnableDarker, ui->enableDarker->isChecked());
+    settings.setValue(IniKey_Darkness, ui->dark->value());
 
     //>>>>> ファイル操作
     settings.setValue(IniKey_ConfirmCopy, ui->confirmCopy->isChecked());