changeset 484:896b7903e8f2

Make "Show all files" persistent (fixing #203), and rationalise some config group names (noting that "General" is actually the default group "" as it appears in the config file, not the name of a group called "General": that appears as "%General")
author Chris Cannam
date Wed, 17 Aug 2011 16:09:04 +0100
parents a582c6417004
children e29685e52654
files src/filestatuswidget.cpp src/filestatuswidget.h src/hgrunner.cpp src/hgtabwidget.cpp src/hgtabwidget.h src/mainwindow.cpp src/mainwindow.h src/settingsdialog.cpp
diffstat 8 files changed, 37 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/src/filestatuswidget.cpp	Wed Aug 17 15:53:17 2011 +0100
+++ b/src/filestatuswidget.cpp	Wed Aug 17 16:09:04 2011 +0100
@@ -157,15 +157,27 @@
     m_showAllFiles = new QCheckBox(tr("Show all files"), this);
     m_showAllFiles->setEnabled(false);
     layout->addWidget(m_showAllFiles, ++row, 0, Qt::AlignLeft);
+
+    QSettings settings;
+    m_showAllFiles->setChecked(settings.value("showall", false).toBool());
+
     connect(m_showAllFiles, SIGNAL(toggled(bool)),
-            this, SIGNAL(showAllChanged(bool)));
+            this, SIGNAL(showAllChanged()));
 }
 
 FileStatusWidget::~FileStatusWidget()
 {
+    QSettings settings;
+    settings.setValue("showall", m_showAllFiles->isChecked());
+
     delete m_dateReference;
 }
 
+bool FileStatusWidget::shouldShowAll() const
+{
+    return m_showAllFiles->isChecked();
+}
+
 QString FileStatusWidget::labelFor(FileStates::State s, bool addHighlightExplanation)
 {
     QSettings settings;
--- a/src/filestatuswidget.h	Wed Aug 17 15:53:17 2011 +0100
+++ b/src/filestatuswidget.h	Wed Aug 17 16:09:04 2011 +0100
@@ -54,9 +54,11 @@
     QStringList getSelectedAddableFiles() const;
     QStringList getSelectedRemovableFiles() const;
 
+    bool shouldShowAll() const;
+
 signals:
     void selectionChanged();
-    void showAllChanged(bool);
+    void showAllChanged();
 
     void annotateFiles(QStringList);
     void diffFiles(QStringList);
--- a/src/hgrunner.cpp	Wed Aug 17 15:53:17 2011 +0100
+++ b/src/hgrunner.cpp	Wed Aug 17 16:09:04 2011 +0100
@@ -499,9 +499,6 @@
         return;
     }
 
-    QSettings settings;
-    settings.beginGroup("General");
-
     if (executable == "") {
         // This is a Hg command
         executable = getHgBinaryName();
@@ -516,6 +513,7 @@
         if (action.mayBeInteractive()) {
             params.push_front("ui.interactive=true");
             params.push_front("--config");
+            QSettings settings;
             if (settings.value("useextension", true).toBool()) {
                 params = addExtensionOptions(params);
             }
--- a/src/hgtabwidget.cpp	Wed Aug 17 15:53:17 2011 +0100
+++ b/src/hgtabwidget.cpp	Wed Aug 17 16:09:04 2011 +0100
@@ -37,8 +37,8 @@
     connect(m_fileStatusWidget, SIGNAL(selectionChanged()),
             this, SIGNAL(selectionChanged()));
 
-    connect(m_fileStatusWidget, SIGNAL(showAllChanged(bool)),
-            this, SIGNAL(showAllChanged(bool)));
+    connect(m_fileStatusWidget, SIGNAL(showAllChanged()),
+            this, SIGNAL(showAllChanged()));
 
     connect(m_fileStatusWidget, SIGNAL(annotateFiles(QStringList)),
             this, SIGNAL(annotateFiles(QStringList)));
@@ -268,3 +268,8 @@
     setCurrentWidget(m_historyWidget);
 }
 
+bool HgTabWidget::shouldShowAll() const
+{
+    return m_fileStatusWidget->shouldShowAll();
+}
+
--- a/src/hgtabwidget.h	Wed Aug 17 15:53:17 2011 +0100
+++ b/src/hgtabwidget.h	Wed Aug 17 16:09:04 2011 +0100
@@ -70,9 +70,11 @@
     QStringList getSelectedAddableFiles() const;
     QStringList getSelectedRemovableFiles() const;
 
+    bool shouldShowAll() const;
+
 signals:
     void selectionChanged();
-    void showAllChanged(bool);
+    void showAllChanged();
 
     void commit();
     void revert();
--- a/src/mainwindow.cpp	Wed Aug 17 15:53:17 2011 +0100
+++ b/src/mainwindow.cpp	Wed Aug 17 16:09:04 2011 +0100
@@ -111,8 +111,8 @@
 
     connect(m_hgTabs, SIGNAL(selectionChanged()),
             this, SLOT(enableDisableActions()));
-    connect(m_hgTabs, SIGNAL(showAllChanged(bool)),
-            this, SLOT(showAllChanged(bool)));
+    connect(m_hgTabs, SIGNAL(showAllChanged()),
+            this, SLOT(showAllChanged()));
 
     setUnifiedTitleAndToolBarOnMac(true);
     connectActions();
@@ -206,9 +206,8 @@
     m_hgTabs->clearSelections();
 }
 
