]> git.nothing2do.fr Git - diary-mobile.git/commitdiff
edit and add buttons is now in action() and outside the menubar
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Fri, 4 Mar 2016 21:13:35 +0000 (22:13 +0100)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Fri, 4 Mar 2016 21:13:35 +0000 (22:13 +0100)
mainwindow.cpp
mainwindow.h

index 5f80936c65db85f63380c96c2688042909d8cffe..eb9857f8d4d8e8da002f7cc5cc73951a03e2a568 100644 (file)
@@ -533,10 +533,10 @@ void MainWindow::createMenuBar(){
     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("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->addAction(trUtf8("&Edit", "Button|Edit"), this, SLOT(chooseDB()), QKeySequence(trUtf8("Ctrl+E", "Button|&Edit")));
     menuBar()->addMenu(EditMenu);
     HackMenu=new QMenu(trUtf8("&Hack", "top menu"));
     HackMenu->addAction(trUtf8("New entry", "Hack|Entry"), this, SLOT(entry()));
@@ -749,7 +749,7 @@ void MainWindow::addDB(const QString & tmp){
     qDebug()<<"addDB";
     if(deb)QMessageBox::information(this, trUtf8("addDB", "box title to debug addDB"), "type : "+tmp);
     bool ok=0;
-    QString cur=label->text();
+    QString cur=beforekey;
     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);
     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);
@@ -783,7 +783,7 @@ 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);
-    else b=label->text();
+    else b=beforekey;
     if(ok)chooseDB(conf->value(QString("currenttype")).toString(), b);
 }
 void MainWindow::chooseDB(const QString & b){
@@ -895,32 +895,56 @@ void MainWindow::keyReleaseEvent(QKeyEvent *event)
     if (k==Qt::Key_Menu){
         const QString a=conf->value(QString("actionmenu"), QString("")).toString();
         if(a!=""){
-            action(a);
+            if(beforekey.isEmpty()){
+                beforekey=lastprint;
+                action(a);
+            }else{
+                action(beforekey);
+                beforekey.clear();
+            };
             accepted=true;
-            }
         }
+    }
     else if(k==Qt::Key_Back){
         const QString a=conf->value(QString("menuback"), QString("")).toString();
         if(a!=""){
-            action(a);
+            if(beforekey.isEmpty()){
+                beforekey=lastprint;
+                action(a);
+            }else{
+                action(beforekey);
+                beforekey.clear();
+            };
             accepted=true;
-            }
         }
+    }
     else if(k==Qt::Key_VolumeDown){
         qDebug()<<"keyvolumdown";
         const QString a=conf->value(QString("volumdown")).toString();
         if(a!=""){
-            action(a);
+            if(beforekey.isEmpty()){
+                beforekey=lastprint;
+                action(a);
+            }else{
+                action(beforekey);
+                beforekey.clear();
+            };
             accepted=true;
-            }
         }
+    }
     else if(k==Qt::Key_VolumeUp){
         const QString a=conf->value(QString("volumup")).toString();
         if(a!=""){
-            action(a);
+            if(beforekey.isEmpty()){
+                beforekey=lastprint;
+                action(a);
+            }else{
+                action(beforekey);
+                beforekey.clear();
+            };
             accepted=true;
-            }
-        };
+        }
+    };
     event->setAccepted(accepted);
 }
 void CLabel::SetTextToLabel(const QString& text)
index 882ff256af734cb7de713f5f7f844ed9770657f4..05a30989ad6e44943f507a8b6f728e4c4c03784d 100644 (file)
@@ -69,35 +69,23 @@ class FileDownloader : public QObject
     Q_OBJECT
 public:
     explicit FileDownloader(QUrl url, QObject *parent = 0);
-
     virtual ~FileDownloader();
-
     QByteArray downloadedData() const;
-
 signals:
         void downloaded();
-
 private slots:
-
     void fileDownloaded(QNetworkReply* pReply);
-
 private:
-
     QNetworkAccessManager m_WebCtrl;
-
     QByteArray m_DownloadedData;
-
 };
-
 #endif // FILEDOWNLOADER_H
 
-
 class CLabel : public QLabel
 {
 Q_OBJECT
     QString m_style;
     QSettings * settings;
-
 public:
     explicit CLabel(const QString&, const QSettings &, QWidget * parent = 0 );
     ~CLabel();
@@ -108,7 +96,6 @@ signals:
     void pressed();
     void released();
 private slots:
-
 protected:
     void mousePressEvent ( QMouseEvent * event ) ;
     void mouseReleaseEvent(QMouseEvent * event ) ;
@@ -193,7 +180,6 @@ private slots:
     bool printItem(const QSqlQuery &);
     //void shellReady();a desperated attempt to get the output of my cmd, i've try Qprocess (but don't get it)
 public slots:
-
 signals:
     void datafilled();
     void writed();
@@ -209,7 +195,7 @@ private:
     QGridLayout *grid;
     QLabel *label;
     QSettings *conf;
-    QString tmp, tmp2, file, lastprint, currenttype, savtitle;//host, user, tmp, password, servercert,database;
+    QString tmp, tmp2, file, lastprint, currenttype, savtitle, beforekey;//host, user, tmp, password, servercert,database;
     QMenu *FileMenu, *EditMenu, *HackMenu;
     QSignalMapper *signalmap;
     QStringList way;