diff options
author | Claudio Maradonna <penguyman@stronzi.org> | 2018-05-15 11:12:13 +0200 |
---|---|---|
committer | Claudio Maradonna <penguyman@stronzi.org> | 2018-05-15 11:12:13 +0200 |
commit | f9e7167bfb191c061cf6bcd964c91f2ebb546745 (patch) | |
tree | 41fda48716a72b1f801b9c6644f5fc0a45ef1758 | |
parent | c8e59dd4ba51ae73ca0e54e52a0309e6cd985938 (diff) |
Converted most of Qt4 signals to Qt5 style. Fixed BUG with main folder hidden (possible regression for Windows users and dot folders)
-rw-r--r-- | main/main.cpp | 7 | ||||
-rw-r--r-- | src/mainwindow.cpp | 61 | ||||
-rw-r--r-- | src/mainwindow.h | 5 | ||||
-rw-r--r-- | src/qpushbuttonwithclipboard.cpp | 5 | ||||
-rw-r--r-- | src/qpushbuttonwithclipboard.h | 2 | ||||
-rw-r--r-- | src/singleapplication.cpp | 4 | ||||
-rw-r--r-- | src/trayicon.cpp | 21 | ||||
-rw-r--r-- | src/usersdialog.cpp | 8 |
8 files changed, 60 insertions, 53 deletions
diff --git a/main/main.cpp b/main/main.cpp index 41fcd955..975efe92 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -85,10 +85,11 @@ int main(int argc, char *argv[]) { app.setActiveWindow(&w); app.setWindowIcon(QIcon(":artwork/icon.png")); - QObject::connect(&app, SIGNAL(aboutToQuit()), &w, SLOT(clearClipboard())); + QObject::connect(&app, &QApplication::aboutToQuit, &w, + &MainWindow::clearClipboard); #if SINGLE_APP - QObject::connect(&app, SIGNAL(messageAvailable(QString)), &w, - SLOT(messageAvailable(QString))); + QObject::connect(&app, &SingleApplication::messageAvailable, &w, + &MainWindow::messageAvailable); #endif w.show(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7a095b9c..01e08fa3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -63,10 +63,10 @@ MainWindow::MainWindow(const QString &searchText, QWidget *parent) connectPassSignalHandlers(QtPassSettings::getImitatePass()); // only for ipass - connect(QtPassSettings::getImitatePass(), SIGNAL(startReencryptPath()), this, - SLOT(startReencryptPath())); - connect(QtPassSettings::getImitatePass(), SIGNAL(endReencryptPath()), this, - SLOT(endReencryptPath())); + connect(QtPassSettings::getImitatePass(), &ImitatePass::startReencryptPath, + this, &MainWindow::startReencryptPath); + connect(QtPassSettings::getImitatePass(), &ImitatePass::endReencryptPath, + this, &MainWindow::endReencryptPath); clearPanelTimer.setSingleShot(true); connect(&clearPanelTimer, SIGNAL(timeout()), this, SLOT(clearPanel())); @@ -94,15 +94,16 @@ MainWindow::MainWindow(const QString &searchText, QWidget *parent) * @brief MainWindow::initToolBarButtons init main ToolBar and connect actions */ void MainWindow::initToolBarButtons() { - connect(ui->actionAddPassword, SIGNAL(triggered()), this, - SLOT(addPassword())); - connect(ui->actionAddFolder, SIGNAL(triggered()), this, SLOT(addFolder())); - connect(ui->actionEdit, SIGNAL(triggered()), this, SLOT(onEdit())); - connect(ui->actionDelete, SIGNAL(triggered()), this, SLOT(onDelete())); - connect(ui->actionPush, SIGNAL(triggered()), this, SLOT(onPush())); - connect(ui->actionUpdate, SIGNAL(triggered()), this, SLOT(onUpdate())); - connect(ui->actionUsers, SIGNAL(triggered()), this, SLOT(onUsers())); - connect(ui->actionConfig, SIGNAL(triggered()), this, SLOT(onConfig())); + connect(ui->actionAddPassword, &QAction::triggered, this, + &MainWindow::addPassword); + connect(ui->actionAddFolder, &QAction::triggered, this, + &MainWindow::addFolder); + connect(ui->actionEdit, &QAction::triggered, this, &MainWindow::onEdit); + connect(ui->actionDelete, &QAction::triggered, this, &MainWindow::onDelete); + connect(ui->actionPush, &QAction::triggered, this, &MainWindow::onPush); + connect(ui->actionUpdate, &QAction::triggered, this, &MainWindow::onUpdate); + connect(ui->actionUsers, &QAction::triggered, this, &MainWindow::onUsers); + connect(ui->actionConfig, &QAction::triggered, this, &MainWindow::onConfig); ui->actionAddPassword->setIcon( QIcon::fromTheme("document-new", QIcon(":/icons/document-new.svg"))); @@ -345,7 +346,12 @@ bool MainWindow::checkConfig() { model.setNameFilters(QStringList() << "*.gpg"); model.setNameFilterDisables(false); - model.setFilter(QDir::NoDotAndDotDot); + /* + * I added this to solve Windows bug but now on GNU/Linux the main folder, + * if hidden, disappear + * + * model.setFilter(QDir::NoDot); + */ proxyModel.setSourceModel(&model); proxyModel.setModelAndStore(&model, passStore); @@ -364,13 +370,14 @@ bool MainWindow::checkConfig() { ui->treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu); ui->treeView->header()->setSectionResizeMode(0, QHeaderView::Stretch); - connect(ui->treeView, SIGNAL(customContextMenuRequested(const QPoint &)), - this, SLOT(showContextMenu(const QPoint &))); - connect(ui->treeView, SIGNAL(emptyClicked()), this, SLOT(deselect())); + connect(ui->treeView, &QWidget::customContextMenuRequested, this, + &MainWindow::showContextMenu); + connect(ui->treeView, &DeselectableTreeView::emptyClicked, this, + &MainWindow::deselect); ui->textBrowser->setOpenExternalLinks(true); ui->textBrowser->setContextMenuPolicy(Qt::CustomContextMenu); - connect(ui->textBrowser, SIGNAL(customContextMenuRequested(const QPoint &)), - this, SLOT(showBrowserContextMenu(const QPoint &))); + connect(ui->textBrowser, &QWidget::customContextMenuRequested, this, + &MainWindow::showBrowserContextMenu); updateProfileBox(); QtPassSettings::getPass()->updateEnv(); @@ -1196,13 +1203,13 @@ void MainWindow::showContextMenu(const QPoint &pos) { QAction *addFolder = contextMenu.addAction(tr("Add folder")); QAction *addPassword = contextMenu.addAction(tr("Add password")); QAction *users = contextMenu.addAction(tr("Users")); - connect(openFolder, SIGNAL(triggered()), this, SLOT(openFolder())); - connect(addFolder, SIGNAL(triggered()), this, SLOT(addFolder())); - connect(addPassword, SIGNAL(triggered()), this, SLOT(addPassword())); - connect(users, SIGNAL(triggered()), this, SLOT(onUsers())); + connect(openFolder, &QAction::triggered, this, &MainWindow::openFolder); + connect(addFolder, &QAction::triggered, this, &MainWindow::addFolder); + connect(addPassword, &QAction::triggered, this, &MainWindow::addPassword); + connect(users, &QAction::triggered, this, &MainWindow::onUsers); } else if (fileOrFolder.isFile()) { QAction *edit = contextMenu.addAction(tr("Edit")); - connect(edit, SIGNAL(triggered()), this, SLOT(onEdit())); + connect(edit, &QAction::triggered, this, &MainWindow::onEdit); } if (selected) { // if (useClipboard != CLIPBOARD_NEVER) { @@ -1214,7 +1221,7 @@ void MainWindow::showContextMenu(const QPoint &pos) { // } contextMenu.addSeparator(); QAction *deleteItem = contextMenu.addAction(tr("Delete")); - connect(deleteItem, SIGNAL(triggered()), this, SLOT(onDelete())); + connect(deleteItem, &QAction::triggered, this, &MainWindow::onDelete); } contextMenu.exec(globalPos); } @@ -1342,8 +1349,8 @@ void MainWindow::addToGridLayout(int position, const QString &field, if (QtPassSettings::getClipBoardType() != Enums::CLIPBOARD_NEVER) { QPushButtonWithClipboard *fieldLabel = new QPushButtonWithClipboard(trimmedValue, this); - connect(fieldLabel, SIGNAL(clicked(QString)), this, - SLOT(copyTextToClipboard(QString))); + connect(fieldLabel, &QPushButtonWithClipboard::clicked, this, + &MainWindow::copyTextToClipboard); fieldLabel->setStyleSheet("border-style: none ; background: transparent;"); // fieldLabel->setContentsMargins(0,5,5,0); diff --git a/src/mainwindow.h b/src/mainwindow.h index d93e3b85..2072e524 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -57,6 +57,8 @@ protected: public slots: void deselect(); + void clearClipboard(); + void messageAvailable(QString message); private slots: void addPassword(); @@ -71,11 +73,9 @@ private slots: void on_treeView_doubleClicked(const QModelIndex &index); void processFinished(const QString &, const QString &); void processError(QProcess::ProcessError); - void clearClipboard(); void clearPanel(bool notify = true); void on_lineEdit_textChanged(const QString &arg1); void on_lineEdit_returnPressed(); - void messageAvailable(QString message); void on_profileBox_currentIndexChanged(QString); void showContextMenu(const QPoint &pos); void showBrowserContextMenu(const QPoint &pos); @@ -85,7 +85,6 @@ private slots: void copyTextToClipboard(const QString &text); void copyPasswordFromTreeview(); void passwordFromFileToClipboard(const QString &text); - void executeWrapperStarted(); void showStatusMessage(QString msg, int timeout); void startReencryptPath(); diff --git a/src/qpushbuttonwithclipboard.cpp b/src/qpushbuttonwithclipboard.cpp index 9ca1e7bd..e7118a62 100644 --- a/src/qpushbuttonwithclipboard.cpp +++ b/src/qpushbuttonwithclipboard.cpp @@ -16,7 +16,8 @@ QPushButtonWithClipboard::QPushButtonWithClipboard(const QString &textToCopy, iconEditPushed( QIcon::fromTheme("document-new", QIcon(":/icons/document-new.svg"))) { setIcon(iconEdit); - connect(this, SIGNAL(clicked(bool)), this, SLOT(buttonClicked(bool))); + connect(this, &QPushButtonWithClipboard::clicked, this, + &QPushButtonWithClipboard::buttonClicked); } /** @@ -39,7 +40,7 @@ void QPushButtonWithClipboard::setTextToCopy(const QString &value) { * @brief QPushButtonWithClipboard::buttonClicked handles clicked event by * emitting clicked(QString) with string provided to constructor */ -void QPushButtonWithClipboard::buttonClicked(bool) { +void QPushButtonWithClipboard::buttonClicked(QString) { setIcon(iconEditPushed); QTimer::singleShot(500, this, SLOT(changeIconDefault())); emit clicked(textToCopy); diff --git a/src/qpushbuttonwithclipboard.h b/src/qpushbuttonwithclipboard.h index fc6546c3..c763860f 100644 --- a/src/qpushbuttonwithclipboard.h +++ b/src/qpushbuttonwithclipboard.h @@ -23,7 +23,7 @@ signals: private slots: void changeIconDefault(); - void buttonClicked(bool); + void buttonClicked(QString); private: QString textToCopy; diff --git a/src/singleapplication.cpp b/src/singleapplication.cpp index a156ca50..a5c97a7f 100644 --- a/src/singleapplication.cpp +++ b/src/singleapplication.cpp @@ -25,8 +25,8 @@ SingleApplication::SingleApplication(int &argc, char *argv[], // create local server and listen to incomming messages from other // instances. localServer.reset(new QLocalServer(this)); - connect(localServer.data(), SIGNAL(newConnection()), this, - SLOT(receiveMessage())); + connect(localServer.data(), &QLocalServer::newConnection, this, + &SingleApplication::receiveMessage); localServer->listen(_uniqueKey); } } diff --git a/src/trayicon.cpp b/src/trayicon.cpp index 332d378a..12fe2894 100644 --- a/src/trayicon.cpp +++ b/src/trayicon.cpp @@ -22,9 +22,8 @@ TrayIcon::TrayIcon(QMainWindow *parent) { sysTrayIcon->show(); - QObject::connect(sysTrayIcon, - SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, - SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); + QObject::connect(sysTrayIcon, &QSystemTrayIcon::activated, this, + &TrayIcon::iconActivated); isAllocated = true; } else { @@ -64,21 +63,21 @@ bool TrayIcon::getIsAllocated() { return isAllocated; } */ void TrayIcon::createActions() { showAction = new QAction(tr("&Show"), this); - connect(showAction, SIGNAL(triggered()), parentwin, SLOT(show())); + connect(showAction, &QAction::triggered, parentwin, &QWidget::show); hideAction = new QAction(tr("&Hide"), this); - connect(hideAction, SIGNAL(triggered()), parentwin, SLOT(hide())); + connect(hideAction, &QAction::triggered, parentwin, &QWidget::hide); minimizeAction = new QAction(tr("Mi&nimize"), this); - connect(minimizeAction, SIGNAL(triggered()), parentwin, - SLOT(showMinimized())); + connect(minimizeAction, &QAction::triggered, parentwin, + &QWidget::showMinimized); maximizeAction = new QAction(tr("Ma&ximize"), this); - connect(maximizeAction, SIGNAL(triggered()), parentwin, - SLOT(showMaximized())); + connect(maximizeAction, &QAction::triggered, parentwin, + &QWidget::showMaximized); restoreAction = new QAction(tr("&Restore"), this); - connect(restoreAction, SIGNAL(triggered()), parentwin, SLOT(showNormal())); + connect(restoreAction, &QAction::triggered, parentwin, &QWidget::showNormal); quitAction = new QAction(tr("&Quit"), this); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + connect(quitAction, &QAction::triggered, qApp, &QApplication::quit); } /** diff --git a/src/usersdialog.cpp b/src/usersdialog.cpp index 23b99e03..25359010 100644 --- a/src/usersdialog.cpp +++ b/src/usersdialog.cpp @@ -10,10 +10,10 @@ UsersDialog::UsersDialog(QWidget *parent) : QDialog(parent), ui(new Ui::UsersDialog) { ui->setupUi(this); - connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - connect(ui->listWidget, SIGNAL(itemChanged(QListWidgetItem *)), this, - SLOT(itemChange(QListWidgetItem *))); + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + connect(ui->listWidget, &QListWidget::itemChanged, this, + &UsersDialog::itemChange); userList = NULL; #if QT_VERSION >= 0x050200 |