-void MainWindow::showAllChanged(bool s)
+void MainWindow::showAllChanged()
 {
-    m_showAllFiles = s;
     hgQueryPaths();
 }
 
@@ -257,6 +256,8 @@
 
 void MainWindow::hgQueryPaths()
 {
+    m_showAllFiles = m_hgTabs->shouldShowAll();
+
     // Quickest is to just read the file
 
     QFileInfo hgrc(m_workFolderPath + "/.hg/hgrc");
@@ -1334,7 +1335,7 @@
                      MultiChoiceDialog::DirectoryArg);
 
         QSettings settings;
-        settings.beginGroup("General");
+        settings.beginGroup("");
         QString lastChoice = settings.value("lastopentype", "remote").toString();
         if (lastChoice != "local" &&
             lastChoice != "remote" &&
@@ -2445,7 +2446,6 @@
     case ACT_TEST_HG:
     {
         QSettings settings;
-        settings.beginGroup("General");
         if (settings.value("useextension", true).toBool()) {
             hgTestExtension();
         } else if (m_workFolderPath == "") {
--- a/src/mainwindow.h	Wed Aug 17 15:53:17 2011 +0100
+++ b/src/mainwindow.h	Wed Aug 17 16:09:04 2011 +0100
@@ -65,7 +65,7 @@
     void changeRemoteRepo(bool initial);
     void startupDialog();
     void clearSelections();
-    void showAllChanged(bool);
+    void showAllChanged();
 
     void hgTest();
     void hgTestExtension();
--- a/src/settingsdialog.cpp	Wed Aug 17 15:53:17 2011 +0100
+++ b/src/settingsdialog.cpp	Wed Aug 17 16:09:04 2011 +0100
@@ -410,7 +410,7 @@
     settings.remove("sshbinary");
     settings.remove("extensionpath");
     settings.endGroup();
-    settings.beginGroup("General");
+    settings.beginGroup("");
     settings.remove("useextension");
     settings.endGroup();
 }
@@ -439,7 +439,7 @@
     m_sshPathLabel->setText(settings.value("sshbinary").toString());
     m_extensionPathLabel->setText(settings.value("extensionpath").toString());
     settings.endGroup();
-    settings.beginGroup("General");
+    settings.beginGroup("");
     m_useExtension->setChecked(settings.value("useextension", true).toBool());
     settings.endGroup();
 }
@@ -486,7 +486,7 @@
     settings.setValue("sshbinary", m_sshPathLabel->text());
     settings.setValue("extensionpath", m_extensionPathLabel->text());
     settings.endGroup();
-    settings.beginGroup("General");
+    settings.beginGroup("");
     settings.setValue("useextension", m_useExtension->isChecked());
     settings.endGroup();
     QDialog::accept();