Skip to content

Commit

Permalink
Change search line edit visibile with action
Browse files Browse the repository at this point in the history
We can't directly show or hide the line edit, we need to do it with the
action.
  • Loading branch information
plfiorini committed Feb 3, 2013
1 parent 6f67d4c commit 6c539c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ void MainWindow::createToolBar()
spacerWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
m_toolBar->addWidget(spacerWidget);

QAction *searchAction = m_toolBar->addWidget(m_search);
searchAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F));
connect(searchAction, SIGNAL(triggered()),
m_searchAction = m_toolBar->addWidget(m_search);
m_searchAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F));
connect(m_searchAction, SIGNAL(triggered()),
m_search, SLOT(setFocus()));

addToolBar(m_toolBar);
Expand Down Expand Up @@ -250,7 +250,7 @@ void MainWindow::slotOverviewTriggered()
}

// Show the search field because now we need it
m_search->show();
m_searchAction->setVisible(true);
}

void MainWindow::slotSearchChanged(const QString &search)
Expand All @@ -270,7 +270,7 @@ void MainWindow::slotListViewClicked(const QModelIndex &index)
createUnlockAction(const_cast<PreferencesModule *>(item->module()));

// Hide the search field because it cannot be used now
m_search->hide();
m_searchAction->setVisible(false);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/app/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private slots:
private:
QTranslator *m_translator;
QAction *m_overviewAction;
QAction *m_searchAction;
PolkitQt1::Gui::Action *m_unlockAction;
QToolBar *m_toolBar;
QLineEdit *m_search;
Expand Down

0 comments on commit 6c539c6

Please sign in to comment.