mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 18:50:44 +00:00
Reset channel strings on language change
This commit is contained in:
parent
8bcb69093f
commit
45559ac721
@ -619,6 +619,11 @@ Channel::Channel(ChannelID id, ChanType type, MachineType machtype, ScopeType sc
|
||||
calc[Calc_UpperThresh] = ChannelCalc(id, Calc_UpperThresh, Qt::red, false);
|
||||
}
|
||||
m_showInOverview = false;
|
||||
|
||||
default_fullname = fullname;
|
||||
default_label = label;
|
||||
default_description = description;
|
||||
|
||||
}
|
||||
bool Channel::isNull()
|
||||
{
|
||||
@ -827,6 +832,17 @@ bool ChannelList::Load(QString filename)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChannelList::resetStrings()
|
||||
{
|
||||
QHash<ChannelID, Channel *>::iterator it;
|
||||
QHash<ChannelID, Channel *>::iterator it_end = channels.end();
|
||||
for (it = channels.begin(); it != it_end; ++it) {
|
||||
Channel * chan = it.value();
|
||||
chan->resetStrings();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ChannelList::add(QString group, Channel *chan)
|
||||
{
|
||||
Q_ASSERT(chan != nullptr);
|
||||
|
@ -129,6 +129,11 @@ class Channel
|
||||
void setOrder(short order) { m_order = order; }
|
||||
|
||||
void setShowInOverview(bool b) { m_showInOverview = b; }
|
||||
void resetStrings() {
|
||||
m_fullname = default_fullname;
|
||||
m_label = default_label;
|
||||
m_description = default_description;
|
||||
}
|
||||
|
||||
QString option(int i) {
|
||||
if (m_options.contains(i)) {
|
||||
@ -150,6 +155,8 @@ class Channel
|
||||
QHash<ChannelCalcType, ChannelCalc> calc;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
int m_id;
|
||||
|
||||
ChanType m_type;
|
||||
@ -162,6 +169,11 @@ class Channel
|
||||
QString m_description;
|
||||
QString m_label;
|
||||
QString m_unit;
|
||||
|
||||
QString default_fullname;
|
||||
QString default_label;
|
||||
QString default_description;
|
||||
|
||||
DataType m_datatype;
|
||||
QColor m_defaultcolor;
|
||||
|
||||
@ -214,6 +226,8 @@ class ChannelList
|
||||
}
|
||||
}
|
||||
|
||||
void resetStrings();
|
||||
|
||||
//! \brief Channel List indexed by integer ID
|
||||
QHash<ChannelID, Channel *> channels;
|
||||
|
||||
|
@ -106,17 +106,25 @@ int main(int argc, char *argv[])
|
||||
|
||||
bool force_login_screen = false;
|
||||
bool force_data_dir = false;
|
||||
bool changing_language = false;
|
||||
|
||||
QApplication a(argc, argv);
|
||||
QStringList args = QCoreApplication::arguments();
|
||||
|
||||
QSettings settings(getDeveloperName(), getAppName());
|
||||
|
||||
QString lastlanguage = settings.value(LangSetting, "").toString();
|
||||
if (lastlanguage.isEmpty())
|
||||
changing_language = true;
|
||||
|
||||
for (int i = 1; i < args.size(); i++) {
|
||||
if (args[i] == "-l") { force_login_screen = true; }
|
||||
else if (args[i] == "-d") { force_data_dir = true; }
|
||||
else if (args[i] == "-language") {
|
||||
settings.setValue("Settings/Language","");
|
||||
changing_language = true;
|
||||
|
||||
// reset to force language dialog
|
||||
settings.setValue(LangSetting,"");
|
||||
} else if (args[i] == "-p") {
|
||||
sDelay(1);
|
||||
}
|
||||
@ -129,9 +137,18 @@ int main(int argc, char *argv[])
|
||||
// Language Selection
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
initTranslations(settings);
|
||||
|
||||
initializeStrings(); // Important, call this AFTER translator is installed.
|
||||
a.setApplicationName(STR_TR_SleepyHead);
|
||||
|
||||
if (settings.value(LangSetting, "").toString() == lastlanguage) {
|
||||
// don't reset if they selected the same language again
|
||||
changing_language = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// OpenGL Detection
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float glversion = getOpenGLVersion();
|
||||
|
||||
bool opengl2supported = glversion >= 2.0;
|
||||
@ -145,7 +162,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
QString lookfor = QObject::tr("Look for this build in <a href='%1'>SleepyHead's files hosted on Sourceforge</a>.").arg("http://sf.net/projects/sleepyhead/files");
|
||||
#ifdef BROKEN_OPENGL_BUILD
|
||||
Q_UNUSED(bad_graphics)
|
||||
Q_UNUSED(intel_graphics)
|
||||
@ -187,8 +203,7 @@ int main(int argc, char *argv[])
|
||||
QObject::tr("You may need to update your computers graphics drivers from the GPU makers website. %1").
|
||||
arg(intel_graphics ? QObject::tr("(<a href='http://intel.com/support'>Intel's support site</a>)") : "")+"<br/><br/>"+
|
||||
QObject::tr("Because graphs will not render correctly, and it may cause crashes, this build will now exit.")+"<br/><br/>"+
|
||||
QObject::tr("Don't be disheartened, there is another build available tagged \"<b>-BrokenGL</b>\" that should work on your computer.")+ "<br/><br/>"+
|
||||
lookfor+ "<br/><br/>"
|
||||
QObject::tr("There is another build available tagged \"<b>-BrokenGL</b>\" that should work on your computer.")
|
||||
|
||||
|
||||
,QMessageBox::Ok, QMessageBox::Ok);
|
||||
@ -397,9 +412,16 @@ retry_directory:
|
||||
|
||||
// Must be initialized AFTER profile creation
|
||||
MainWindow w;
|
||||
|
||||
mainwin = &w;
|
||||
|
||||
loadChannels();
|
||||
|
||||
if (changing_language) {
|
||||
qDebug() << "Resetting Channel strings to defaults for language change";
|
||||
schema::channel.resetStrings();
|
||||
}
|
||||
|
||||
|
||||
// if (check_updates) { mainwin->CheckForUpdates(); }
|
||||
|
||||
w.show();
|
||||
|
@ -121,9 +121,6 @@ void MainWindow::logMessage(QString msg)
|
||||
ui->logText->appendPlainText(msg);
|
||||
}
|
||||
|
||||
void loadChannels();
|
||||
void saveChannels();
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
@ -327,7 +324,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
wtimer.setParent(this);
|
||||
warnidx = 0;
|
||||
wtimer.singleShot(0, this, SLOT(on_changeWarningMessage()));
|
||||
loadChannels();
|
||||
|
||||
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(on_aboutToQuit()));
|
||||
|
||||
@ -1918,8 +1914,10 @@ void MainWindow::on_action_Rebuild_Oximetry_Index_triggered()
|
||||
overview->ReloadGraphs();
|
||||
}
|
||||
|
||||
void MainWindow::RestartApplication(bool force_login, bool change_datafolder)
|
||||
void MainWindow::RestartApplication(bool force_login, QString cmdline)
|
||||
{
|
||||
p_profile->removeLock();
|
||||
|
||||
QString apppath;
|
||||
#ifdef Q_OS_MAC
|
||||
// In Mac OS the full path of aplication binary is:
|
||||
@ -1938,7 +1936,7 @@ void MainWindow::RestartApplication(bool force_login, bool change_datafolder)
|
||||
|
||||
if (force_login) { args << "-l"; }
|
||||
|
||||
if (change_datafolder) { args << "-d"; }
|
||||
args << cmdline;
|
||||
|
||||
if (QProcess::startDetached("/usr/bin/open", args)) {
|
||||
QApplication::instance()->exit();
|
||||
@ -1958,7 +1956,9 @@ void MainWindow::RestartApplication(bool force_login, bool change_datafolder)
|
||||
|
||||
if (force_login) { args << "-l"; }
|
||||
|
||||
if (change_datafolder) { args << "-d"; }
|
||||
args << cmdline;
|
||||
|
||||
//if (change_datafolder) { args << "-d"; }
|
||||
|
||||
if (QProcess::startDetached(apppath, args)) {
|
||||
::exit(0);
|
||||
@ -1972,7 +1972,6 @@ void MainWindow::on_actionChange_User_triggered()
|
||||
{
|
||||
p_profile->Save();
|
||||
PREF.Save();
|
||||
p_profile->removeLock();
|
||||
|
||||
RestartApplication(true);
|
||||
}
|
||||
@ -2507,14 +2506,13 @@ void MainWindow::on_actionHelp_Support_SleepyHead_Development_triggered()
|
||||
|
||||
void MainWindow::on_actionChange_Language_triggered()
|
||||
{
|
||||
QSettings *settings = new QSettings(getDeveloperName(), getAppName());
|
||||
settings->remove("Settings/Language");
|
||||
delete settings;
|
||||
//QSettings *settings = new QSettings(getDeveloperName(), getAppName());
|
||||
//settings->remove("Settings/Language");
|
||||
//delete settings;
|
||||
p_profile->Save();
|
||||
PREF.Save();
|
||||
p_profile->removeLock();
|
||||
|
||||
RestartApplication(true);
|
||||
RestartApplication(true, "-language");
|
||||
}
|
||||
|
||||
void MainWindow::on_actionChange_Data_Folder_triggered()
|
||||
@ -2523,7 +2521,7 @@ void MainWindow::on_actionChange_Data_Folder_triggered()
|
||||
PREF.Save();
|
||||
p_profile->removeLock();
|
||||
|
||||
RestartApplication(false, true);
|
||||
RestartApplication(false, "-d");
|
||||
}
|
||||
|
||||
void MainWindow::on_actionImport_Somnopose_Data_triggered()
|
||||
|
@ -66,6 +66,9 @@ class Daily;
|
||||
class Report;
|
||||
class Overview;
|
||||
|
||||
void loadChannels();
|
||||
void saveChannels();
|
||||
|
||||
|
||||
/*! \class MainWindow
|
||||
\author Mark Watkins
|
||||
@ -123,7 +126,7 @@ class MainWindow : public QMainWindow
|
||||
|
||||
If force_login is set, it will return to the login menu even if it's set to skip
|
||||
*/
|
||||
static void RestartApplication(bool force_login = false, bool change_datafolder = false);
|
||||
static void RestartApplication(bool force_login = false, QString cmdline = QString());
|
||||
|
||||
void JumpDaily();
|
||||
|
||||
|
@ -393,7 +393,7 @@ void ProfileSelect::on_listView_customContextMenuRequested(const QPoint &pos)
|
||||
|
||||
void ProfileSelect::on_pushButton_clicked()
|
||||
{
|
||||
MainWindow::RestartApplication(false, true);
|
||||
MainWindow::RestartApplication(false, "-d");
|
||||
}
|
||||
|
||||
void ProfileSelect::on_filter_textChanged(const QString &arg1)
|
||||
|
@ -56,7 +56,7 @@ void initTranslations(QSettings & settings) {
|
||||
dir.setNameFilters(QStringList("*.qm"));
|
||||
|
||||
QFileInfoList list = dir.entryInfoList();
|
||||
QString language = settings.value("Settings/Language").toString();
|
||||
QString language = settings.value(LangSetting).toString();
|
||||
|
||||
QString langfile, langname;
|
||||
|
||||
@ -140,7 +140,7 @@ void initTranslations(QSettings & settings) {
|
||||
langsel.disconnect(&langlist, SIGNAL(itemDoubleClicked(QListWidgetItem*)), &langsel, SLOT(close()));
|
||||
langname = langlist.currentItem()->text();
|
||||
language = langlist.currentItem()->data(Qt::UserRole).toString();
|
||||
settings.setValue("Settings/Language", language);
|
||||
settings.setValue(LangSetting, language);
|
||||
}
|
||||
|
||||
langname=langNames[language];
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
const QString LangSetting = "Settings/Language";
|
||||
|
||||
void initTranslations(QSettings & settings);
|
||||
|
||||
#endif // TRANSLATION_H
|
||||
|
Loading…
Reference in New Issue
Block a user