summaryrefslogtreecommitdiffhomepage
path: root/gui
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-06-26 22:25:22 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-06-26 23:05:21 +0200
commitd65936200a2756e6619a109fa6fa673b91df802e (patch)
tree80b6b6fc7ba9023cbe47290b8ae1bc5468a19bb1 /gui
parent4046773c41ee3c0f65840828ab983cfd13451c85 (diff)
modernize C++ syntax
No visible changes (hopefully).
Diffstat (limited to 'gui')
-rw-r--r--gui/init.cpp8
-rw-r--r--gui/keyboard.cpp4
-rw-r--r--gui/mapping-dialog.cpp2
-rw-r--r--gui/process_detector.cpp20
-rw-r--r--gui/process_detector.h2
-rw-r--r--gui/settings.cpp7
-rw-r--r--gui/settings.hpp8
7 files changed, 28 insertions, 23 deletions
diff --git a/gui/init.cpp b/gui/init.cpp
index cddea9ae..75f6b1eb 100644
--- a/gui/init.cpp
+++ b/gui/init.cpp
@@ -169,7 +169,7 @@ void attach_parent_console()
#endif
-int run_window(QApplication& app, std::unique_ptr<QWidget> main_window)
+static int run_window(std::unique_ptr<QWidget> main_window)
{
if (!main_window->isEnabled())
{
@@ -177,8 +177,8 @@ int run_window(QApplication& app, std::unique_ptr<QWidget> main_window)
return 2;
}
- app.setQuitOnLastWindowClosed(true);
- int status = app.exec();
+ QApplication::setQuitOnLastWindowClosed(true);
+ int status = QApplication::exec();
return status;
}
@@ -224,7 +224,7 @@ OTR_GUI_EXPORT int otr_main(int argc, char** argv, std::function<QWidget*()> con
}
}
- int ret = run_window(app, std::unique_ptr<QWidget>(make_main_window()));
+ int ret = run_window(std::unique_ptr<QWidget>(make_main_window()));
#if 0
// msvc crashes in Qt plugin system's dtor
diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp
index 4987d9c0..b9964ecb 100644
--- a/gui/keyboard.cpp
+++ b/gui/keyboard.cpp
@@ -12,14 +12,14 @@ keyboard_listener::keyboard_listener(QWidget* parent) :
if (k.alt) mods |= Qt::AltModifier;
if (k.shift) mods |= Qt::ShiftModifier;
if (k.ctrl) mods |= Qt::ControlModifier;
- joystick_button_pressed(k.guid, k.keycode | mods, k.held);
+ emit joystick_button_pressed(k.guid, k.keycode | mods, k.held);
}
else
{
Qt::KeyboardModifiers m;
QKeySequence k_;
if (win_key::to_qt(k, k_, m))
- key_pressed(static_cast<QVariant>(k_).toInt() | m);
+ emit key_pressed(static_cast<QVariant>(k_).toInt() | m);
}
})
// token initializer ends, real ctor body begins
diff --git a/gui/mapping-dialog.cpp b/gui/mapping-dialog.cpp
index 43130a92..c6e49cee 100644
--- a/gui/mapping-dialog.cpp
+++ b/gui/mapping-dialog.cpp
@@ -12,6 +12,8 @@
#include <QtEvents>
+using namespace options;
+
mapping_dialog::mapping_dialog(Mappings& m) : m(m), widgets{}
{
ui.setupUi(this);
diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp
index 7563d521..969b1856 100644
--- a/gui/process_detector.cpp
+++ b/gui/process_detector.cpp
@@ -58,7 +58,7 @@ 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);
- for (auto pair : pairs)
+ for (auto const& pair : pairs)
{
QList<QString> tmp = pair.split(UNIT_SEPARATOR);
if (tmp.count() != 2)
@@ -67,7 +67,7 @@ QHash<QString, QString> proc_detector_settings::split_process_names()
continue;
if (tmp[1].contains(UNIT_SEPARATOR) || tmp[1].contains(RECORD_SEPARATOR))
continue;
- if (tmp[0] == QLatin1String("") || tmp[1] == QLatin1String(""))
+ if (tmp[0].isEmpty() || tmp[1].isEmpty())
continue;
ret[tmp[0]] = tmp[1];
}
@@ -76,21 +76,19 @@ QHash<QString, QString> proc_detector_settings::split_process_names()
void BrowseButton::browse()
{
- QFileDialog dialog(this);
- dialog.setFileMode(QFileDialog::ExistingFile);
QString dir_path = QFileInfo(group::ini_pathname()).absolutePath();
- QString filename = dialog.getOpenFileName(
- this,
- tr("Set executable name"),
- dir_path,
- tr("Executable (*.exe);;All Files (*)"));
+ QString filename = QFileDialog::getOpenFileName(
+ this,
+ tr("Set executable name"),
+ dir_path,
+ tr("Executable (*.exe);;All Files (*)"));
QDir::setCurrent(OPENTRACK_BASE_PATH);
filename = QFileInfo(filename).fileName();
if (!filename.isNull())
twi->setText(filename);
}
-int process_detector::add_row(QString exe_name, QString profile)
+int process_detector::add_row(QString const& exe_name, QString const& profile)
{
int i = ui.tableWidget->rowCount();
ui.tableWidget->insertRow(i);
@@ -122,7 +120,7 @@ void process_detector::add_items()
ui.tableWidget->clearContents();
auto keys = names.keys();
std::sort(keys.begin(), keys.end());
- for (auto n : keys)
+ for (auto const& n : keys)
add_row(n, names[n]);
}
diff --git a/gui/process_detector.h b/gui/process_detector.h
index c3ff078a..7439b19b 100644
--- a/gui/process_detector.h
+++ b/gui/process_detector.h
@@ -34,7 +34,7 @@ class OTR_GUI_EXPORT process_detector final : public QWidget
Ui_process_detector ui;
proc_detector_settings s;
- int add_row(QString exe_name = "...", QString profile = "");
+ int add_row(const QString& exe_name = "...", const QString& profile = "");
void add_items();
public:
process_detector(QWidget* parent = nullptr);
diff --git a/gui/settings.cpp b/gui/settings.cpp
index ee0e9959..d280a9b7 100644
--- a/gui/settings.cpp
+++ b/gui/settings.cpp
@@ -9,6 +9,9 @@
#include "settings.hpp"
#include "keyboard.h"
#include "compat/library-path.hpp"
+
+#include <utility>
+
#include <QPushButton>
#include <QLayout>
#include <QDialog>
@@ -41,8 +44,8 @@ void options_dialog::set_disable_translation_state(bool value)
});
}
-options_dialog::options_dialog(std::function<void(bool)> pause_keybindings) :
- pause_keybindings(pause_keybindings)
+options_dialog::options_dialog(std::function<void(bool)>&& pause_keybindings) :
+ pause_keybindings(std::move(pause_keybindings))
{
ui.setupUi(this);
diff --git a/gui/settings.hpp b/gui/settings.hpp
index 63e109a4..ebcaa66c 100644
--- a/gui/settings.hpp
+++ b/gui/settings.hpp
@@ -4,10 +4,12 @@
#include "gui/ui_settings-dialog.h"
#include "logic/shortcuts.h"
+
+#include <functional>
+
#include <QObject>
#include <QDialog>
#include <QWidget>
-#include <functional>
class OTR_GUI_EXPORT options_dialog : public QDialog
{
@@ -15,12 +17,12 @@ class OTR_GUI_EXPORT options_dialog : public QDialog
signals:
void closing();
public:
- options_dialog(std::function<void(bool)> pause_keybindings);
+ options_dialog(std::function<void(bool)>&& pause_keybindings);
private:
main_settings main;
std::function<void(bool)> pause_keybindings;
Ui::options_dialog ui;
- void closeEvent(QCloseEvent *) override;
+ void closeEvent(QCloseEvent*) override;
static QString kopts_to_string(const key_opts& opts);
private slots:
void doOK();