Skip to content

Commit

Permalink
Remove some error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
probonopd committed Aug 29, 2023
1 parent 9b70533 commit dca15bf
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 47 deletions.
92 changes: 47 additions & 45 deletions src/appmenuwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,56 +153,58 @@ class MyLineEditEventFilter : public QObject
{
// qDebug() << "probono: e->type()" << e->type();
switch (e->type()) {
case QEvent::WindowActivate: {
// Whenever this window becomes active, then set the focus on the search box
if (reinterpret_cast<QLineEdit *>(parent())->hasFocus() == false) {
reinterpret_cast<QLineEdit *>(parent())->setFocus();
case QEvent::WindowActivate: {
// Whenever this window becomes active, then set the focus on the search box
if (reinterpret_cast<QLineEdit *>(parent())->hasFocus() == false) {
reinterpret_cast<QLineEdit *>(parent())->setFocus();
}
break;
}
break;
}
case QEvent::KeyPress: {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
// qDebug() << "probono: keyEvent->key()" << keyEvent->key();
if (keyEvent->key() == Qt::Key_Escape) {
// When esc key is pressed while cursor is in QLineEdit, empty the QLineEdit
// https://stackoverflow.com/a/38066410
reinterpret_cast<QLineEdit *>(parent())->clear();
reinterpret_cast<QLineEdit *>(parent())->setText("");
case QEvent::KeyPress: {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
// qDebug() << "probono: keyEvent->key()" << keyEvent->key();
if (keyEvent->key() == Qt::Key_Escape) {
// When esc key is pressed while cursor is in QLineEdit, empty the QLineEdit
// https://stackoverflow.com/a/38066410
reinterpret_cast<QLineEdit *>(parent())->clear();
reinterpret_cast<QLineEdit *>(parent())->setText("");
}
if (keyEvent->key() == (Qt::Key_Tab | Qt::Key_Alt)) {
// When esc Tab is pressed while cursor is in QLineEdit, also empty the QLineEdit
// and prevent the focus from going elsewhere in the menu. This effectively prevents
// the menu from being operated by cursor keys. If we want that functionality back,
// we might remove the handling of Qt::Key_Tab but instead we would have to ensure
// that we put the focus back on the search box whenever this application is
// launched (again) and re-invoked by QSingleApplication
reinterpret_cast<QLineEdit *>(parent())->clear();
reinterpret_cast<QLineEdit *>(parent())->setText("");
}
break;
}
if (keyEvent->key() == (Qt::Key_Tab | Qt::Key_Alt)) {
// When esc Tab is pressed while cursor is in QLineEdit, also empty the QLineEdit
// and prevent the focus from going elsewhere in the menu. This effectively prevents
// the menu from being operated by cursor keys. If we want that functionality back,
// we might remove the handling of Qt::Key_Tab but instead we would have to ensure
// that we put the focus back on the search box whenever this application is
// launched (again) and re-invoked by QSingleApplication
case QEvent::FocusOut: // QEvent::FocusOut:
{
// When the focus goes not of the QLineEdit, empty the QLineEdit and restore the
// placeholder text reinterpret_cast<QLineEdit
// *>(parent())->setPlaceholderText("Alt+Space"); reinterpret_cast<QLineEdit
// *>(parent())->setPlaceholderText(tr("Search")); Note that we write Alt-Space here but
// in fact this is not a feature of this application but is a feature of
// lxqt-config-globalkeyshortcuts in our case, where we set up a shortcut that simply
// launches this application (again). Since we are using
// searchLineEdit->setStyleSheet("background: white"); // Do this in stylesheet.qss
// instead reinterpret_cast<QLineEdit
// *>(parent())->setAlignment(Qt::AlignmentFlag::AlignRight);
reinterpret_cast<QLineEdit *>(parent())->clear();
reinterpret_cast<QLineEdit *>(parent())->setText("");
break;
}
break;
}
case QEvent::FocusOut: // QEvent::FocusOut:
{
// When the focus goes not of the QLineEdit, empty the QLineEdit and restore the
// placeholder text reinterpret_cast<QLineEdit
// *>(parent())->setPlaceholderText("Alt+Space"); reinterpret_cast<QLineEdit
// *>(parent())->setPlaceholderText(tr("Search")); Note that we write Alt-Space here but
// in fact this is not a feature of this application but is a feature of
// lxqt-config-globalkeyshortcuts in our case, where we set up a shortcut that simply
// launches this application (again). Since we are using
// searchLineEdit->setStyleSheet("background: white"); // Do this in stylesheet.qss
// instead reinterpret_cast<QLineEdit
// *>(parent())->setAlignment(Qt::AlignmentFlag::AlignRight);
reinterpret_cast<QLineEdit *>(parent())->clear();
reinterpret_cast<QLineEdit *>(parent())->setText("");
break;
}
case QEvent::FocusIn: {
// When the focus goes into the QLineEdit, empty the QLineEdit
// reinterpret_cast<QLineEdit *>(parent())->setPlaceholderText("");
// reinterpret_cast<QLineEdit *>(parent())->setAlignment(Qt::AlignmentFlag::AlignLeft);
break;
}
case QEvent::FocusIn: {
// When the focus goes into the QLineEdit, empty the QLineEdit
// reinterpret_cast<QLineEdit *>(parent())->setPlaceholderText("");
// reinterpret_cast<QLineEdit *>(parent())->setAlignment(Qt::AlignmentFlag::AlignLeft);
break;
}
default:
return QObject::eventFilter(obj, e);
}
return QObject::eventFilter(obj, e);
}
Expand Down
3 changes: 2 additions & 1 deletion src/appmenuwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class AppMenuWidget : public QWidget
void updateMenu();
void toggleMaximizeWindow();
QMenuBar *m_menuBar;
QFileSystemWatcher *watcher;

void focusMenu();
signals:
void menuAboutToBeImported();
Expand Down Expand Up @@ -150,6 +150,7 @@ private slots:
void addAppToMenu(QString candidate, QMenu *submenu);

private:
QFileSystemWatcher *watcher;
QWidget *searchLineWidget;
SearchLineEdit *searchLineEdit;
QCompleter *actionCompleter;
Expand Down
2 changes: 1 addition & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ MainWindow::MainWindow(QWidget *parent)
// TODO: Instead of having applicationStartingLabel here, we might want to make it a part of
// m_MainWidget to allow for it to be animated from the center to the side and morph into a menu
// with an animation...
applicationStartingLabel->setStyleSheet("align: center; font-weight: bold;");
applicationStartingLabel->setStyleSheet("font-weight: bold;");
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(applicationStartingLabel, 0, Qt::AlignCenter);

Expand Down

0 comments on commit dca15bf

Please sign in to comment.