StelShortcutMgr.cpp   StelShortcutMgr.cpp 
skipping to change at line 35 skipping to change at line 35
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelMainGraphicsView.hpp" #include "StelMainGraphicsView.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelShortcutGroup.hpp" #include "StelShortcutGroup.hpp"
#include <QDateTime> #include <QDateTime>
#include <QAction> #include <QAction>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QDir>
StelShortcutMgr::StelShortcutMgr() StelShortcutMgr::StelShortcutMgr()
{ {
} }
void StelShortcutMgr::init() void StelShortcutMgr::init()
{ {
stelAppGraphicsWidget = StelMainGraphicsView::getInstance().getStelA ppGraphicsWidget(); stelAppGraphicsWidget = StelMainGraphicsView::getInstance().getStelA ppGraphicsWidget();
} }
skipping to change at line 232 skipping to change at line 233
shGroups[id]->setEnabled(enabled); shGroups[id]->setEnabled(enabled);
shGroups[id]->setPluginId(pluginId); shGroups[id]->setPluginId(pluginId);
} }
bool StelShortcutMgr::copyDefaultFile() bool StelShortcutMgr::copyDefaultFile()
{ {
try try
{ {
StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::get UserDir() + "/data/"); StelFileMgr::makeSureDirExistsAndIsWritable(StelFileMgr::get UserDir() + "/data/");
QString shortcutsFileFullPath = StelFileMgr::getUserDir() + "/data/shortcuts.json"; QString shortcutsFileFullPath = StelFileMgr::getUserDir() + "/data/shortcuts.json";
qDebug() << "Creating file" << shortcutsFileFullPath; qDebug() << "Creating file" << QDir::toNativeSeparators(shor tcutsFileFullPath);
QString defaultPath = StelFileMgr::findFile("data/default_sh ortcuts.json"); QString defaultPath = StelFileMgr::findFile("data/default_sh ortcuts.json");
QFile::copy(defaultPath, shortcutsFileFullPath); QFile::copy(defaultPath, shortcutsFileFullPath);
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "Could not create shortcuts file data/shortcut s.json. Error: " << e.what(); qWarning() << "Could not create shortcuts file data/shortcut s.json. Error: " << e.what();
return false; return false;
} }
return true; return true;
} }
skipping to change at line 313 skipping to change at line 314
if (!script.isEmpty()) if (!script.isEmpty())
{ {
addScriptToAction(actionId, script); addScriptToAction(actionId, script);
} }
QString filePath = actionMap.value("scriptFile").toS tring(); QString filePath = actionMap.value("scriptFile").toS tring();
if (!filePath.isEmpty()) if (!filePath.isEmpty())
{ {
QString scriptFilePath = StelFileMgr::findFi le(filePath); QString scriptFilePath = StelFileMgr::findFi le(filePath);
if (!QFileInfo(scriptFilePath).exists()) if (!QFileInfo(scriptFilePath).exists())
{ {
qWarning() << "Couldn't find script file" << scriptFilePath qWarning() << "Couldn't find script file" << QDir::toNativeSeparators(scriptFilePath)
<< "for shortcut" << acti onId; << "for shortcut" << acti onId;
} }
else else
{ {
QFile scriptFile(scriptFilePath); QFile scriptFile(scriptFilePath);
if (scriptFile.open(QIODevice::ReadO nly)) if (scriptFile.open(QIODevice::ReadO nly))
{ {
QString code = QString(scrip tFile.readAll()); QString code = QString(scrip tFile.readAll());
addScriptToAction(actionId, code, filePath); addScriptToAction(actionId, code, filePath);
scriptFile.close(); scriptFile.close();
skipping to change at line 362 skipping to change at line 363
// merge with default for getting actual shortcuts info // merge with default for getting actual shortcuts info
QString defaultFilePath = StelFileMgr::getInstallationDir() + "/data /default_shortcuts.json"; QString defaultFilePath = StelFileMgr::getInstallationDir() + "/data /default_shortcuts.json";
loadShortcuts(defaultFilePath); loadShortcuts(defaultFilePath);
} }
void StelShortcutMgr::restoreDefaultShortcuts() void StelShortcutMgr::restoreDefaultShortcuts()
{ {
QString defaultPath = StelFileMgr::getInstallationDir() + "/data/def ault_shortcuts.json"; QString defaultPath = StelFileMgr::getInstallationDir() + "/data/def ault_shortcuts.json";
if (!QFileInfo(defaultPath).exists()) if (!QFileInfo(defaultPath).exists())
{ {
qWarning() << "Default shortcuts file (" << defaultPath qWarning() << "Default shortcuts file (" << QDir::toNativeSe parators(defaultPath)
<< ") doesn't exist, restore defaults failed."; << ") doesn't exist, restore defaults failed.";
return; return;
} }
// Reload default shortcuts // Reload default shortcuts
loadShortcuts(defaultPath, true); loadShortcuts(defaultPath, true);
// save shortcuts to actual file // save shortcuts to actual file
saveShortcuts(); saveShortcuts();
} }
skipping to change at line 391 skipping to change at line 392
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "Creating a new shortcuts.json file..."; qWarning() << "Creating a new shortcuts.json file...";
QString userDataPath = StelFileMgr::getUserDir() + "/data"; QString userDataPath = StelFileMgr::getUserDir() + "/data";
if (!StelFileMgr::exists(userDataPath)) if (!StelFileMgr::exists(userDataPath))
{ {
if (!StelFileMgr::mkDir(userDataPath)) if (!StelFileMgr::mkDir(userDataPath))
{ {
qWarning() << "ERROR - cannot create non-exi stent data directory" qWarning() << "ERROR - cannot create non-exi stent data directory"
<< userDataPath; << QDir::toNativeSeparators(userD ataPath);
qWarning() << "Shortcuts aren't' saved"; qWarning() << "Shortcuts aren't' saved";
return; return;
} }
} }
} }
QFile shortcutsFile(shortcutsFilePath); QFile shortcutsFile(shortcutsFilePath);
if (!shortcutsFile.open(QIODevice::WriteOnly | QIODevice::Text)) if (!shortcutsFile.open(QIODevice::WriteOnly | QIODevice::Text))
{ {
qWarning() << "ERROR: Could not save shortcuts file" qWarning() << "ERROR: Could not save shortcuts file"
<< shortcutsFilePath; << QDir::toNativeSeparators(shortcutsFilePath);
return; return;
} }
// QTextStream stream(&shortcutsFile); // QTextStream stream(&shortcutsFile);
saveShortcuts(&shortcutsFile); saveShortcuts(&shortcutsFile);
shortcutsFile.close(); shortcutsFile.close();
qDebug() << "New shortcuts file saved to" << shortcutsFilePath; qDebug() << "New shortcuts file saved to" << QDir::toNativeSeparator s(shortcutsFilePath);
} }
void StelShortcutMgr::saveShortcuts(QIODevice* output) const void StelShortcutMgr::saveShortcuts(QIODevice* output) const
{ {
QVariantMap resMap, groupsMap; QVariantMap resMap, groupsMap;
for(QMap<QString, StelShortcutGroup*>::const_iterator it = shGroups. begin(); it != shGroups.end(); ++it) for(QMap<QString, StelShortcutGroup*>::const_iterator it = shGroups. begin(); it != shGroups.end(); ++it)
{ {
groupsMap[it.key()] = it.value()->toQVariant(); groupsMap[it.key()] = it.value()->toQVariant();
} }
resMap["groups"] = QVariant(groupsMap); resMap["groups"] = QVariant(groupsMap);
 End of changes. 7 change blocks. 
6 lines changed or deleted 7 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/