Fix build without features.shortcut

Change-Id: I87a7ba1a77b0671559616a3ea4722bcc233af32d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Tasuku Suzuki 2017-04-25 15:36:48 +09:00 committed by Stephan Binner
parent c1e19a2ecb
commit a9e0879ee1
6 changed files with 18 additions and 2 deletions

View File

@ -47,6 +47,7 @@
QT_BEGIN_NAMESPACE
#if QT_CONFIG(shortcut)
static guint qt_gdkKey(const QKeySequence &shortcut)
{
if (shortcut.isEmpty())
@ -75,6 +76,7 @@ static GdkModifierType qt_gdkModifiers(const QKeySequence &shortcut)
return static_cast<GdkModifierType>(mods);
}
#endif
QGtk3MenuItem::QGtk3MenuItem()
: m_visible(true),
@ -126,10 +128,12 @@ GtkWidget *QGtk3MenuItem::create()
if (m_menu)
gtk_menu_item_set_submenu(GTK_MENU_ITEM(m_item), m_menu->handle());
g_signal_connect(m_item, "select", G_CALLBACK(onSelect), this);
#if QT_CONFIG(shortcut)
if (!m_shortcut.isEmpty()) {
GtkWidget *label = gtk_bin_get_child(GTK_BIN(m_item));
gtk_accel_label_set_accel(GTK_ACCEL_LABEL(label), qt_gdkKey(m_shortcut), qt_gdkModifiers(m_shortcut));
}
#endif
}
gtk_widget_set_sensitive(m_item, m_enabled);
gtk_widget_set_visible(m_item, m_visible);
@ -267,6 +271,7 @@ void QGtk3MenuItem::setChecked(bool checked)
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(m_item), checked);
}
#if QT_CONFIG(shortcut)
QKeySequence QGtk3MenuItem::shortcut() const
{
return m_shortcut;
@ -283,6 +288,7 @@ void QGtk3MenuItem::setShortcut(const QKeySequence& shortcut)
gtk_accel_label_set_accel(GTK_ACCEL_LABEL(label), qt_gdkKey(m_shortcut), qt_gdkModifiers(m_shortcut));
}
}
#endif
bool QGtk3MenuItem::isEnabled() const
{

View File

@ -82,8 +82,10 @@ public:
bool isChecked() const;
void setChecked(bool checked) override;
#if QT_CONFIG(shortcut)
QKeySequence shortcut() const;
void setShortcut(const QKeySequence &shortcut) override;
#endif
bool isEnabled() const;
void setEnabled(bool enabled) override;
@ -114,7 +116,9 @@ private:
QGtk3Menu *m_menu;
GtkWidget *m_item;
QString m_text;
#if QT_CONFIG(shortcut)
QKeySequence m_shortcut;
#endif
};
class QGtk3Menu : public QPlatformMenu

View File

@ -148,6 +148,8 @@ QString qt_accHotKey(const QString &text)
int ampIndex = qt_accAmpIndex(text);
if (ampIndex != -1)
return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + text.at(ampIndex + 1);
#else
Q_UNUSED(text)
#endif
return QString();

View File

@ -3812,8 +3812,8 @@ void QFileDialogPrivate::_q_nativeEnterDirectory(const QUrl &directory)
*/
bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) {
Q_Q(QFileDialog);
#if QT_CONFIG(shortcut)
Q_Q(QFileDialog);
if (event->matches(QKeySequence::Cancel)) {
q->reject();
return true;
@ -4018,7 +4018,9 @@ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e)
}
#endif // QT_KEYPAD_NAVIGATION
#if QT_CONFIG(shortcut)
int key = e->key();
#endif
QLineEdit::keyPressEvent(e);
#if QT_CONFIG(shortcut)
if (!e->matches(QKeySequence::Cancel) && key != Qt::Key_Back)

View File

@ -1404,8 +1404,8 @@ void QMessageBox::changeEvent(QEvent *ev)
*/
void QMessageBox::keyPressEvent(QKeyEvent *e)
{
Q_D(QMessageBox);
#if QT_CONFIG(shortcut)
Q_D(QMessageBox);
if (e->matches(QKeySequence::Cancel)) {
if (d->detectedEscapeButton) {
#ifdef Q_OS_MAC

View File

@ -1704,7 +1704,9 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
}
bool unknown = false;
#if QT_CONFIG(shortcut)
bool visual = cursorMoveStyle() == Qt::VisualMoveStyle;
#endif
if (false) {
}