Changeset 31694c8b58 in tspsg for src


Ignore:
Timestamp:
Sep 16, 2012, 10:40:01 PM (12 years ago)
Author:
Oleksii Serdiuk
Branches:
appveyor, imgbot, master, readme
Children:
1b0d08aa2e
Parents:
0784c85e46
git-author:
Oleksii Serdiuk <contacts@…> (09/16/12 22:40:01)
git-committer:
Oleksii Serdiuk <contacts@…> (09/16/12 22:41:39)
Message:

Fixed wrong placement of tspsg.ini on Windows Mobile.

Also, Main Window stopped showing maximized on Windows Mobile. Made a
workaround for this.

Closes #15 - Try to fix wrong placement of tspsg.ini.

Location:
src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/globals.cpp

    r0784c85e46 r31694c8b58  
    2424#include "globals.h"
    2525
     26#ifdef Q_OS_WINCE_WM
     27#   include <shellapi.h>
     28#endif
     29
     30QSettings *initSettings(QObject *parent)
     31{
     32#ifdef Q_OS_WINCE_WM
     33    /*!
     34     * \hack HACK: On Windows Mobile the way Qt tries to get path for saving
     35     *  settings doesn't always work. This workaround tries to fix it.
     36     */
     37    if (!QDesktopServices::storageLocation(QDesktopServices::DataLocation).isEmpty()) {
     38#endif // Q_OS_WINCE_WM
     39    return new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", parent);
     40#ifdef Q_OS_WINCE_WM
     41    } else {
     42        wchar_t path[MAX_PATH];
     43        SHGetSpecialFolderPath(0, path, 0x001a, FALSE);
     44        QString fileName = QString::fromWCharArray(path);
     45        fileName.append("\\TSPSG\\tspsg.ini");
     46        return new QSettings(fileName, QSettings::IniFormat, parent);
     47    }
     48#endif // Q_OS_WINCE_WM
     49}
     50
    2651#ifndef HANDHELD
    2752void toggleStyle(QWidget *widget, bool enable)
  • src/globals.h

    r0784c85e46 r31694c8b58  
    154154}
    155155
     156/*!
     157 * \brief Creates QSettings instance with TSPSG-specific options.
     158 * \param parent A QObject which will become parent for new QSetting instance.
     159 * \return A pointer to new QSettings instance.
     160 */
     161QSettings *initSettings(QObject *parent);
     162
    156163#ifndef HANDHELD
    157164/*!
  • src/main.cpp

    r0784c85e46 r31694c8b58  
    9292#ifdef HANDHELD
    9393    mainwindow.showMaximized();
     94#ifdef Q_OS_WINCE_WM
     95    /*!
     96     * \hack HACK: For some reason showMaximized() stopped working on
     97     *  Windows Mobile. This workaround works all the time.
     98     */
     99    mainwindow.setWindowState(Qt::WindowMaximized);
     100#endif // Q_OS_WINCE_WM
    94101#else // HANDHELD
    95102    mainwindow.show();
  • src/mainwindow.cpp

    r0784c85e46 r31694c8b58  
    4343    : QMainWindow(parent)
    4444{
    45     settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this);
     45    settings = initSettings(this);
    4646
    4747    if (settings->contains("Style")) {
  • src/settingsdialog.cpp

    r0784c85e46 r31694c8b58  
    234234#endif // HANDHELD
    235235
    236     settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this);
     236    settings = initSettings(this);
    237237    settings->remove("SettingsReset");
    238238
  • src/tspmodel.cpp

    r0784c85e46 r31694c8b58  
    3131    : QAbstractTableModel(parent), nCities(0)
    3232{
    33     settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this);
     33    settings = initSettings(this);
    3434}
    3535
Note: See TracChangeset for help on using the changeset viewer.