Changeset View
Changeset View
Standalone View
Standalone View
src/dolphinmainwindow.cpp
| Show First 20 Lines • Show All 1721 Lines • ▼ Show 20 Line(s) | |||||
| 1722 | void DolphinMainWindow::createControlButton() | 1722 | void DolphinMainWindow::createControlButton() | ||
| 1723 | { | 1723 | { | ||
| 1724 | if (m_controlButton) { | 1724 | if (m_controlButton) { | ||
| 1725 | return; | 1725 | return; | ||
| 1726 | } | 1726 | } | ||
| 1727 | Q_ASSERT(!m_controlButton); | 1727 | Q_ASSERT(!m_controlButton); | ||
| 1728 | 1728 | | |||
| 1729 | m_controlButton = new QToolButton(this); | 1729 | m_controlButton = new QToolButton(this); | ||
| 1730 | m_controlButton->setIcon(QIcon::fromTheme(QStringLiteral("application-menu"))); | 1730 | m_controlButton->setIcon(QIcon::fromTheme(QStringLiteral("application-menu"))); | ||
ngraham: Tooltips are written as commands or sentences. Maybe change this to something like "Show menu" | |||||
simonkr: Done! :) | |||||
| 1731 | m_controlButton->setText(i18nc("@action", "Control")); | 1731 | m_controlButton->setToolTip(i18nc("@action", "Show menu")); | ||
| 1732 | m_controlButton->setAttribute(Qt::WidgetAttribute::WA_CustomWhatsThis); | 1732 | m_controlButton->setAttribute(Qt::WidgetAttribute::WA_CustomWhatsThis); | ||
| 1733 | m_controlButton->setPopupMode(QToolButton::InstantPopup); | 1733 | m_controlButton->setPopupMode(QToolButton::InstantPopup); | ||
| 1734 | m_controlButton->setToolButtonStyle(toolBar()->toolButtonStyle()); | | |||
| 1735 | 1734 | | |||
| 1736 | QMenu* controlMenu = new QMenu(m_controlButton); | 1735 | QMenu* controlMenu = new QMenu(m_controlButton); | ||
| 1737 | connect(controlMenu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateControlMenu); | 1736 | connect(controlMenu, &QMenu::aboutToShow, this, &DolphinMainWindow::updateControlMenu); | ||
| 1738 | controlMenu->installEventFilter(this); | 1737 | controlMenu->installEventFilter(this); | ||
| 1739 | 1738 | | |||
| 1740 | m_controlButton->setMenu(controlMenu); | 1739 | m_controlButton->setMenu(controlMenu); | ||
| 1741 | 1740 | | |||
| 1742 | toolBar()->addWidget(m_controlButton); | 1741 | toolBar()->addWidget(m_controlButton); | ||
| 1743 | connect(toolBar(), &KToolBar::iconSizeChanged, | 1742 | connect(toolBar(), &KToolBar::iconSizeChanged, | ||
| 1744 | m_controlButton, &QToolButton::setIconSize); | 1743 | m_controlButton, &QToolButton::setIconSize); | ||
| 1745 | connect(toolBar(), &KToolBar::toolButtonStyleChanged, | | |||
| 1746 | m_controlButton, &QToolButton::setToolButtonStyle); | | |||
| 1747 | 1744 | | |||
| 1748 | // The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar | 1745 | // The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar | ||
| 1749 | // gets edited. In this case we must add them again. The adding is done asynchronously by | 1746 | // gets edited. In this case we must add them again. The adding is done asynchronously by | ||
| 1750 | // m_updateToolBarTimer. | 1747 | // m_updateToolBarTimer. | ||
| 1751 | connect(m_controlButton, &QToolButton::destroyed, this, &DolphinMainWindow::slotControlButtonDeleted); | 1748 | connect(m_controlButton, &QToolButton::destroyed, this, &DolphinMainWindow::slotControlButtonDeleted); | ||
| 1752 | m_updateToolBarTimer = new QTimer(this); | 1749 | m_updateToolBarTimer = new QTimer(this); | ||
| 1753 | m_updateToolBarTimer->setInterval(500); | 1750 | m_updateToolBarTimer->setInterval(500); | ||
| 1754 | connect(m_updateToolBarTimer, &QTimer::timeout, this, &DolphinMainWindow::updateToolBar); | 1751 | connect(m_updateToolBarTimer, &QTimer::timeout, this, &DolphinMainWindow::updateToolBar); | ||
| ▲ Show 20 Lines • Show All 345 Lines • Show Last 20 Lines | |||||
Tooltips are written as commands or sentences. Maybe change this to something like "Show menu"