diff options
author | Maciej S. Szmigiero <mail@maciej.szmigiero.name> | 2019-10-02 22:33:02 +0200 |
---|---|---|
committer | Maciej S. Szmigiero <mail@maciej.szmigiero.name> | 2019-10-02 22:51:58 +0200 |
commit | fc2aed35a9eae1ecede54321fd0644f89f9bd3c3 (patch) | |
tree | c58e408f2aaa70244d6e7de29e384ec189b486b2 | |
parent | 397ca5b3de3b332885602054800ea6dd3b45e1e8 (diff) |
Make QtPass class constructor take a MainWindow object directly
The QtPass class is not usable without a MainWindow object so it can as
well take it directly as its constructor parameter.
-rw-r--r-- | src/mainwindow.cpp | 3 | ||||
-rw-r--r-- | src/qtpass.cpp | 9 | ||||
-rw-r--r-- | src/qtpass.h | 4 |
3 files changed, 9 insertions, 7 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5a0afb0c..db241c2b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -44,8 +44,7 @@ MainWindow::MainWindow(const QString &searchText, QWidget *parent) #endif ui->setupUi(this); - m_qtPass = new QtPass(); - m_qtPass->setMainWindow(this); + m_qtPass = new QtPass(this); // register shortcut ctrl/cmd + Q to close the main window new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close())); diff --git a/src/qtpass.cpp b/src/qtpass.cpp index 1c207052..8d90d370 100644 --- a/src/qtpass.cpp +++ b/src/qtpass.cpp @@ -22,7 +22,9 @@ #include "debughelper.h" #endif -QtPass::QtPass() : clippedText(QString()), freshStart(true) { +QtPass::QtPass(MainWindow *mainWindow) : m_mainWindow(mainWindow), + clippedText(QString()), + freshStart(true) { if (!setup()) { // no working config so this should quit without config anything QApplication::quit(); @@ -36,6 +38,8 @@ QtPass::QtPass() : clippedText(QString()), freshStart(true) { QObject::connect(qApp, &QApplication::aboutToQuit, this, &QtPass::clearClipboard); + + setMainWindow(); } /** @@ -111,8 +115,7 @@ bool QtPass::setup() { return true; } -void QtPass::setMainWindow(MainWindow *mW) { - m_mainWindow = mW; +void QtPass::setMainWindow(void) { m_mainWindow->restoreWindow(); fusedav.setParent(m_mainWindow); diff --git a/src/qtpass.h b/src/qtpass.h index 05470d83..707ad5d2 100644 --- a/src/qtpass.h +++ b/src/qtpass.h @@ -11,10 +11,9 @@ class QtPass : public QObject { Q_OBJECT public: - QtPass(); + QtPass(MainWindow *mainWindow); ~QtPass(); - void setMainWindow(MainWindow *mW); void setClippedText(const QString &, const QString &p_output = QString()); void clearClippedText(); void setClipboardTimer(); @@ -30,6 +29,7 @@ private: QString clippedText; bool freshStart; + void setMainWindow(); bool setup(); void connectPassSignalHandlers(Pass *pass); void mountWebDav(); |