Skip to content

Commit bfc61cd

Browse files
vkconfig: Add diagnostics search
1 parent 131c5ff commit bfc61cd

17 files changed

+232
-4
lines changed

vkconfig_core/configurator.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,14 @@ bool Configurator::Load() {
883883

884884
this->use_system_tray = json_object.value("use_system_tray").toBool();
885885

886+
if (json_object.value("show_diagnostic_search") != QJsonValue::Undefined) {
887+
this->show_diagnostic_search = json_object.value("show_diagnostic_search").toBool();
888+
}
889+
890+
if (json_object.value("diagnostic_search_text") != QJsonValue::Undefined) {
891+
this->diagnostic_search_text = json_object.value("diagnostic_search_text").toString().toStdString();
892+
}
893+
886894
if (json_object.value("VULKAN_HOME") != QJsonValue::Undefined) {
887895
::SetHomePath(json_object.value("VULKAN_HOME").toString().toStdString());
888896
}
@@ -939,6 +947,8 @@ bool Configurator::Save() const {
939947
json_object.insert("use_notify_releases", this->use_notify_releases);
940948
json_object.insert("latest_sdk_version", this->latest_sdk_version.str().c_str());
941949
json_object.insert("last_vkconfig_version", Version::VKCONFIG.str().c_str());
950+
json_object.insert("show_diagnostic_search", this->show_diagnostic_search);
951+
json_object.insert("diagnostic_search_text", this->diagnostic_search_text.c_str());
942952
json_object.insert("VULKAN_HOME", ::Path(Path::HOME).RelativePath().c_str());
943953
json_object.insert("VULKAN_DOWNLOAD", ::Path(Path::DOWNLOAD).RelativePath().c_str());
944954
json_interface_object.insert(GetToken(TAB_PREFERENCES), json_object);
@@ -1004,6 +1014,10 @@ bool Configurator::GetUseNotifyReleases() const { return this->use_notify_releas
10041014

10051015
void Configurator::SetUseNotifyReleases(bool enabled) { this->use_notify_releases = enabled; }
10061016

1017+
bool Configurator::GetShowDiagnosticSearch() const { return show_diagnostic_search; }
1018+
1019+
void Configurator::SetShowDiagnosticSearch(bool enabled) { this->show_diagnostic_search = enabled; }
1020+
10071021
bool Configurator::ShouldNotify() const {
10081022
return this->latest_sdk_version < this->online_sdk_version && this->online_sdk_version != Version::NONE &&
10091023
!(Version::VKCONFIG > this->last_vkconfig_version);

vkconfig_core/configurator.h

+5
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ class Configurator {
113113
bool GetUseNotifyReleases() const;
114114
void SetUseNotifyReleases(bool enabled);
115115

116+
bool GetShowDiagnosticSearch() const;
117+
void SetShowDiagnosticSearch(bool enabled);
118+
116119
bool ShouldNotify() const;
117120

118121
bool HasActiveSettings() const;
@@ -149,12 +152,14 @@ class Configurator {
149152
Version latest_sdk_version = Version::NONE;
150153
Version online_sdk_version = Version::NONE;
151154
Version last_vkconfig_version = Version::NONE;
155+
std::string diagnostic_search_text;
152156

153157
private:
154158
int hide_message_boxes_flags = 0;
155159
bool use_system_tray = false;
156160
bool use_layer_dev_mode = false;
157161
bool use_notify_releases = true;
162+
bool show_diagnostic_search = false;
158163
ExecutableScope executable_scope = EXECUTABLE_ANY;
159164
std::string selected_global_configuration = "Validation";
160165
};

vkconfig_gui/mainwindow.ui

+85-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>1200</width>
9+
<width>1024</width>
1010
<height>640</height>
1111
</rect>
1212
</property>
@@ -85,7 +85,7 @@
8585
<enum>QTabWidget::TabShape::Rounded</enum>
8686
</property>
8787
<property name="currentIndex">
88-
<number>5</number>
88+
<number>3</number>
8989
</property>
9090
<widget class="QWidget" name="tab_configurations">
9191
<attribute name="title">
@@ -1588,6 +1588,89 @@
15881588
<property name="bottomMargin">
15891589
<number>5</number>
15901590
</property>
1591+
<item>
1592+
<layout class="QHBoxLayout" name="diagnostic_search_layout">
1593+
<property name="spacing">
1594+
<number>0</number>
1595+
</property>
1596+
<property name="topMargin">
1597+
<number>0</number>
1598+
</property>
1599+
<property name="bottomMargin">
1600+
<number>0</number>
1601+
</property>
1602+
<item>
1603+
<widget class="QLineEdit" name="diagnostic_search_edit"/>
1604+
</item>
1605+
<item>
1606+
<widget class="QPushButton" name="diagnostic_search_next">
1607+
<property name="maximumSize">
1608+
<size>
1609+
<width>32</width>
1610+
<height>16777215</height>
1611+
</size>
1612+
</property>
1613+
<property name="toolTip">
1614+
<string>Find Next (F3)</string>
1615+
</property>
1616+
<property name="text">
1617+
<string/>
1618+
</property>
1619+
<property name="shortcut">
1620+
<string>F3</string>
1621+
</property>
1622+
</widget>
1623+
</item>
1624+
<item>
1625+
<widget class="QPushButton" name="diagnostic_search_prev">
1626+
<property name="maximumSize">
1627+
<size>
1628+
<width>32</width>
1629+
<height>16777215</height>
1630+
</size>
1631+
</property>
1632+
<property name="toolTip">
1633+
<string>Find Previous (Shift+F3)</string>
1634+
</property>
1635+
<property name="text">
1636+
<string/>
1637+
</property>
1638+
<property name="shortcut">
1639+
<string>Shift+F3</string>
1640+
</property>
1641+
</widget>
1642+
</item>
1643+
<item>
1644+
<widget class="QPushButton" name="diagnostic_search_mode">
1645+
<property name="maximumSize">
1646+
<size>
1647+
<width>16</width>
1648+
<height>32</height>
1649+
</size>
1650+
</property>
1651+
<property name="text">
1652+
<string/>
1653+
</property>
1654+
</widget>
1655+
</item>
1656+
<item>
1657+
<widget class="QPushButton" name="diagnostic_search_hide">
1658+
<property name="maximumSize">
1659+
<size>
1660+
<width>32</width>
1661+
<height>16777215</height>
1662+
</size>
1663+
</property>
1664+
<property name="toolTip">
1665+
<string>Hide search field</string>
1666+
</property>
1667+
<property name="text">
1668+
<string/>
1669+
</property>
1670+
</widget>
1671+
</item>
1672+
</layout>
1673+
</item>
15911674
<item>
15921675
<widget class="QTextEdit" name="diagnostic_status_text">
15931676
<property name="font">
657 Bytes
Loading
947 Bytes
Loading
800 Bytes
Loading
824 Bytes
Loading
588 Bytes
Loading
756 Bytes
Loading
608 Bytes
Loading
621 Bytes
Loading

vkconfig_gui/resources.qrc

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
<file>resourcefiles/dark/clear.png</file>
1212
<file>resourcefiles/dark/drag.png</file>
13+
<file>resourcefiles/dark/next.png</file>
14+
<file>resourcefiles/dark/prev.png</file>
15+
<file>resourcefiles/dark/down.png</file>
16+
<file>resourcefiles/dark/exit.png</file>
1317

1418
<file>resourcefiles/dark/file_export.png</file>
1519
<file>resourcefiles/dark/file_search.png</file>
@@ -38,6 +42,10 @@
3842

3943
<file>resourcefiles/light/clear.png</file>
4044
<file>resourcefiles/light/drag.png</file>
45+
<file>resourcefiles/light/next.png</file>
46+
<file>resourcefiles/light/prev.png</file>
47+
<file>resourcefiles/light/down.png</file>
48+
<file>resourcefiles/light/exit.png</file>
4149

4250
<file>resourcefiles/light/file_export.png</file>
4351
<file>resourcefiles/light/file_search.png</file>

vkconfig_gui/source/arrow.pdn

20.7 KB
Binary file not shown.

vkconfig_gui/style.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ QIcon Get(Icon icon) {
3838
static const char* ICONS[] = {
3939
"clear.png", // ICON_CLEAR
4040
"drag.png", // ICON_DRAG
41+
"next.png", // ICON_NEXT
42+
"prev.png", // ICON_PREV
43+
"down.png", // ICON_MODE
44+
"exit.png", // ICON_EXIT
4145
"file_append.png", // ICON_FILE_APPEND,
4246
"file_export.png", // ICON_FILE_EXPORT,
4347
"file_remove.png", // ICON_FILE_REMOVE,

vkconfig_gui/style.h

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ bool isDarkMode();
2727
enum Icon {
2828
ICON_CLEAR = 0,
2929
ICON_DRAG,
30+
ICON_NEXT,
31+
ICON_PREV,
32+
ICON_MODE,
33+
ICON_EXIT,
3034
ICON_FILE_APPEND,
3135
ICON_FILE_EXPORT,
3236
ICON_FILE_REMOVE,

vkconfig_gui/tab_diagnostics.cpp

+103-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,35 @@
2929
#include <QMessageBox>
3030
#include <QMenu>
3131
#include <QDesktopServices>
32+
#include <QShortcut>
3233

3334
TabDiagnostics::TabDiagnostics(MainWindow &window, std::shared_ptr<Ui::MainWindow> ui) : Tab(TAB_DIAGNOSTIC, window, ui) {
35+
this->connect(this->ui->diagnostic_search_edit, SIGNAL(textEdited(QString)), this, SLOT(on_search_textEdited(QString)));
36+
this->connect(this->ui->diagnostic_search_edit, SIGNAL(returnPressed()), this, SLOT(on_search_find_pressed()));
37+
this->connect(this->ui->diagnostic_search_next, SIGNAL(clicked()), this, SLOT(on_search_next_pressed()));
38+
this->connect(this->ui->diagnostic_search_prev, SIGNAL(clicked()), this, SLOT(on_search_prev_pressed()));
39+
this->connect(this->ui->diagnostic_search_mode, SIGNAL(clicked()), this, SLOT(on_search_mode_pressed()));
40+
this->connect(this->ui->diagnostic_status_text, SIGNAL(customContextMenuRequested(QPoint)), this,
41+
SLOT(on_customContextMenuRequested(const QPoint &)));
42+
this->connect(this->ui->diagnostic_status_text, SIGNAL(returnPressed()), this, SLOT(on_search_find_pressed()));
43+
this->connect(this->ui->diagnostic_search_hide, SIGNAL(clicked()), this, SLOT(on_hide_search()));
44+
45+
QShortcut *shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F), this->ui->diagnostic_status_text);
46+
this->connect(shortcut, SIGNAL(activated()), this, SLOT(on_show_search()));
47+
48+
Configurator &configurator = Configurator::Get();
49+
50+
this->ui->diagnostic_search_edit->setText(configurator.diagnostic_search_text.c_str());
51+
this->ui->diagnostic_search_next->setIcon(::Get(::ICON_NEXT));
52+
this->ui->diagnostic_search_prev->setIcon(::Get(::ICON_PREV));
53+
this->ui->diagnostic_search_mode->setIcon(::Get(::ICON_MODE));
54+
this->ui->diagnostic_search_hide->setIcon(::Get(::ICON_EXIT));
55+
3456
this->ui->diagnostic_status_text->installEventFilter(&window);
3557
this->ui->diagnostic_status_text->document()->setMaximumBlockCount(65536);
3658
this->ui->diagnostic_status_text->setContextMenuPolicy(Qt::CustomContextMenu);
37-
this->connect(this->ui->diagnostic_status_text, SIGNAL(customContextMenuRequested(QPoint)), this,
38-
SLOT(on_customContextMenuRequested(const QPoint &)));
3959

60+
this->ShowSearch(false);
4061
this->UpdateStatus();
4162
}
4263

@@ -53,6 +74,20 @@ void TabDiagnostics::UpdateStatus() {
5374
configurator.Override(OVERRIDE_AREA_LOADER_SETTINGS_BIT);
5475
}
5576

77+
void TabDiagnostics::ShowSearch(bool visible) {
78+
this->ui->diagnostic_search_edit->setVisible(visible);
79+
this->ui->diagnostic_search_next->setVisible(visible && mode_next);
80+
this->ui->diagnostic_search_next->setEnabled(!this->ui->diagnostic_search_edit->text().isEmpty());
81+
this->ui->diagnostic_search_prev->setVisible(visible && !mode_next);
82+
this->ui->diagnostic_search_prev->setEnabled(!this->ui->diagnostic_search_edit->text().isEmpty());
83+
this->ui->diagnostic_search_mode->setVisible(visible);
84+
this->ui->diagnostic_search_hide->setVisible(visible);
85+
86+
if (visible) {
87+
this->ui->diagnostic_search_edit->setFocus();
88+
}
89+
}
90+
5691
void TabDiagnostics::UpdateUI(UpdateUIMode mode) {
5792
(void)mode;
5893

@@ -68,6 +103,64 @@ bool TabDiagnostics::EventFilter(QObject *target, QEvent *event) {
68103
return false;
69104
}
70105

106+
void TabDiagnostics::on_show_search() { this->ShowSearch(true); }
107+
108+
void TabDiagnostics::on_hide_search() { this->ShowSearch(false); }
109+
110+
void TabDiagnostics::on_search_textEdited(const QString &text) {
111+
this->ui->diagnostic_search_next->setEnabled(!this->ui->diagnostic_search_edit->text().isEmpty() && mode_next);
112+
this->ui->diagnostic_search_prev->setEnabled(!this->ui->diagnostic_search_edit->text().isEmpty() && !mode_next);
113+
114+
Configurator &configurator = Configurator::Get();
115+
configurator.diagnostic_search_text = text.toStdString();
116+
}
117+
118+
void TabDiagnostics::on_search_next_pressed() {
119+
this->mode_next = true;
120+
this->ShowSearch(true);
121+
this->on_search_find_pressed();
122+
}
123+
124+
void TabDiagnostics::on_search_prev_pressed() {
125+
this->mode_next = false;
126+
this->ShowSearch(true);
127+
this->on_search_find_pressed();
128+
}
129+
130+
void TabDiagnostics::on_search_find_pressed() {
131+
QTextDocument::FindFlags flags =
132+
QTextDocument::FindFlags(0); //= QTextDocument::FindBackward | QTextDocument::FindCaseSensitively |
133+
// QTextDocument::FindWholeWords;
134+
if (!mode_next) {
135+
flags |= QTextDocument::FindBackward;
136+
}
137+
138+
this->ui->diagnostic_status_text->setFocus();
139+
this->ui->diagnostic_status_text->find(this->ui->diagnostic_search_edit->text(), flags);
140+
}
141+
142+
void TabDiagnostics::on_search_mode_pressed() {
143+
QMenu menu(this->ui->diagnostic_search_mode);
144+
QAction *action_next = new QAction("Find Next", nullptr);
145+
action_next->setShortcut(QKeySequence(Qt::Key_F3));
146+
menu.addAction(action_next);
147+
QAction *action_prev = new QAction("Find Previous", nullptr);
148+
action_prev->setShortcut(QKeySequence(Qt::Key_Shift + Qt::Key_F3));
149+
menu.addAction(action_prev);
150+
151+
QPoint point(this->window.mapToGlobal(this->ui->diagnostic_search_mode->pos()));
152+
QAction *action = menu.exec(point);
153+
if (action == action_next) {
154+
this->mode_next = true;
155+
this->ui->diagnostic_search_next->setVisible(true);
156+
this->ui->diagnostic_search_prev->setVisible(false);
157+
} else if (action == action_prev) {
158+
this->mode_next = false;
159+
this->ui->diagnostic_search_next->setVisible(false);
160+
this->ui->diagnostic_search_prev->setVisible(true);
161+
}
162+
}
163+
71164
void TabDiagnostics::on_customContextMenuRequested(const QPoint &pos) {
72165
Configurator &configurator = Configurator::Get();
73166

@@ -82,6 +175,12 @@ void TabDiagnostics::on_customContextMenuRequested(const QPoint &pos) {
82175
action_save->setEnabled(!this->status.empty());
83176
menu->addAction(action_save);
84177

178+
menu->addSeparator();
179+
180+
QAction *action_search = new QAction("Search...", nullptr);
181+
action_search->setEnabled(!configurator.GetShowDiagnosticSearch());
182+
menu->addAction(action_search);
183+
85184
QAction *action = menu->exec(this->ui->diagnostic_status_text->mapToGlobal(pos));
86185

87186
if (action == action_refresh) {
@@ -96,6 +195,8 @@ void TabDiagnostics::on_customContextMenuRequested(const QPoint &pos) {
96195
this->status.clear();
97196
this->ui->diagnostic_status_text->clear();
98197
}
198+
} else if (action == action_search) {
199+
this->ShowSearch(true);
99200
} else if (action == action_save) {
100201
const QString selected_path =
101202
QFileDialog::getSaveFileName(this->ui->diagnostic_group_box_refresh, "Select Log file...",

vkconfig_gui/tab_diagnostics.h

+9
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,20 @@ class TabDiagnostics : public Tab {
3737

3838
public Q_SLOTS:
3939
void on_customContextMenuRequested(const QPoint& pos);
40+
void on_show_search();
41+
void on_hide_search();
42+
void on_search_textEdited(const QString& text);
43+
void on_search_find_pressed();
44+
void on_search_mode_pressed();
45+
void on_search_next_pressed();
46+
void on_search_prev_pressed();
4047

4148
private:
4249
QPushButton* widget_refresh = nullptr;
4350
QPushButton* widget_export = nullptr;
4451
std::string status;
52+
bool mode_next = true;
4553

4654
void UpdateStatus();
55+
void ShowSearch(bool visible);
4756
};

0 commit comments

Comments
 (0)