Fix crashes on language settings changes
This commit is contained in:
@@ -104,10 +104,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
/* get the percentage and mouse message, TODO: refactor ui_window_title() */
|
/* get the percentage and mouse message, TODO: refactor ui_window_title() */
|
||||||
auto parts = title.split(" - ");
|
auto parts = title.split(" - ");
|
||||||
if (parts.size() < 5)
|
if (parts.size() >= 2) {
|
||||||
toolbar_label->setText(parts[1]);
|
if (parts.size() < 5)
|
||||||
else
|
toolbar_label->setText(parts[1]);
|
||||||
toolbar_label->setText(QString("%1 - %2").arg(parts[1], parts.last()));
|
else
|
||||||
|
toolbar_label->setText(QString("%1 - %2").arg(parts[1], parts.last()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ui->actionPause->setChecked(dopause);
|
ui->actionPause->setChecked(dopause);
|
||||||
@@ -346,11 +348,11 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
#ifdef MTR_ENABLED
|
#ifdef MTR_ENABLED
|
||||||
{
|
{
|
||||||
ui->menuTools->addSeparator();
|
ui->menuTools->addSeparator();
|
||||||
static auto actionBegin_trace = ui->menuTools->addAction(tr("Begin trace"));
|
ui->actionBegin_trace->setVisible(true);
|
||||||
static auto actionEnd_trace = ui->menuTools->addAction(tr("End trace"));
|
ui->actionEnd_trace->setVisible(true);
|
||||||
actionBegin_trace->setShortcut(QKeySequence(Qt::Key_Control + Qt::Key_T));
|
ui->actionBegin_trace->setShortcut(QKeySequence(Qt::Key_Control + Qt::Key_T));
|
||||||
actionEnd_trace->setShortcut(QKeySequence(Qt::Key_Control + Qt::Key_T));
|
ui->actionEnd_trace->setShortcut(QKeySequence(Qt::Key_Control + Qt::Key_T));
|
||||||
actionEnd_trace->setDisabled(true);
|
ui->actionEnd_trace->setDisabled(true);
|
||||||
static auto init_trace = [&]
|
static auto init_trace = [&]
|
||||||
{
|
{
|
||||||
mtr_init("trace.json");
|
mtr_init("trace.json");
|
||||||
@@ -362,23 +364,23 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
mtr_shutdown();
|
mtr_shutdown();
|
||||||
};
|
};
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
actionBegin_trace->setShortcutVisibleInContextMenu(true);
|
ui->actionBegin_trace->setShortcutVisibleInContextMenu(true);
|
||||||
actionEnd_trace->setShortcutVisibleInContextMenu(true);
|
ui->actionEnd_trace->setShortcutVisibleInContextMenu(true);
|
||||||
#endif
|
#endif
|
||||||
static bool trace = false;
|
static bool trace = false;
|
||||||
connect(actionBegin_trace, &QAction::triggered, this, [this]
|
connect(ui->actionBegin_trace, &QAction::triggered, this, [this]
|
||||||
{
|
{
|
||||||
if (trace) return;
|
if (trace) return;
|
||||||
actionBegin_trace->setDisabled(true);
|
ui->actionBegin_trace->setDisabled(true);
|
||||||
actionEnd_trace->setDisabled(false);
|
ui->actionEnd_trace->setDisabled(false);
|
||||||
init_trace();
|
init_trace();
|
||||||
trace = true;
|
trace = true;
|
||||||
});
|
});
|
||||||
connect(actionEnd_trace, &QAction::triggered, this, [this]
|
connect(ui->actionEnd_trace, &QAction::triggered, this, [this]
|
||||||
{
|
{
|
||||||
if (!trace) return;
|
if (!trace) return;
|
||||||
actionBegin_trace->setDisabled(false);
|
ui->actionBegin_trace->setDisabled(false);
|
||||||
actionEnd_trace->setDisabled(true);
|
ui->actionEnd_trace->setDisabled(true);
|
||||||
shutdown_trace();
|
shutdown_trace();
|
||||||
trace = false;
|
trace = false;
|
||||||
});
|
});
|
||||||
|
@@ -47,7 +47,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>724</width>
|
<width>724</width>
|
||||||
<height>21</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuAction">
|
<widget class="QMenu" name="menuAction">
|
||||||
@@ -79,6 +79,9 @@
|
|||||||
<addaction name="actionSound_gain"/>
|
<addaction name="actionSound_gain"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionPreferences"/>
|
<addaction name="actionPreferences"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionBegin_trace"/>
|
||||||
|
<addaction name="actionEnd_trace"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuView">
|
<widget class="QMenu" name="menuView">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@@ -666,6 +669,34 @@
|
|||||||
<string>ACPI Shutdown</string>
|
<string>ACPI Shutdown</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionBegin_trace">
|
||||||
|
<property name="text">
|
||||||
|
<string>Begin trace</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+T</string>
|
||||||
|
</property>
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="shortcutVisibleInContextMenu">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionEnd_trace">
|
||||||
|
<property name="text">
|
||||||
|
<string>End trace</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+T</string>
|
||||||
|
</property>
|
||||||
|
<property name="visible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="shortcutVisibleInContextMenu">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
Reference in New Issue
Block a user