summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-07-05 10:23:44 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-07-05 10:24:19 +0200
commit38d466a972d4455b02aee2b55674f3b29ece24d7 (patch)
tree2901ed2ce0b78dd47a7be784296d3f66990df094
parentbc179804008c05821bccf52482eeee11ddb7f465 (diff)
gui: minor process detector fixes
-rw-r--r--gui/process_detector.cpp18
-rw-r--r--gui/process_detector.h23
2 files changed, 19 insertions, 22 deletions
diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp
index 332801cc..b8de227d 100644
--- a/gui/process_detector.cpp
+++ b/gui/process_detector.cpp
@@ -58,12 +58,13 @@ void proc_detector_settings::set_is_enabled(bool enabled)
QHash<QString, QString> proc_detector_settings::split_process_names()
{
- QHash<QString, QString> ret;
QString str = get_game_list();
QStringList pairs = str.split(RECORD_SEPARATOR, QString::SkipEmptyParts);
+ QHash<QString, QString> ret;
+ ret.reserve(pairs.size() * 2);
for (auto const& pair : pairs)
{
- QList<QString> tmp = pair.split(UNIT_SEPARATOR);
+ QStringList tmp = pair.split(UNIT_SEPARATOR);
if (tmp.count() != 2)
continue;
if (tmp[0].contains(UNIT_SEPARATOR) || tmp[0].contains(RECORD_SEPARATOR))
@@ -138,9 +139,6 @@ process_detector::process_detector(QWidget* parent) : QWidget(parent)
QResizeEvent e(ui.tableWidget->size(), ui.tableWidget->size());
ui.tableWidget->resizeEvent(&e);
-
- proc_detector_settings s;
-
ui.enabled->setChecked(s.is_enabled());
}
@@ -216,20 +214,18 @@ bool process_detector_worker::profile_to_start(QString& str)
// assuming manual stop by user button click.
// don't automatically start again while the same process is running.
- if (last_exe_name != "" && exe_list.contains(last_exe_name))
+ if (!last_exe_name.isEmpty() && exe_list.contains(last_exe_name))
return false;
// it's gone, we can start automatically again
- last_exe_name = "";
+ last_exe_name = QString();
- for (auto& name : exe_list)
- {
+ for (auto&& name : exe_list)
if (filenames.contains(name))
{
str = filenames[name];
- last_exe_name = std::move(name);
+ last_exe_name = name;
return str != QString{};
}
- }
return false;
}
diff --git a/gui/process_detector.h b/gui/process_detector.h
index 01bda14b..b57d859a 100644
--- a/gui/process_detector.h
+++ b/gui/process_detector.h
@@ -10,21 +10,22 @@
#include "export.hpp"
-#include <QObject>
-#include <QWidget>
-#include <QTableWidget>
-
#include "gui/ui_process_widget.h"
#include "process-detector-fancy-table.hpp"
#include "options/options.hpp"
+#include <QObject>
+#include <QString>
+#include <QWidget>
+#include <QTableWidget>
+
struct OTR_GUI_EXPORT proc_detector_settings
{
- QHash<QString, QString> split_process_names();
- QString get_game_list();
- void set_game_list(const QString& game_list);
- bool is_enabled();
- void set_is_enabled(bool enabled);
+ static QHash<QString, QString> split_process_names();
+ static QString get_game_list();
+ static void set_game_list(const QString& game_list);
+ static bool is_enabled();
+ static void set_is_enabled(bool enabled);
};
class OTR_GUI_EXPORT process_detector final : public QWidget
@@ -60,10 +61,10 @@ public slots:
class OTR_GUI_EXPORT process_detector_worker : QObject
{
Q_OBJECT
- proc_detector_settings s;
QString last_exe_name;
+ proc_detector_settings s;
public:
- bool profile_to_start(QString& str);
+ [[nodiscard]] bool profile_to_start(QString& str);
bool should_stop();
};