From: Norbert Moutarde Date: Sat, 16 Mar 2019 11:14:26 +0000 (+0100) Subject: few cleanup for the nest Qt version (and C++17 too) X-Git-Url: https://git.nothing2do.fr/?a=commitdiff_plain;h=0a2c82c3ee9ccb168852180f50ee641765dfc16e;p=diary-mobile.git few cleanup for the nest Qt version (and C++17 too) --- diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml deleted file mode 100644 index 8332b85..0000000 --- a/android/AndroidManifest.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index d1ff362..0000000 --- a/android/build.gradle +++ /dev/null @@ -1,51 +0,0 @@ -buildscript { - repositories { - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:0.12.1' - } -} - -apply plugin: 'android' - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) -} - -android { - /******************************************************* - * The following variables: - * - androidBuildToolsVersion, - * - androidCompileSdkVersion - * - qt5AndroidDir - holds the path to qt android files - * needed to build any Qt application - * on Android. - * - * are defined in gradle.properties file. This file is - * updated by QtCreator and androiddeployqt tools. - * Changing them manually might break the compilation! - *******************************************************/ - - compileSdkVersion androidCompileSdkVersion.toInteger() - - buildToolsVersion androidBuildToolsVersion - - sourceSets { - main { - manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java'] - aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl'] - res.srcDirs = [qt5AndroidDir + '/res', 'res'] - resources.srcDirs = ['src'] - renderscript.srcDirs = ['src'] - assets.srcDirs = ['assets'] - jniLibs.srcDirs = ['libs'] - } - } - - lintOptions { - abortOnError false - } -} diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 8c0fb64..0000000 Binary files a/android/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 1e61d1f..0000000 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Wed Apr 10 15:27:10 PDT 2013 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip diff --git a/android/gradlew b/android/gradlew deleted file mode 100755 index 91a7e26..0000000 --- a/android/gradlew +++ /dev/null @@ -1,164 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat deleted file mode 100644 index aec9973..0000000 --- a/android/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/android/res/values/libs.xml b/android/res/values/libs.xml deleted file mode 100644 index 4d68673..0000000 --- a/android/res/values/libs.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - https://download.qt-project.org/ministro/android/qt5/qt-5.4 - - - - - - - - - - - - - - - - - - - - diff --git a/diary-mobile.pro b/diary-mobile.pro index fdf5f27..790c237 100644 --- a/diary-mobile.pro +++ b/diary-mobile.pro @@ -27,7 +27,7 @@ CONFIG += mobility c++11 MOBILITY = QMAKE_CXXFLAGS += -fpermissive -Wswitch TRANSLATIONS = diary-mobile_fr_FR.ts diary-mobile_en_EN.ts -ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android +# ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android OTHER_FILES += \ android/AndroidManifest.xml \ diff --git a/mainwindow.cpp b/mainwindow.cpp index f57d221..be715a9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -77,7 +77,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) if((conf->value(QString("first")).toInt()==1)){ qDebug()<<"second"; bool ok; - QString ser=QInputDialog::getText(this, trUtf8("init file"), trUtf8("Enter the URL to download the init file"), QLineEdit::Normal, conf->value(QString("init")).toString(), &ok); + QString ser=QInputDialog::getText(this, tr("init file"), tr("Enter the URL to download the init file"), QLineEdit::Normal, conf->value(QString("init")).toString(), &ok); conf->setValue(QString("init"), ser); downSQL(ser); conf->setValue(QString("first"), 2); @@ -167,10 +167,11 @@ void MainWindow::quit(){ db.close(); qApp->quit(); } -int unsigned MainWindow::addWidget(const QString &key, const CLabel *a){ +int unsigned MainWindow::addWidget(QString &key, CLabel *a){ qDebug()<<"addWidget("<text()<<", "<text()); + const QString mark="idem"; + if(key.contains(mark)){ + key.replace(mark, a->text(), Qt::CaseSensitive); } int c=grid->count(), maxc=conf->value(QString("maxcolumn")).toInt(), maxl=conf->value(QString("maxline")).toInt(); grid->addWidget(a, c/maxc, c%maxc, 1, 1, Qt::AlignJustify| Qt::AlignVCenter | Qt::AlignHCenter); @@ -185,7 +186,7 @@ int unsigned MainWindow::addWidget(const QString &key, const CLabel *a){ } void MainWindow::action(const QString &a){ qDebug()<<"action("<"+aa)); + if(deb)QMessageBox::information(this, tr("valeur replace", "box title to debug valeur replace"), QString(abefore+"=>"+aa)); } }}else{ aa.chop(1); @@ -201,7 +202,7 @@ void MainWindow::action(const QString &a){ QString c=aa; QStringList b=aa.split(QString(" ")); c.remove(0,4); - if(deb)QMessageBox::information(this, trUtf8("action after replace", "box title to debug action"), aa); + if(deb)QMessageBox::information(this, tr("action after replace", "box title to debug action"), aa); int bs=b.size(), part=aa.count(conf->value(QString("sepcmd")).toString()); if(part){ for(int d=0; d<=part; d++){ @@ -212,7 +213,7 @@ void MainWindow::action(const QString &a){ QString d, e; bool ok; if(bs==1){ - d=QInputDialog::getText(this, "set", trUtf8("Variable's name ?", "text to ask value's name before changing it (set)"), QLineEdit::Normal, QString(""), &ok); + d=QInputDialog::getText(this, "set", tr("Variable's name ?", "text to ask value's name before changing it (set)"), QLineEdit::Normal, QString(""), &ok); if(!ok)return; e=QInputDialog::getText(this, "set", d, QLineEdit::Normal, conf->value(d).toString(), &ok); if(!ok)return; @@ -224,11 +225,11 @@ void MainWindow::action(const QString &a){ d=b[1]; e=b[2]; }else{ - QMessageBox::critical(this, trUtf8("Error","title if action(\"set\") has too much value"), trUtf8("Too much value in button's action", "text if action(\"set\") has too much value")); + QMessageBox::critical(this, tr("Error","title if action(\"set\") has too much value"), tr("Too much value in button's action", "text if action(\"set\") has too much value")); return; } //QString z=d+" will be changed to "+e; - if(conf->value(QString("saychange")).toBool()||deb)QMessageBox::information(this, trUtf8("variable text change", "title to warn about variable content change"), trUtf8("value of "+d.toLocal8Bit()+" changed to "+e.toLocal8Bit(), "text to warn about variable content change")); + if(conf->value(QString("saychange")).toBool()||deb)QMessageBox::information(this, tr("variable text change", "title to warn about variable content change"), tr("value of "+d.toLocal8Bit()+" changed to "+e.toLocal8Bit(), "text to warn about variable content change")); conf->setValue(d, e); } else if(b[0]==QString("setint")){ @@ -236,7 +237,7 @@ void MainWindow::action(const QString &a){ int e; QString d; if(bs==1){ - d=QInputDialog::getText(this, "setInt", trUtf8("Variable's name ?", "text to ask value's name before changing it (setint)"), QLineEdit::Normal, QString(""), &ok); + d=QInputDialog::getText(this, "setInt", tr("Variable's name ?", "text to ask value's name before changing it (setint)"), QLineEdit::Normal, QString(""), &ok); if(!ok)return; e=QInputDialog::getInt(this, "setInt", d, QLineEdit::Normal, conf->value(d).toInt(), &ok); if(!ok)return; @@ -248,11 +249,11 @@ void MainWindow::action(const QString &a){ d=b[1]; e=b[2].toInt(); }else{ - QMessageBox::critical(this, trUtf8("Error","title if action(\"set\") has too much value"), trUtf8("Too much value in button's action", "text if action(\"set\") has too much value")); + QMessageBox::critical(this, tr("Error","title if action(\"set\") has too much value"), tr("Too much value in button's action", "text if action(\"set\") has too much value")); return; } //QString z=d+" will be changed to "+e; - if(conf->value(QString("saychange")).toBool())QMessageBox::information(this, trUtf8("variable integer change", "title to warn about variable content change"), trUtf8("Value of "+d.toLocal8Bit()+" changed", "text to warn about variable content change")); + if(conf->value(QString("saychange")).toBool())QMessageBox::information(this, tr("variable integer change", "title to warn about variable content change"), tr("Value of "+d.toLocal8Bit()+" changed", "text to warn about variable content change")); conf->setValue(d, e); } else if(b[0]==QString("start")){ @@ -298,7 +299,7 @@ void MainWindow::action(const QString &a){ int max=conf->value(QString("maxcolumn")).toInt()*conf->value(QString("maxline")).toInt(); if(!page)tmp=q->seek(0); else tmp=q->seek(page*(max-2)); - if(deb)QMessageBox::information(this, trUtf8("result", "box title to debug prevpage"), int(tmp)); + if(deb)QMessageBox::information(this, tr("result", "box title to debug prevpage"), int(tmp)); printItem(*q); } @@ -311,21 +312,21 @@ void MainWindow::action(const QString &a){ bool ok=0; QString d, e; if(bs==1){ - d=QInputDialog::getText(this, "setFile", trUtf8("Variable's name ?", "text to ask value's name before changing it (setint)") , QLineEdit::Normal, QString(""), &ok); + d=QInputDialog::getText(this, "setFile", tr("Variable's name ?", "text to ask value's name before changing it (setint)") , QLineEdit::Normal, QString(""), &ok); if(!ok)return; - e=QFileDialog::getSaveFileName(this, trUtf8("get file", "title to ask file"), conf->value(d).toString()); + e=QFileDialog::getSaveFileName(this, tr("get file", "title to ask file"), conf->value(d).toString()); }else if(bs==2){ d=b[1]; - e=QFileDialog::getSaveFileName(this, trUtf8("get file", "title to ask file"), conf->value(d).toString()); + e=QFileDialog::getSaveFileName(this, tr("get file", "title to ask file"), conf->value(d).toString()); }else if(bs==3){ d=b[1]; e=b[2]; } - if(conf->value(QString("saychange")).toBool())QMessageBox::information(this, trUtf8("variable file change", "title to warn about variable content change"), trUtf8("value of "+d.toLocal8Bit()+" has been changed to "+e.toLocal8Bit(), "text to warn about variable content change")); + if(conf->value(QString("saychange")).toBool())QMessageBox::information(this, tr("variable file change", "title to warn about variable content change"), tr("value of "+d.toLocal8Bit()+" has been changed to "+e.toLocal8Bit(), "text to warn about variable content change")); conf->setValue(d, e); } else if(b[0]==QString("box")){ - QMessageBox::information(this, trUtf8("box", "box title to show a text"), c); + QMessageBox::information(this, tr("box", "box title to show a text"), c); } else if(b[0]==QString("quit")){ @@ -342,7 +343,7 @@ void MainWindow::action(const QString &a){ //if (value){ for(int d=1; d<=value; d++){ bool ok; - QString e=QInputDialog::getText(this, trUtf8("set"), c+" : "+d, QLineEdit::Normal, QString(""), &ok); + QString e=QInputDialog::getText(this, tr("set"), c+" : "+d, QLineEdit::Normal, QString(""), &ok); if(ok)cmd.append(e); else break;// in case of break, exec complain about cmd size } @@ -354,7 +355,7 @@ void MainWindow::action(const QString &a){ //bool ok; action(beforekey); if(bs==1){ - /*e=QInputDialog::getText(this, QString("ID"), trUtf8("Enter ID of button to edit"), QLineEdit::Normal, QString(""), &ok); + /*e=QInputDialog::getText(this, QString("ID"), tr("Enter ID of button to edit"), QLineEdit::Normal, QString(""), &ok); if(!ok)return;*/ chooseDB(); } @@ -362,7 +363,7 @@ void MainWindow::action(const QString &a){ editDB(conf->value(QString("currenttype")).toString(),b[1]); } else{ - QMessageBox::critical(this, trUtf8("Error","title if action(\"edit\") has too much value"), trUtf8("Too much value in button's action", "text if action(\"edit\") has too much value")); + QMessageBox::critical(this, tr("Error","title if action(\"edit\") has too much value"), tr("Too much value in button's action", "text if action(\"edit\") has too much value")); return; } //editDB(conf->value(QString("currenttype")).toString(),e); @@ -382,13 +383,13 @@ void MainWindow::action(const QString &a){ bool ok; int bs=b.size(); if(bs==1){ - a=QInputDialog::getText(this, trUtf8("URL", "title to download a custom file from URL"), trUtf8("Enter the URL of the file", "label to download a custom file"), QLineEdit::Normal, QString(""), &ok); + a=QInputDialog::getText(this, tr("URL", "title to download a custom file from URL"), tr("Enter the URL of the file", "label to download a custom file"), QLineEdit::Normal, QString(""), &ok); if(!ok)return; - aa=QInputDialog::getText(this, trUtf8("File", "title to write a file downloaded from URL"), trUtf8("Enter the name of the file", "label to write the downloaded data"), QLineEdit::Normal, QString(""), &ok); + aa=QInputDialog::getText(this, tr("File", "title to write a file downloaded from URL"), tr("Enter the name of the file", "label to write the downloaded data"), QLineEdit::Normal, QString(""), &ok); if(!ok)return; }else if(bs==2){ a=b[1]; - aa=QInputDialog::getText(this, trUtf8("File", "title to write a file downloaded from URL"), trUtf8("Enter the name of the file", "label to write the downloaded data"), QLineEdit::Normal, QString(""), &ok); + aa=QInputDialog::getText(this, tr("File", "title to write a file downloaded from URL"), tr("Enter the name of the file", "label to write the downloaded data"), QLineEdit::Normal, QString(""), &ok); if(!ok)return; }else if(bs==3){ a=b[1]; @@ -427,7 +428,7 @@ void MainWindow::action(const QString &a){ a.open(QIODevice::ReadOnly); read(conf->value(QString("currenttype")).toString(),a.readAll()); }else{ - QMessageBox::warning(this, trUtf8("Error", "title of box if action(\"read\" has too much (or too \"less\") value"), trUtf8("Bad number of value", "text of box if action(\"read\") has too much (or too \"less\") value")); + QMessageBox::warning(this, tr("Error", "title of box if action(\"read\" has too much (or too \"less\") value"), tr("Bad number of value", "text of box if action(\"read\") has too much (or too \"less\") value")); } } else if(b[0]==QString("mass")){ @@ -534,27 +535,27 @@ void MainWindow::action(const QString &a){ } void MainWindow::createMenuBar(){ qDebug()<<"createMenuBar()"; - FileMenu=new QMenu(trUtf8("&File", "top menu"), this); - FileMenu->addAction(trUtf8("&Start", "File|Start"), this, SLOT(start()),QKeySequence(trUtf8("Ctrl+S", "File|Start"))); - FileMenu->addAction(trUtf8("&Back", "File|Back"), this, SLOT(back()),QKeySequence(trUtf8("Ctrl+B", "File|Back"))); - FileMenu->addAction(trUtf8("&View/Hide menu", "File|View/Hide menu"), this, SLOT(toggleMenu()), QKeySequence(trUtf8("Ctrl+T", "File|View menu"))); - FileMenu->addAction(trUtf8("sendRAW", "File|SendRAW"), this, SLOT(sendRAW()), QKeySequence(trUtf8("Ctrl+L", "File|Upload"))); - FileMenu->addAction(trUtf8("Reset RAW", "File|resetRAW"), this, SLOT(resetRAW()), QKeySequence(trUtf8("Ctrl+E", "File|Reset"))); - FileMenu->addAction(trUtf8("&Quit", "File|Quit"), this, SLOT(quit()),QKeySequence(trUtf8("Ctrl+Q", "File|Quit"))); + FileMenu=new QMenu(tr("&File", "top menu"), this); + FileMenu->addAction(tr("&Start", "File|Start"), this, SLOT(start()),QKeySequence(tr("Ctrl+S", "File|Start"))); + FileMenu->addAction(tr("&Back", "File|Back"), this, SLOT(back()),QKeySequence(tr("Ctrl+B", "File|Back"))); + FileMenu->addAction(tr("&View/Hide menu", "File|View/Hide menu"), this, SLOT(toggleMenu()), QKeySequence(tr("Ctrl+T", "File|View menu"))); + FileMenu->addAction(tr("sendRAW", "File|SendRAW"), this, SLOT(sendRAW()), QKeySequence(tr("Ctrl+L", "File|Upload"))); + FileMenu->addAction(tr("Reset RAW", "File|resetRAW"), this, SLOT(resetRAW()), QKeySequence(tr("Ctrl+E", "File|Reset"))); + FileMenu->addAction(tr("&Quit", "File|Quit"), this, SLOT(quit()),QKeySequence(tr("Ctrl+Q", "File|Quit"))); menuBar()->addMenu(FileMenu); - EditMenu=new QMenu(trUtf8("&Button", "top menu")); - EditMenu->addAction(trUtf8("&Download", "Button|Downlad"), this, SLOT(downloadData()),QKeySequence(trUtf8("Ctrl+W", "Button|Downlad"))); - EditMenu->addAction(trUtf8("A&dd", "Button|Add"), this, SLOT(addDB()), QKeySequence(trUtf8("Ctrl+D", "Button|Add"))); - EditMenu->addAction(trUtf8("Sa&v", "Button|Sav"), this, SLOT(savData()), QKeySequence(trUtf8("Ctrl+V", "Button|Save"))); - //EditMenu->addAction(trUtf8("Reset", "Button|Reset"), this, SLOT(reset()), QKeySequence(trUtf8("Ctrl+Z", "Button|Reset"))); - EditMenu->addAction(trUtf8("&Edit", "Button|Edit"), this, SLOT(chooseDB()), QKeySequence(trUtf8("Ctrl+E", "Button|&Edit"))); + EditMenu=new QMenu(tr("&Button", "top menu")); + EditMenu->addAction(tr("&Download", "Button|Downlad"), this, SLOT(downloadData()),QKeySequence(tr("Ctrl+W", "Button|Downlad"))); + EditMenu->addAction(tr("A&dd", "Button|Add"), this, SLOT(addDB()), QKeySequence(tr("Ctrl+D", "Button|Add"))); + EditMenu->addAction(tr("Sa&v", "Button|Sav"), this, SLOT(savData()), QKeySequence(tr("Ctrl+V", "Button|Save"))); + //EditMenu->addAction(tr("Reset", "Button|Reset"), this, SLOT(reset()), QKeySequence(tr("Ctrl+Z", "Button|Reset"))); + EditMenu->addAction(tr("&Edit", "Button|Edit"), this, SLOT(chooseDB()), QKeySequence(tr("Ctrl+E", "Button|&Edit"))); menuBar()->addMenu(EditMenu); - HackMenu=new QMenu(trUtf8("&Hack", "top menu")); - HackMenu->addAction(trUtf8("New entry", "Hack|Entry"), this, SLOT(entry())); - HackMenu->addAction(trUtf8("Action", "Hack|Action"), this, SLOT(action())); - HackMenu->addAction(trUtf8("About Qt", "Hack|About Qt"), qApp, SLOT(aboutQt()), QKeySequence(trUtf8("ctrl+H", "Help|About Qt"))); - //HackMenu->addAction(trUtf8("C&reate Database", "Hack|Create"), this, SLOT(createDB()), QKeySequence(trUtf8("Ctrl+R", "Help|CreateDB"))); - HackMenu->addAction(trUtf8("Download sql", "Hack|download sql"), this, SLOT(tmpdown())); + HackMenu=new QMenu(tr("&Hack", "top menu")); + HackMenu->addAction(tr("New entry", "Hack|Entry"), this, SLOT(entry())); + HackMenu->addAction(tr("Action", "Hack|Action"), this, SLOT(action())); + HackMenu->addAction(tr("About Qt", "Hack|About Qt"), qApp, SLOT(aboutQt()), QKeySequence(tr("ctrl+H", "Help|About Qt"))); + //HackMenu->addAction(tr("C&reate Database", "Hack|Create"), this, SLOT(createDB()), QKeySequence(tr("Ctrl+R", "Help|CreateDB"))); + HackMenu->addAction(tr("Download sql", "Hack|download sql"), this, SLOT(tmpdown())); menuBar()->addMenu(HackMenu); menuBar()->show(); } @@ -576,7 +577,7 @@ void MainWindow::flush(){ } //widget.clear(); } -CLabel::CLabel( const QString& text, const QSettings & set, int tmpid, QWidget * parent ) : QLabel(parent) +CLabel::CLabel( const QString& text, QSettings & set, int tmpid, QWidget * parent ) : QLabel(parent) { QString a=set.value(QString("currenttype")).toString(); m_style=set.value(a).toString(); @@ -609,7 +610,7 @@ void CLabel::mouseReleaseEvent( QMouseEvent * event ) QString a=settings->value(QString("currenttype")).toString(); QString bb=settings->value(a+QString("before")).toString(); QString ba=settings->value(a+QString("after")).toString(); - QString tmp("edit "+id); + QString tmp("edit "+QString::number(id)); switch(event->button()){ case Qt::LeftButton: setStyleSheet(m_style.replace(ba, bb)); @@ -753,8 +754,8 @@ void MainWindow::entry(const QString &a){ else if((a=="")&&(conf->value(QString("onlylast")).toBool()))label=way.last()+" : "; else if((a!="")&&(!conf->value(QString("onlylast")).toBool()))label=context+",\n"+ a +" : "; else label=way.last()+", "+a+" :\n "; - if(conf->value(QString("multiline")).toBool())entry=QInputDialog::getMultiLineText(this, trUtf8("New entry"), label, QString(""), &ok); - else entry=QInputDialog::getText(this, trUtf8("New entry"), label, QLineEdit::Normal, "", &ok); + if(conf->value(QString("multiline")).toBool())entry=QInputDialog::getMultiLineText(this, tr("New entry"), label, QString(""), &ok); + else entry=QInputDialog::getText(this, tr("New entry"), label, QLineEdit::Normal, "", &ok); if(!ok)return; QString c; @@ -770,14 +771,14 @@ void MainWindow::entry(){ } void MainWindow::addDB(const QString & tmp, const QString & cur){ qDebug()<<"addDB : tmp="<text(); - QString a, b, c=QInputDialog::getText(this, trUtf8("label", "Title of box where ask for new label"), trUtf8("Enter his label", "his/her/?they? I've forget my school lesson"), QLineEdit::Normal, QString(""), &ok); + QString a, b, c=QInputDialog::getText(this, tr("label", "Title of box where ask for new label"), tr("Enter his label", "his/her/?they? I've forget my school lesson"), QLineEdit::Normal, QString(""), &ok); if ((c=="")||(ok==0))return; - b=QInputDialog::getText(this, trUtf8("keyword", "Title of box where ask for new keyword"), trUtf8("Enter they keyword (no limit !)"), QLineEdit::Normal, *&cur, &ok); + b=QInputDialog::getText(this, tr("keyword", "Title of box where ask for new keyword"), tr("Enter they keyword (no limit !)"), QLineEdit::Normal, *&cur, &ok); if ((b=="")||(ok==0))return; - a=QInputDialog::getText(this, trUtf8("action", "Title of box where ask for new action"), trUtf8("Enter his action"), QLineEdit::Normal, QString("new idem"), &ok); + a=QInputDialog::getText(this, tr("action", "Title of box where ask for new action"), tr("Enter his action"), QLineEdit::Normal, QString("new idem"), &ok); if ((a=="")||(ok==0))return; QString tmpfile; if(a.contains(QString("!file!"))){ @@ -791,7 +792,7 @@ void MainWindow::addDB(const QString & tmp, const QString & cur){ return; } void MainWindow::get(const QString & d, const QString &b){ - if(deb)QMessageBox::information(this, trUtf8("action", "box title to debug get"), "type:"+d+" keyword:"+b); + if(deb)QMessageBox::information(this, tr("action", "box title to debug get"), "type:"+d+" keyword:"+b); QString a=b;lastprint=b; if((b[0]!='-')&&(b[0]!='+'))way.append(a); else a.remove(0, 1); @@ -814,7 +815,7 @@ void MainWindow::get(const QString & d, const QString &b){ void MainWindow::chooseDB(){ QString b; bool ok=1; - if(conf->value("askkeyword").toBool())b=QInputDialog::getText(this, trUtf8("chooseDB"), trUtf8("Enter the keyword : "), QLineEdit::Normal, label->text(), &ok); + if(conf->value("askkeyword").toBool())b=QInputDialog::getText(this, tr("chooseDB"), tr("Enter the keyword : "), QLineEdit::Normal, label->text(), &ok); else b=label->text(); if(ok)chooseDB(conf->value(QString("currenttype")).toString(), b); @@ -841,7 +842,7 @@ void MainWindow::chooseDB(const QString & a,const QString & b){ void MainWindow::editDB(const QString & a, const QString & b){ QString tmp=conf->value(QString("edit")+a).toString(), txt="type="+a+" id="+b;; - if(deb)QMessageBox::information(this, trUtf8("EditDB", "box title to debug editDB"), txt); + if(deb)QMessageBox::information(this, tr("EditDB", "box title to debug editDB"), txt); exec(QList({tmp, b})); if(q->isSelect())q->first(); @@ -850,16 +851,16 @@ void MainWindow::editDB(const QString & a, const QString & b){ QString label=q->value(2).toString(); QString action=q->value(3).toString(); QString tmpkeyword, tmplabel, tmpaction; - if(conf->value(QString("multiline")).toBool())tmpkeyword=QInputDialog::getMultiLineText(this, trUtf8("keyword", "Title of box where ask for button's keyword"), trUtf8("new keyword", "question to get new button's keyword"), keyword, &ok); - else tmpkeyword=QInputDialog::getText(this, trUtf8("keyword", "Title of box where ask for button's keyword"), trUtf8("new keyword", "question to get new button's keyword"), QLineEdit::Normal, keyword, &ok); + if(conf->value(QString("multiline")).toBool())tmpkeyword=QInputDialog::getMultiLineText(this, tr("keyword", "Title of box where ask for button's keyword"), tr("new keyword", "question to get new button's keyword"), keyword, &ok); + else tmpkeyword=QInputDialog::getText(this, tr("keyword", "Title of box where ask for button's keyword"), tr("new keyword", "question to get new button's keyword"), QLineEdit::Normal, keyword, &ok); if(!ok)return; - if(conf->value(QString("multiline")).toBool())tmplabel=QInputDialog::getMultiLineText(this, trUtf8("label", "Title of box where ask for button's label"), trUtf8("new label", "question to get new button's label"), label, &ok); - else tmplabel=QInputDialog::getText(this, trUtf8("label", "Title of box where ask for button's label"), trUtf8("new label", "question to get new button's label"), QLineEdit::Normal, label, &ok); + if(conf->value(QString("multiline")).toBool())tmplabel=QInputDialog::getMultiLineText(this, tr("label", "Title of box where ask for button's label"), tr("new label", "question to get new button's label"), label, &ok); + else tmplabel=QInputDialog::getText(this, tr("label", "Title of box where ask for button's label"), tr("new label", "question to get new button's label"), QLineEdit::Normal, label, &ok); if(!ok)return; - if(conf->value(QString("multiline")).toBool())tmpaction=QInputDialog::getMultiLineText(this, trUtf8("action", "Title of box where ask for button's action"), trUtf8("new action", "question to get new button's action"), action, &ok); - else tmpaction=QInputDialog::getText(this, trUtf8("action", "Title of box where ask for button's action"), trUtf8("new action", "question to get new button's action"), QLineEdit::Normal, action, &ok); + if(conf->value(QString("multiline")).toBool())tmpaction=QInputDialog::getMultiLineText(this, tr("action", "Title of box where ask for button's action"), tr("new action", "question to get new button's action"), action, &ok); + else tmpaction=QInputDialog::getText(this, tr("action", "Title of box where ask for button's action"), tr("new action", "question to get new button's action"), QLineEdit::Normal, action, &ok); if(!ok)return; QString tmpfile; if(tmpaction.contains(QString("!file!"))){ @@ -870,10 +871,10 @@ void MainWindow::editDB(const QString & a, const QString & b){ if((tmpkeyword=="")||(tmplabel=="")||(tmpaction=="")){ remove(a, keyword, label, action); - if(deb)QMessageBox::information(this, trUtf8("EditDB", "title of box to say a button was deleted"), trUtf8("button was deleted", "text to say button was deleted")); + if(deb)QMessageBox::information(this, tr("EditDB", "title of box to say a button was deleted"), tr("button was deleted", "text to say button was deleted")); return; } - if(deb)QMessageBox::information(this, trUtf8("EditDB", "title to print new value of button"), QString("keyword="+tmpkeyword+", label="+tmplabel+", action="+tmpaction)); + if(deb)QMessageBox::information(this, tr("EditDB", "title to print new value of button"), QString("keyword="+tmpkeyword+", label="+tmplabel+", action="+tmpaction)); exec(QList({conf->value(QString("update")+a).toString(), tmpkeyword, tmplabel, tmpaction, b})); } @@ -914,7 +915,7 @@ void MainWindow::sendRAW(){ } void MainWindow::RAWsent(){ qDebug()<<"RAWsent"; - QMessageBox::information(this, trUtf8("RAWsent", "message title when data has been send"), trUtf8("sendRAW finish", "message text when data has been send")); + QMessageBox::information(this, tr("RAWsent", "message title when data has been send"), tr("sendRAW finish", "message text when data has been send")); } void MainWindow::back(){ if(QString("-")+label->text()!=conf->value(QString("menuback")).toString()){ @@ -931,10 +932,11 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event) QString tmp; tmp.setNum(k); qDebug()<<"key released="<value(QString("actionmenu"), QString("")).toString(); - if(a=="")accepted++; + if((a=="")&&(accepted))accepted=0; + if((a=="")&&(!accepted))accepted=1; if(a!=lastprint){ beforekey=label->text(); action(a); @@ -943,7 +945,8 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event) }; }else if(k==Qt::Key_Back){ const QString a=conf->value(QString("menuback"), QString("")).toString(); - if(a=="")accepted++; + if((a=="")&&(accepted))accepted=0; + if((a=="")&&(!accepted))accepted=1; if(a!=lastprint){ beforekey=label->text(); action(a); @@ -953,7 +956,8 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event) }else if(k==Qt::Key_VolumeDown){ qDebug()<<"keyvolumdown"; const QString a=conf->value(QString("volumdown"), QString("")).toString(); - if(a=="")accepted++; + if((a=="")&&(accepted))accepted=0; + if((a=="")&&(!accepted))accepted=1; if(a!=lastprint){ beforekey=lastprint; action(a); @@ -962,7 +966,8 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event) }; }else if(k==Qt::Key_VolumeUp){ const QString a=conf->value(QString("volumup"), QString("")).toString(); - if(a=="")accepted++; + if((a=="")&&(accepted))accepted=0; + if((a=="")&&(!accepted))accepted=1; if(a!=lastprint){ beforekey=lastprint; action(a); @@ -1030,11 +1035,11 @@ void MainWindow::read(const QString &a, const QByteArray &in){ } void MainWindow::datasent(){ qDebug()<<"datasent"; - QString texte=trUtf8("Upload finish : ", "pop-up when data has been sent"); + QString texte=tr("Upload finish : ", "pop-up when data has been sent"); texte=texte+conf->value(QString("uploadDB")).toString(); qDebug()<<"texte : "<value(QString("restore")).toString(); @@ -1100,13 +1105,13 @@ void MainWindow::sav(const QString & a){ void MainWindow::Uisent(){ qDebug()<<"Uisent"; Msav.unlock(); - QMessageBox::information(this, trUtf8("Uisent", "pop-up title when data has been sent"), trUtf8(QString("sav finish of "+savtitle).toStdString().c_str(), "pop-up text when data has been sent")); + QMessageBox::information(this, tr("Uisent", "pop-up title when data has been sent"), tr(QString("sav finish of "+savtitle).toStdString().c_str(), "pop-up text when data has been sent")); } void MainWindow::resetRAW(){ exec(QList({"delete from raw;"})); } void MainWindow::get(const QString & a){ - const QString b=QInputDialog::getText(this, trUtf8("get", "title to ask keyword to get"), trUtf8("Enter the keyword : ", "ask keyword to get buttons")); + const QString b=QInputDialog::getText(this, tr("get", "title to ask keyword to get"), tr("Enter the keyword : ", "ask keyword to get buttons")); get(a, b); } void MainWindow::insert(const QString & type, const QString & keyword, const QString & label, const QString & action){ @@ -1127,9 +1132,9 @@ void MainWindow::insert(const QString & type, const QString & keyword, const QSt key=key+" "+keyword; }else{ - if(deb)QMessageBox::information(this, trUtf8("key.contain(keyword)", "box title to debug insert"), trUtf8("la chaine est déja dans le bouton")); + if(deb)QMessageBox::information(this, tr("key.contain(keyword)", "box title to debug insert"), tr("la chaine est déja dans le bouton")); } - if(deb)QMessageBox::information(this, trUtf8("action", "box title to debug insert"), trUtf8("insert : key="+key.toLocal8Bit()+" label="+label.toLocal8Bit()+" action="+action.toLocal8Bit(), "label to debug insert")); + if(deb)QMessageBox::information(this, tr("action", "box title to debug insert"), tr("insert : key="+key.toLocal8Bit()+" label="+label.toLocal8Bit()+" action="+action.toLocal8Bit(), "label to debug insert")); if(!id.isValid())exec(QList({conf->value(QString("add")+type).toString(), key, label, action})); else{exec(QList({conf->value(QString("update")+type).toString(), key, label, action, id.toString()})); }; @@ -1154,7 +1159,7 @@ void MainWindow::remove(const QString & type, const QString & keyword, const QSt qDebug()<<"key="<({conf->value(QString("delete")+type).toString(), id.toString()})); else{ exec(QList({conf->value(QString("update")+type).toString(), key, label, action, id.toString()})); @@ -1175,7 +1180,7 @@ void MainWindow::writeFile(){ QDataStream str(&tmp); str<downloadedData(); emit writed(); - QMessageBox::information(this, trUtf8("writeFile", "pop-up title when file has been written"), trUtf8("File written : "+file.toLocal8Bit(), "pop-up text when file has been written")); + QMessageBox::information(this, tr("writeFile", "pop-up title when file has been written"), tr("File written : "+file.toLocal8Bit(), "pop-up text when file has been written")); m->disconnect(); d.unlock(); } @@ -1222,7 +1227,7 @@ void MainWindow::resizeEvent(/*QResizeEvent *event*/) } void MainWindow::tmpdown(){ bool ok; - QString url=QInputDialog::getText(this, trUtf8("tmp URL", "Title of box where ask for button file's URL"), trUtf8("Enter URL", "Label of box where ask for button file's URL"), QLineEdit::Normal, QString(""), &ok), file="file"; + QString url=QInputDialog::getText(this, tr("tmp URL", "Title of box where ask for button file's URL"), tr("Enter URL", "Label of box where ask for button file's URL"), QLineEdit::Normal, QString(""), &ok), file="file"; if(!ok)download(url); connect(m, SIGNAL(downloaded()), this, SLOT(readData())); @@ -1233,7 +1238,7 @@ void MainWindow::readData(){ } void MainWindow::action(){ bool ok; - QString cmd=QInputDialog::getText(this, trUtf8("action", "Title of box where ask for a custom action"), trUtf8("Enter your action", "Label of box where ask for custom action"), QLineEdit::Normal, QString(""), &ok); + QString cmd=QInputDialog::getText(this, tr("action", "Title of box where ask for a custom action"), tr("Enter your action", "Label of box where ask for custom action"), QLineEdit::Normal, QString(""), &ok); if(ok)action(cmd); } void MainWindow::mass(const QString & type, const QString & column, const QString & before, const QString & after){ @@ -1289,7 +1294,7 @@ void MainWindow::reset(const QString & a){ } void MainWindow::use(const QString & a){ bool ok; - QString use=QInputDialog::getText(this, trUtf8("tmp URL", "Title of box where ask for current type"), trUtf8("Enter string", "Label of box where ask for current type"), QLineEdit::Normal, a, &ok); + QString use=QInputDialog::getText(this, tr("tmp URL", "Title of box where ask for current type"), tr("Enter string", "Label of box where ask for current type"), QLineEdit::Normal, a, &ok); if(ok){ //currenttype=use; conf->setValue(QString("currenttype"), use); @@ -1306,14 +1311,14 @@ bool MainWindow::printItem(const QSqlQuery & a){ int i=0; qDebug()<<"printItem()"; if(page){ - addWidget(QString("prevpage"), new CLabel(trUtf8("Prev"), *conf)); + addWidget(QString("prevpage"), new CLabel(tr("Prev"), *conf)); }; do{ int tmp=0; if(a.isValid())tmp=addWidget(a.value(actCol).toString(), new CLabel(a.value(labCol).toString(), *conf, a.value(idcol).toInt())); if(tmp==1){ - addWidget(QString("nextpage"), new CLabel(trUtf8("Next"), *conf)); + addWidget(QString("nextpage"), new CLabel(tr("Next"), *conf)); return 1; }; i++; @@ -1323,7 +1328,7 @@ bool MainWindow::printItem(const QSqlQuery & a){ return 0; } void MainWindow::get2(const QString & d, const QString &b){ - if(deb)QMessageBox::information(this, trUtf8("action", "box title to debug get"), "type:"+d+" keyword:"+b); + if(deb)QMessageBox::information(this, tr("action", "box title to debug get"), "type:"+d+" keyword:"+b); QString a=b;lastprint=b; if((b[0]!='-')&&(b[0]!='+'))way.append(a); else a.remove(0, 1); diff --git a/mainwindow.h b/mainwindow.h index a06b107..e1b277a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -90,7 +90,7 @@ Q_OBJECT int id; QWidget * parents; public: - explicit CLabel(const QString&, const QSettings &, int=0, QWidget * parent = 0 ); + explicit CLabel(const QString&, QSettings &, int=0, QWidget * parent = 0 ); ~CLabel(); void SetTextToLabel(const QString &); QSettings * getSettings(); @@ -124,7 +124,7 @@ public: void setOrientation(ScreenOrientation orientation); QSettings & getSettings(); void showExpanded(); - unsigned int addWidget(const QString &, const CLabel *); + unsigned int addWidget(QString &, CLabel *); void resizeEvent(); void sav(const QString &); void mass(const QString &, const QString &, const QString &, const QString &);