From 1b64446af3d59b5033fe8f3f22803a46356c765d Mon Sep 17 00:00:00 2001 From: Norbert Moutarde Date: Fri, 4 Mar 2016 22:13:35 +0100 Subject: [PATCH] edit and add buttons is now in action() and outside the menubar --- mainwindow.cpp | 50 +++++++++++++++++++++++++++++++++++++------------- mainwindow.h | 16 +--------------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 5f80936..eb9857f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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) diff --git a/mainwindow.h b/mainwindow.h index 882ff25..05a3098 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -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; -- 2.45.1