Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/sublime/idealbuttonbarwidget.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 46 | { | |||
---|---|---|---|---|---|
55 | KConfigGroup config = KSharedConfig::openConfig()->group("UI"); | 55 | KConfigGroup config = KSharedConfig::openConfig()->group("UI"); | ||
56 | QStringList shortcutStrings = config.readEntry(QStringLiteral("Shortcut for %1").arg(title), QStringList()); | 56 | QStringList shortcutStrings = config.readEntry(QStringLiteral("Shortcut for %1").arg(title), QStringList()); | ||
57 | setShortcuts({ QKeySequence::fromString(shortcutStrings.value(0)), QKeySequence::fromString(shortcutStrings.value(1)) }); | 57 | setShortcuts({ QKeySequence::fromString(shortcutStrings.value(0)), QKeySequence::fromString(shortcutStrings.value(1)) }); | ||
58 | 58 | | |||
59 | dock->setWindowTitle(title); | 59 | dock->setWindowTitle(title); | ||
60 | dock->view()->widget()->installEventFilter(this); | 60 | dock->view()->widget()->installEventFilter(this); | ||
61 | refreshText(); | 61 | refreshText(); | ||
62 | } | 62 | } | ||
63 | 63 | | |||
mwolff: remove if it doesn't fix anything (this should be done automatically anyways) | |||||
64 | IdealDockWidget *dockWidget() const | 64 | IdealDockWidget *dockWidget() const | ||
65 | { | 65 | { | ||
66 | Q_ASSERT(m_dock); | 66 | Q_ASSERT(m_dock); | ||
67 | return m_dock; | 67 | return m_dock; | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | IdealToolButton* button() { return m_button; } | 70 | IdealToolButton* button() { return m_button; } | ||
71 | void setButton(IdealToolButton* button) { | 71 | void setButton(IdealToolButton* button) { | ||
72 | m_button = button; | 72 | m_button = button; | ||
73 | refreshText(); | 73 | refreshText(); | ||
74 | } | 74 | } | ||
75 | 75 | | |||
76 | QString id() { | 76 | QString id() { | ||
77 | return m_dock->view()->document()->documentSpecifier(); | 77 | return m_dock->view()->document()->documentSpecifier(); | ||
78 | } | 78 | } | ||
79 | 79 | | |||
80 | private: | 80 | private: | ||
81 | bool eventFilter(QObject * watched, QEvent * event) override | 81 | bool eventFilter(QObject * watched, QEvent * event) override | ||
82 | { | 82 | { | ||
83 | if (watched == m_dock->view()->widget() && event->type() == QEvent::EnabledChange) { | 83 | // an event may arrive when m_dock->view()->widget() is already destroyed | ||
84 | // so check for event type first. | ||||
mwolff: remove this line then | |||||
85 | if (event->type() == QEvent::EnabledChange && watched == m_dock->view()->widget()) { | ||||
84 | refreshText(); | 86 | refreshText(); | ||
85 | } | 87 | } | ||
86 | 88 | | |||
87 | return QObject::eventFilter(watched, event); | 89 | return QObject::eventFilter(watched, event); | ||
88 | } | 90 | } | ||
89 | 91 | | |||
90 | void refreshText() | 92 | void refreshText() | ||
91 | { | 93 | { | ||
▲ Show 20 Lines • Show All 273 Lines • Show Last 20 Lines |
remove if it doesn't fix anything (this should be done automatically anyways)