mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #577, make read only checkboxes better readable
(by not disabling them, but using a little trick)
This commit is contained in:
@@ -132,9 +132,9 @@ namespace BlackGui
|
||||
this->ui->le_Family->setReadOnly(readOnly);
|
||||
this->ui->le_Iata->setReadOnly(readOnly);
|
||||
|
||||
this->ui->cb_Legacy->setCheckable(!readOnly);
|
||||
this->ui->cb_Military->setCheckable(!readOnly);
|
||||
this->ui->cb_RealWorld->setCheckable(!readOnly);
|
||||
CGuiUtility::checkBoxReadOnly(this->ui->cb_Legacy, readOnly);
|
||||
CGuiUtility::checkBoxReadOnly(this->ui->cb_Military, readOnly);
|
||||
CGuiUtility::checkBoxReadOnly(this->ui->cb_RealWorld, readOnly);
|
||||
|
||||
this->ui->cb_Wtc->setEnabled(!readOnly);
|
||||
this->ui->cb_Rank->setEnabled(!readOnly);
|
||||
|
||||
@@ -198,6 +198,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_RealWorld">
|
||||
<property name="toolTip">
|
||||
<string>Real world aircraft</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Real</string>
|
||||
</property>
|
||||
@@ -205,6 +208,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_Legacy">
|
||||
<property name="toolTip">
|
||||
<string>Legacy aircraft, e.g. Concord, ME109</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Legacy</string>
|
||||
</property>
|
||||
@@ -213,7 +219,7 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_Military">
|
||||
<property name="toolTip">
|
||||
<string>Military</string>
|
||||
<string>Military aircraft</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mil.</string>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "blackmisc/filelogger.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include <QMainWindow>
|
||||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
@@ -200,11 +201,29 @@ namespace BlackGui
|
||||
return m;
|
||||
}
|
||||
|
||||
void CGuiUtility::checkBoxReadOnly(QCheckBox *checkBox, bool readOnly)
|
||||
{
|
||||
static const QCheckBox defaultBox;
|
||||
BLACK_VERIFY_X(checkBox, Q_FUNC_INFO, "no checkbox");
|
||||
if (!checkBox) { return; }
|
||||
|
||||
if (readOnly)
|
||||
{
|
||||
checkBox->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
checkBox->setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
else
|
||||
{
|
||||
checkBox->setAttribute(Qt::WA_TransparentForMouseEvents, defaultBox.testAttribute(Qt::WA_TransparentForMouseEvents));
|
||||
checkBox->setFocusPolicy(defaultBox.focusPolicy());
|
||||
}
|
||||
}
|
||||
|
||||
QWidgetList CGuiUtility::topLevelApplicationWidgetsWithName()
|
||||
{
|
||||
QWidgetList tlw = QApplication::topLevelWidgets();
|
||||
QWidgetList rl;
|
||||
foreach(QWidget * w, tlw)
|
||||
foreach (QWidget *w, tlw)
|
||||
{
|
||||
if (w->objectName().isEmpty()) { continue; }
|
||||
rl.append(w);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "enableforframelesswindow.h"
|
||||
#include <QWidgetList>
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QCommandLineParser>
|
||||
|
||||
namespace BlackGui
|
||||
@@ -80,6 +81,9 @@ namespace BlackGui
|
||||
//! Metatype
|
||||
static const QString &swiftJsonDragAndDropMimeType();
|
||||
|
||||
//! Pseudo readonly state for checkbox
|
||||
static void checkBoxReadOnly(QCheckBox *checkBox, bool readOnly);
|
||||
|
||||
private:
|
||||
//! Constructor, use static methods only
|
||||
CGuiUtility() {}
|
||||
|
||||
Reference in New Issue
Block a user