From d73dc6bb9ec120d21ec9b52a33f3537eec231b20 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Mon, 8 Sep 2014 20:07:42 +0300 Subject: [PATCH] Local changes according to users settings + CSV extention file is fixed --- main/main.cpp | 15 +++++++- main/mainscreen.cpp | 66 +++++++++++++++++++++++--------- main/mainscreen.h | 4 ++ main/mainscreen.ui | 15 ++++++-- src/jceData/CSV/csv_exporter.cpp | 16 ++++---- 5 files changed, 83 insertions(+), 33 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index 96f4be6..93c9496 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2,13 +2,24 @@ #include #include #include +#include "../src/appDatabase/savedata.h" + int main(int argc, char *argv[]) { QApplication a(argc, argv); QTranslator translator; - QString locale = QLocale::system().name(); - translator.load("jce_"+locale , a.applicationDirPath()); + QString loco; + SaveData data; + loco = data.getLocal(); + if(loco == "default") + { + QString locale = QLocale::system().name(); + translator.load("jce_"+locale , a.applicationDirPath()); + }else if(loco == "he") + translator.load("jce_he" , a.applicationDirPath()); + else + translator.load("jce_en" , a.applicationDirPath()); a.installTranslator(&translator); MainScreen w; w.show(); diff --git a/main/mainscreen.cpp b/main/mainscreen.cpp index ac10b1e..a7c0ec7 100644 --- a/main/mainscreen.cpp +++ b/main/mainscreen.cpp @@ -46,6 +46,23 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr ui->pswdLineEdit->setText(data->getPassword()); ui->keepLogin->setChecked(true); } + + //Local Check and ui setting. + if(data->getLocal() == "en") + { + ui->actionHebrew->setChecked(false); + ui->actionOS_Default->setChecked(false); + ui->actionEnglish->setChecked(true); + }else if(data->getLocal() == "he"){ + ui->actionHebrew->setChecked(true); + ui->actionOS_Default->setChecked(false); + ui->actionEnglish->setChecked(false); + }else{ + ui->actionHebrew->setChecked(false); + ui->actionOS_Default->setChecked(true); + ui->actionEnglish->setChecked(false); + } + } MainScreen::~MainScreen() @@ -240,6 +257,13 @@ void MainScreen::setLabelConnectionStatus(jceLogin::jceStatus statusDescription) this->repaint(); } + +void MainScreen::showMSG(QString msg) +{ + QMessageBox msgBox; + msgBox.setText(msg); + msgBox.exec(); +} void MainScreen::on_actionCredits_triggered() { QMessageBox::about(this, "About", tr("CREDITS-ROOL-UP1") + " v1.0

" @@ -318,39 +342,43 @@ void MainScreen::on_exportToCVSBtn_clicked() void MainScreen::on_actionHebrew_triggered() { - if (ui->actionEnglish->isChecked()) + if (ui->actionEnglish->isChecked() || ui->actionOS_Default->isChecked()) { ui->actionEnglish->setChecked(false); - qDebug() << "Changed Language"; + ui->actionOS_Default->setChecked(false); + qDebug() << "Changed Language to hebrew"; + data->setLocal("he"); + showMSG("ההגדרות שלך יכנסו לתוקף בהפעלה הבאה של התוכנית"); } else - { ui->actionHebrew->setChecked(true); - qDebug() << "Set Hebrew Language: "; - } - } void MainScreen::on_actionEnglish_triggered() { - if (ui->actionHebrew->isChecked()) + if (ui->actionHebrew->isChecked() || ui->actionOS_Default->isChecked()) { ui->actionHebrew->setChecked(false); - qDebug() << "Changed Language"; + ui->actionOS_Default->setChecked(false); + qDebug() << "Changed Language to English"; + data->setLocal("en"); + showMSG("Your settings will take effect next time you start the program"); } else - { ui->actionEnglish->setChecked(true); - qDebug() << "Set English Language: "; - } } - - - - - - - - +void MainScreen::on_actionOS_Default_triggered() +{ + if (ui->actionHebrew->isChecked() || ui->actionEnglish->isChecked()) + { + ui->actionHebrew->setChecked(false); + ui->actionEnglish->setChecked(false); + qDebug() << "Changed Language to OS Default"; + data->setLocal("default"); + showMSG("Your settings will take effect next time you start the program"); + } + else + ui->actionOS_Default->setChecked(true); +} diff --git a/main/mainscreen.h b/main/mainscreen.h index effef20..b17ceaa 100644 --- a/main/mainscreen.h +++ b/main/mainscreen.h @@ -66,6 +66,8 @@ private slots: void on_actionEnglish_triggered(); + void on_actionOS_Default_triggered(); + private: void uiSetDisconnectMode(); @@ -83,6 +85,8 @@ private: QLabel *ButtomStatusLabel; QLabel *statusLabel; + void showMSG(QString msg); + }; #endif // MAINSCREEN_H diff --git a/main/mainscreen.ui b/main/mainscreen.ui index 65e6a55..837858b 100644 --- a/main/mainscreen.ui +++ b/main/mainscreen.ui @@ -61,7 +61,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r QTabWidget::Rounded - 2 + 0 false @@ -626,7 +626,7 @@ font-size: 15px; 0 0 855 - 22 + 29 @@ -637,6 +637,7 @@ font-size: 15px; Language + @@ -675,7 +676,7 @@ font-size: 15px; true - hebrew + Hebrew @@ -686,6 +687,14 @@ font-size: 15px; English + + + true + + + OS Default + + diff --git a/src/jceData/CSV/csv_exporter.cpp b/src/jceData/CSV/csv_exporter.cpp index 66cdd85..249548d 100644 --- a/src/jceData/CSV/csv_exporter.cpp +++ b/src/jceData/CSV/csv_exporter.cpp @@ -40,16 +40,13 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched) QString room = QString(coursePtr->getRoom().c_str()); QString line = makeLine(name, day, startH, startM, endH, endM, lecturer, room, type); -#ifndef _WIN32 - if(line != NULL) - out << line << char(0x0D) << " "; -#elif __APPLE__ && __MACH__ - if(line != NULL) - out << line << char(0x0D) << " "; -#elif __LINUX__ if(line != NULL) + { + #ifndef Q_OS_WIN32 + out << line << char(0x0D) << " "; //Fucking M$ Special end line shit... + #endif out << line << char(0x0A); -#endif + } } @@ -67,7 +64,8 @@ QString CSV_Exporter::getFileFath() QString fileName = QFileDialog::getSaveFileName(); if(fileName == "") return NULL; - fileName.append(".csv"); + if(!fileName.contains(".csv", Qt::CaseInsensitive)) + fileName.append(".csv"); return fileName; }