summaryrefslogtreecommitdiffstats
path: root/tools/linguist/linguist
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-06-02 12:34:30 +0200
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-06-15 20:17:25 +0200
commita8ddfa19732a84affd2ffb3fe4cfb8b138296136 (patch)
tree702c557ed89a9a1eccee655b675f05d4fca380bb /tools/linguist/linguist
parenta6d9cf91c34092d5056d9da96de08aece15615b2 (diff)
centralize settings
Diffstat (limited to 'tools/linguist/linguist')
-rw-r--r--tools/linguist/linguist/globals.cpp55
-rw-r--r--tools/linguist/linguist/globals.h50
-rw-r--r--tools/linguist/linguist/linguist.pro2
-rw-r--r--tools/linguist/linguist/main.cpp5
-rw-r--r--tools/linguist/linguist/mainwindow.cpp39
-rw-r--r--tools/linguist/linguist/mainwindow.h2
-rw-r--r--tools/linguist/linguist/phraseview.cpp3
-rw-r--r--tools/linguist/linguist/recentfiles.cpp5
8 files changed, 128 insertions, 33 deletions
diff --git a/tools/linguist/linguist/globals.cpp b/tools/linguist/linguist/globals.cpp
new file mode 100644
index 0000000000..697b28b8e7
--- /dev/null
+++ b/tools/linguist/linguist/globals.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the Qt Linguist of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "globals.h"
+
+const QString &settingsPrefix()
+{
+ static QString prefix = QString(QLatin1String("%1.%2/"))
+ .arg((QT_VERSION >> 16) & 0xff)
+ .arg((QT_VERSION >> 8) & 0xff);
+ return prefix;
+}
+
+QString settingPath(const char *path)
+{
+ return settingsPrefix() + QLatin1String(path);
+}
diff --git a/tools/linguist/linguist/globals.h b/tools/linguist/linguist/globals.h
new file mode 100644
index 0000000000..6b7293f562
--- /dev/null
+++ b/tools/linguist/linguist/globals.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the Qt Linguist of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GLOBALS_H
+#define GLOBALS_H
+
+#include <QString>
+
+const QString &settingsPrefix();
+QString settingPath(const char *path);
+
+#endif // GLOBALS_H
diff --git a/tools/linguist/linguist/linguist.pro b/tools/linguist/linguist/linguist.pro
index 968293a56b..234b0b1691 100644
--- a/tools/linguist/linguist/linguist.pro
+++ b/tools/linguist/linguist/linguist.pro
@@ -26,6 +26,7 @@ SOURCES += \
errorsview.cpp \
finddialog.cpp \
formpreviewview.cpp \
+ globals.cpp \
main.cpp \
mainwindow.cpp \
messageeditor.cpp \
@@ -49,6 +50,7 @@ HEADERS += \
errorsview.h \
finddialog.h \
formpreviewview.h \
+ globals.h \
mainwindow.h \
messageeditor.h \
messageeditorwidgets.h \
diff --git a/tools/linguist/linguist/main.cpp b/tools/linguist/linguist/main.cpp
index a6a0d27b4e..98cd876636 100644
--- a/tools/linguist/linguist/main.cpp
+++ b/tools/linguist/linguist/main.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "mainwindow.h"
+#include "globals.h"
#include <QtCore/QFile>
#include <QtCore/QLibraryInfo>
@@ -92,13 +93,11 @@ int main(int argc, char **argv)
app.setOrganizationName(QLatin1String("Trolltech"));
app.setApplicationName(QLatin1String("Linguist"));
- QString keybase(QString::number( (QT_VERSION >> 16) & 0xff ) +
- QLatin1Char('.') + QString::number( (QT_VERSION >> 8) & 0xff ) + QLatin1Char('/') );
QSettings config;
QWidget tmp;
- tmp.restoreGeometry(config.value(keybase + QLatin1String("Geometry/WindowGeometry")).toByteArray());
+ tmp.restoreGeometry(config.value(settingPath("Geometry/WindowGeometry")).toByteArray());
QSplashScreen *splash = 0;
int screenId = QApplication::desktop()->screenNumber(tmp.geometry().center());
diff --git a/tools/linguist/linguist/mainwindow.cpp b/tools/linguist/linguist/mainwindow.cpp
index f91175dec3..99ef7a4836 100644
--- a/tools/linguist/linguist/mainwindow.cpp
+++ b/tools/linguist/linguist/mainwindow.cpp
@@ -50,6 +50,7 @@
#include "errorsview.h"
#include "finddialog.h"
#include "formpreviewview.h"
+#include "globals.h"
#include "messageeditor.h"
#include "messagemodel.h"
#include "phrasebookbox.h"
@@ -96,14 +97,6 @@ QT_BEGIN_NAMESPACE
static const int MessageMS = 2500;
-const QString &settingsPrefix()
-{
- static QString prefix = QString(QLatin1String("%1.%2/"))
- .arg((QT_VERSION >> 16) & 0xff)
- .arg((QT_VERSION >> 8) & 0xff);
- return prefix;
-}
-
enum Ending {
End_None,
End_FullStop,
@@ -2494,25 +2487,24 @@ void MainWindow::updateDanger(const MultiDataIndex &index, bool verbose)
void MainWindow::readConfig()
{
- QString keybase = settingsPrefix();
QSettings config;
QRect r(pos(), size());
- restoreGeometry(config.value(keybase + QLatin1String("Geometry/WindowGeometry")).toByteArray());
- restoreState(config.value(keybase + QLatin1String("MainWindowState")).toByteArray());
+ restoreGeometry(config.value(settingPath("Geometry/WindowGeometry")).toByteArray());
+ restoreState(config.value(settingPath("MainWindowState")).toByteArray());
m_ui.actionAccelerators->setChecked(
- config.value(keybase + QLatin1String("Validators/Accelerator"), true).toBool());
+ config.value(settingPath("Validators/Accelerator"), true).toBool());
m_ui.actionEndingPunctuation->setChecked(
- config.value(keybase + QLatin1String("Validators/EndingPunctuation"), true).toBool());
+ config.value(settingPath("Validators/EndingPunctuation"), true).toBool());
m_ui.actionPhraseMatches->setChecked(
- config.value(keybase + QLatin1String("Validators/PhraseMatch"), true).toBool());
+ config.value(settingPath("Validators/PhraseMatch"), true).toBool());
m_ui.actionPlaceMarkerMatches->setChecked(
- config.value(keybase + QLatin1String("Validators/PlaceMarkers"), true).toBool());
+ config.value(settingPath("Validators/PlaceMarkers"), true).toBool());
recentFiles().readConfig();
- int size = config.beginReadArray(keybase + QLatin1String("OpenedPhraseBooks"));
+ int size = config.beginReadArray(settingPath("OpenedPhraseBooks"));
for (int i = 0; i < size; ++i) {
config.setArrayIndex(i);
openPhraseBook(config.value(QLatin1String("FileName")).toString());
@@ -2522,23 +2514,22 @@ void MainWindow::readConfig()
void MainWindow::writeConfig()
{
- QString keybase = settingsPrefix();
QSettings config;
- config.setValue(keybase + QLatin1String("Geometry/WindowGeometry"),
+ config.setValue(settingPath("Geometry/WindowGeometry"),
saveGeometry());
- config.setValue(keybase + QLatin1String("Validators/Accelerator"),
+ config.setValue(settingPath("Validators/Accelerator"),
m_ui.actionAccelerators->isChecked());
- config.setValue(keybase + QLatin1String("Validators/EndingPunctuation"),
+ config.setValue(settingPath("Validators/EndingPunctuation"),
m_ui.actionEndingPunctuation->isChecked());
- config.setValue(keybase + QLatin1String("Validators/PhraseMatch"),
+ config.setValue(settingPath("Validators/PhraseMatch"),
m_ui.actionPhraseMatches->isChecked());
- config.setValue(keybase + QLatin1String("Validators/PlaceMarkers"),
+ config.setValue(settingPath("Validators/PlaceMarkers"),
m_ui.actionPlaceMarkerMatches->isChecked());
- config.setValue(keybase + QLatin1String("MainWindowState"),
+ config.setValue(settingPath("MainWindowState"),
saveState());
recentFiles().writeConfig();
- config.beginWriteArray(keybase + QLatin1String("OpenedPhraseBooks"),
+ config.beginWriteArray(settingPath("OpenedPhraseBooks"),
m_phraseBooks.size());
for (int i = 0; i < m_phraseBooks.size(); ++i) {
config.setArrayIndex(i);
diff --git a/tools/linguist/linguist/mainwindow.h b/tools/linguist/linguist/mainwindow.h
index 9f6b4d9e2a..6eed8acd14 100644
--- a/tools/linguist/linguist/mainwindow.h
+++ b/tools/linguist/linguist/mainwindow.h
@@ -79,8 +79,6 @@ class Statistics;
class TranslateDialog;
class TranslationSettingsDialog;
-const QString &settingsPrefix();
-
class MainWindow : public QMainWindow
{
Q_OBJECT
diff --git a/tools/linguist/linguist/phraseview.cpp b/tools/linguist/linguist/phraseview.cpp
index 72c27dcc15..e5c3508de9 100644
--- a/tools/linguist/linguist/phraseview.cpp
+++ b/tools/linguist/linguist/phraseview.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
+#include "globals.h"
#include "mainwindow.h"
#include "messagemodel.h"
#include "phrase.h"
@@ -61,7 +62,7 @@ static const int MaxCandidates = 5;
static QString phraseViewHeaderKey()
{
- return settingsPrefix() + QLatin1String("PhraseViewHeader");
+ return settingPath("PhraseViewHeader");
}
PhraseView::PhraseView(MultiDataModel *model, QList<QHash<QString, QList<Phrase *> > > *phraseDict, QWidget *parent)
diff --git a/tools/linguist/linguist/recentfiles.cpp b/tools/linguist/linguist/recentfiles.cpp
index 6fc72f7651..568f5c226c 100644
--- a/tools/linguist/linguist/recentfiles.cpp
+++ b/tools/linguist/linguist/recentfiles.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "recentfiles.h"
+#include "globals.h"
#include <QtCore/QDebug>
#include <QtCore/QFileInfo>
@@ -49,11 +50,9 @@
QT_BEGIN_NAMESPACE
-const QString &settingsPrefix();
-
static QString configKey()
{
- return settingsPrefix() + QLatin1String("RecentlyOpenedFiles");
+ return settingPath("RecentlyOpenedFiles");
}