Skip to content

Commit 880c3ae

Browse files
committed
Add search help pop-up
* Support ! modifier (same as '-') * Create reusable PopupHelpWidget as self-contained popup that can be positioned around a parent widget and will follow the movement and sizing of the window * Eliminated KEEPASSXC_MAIN_WINDOW macro and replaced with getMainWindow() function * Add tests to cover search help show/hide
1 parent d6ffee5 commit 880c3ae

File tree

20 files changed

+671
-36
lines changed

20 files changed

+671
-36
lines changed
897 Bytes
Loading
1.19 KB
Loading
2.07 KB
Loading

src/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ set(keepassx_SOURCES
126126
gui/UnlockDatabaseWidget.cpp
127127
gui/UnlockDatabaseDialog.cpp
128128
gui/WelcomeWidget.cpp
129-
gui/widgets/ElidedLabel.cpp
130129
gui/csvImport/CsvImportWidget.cpp
131130
gui/csvImport/CsvImportWizard.cpp
132131
gui/csvImport/CsvParserModel.cpp
@@ -154,6 +153,8 @@ set(keepassx_SOURCES
154153
gui/dbsettings/DatabaseSettingsWidgetEncryption.cpp
155154
gui/dbsettings/DatabaseSettingsWidgetMasterKey.cpp
156155
gui/settings/SettingsWidget.cpp
156+
gui/widgets/ElidedLabel.cpp
157+
gui/widgets/PopupHelpWidget.cpp
157158
gui/wizard/NewDatabaseWizard.cpp
158159
gui/wizard/NewDatabaseWizardPage.cpp
159160
gui/wizard/NewDatabaseWizardPageMetaData.cpp

src/browser/BrowserService.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ bool BrowserService::openDatabase(bool triggerUnlock)
8888
}
8989

9090
if (triggerUnlock) {
91-
KEEPASSXC_MAIN_WINDOW->bringToFront();
91+
getMainWindow()->bringToFront();
9292
m_bringToFrontRequested = true;
9393
}
9494

@@ -901,7 +901,7 @@ void BrowserService::databaseUnlocked(DatabaseWidget* dbWidget)
901901
{
902902
if (dbWidget) {
903903
if (m_bringToFrontRequested) {
904-
KEEPASSXC_MAIN_WINDOW->lower();
904+
getMainWindow()->lower();
905905
m_bringToFrontRequested = false;
906906
}
907907
emit databaseUnlocked();

src/core/EntrySearcher.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ bool EntrySearcher::searchEntryImpl(const QString& searchString, Entry* entry)
9696
found = !attachments.filter(term->regex).empty();
9797
break;
9898
default:
99+
// Terms without a specific field try to match title, username, url, and notes
99100
found = term->regex.match(entry->resolvePlaceholder(entry->title())).hasMatch() ||
100101
term->regex.match(entry->resolvePlaceholder(entry->username())).hasMatch() ||
101102
term->regex.match(entry->resolvePlaceholder(entry->url())).hasMatch() ||
@@ -139,7 +140,7 @@ QList<QSharedPointer<EntrySearcher::SearchTerm> > EntrySearcher::parseSearchTerm
139140
term->regex = Tools::convertToRegex(term->word, !mods.contains("*"), mods.contains("+"), m_caseSensitive);
140141

141142
// Exclude modifier
142-
term->exclude = mods.contains("-");
143+
term->exclude = mods.contains("-") || mods.contains("!");
143144

144145
// Determine the field to search
145146
QString field = result.captured(2);

src/gui/Application.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ namespace
4949

5050
Application::Application(int& argc, char** argv)
5151
: QApplication(argc, argv)
52-
, m_mainWindow(nullptr)
5352
#ifdef Q_OS_UNIX
5453
, m_unixSignalNotifier(nullptr)
5554
#endif
@@ -143,16 +142,6 @@ Application::~Application()
143142
}
144143
}
145144

146-
QWidget* Application::mainWindow() const
147-
{
148-
return m_mainWindow;
149-
}
150-
151-
void Application::setMainWindow(QWidget* mainWindow)
152-
{
153-
m_mainWindow = mainWindow;
154-
}
155-
156145
bool Application::event(QEvent* event)
157146
{
158147
// Handle Apple QFileOpenEvent from finder (double click on .kdbx file)

src/gui/Application.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ class Application : public QApplication
3737

3838
public:
3939
Application(int& argc, char** argv);
40-
QWidget* mainWindow() const;
4140
~Application() override;
42-
void setMainWindow(QWidget* mainWindow);
4341

4442
bool event(QEvent* event) override;
4543
bool isAlreadyRunning() const;
@@ -60,8 +58,6 @@ private slots:
6058
void socketReadyRead();
6159

6260
private:
63-
QWidget* m_mainWindow;
64-
6561
#if defined(Q_OS_UNIX)
6662
/**
6763
* Register Unix signals such as SIGINT and SIGTERM for clean shutdown.

src/gui/MainWindow.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,17 @@ class BrowserPlugin : public ISettingsPage
109109

110110
const QString MainWindow::BaseWindowTitle = "KeePassXC";
111111

112+
MainWindow* g_MainWindow = nullptr;
113+
MainWindow* getMainWindow() { return g_MainWindow; }
114+
112115
MainWindow::MainWindow()
113116
: m_ui(new Ui::MainWindow())
114117
, m_trayIcon(nullptr)
115118
, m_appExitCalled(false)
116119
, m_appExiting(false)
117120
{
121+
g_MainWindow = this;
122+
118123
m_ui->setupUi(this);
119124

120125
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) && !defined(QT_NO_DBUS)

src/gui/MainWindow.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,12 @@ private slots:
148148
bool m_appExiting;
149149
};
150150

151-
#define KEEPASSXC_MAIN_WINDOW \
152-
(qobject_cast<Application*>(qApp) ? qobject_cast<MainWindow*>(qobject_cast<Application*>(qApp)->mainWindow()) \
153-
: nullptr)
151+
/**
152+
* Return instance of MainWindow created on app load
153+
* non-gui instances will return nullptr
154+
*
155+
* @return MainWindow instance or nullptr
156+
*/
157+
MainWindow* getMainWindow();
154158

155159
#endif // KEEPASSX_MAINWINDOW_H

0 commit comments

Comments
 (0)