forked from blue/squawk
qt6 build
This commit is contained in:
parent
a04693e39d
commit
d4cec645b5
35 changed files with 279 additions and 632 deletions
|
@ -21,36 +21,39 @@
|
|||
SettingsList::SettingsList(QWidget* parent):
|
||||
QListWidget(parent),
|
||||
lastWidth(0)
|
||||
{
|
||||
{}
|
||||
|
||||
SettingsList::~SettingsList() {}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
void SettingsList::initViewItemOption(QStyleOptionViewItem* option) const {
|
||||
QListWidget::initViewItemOption(option);
|
||||
if (!iconSize().isValid())
|
||||
option->decorationSize.setWidth(lastWidth);
|
||||
|
||||
option->rect.setWidth(lastWidth);
|
||||
}
|
||||
|
||||
SettingsList::~SettingsList()
|
||||
{
|
||||
}
|
||||
|
||||
QStyleOptionViewItem SettingsList::viewOptions() const
|
||||
{
|
||||
#else
|
||||
QStyleOptionViewItem SettingsList::viewOptions() const {
|
||||
QStyleOptionViewItem option = QListWidget::viewOptions();
|
||||
if (!iconSize().isValid()) {
|
||||
if (!iconSize().isValid())
|
||||
option.decorationSize.setWidth(lastWidth);
|
||||
}
|
||||
|
||||
option.rect.setWidth(lastWidth);
|
||||
return option;
|
||||
}
|
||||
#endif
|
||||
|
||||
void SettingsList::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
void SettingsList::resizeEvent(QResizeEvent* event) {
|
||||
lastWidth = event->size().width();
|
||||
QListWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
QRect SettingsList::visualRect(const QModelIndex& index) const
|
||||
{
|
||||
QRect SettingsList::visualRect(const QModelIndex& index) const {
|
||||
QRect res = QListWidget::visualRect(index);
|
||||
if (index.isValid()) {
|
||||
if (index.isValid())
|
||||
res.setWidth(lastWidth);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,29 +16,28 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef UI_SETTINGSLIST_H
|
||||
#define UI_SETTINGSLIST_H
|
||||
#pragma once
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QResizeEvent>
|
||||
#include <QStyleOptionViewItem>
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
class SettingsList : public QListWidget
|
||||
{
|
||||
class SettingsList : public QListWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SettingsList(QWidget* parent = nullptr);
|
||||
~SettingsList();
|
||||
|
||||
protected:
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
void initViewItemOption(QStyleOptionViewItem* option) const override;
|
||||
#else
|
||||
QStyleOptionViewItem viewOptions() const override;
|
||||
#endif
|
||||
|
||||
void resizeEvent(QResizeEvent * event) override;
|
||||
QRect visualRect(const QModelIndex & index) const override;
|
||||
|
||||
private:
|
||||
int lastWidth;
|
||||
};
|
||||
|
||||
#endif // UI_SETTINGSLIST_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue