diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 1495e67e0..fdaaa5962 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -616,8 +616,6 @@ add_library(gui SHARED guiapplication.h guiutility.cpp guiutility.h - horizontalcombobox.cpp - horizontalcombobox.h infoarea.cpp infoarea.h labelandicon.cpp diff --git a/src/gui/components/hotkeydialog.cpp b/src/gui/components/hotkeydialog.cpp index a629df39b..5bba5763e 100644 --- a/src/gui/components/hotkeydialog.cpp +++ b/src/gui/components/hotkeydialog.cpp @@ -115,7 +115,7 @@ namespace swift::gui::components CHotkeyDialog::~CHotkeyDialog() {} - CKeySelectionBox::CKeySelectionBox(QWidget *parent) : CHorizontalComboBox(parent) + CKeySelectionBox::CKeySelectionBox(QWidget *parent) : QComboBox(parent) { connect(this, qOverload(&CKeySelectionBox::currentIndexChanged), this, &CKeySelectionBox::updateSelectedIndex); @@ -199,7 +199,6 @@ namespace swift::gui::components const CKeyboardKey &keyboardKey) { int currentIndex = 0; - const int width = qRound(1.5 * this->width()); const bool select = !keyboardKey.isUnknown(); CKeySelectionBox *ksb = new CKeySelectionBox(ui->qf_Advanced); @@ -211,7 +210,6 @@ namespace swift::gui::components } ksb->setSelectedIndex(currentIndex); - ksb->setPopupWidth(qMin(width, 600)); ksb->addItem(noKeyButton(), QVariant::fromValue(CKeyboardKey())); // at back (easier to find it is there twice) ui->qf_Advanced->layout()->addWidget(ksb); @@ -226,7 +224,6 @@ namespace swift::gui::components const CJoystickButton &joystickButton) { int currentIndex = -1; - const int width = qRound(1.5 * this->width()); CKeySelectionBox *ksb = new CKeySelectionBox(ui->qf_Advanced); ksb->addItem(noKeyButton(), QVariant::fromValue(CJoystickButton())); // at front @@ -241,7 +238,6 @@ namespace swift::gui::components } ksb->setSelectedIndex(currentIndex); - ksb->setPopupWidth(qMin(width, 600)); ksb->addItem(noKeyButton(), QVariant::fromValue(CJoystickButton())); // at back (easier to find it is there twice) diff --git a/src/gui/components/hotkeydialog.h b/src/gui/components/hotkeydialog.h index 97ce117bb..756d218b8 100644 --- a/src/gui/components/hotkeydialog.h +++ b/src/gui/components/hotkeydialog.h @@ -10,7 +10,6 @@ #include #include -#include "gui/horizontalcombobox.h" #include "gui/models/actionmodel.h" #include "gui/swiftguiexport.h" #include "misc/identifierlist.h" @@ -36,7 +35,7 @@ namespace swift::gui::components /*! * ComboBox for selecting keyboard keys */ - class SWIFT_GUI_EXPORT CKeySelectionBox : public CHorizontalComboBox + class SWIFT_GUI_EXPORT CKeySelectionBox : public QComboBox { Q_OBJECT diff --git a/src/gui/horizontalcombobox.cpp b/src/gui/horizontalcombobox.cpp deleted file mode 100644 index de5af4055..000000000 --- a/src/gui/horizontalcombobox.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2014 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -#include "horizontalcombobox.h" - -namespace swift::gui -{ - CHorizontalComboBox::CHorizontalComboBox(QWidget *parent) : QComboBox(parent) - { - m_view = new QListView(this); - m_view->setFlow(QListView::LeftToRight); - this->setView(m_view); - for (QWidget *o : findChildren()) - { - if (o->inherits("QComboBoxPrivateContainer")) - { - // popup - o->setFixedHeight(view()->height()); - break; - } - } - } - - void CHorizontalComboBox::showPopup() - { - QComboBox::showPopup(); - int w = m_popupWidth; - if (w < 0) - { - w = 0; - for (int i = 0; i < count(); i++) - { - const QModelIndex ix = model()->index(i, modelColumn(), rootModelIndex()); - w += view()->visualRect(ix).width(); - } - } - view()->setFixedWidth(w); - } - - void CHorizontalComboBox::setPopupWidth(int w) { m_popupWidth = w; } -} // namespace swift::gui diff --git a/src/gui/horizontalcombobox.h b/src/gui/horizontalcombobox.h deleted file mode 100644 index e8b4c1a9b..000000000 --- a/src/gui/horizontalcombobox.h +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -//! \file - -#ifndef SWIFT_GUI_HORIZONTALCOMBOBOX_H -#define SWIFT_GUI_HORIZONTALCOMBOBOX_H - -#include -#include - -namespace swift::gui -{ - //! A combobox where the dropdown is horizontally and not vertically - class CHorizontalComboBox : public QComboBox - { - Q_OBJECT - - public: - //! ComboBox displaying the values horizontally - explicit CHorizontalComboBox(QWidget *parent = nullptr); - - //! \copydoc QComboBox::showPopup - virtual void showPopup() override; - - //! Width of the popup - void setPopupWidth(int w); - - private: - QListView *m_view = nullptr; - int m_popupWidth = -1; - }; -} // namespace swift::gui - -#endif // SWIFT_GUI_HORIZONTALCOMBOBOX_H