forked from blue/squawk
some more thoughts about settings widgets
This commit is contained in:
parent
841e526e59
commit
a8a7ce2538
@ -4,4 +4,10 @@ target_sources(squawk PRIVATE
|
|||||||
settings.h
|
settings.h
|
||||||
settings.cpp
|
settings.cpp
|
||||||
settings.ui
|
settings.ui
|
||||||
|
pagegeneral.h
|
||||||
|
pagegeneral.cpp
|
||||||
|
pagegeneral.ui
|
||||||
|
pageappearance.h
|
||||||
|
pageappearance.cpp
|
||||||
|
pageappearance.ui
|
||||||
)
|
)
|
||||||
|
13
ui/widgets/settings/pageappearance.cpp
Normal file
13
ui/widgets/settings/pageappearance.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "pageappearance.h"
|
||||||
|
#include "ui_pageappearance.h"
|
||||||
|
|
||||||
|
PageAppearance::PageAppearance(QWidget* parent):
|
||||||
|
QWidget(parent),
|
||||||
|
m_ui(new Ui::PageAppearance())
|
||||||
|
{
|
||||||
|
m_ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
PageAppearance::~PageAppearance()
|
||||||
|
{
|
||||||
|
}
|
26
ui/widgets/settings/pageappearance.h
Normal file
26
ui/widgets/settings/pageappearance.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef PAGEAPPEARANCE_H
|
||||||
|
#define PAGEAPPEARANCE_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class PageAppearance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo write docs
|
||||||
|
*/
|
||||||
|
class PageAppearance : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
PageAppearance(QWidget* parent = nullptr);
|
||||||
|
~PageAppearance();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QScopedPointer<Ui::PageAppearance> m_ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PAGEAPPEARANCE_H
|
28
ui/widgets/settings/pageappearance.ui
Normal file
28
ui/widgets/settings/pageappearance.ui
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>PageAppearance</class>
|
||||||
|
<widget class="QWidget" name="PageAppearance">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="themeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Theme</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="themeInput"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
13
ui/widgets/settings/pagegeneral.cpp
Normal file
13
ui/widgets/settings/pagegeneral.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include "pagegeneral.h"
|
||||||
|
#include "ui_pagegeneral.h"
|
||||||
|
|
||||||
|
PageGeneral::PageGeneral(QWidget* parent):
|
||||||
|
QWidget(parent),
|
||||||
|
m_ui(new Ui::PageGeneral())
|
||||||
|
{
|
||||||
|
m_ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
PageGeneral::~PageGeneral()
|
||||||
|
{
|
||||||
|
}
|
26
ui/widgets/settings/pagegeneral.h
Normal file
26
ui/widgets/settings/pagegeneral.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef PAGEGENERAL_H
|
||||||
|
#define PAGEGENERAL_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class PageGeneral;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo write docs
|
||||||
|
*/
|
||||||
|
class PageGeneral : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
PageGeneral(QWidget* parent = nullptr);
|
||||||
|
~PageGeneral();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QScopedPointer<Ui::PageGeneral> m_ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PAGEGENERAL_H
|
28
ui/widgets/settings/pagegeneral.ui
Normal file
28
ui/widgets/settings/pagegeneral.ui
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>PageGeneral</class>
|
||||||
|
<widget class="QWidget" name="PageGeneral">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Downloads path</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="downloadsPathInput"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -6,9 +6,19 @@ Settings::Settings(QWidget* parent):
|
|||||||
m_ui(new Ui::Settings())
|
m_ui(new Ui::Settings())
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
|
connect(m_ui->list, &QListWidget::currentItemChanged, this, &Settings::onCurrentPageChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::~Settings()
|
Settings::~Settings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::onCurrentPageChanged(QListWidgetItem* current)
|
||||||
|
{
|
||||||
|
if (current != nullptr) {
|
||||||
|
m_ui->header->setText(current->text());
|
||||||
|
|
||||||
|
m_ui->content->setCurrentIndex(m_ui->list->currentRow());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QListWidgetItem>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@ -19,6 +20,9 @@ public:
|
|||||||
Settings(QWidget* parent = nullptr);
|
Settings(QWidget* parent = nullptr);
|
||||||
~Settings();
|
~Settings();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void onCurrentPageChanged(QListWidgetItem* current);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::Settings> m_ui;
|
QScopedPointer<Ui::Settings> m_ui;
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>465</width>
|
<width>502</width>
|
||||||
<height>363</height>
|
<height>363</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -21,33 +21,13 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>7</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="2" column="3">
|
<item row="0" column="0" rowspan="2">
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="SettingsList" name="list">
|
||||||
<property name="text">
|
|
||||||
<string>Apply</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="dialog-ok-apply"/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="2">
|
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Ok</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset theme="dialog-ok"/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" rowspan="3">
|
|
||||||
<widget class="SettingsList" name="listWidget">
|
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -66,12 +46,12 @@
|
|||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::NoFrame</enum>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="lineWidth">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="horizontalScrollBarPolicy">
|
<property name="horizontalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -103,7 +83,7 @@
|
|||||||
<enum>QListView::Adjust</enum>
|
<enum>QListView::Adjust</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="layoutMode">
|
<property name="layoutMode">
|
||||||
<enum>QListView::Batched</enum>
|
<enum>QListView::SinglePass</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="viewMode">
|
<property name="viewMode">
|
||||||
<enum>QListView::IconMode</enum>
|
<enum>QListView::IconMode</enum>
|
||||||
@ -143,24 +123,71 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" colspan="3">
|
<item row="0" column="1" rowspan="2" colspan="2">
|
||||||
<widget class="QWidget" name="widget" native="true"/>
|
<widget class="QWidget" name="groupper" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QPushButton" name="applyButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Apply</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="dialog-ok-apply">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="2" column="3">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QPushButton" name="cancelButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="dialog-cancel">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QPushButton" name="okButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ok</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="dialog-ok">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="4">
|
||||||
|
<widget class="QLabel" name="header">
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">font-size: 14pt;</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>General</string>
|
<string>General</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="4">
|
<item row="1" column="0" colspan="4">
|
||||||
<widget class="QPushButton" name="pushButton_3">
|
<widget class="QStackedWidget" name="content">
|
||||||
<property name="text">
|
<property name="sizePolicy">
|
||||||
<string>Cancel</string>
|
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||||
</property>
|
<horstretch>0</horstretch>
|
||||||
<property name="icon">
|
<verstretch>0</verstretch>
|
||||||
<iconset theme="dialog-cancel"/>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="PageGeneral" name="General" native="true"/>
|
||||||
|
<widget class="PageAppearance" name="Appearance" native="true"/>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -171,6 +198,16 @@
|
|||||||
<extends>QListWidget</extends>
|
<extends>QListWidget</extends>
|
||||||
<header location="global">ui/widgets/settings/settingslist.h</header>
|
<header location="global">ui/widgets/settings/settingslist.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>PageGeneral</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header location="global">ui/widgets/settings/pagegeneral.h</header>
|
||||||
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>PageAppearance</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header location="global">ui/widgets/settings/pageappearance.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -4,6 +4,7 @@ SettingsList::SettingsList(QWidget* parent):
|
|||||||
QListWidget(parent),
|
QListWidget(parent),
|
||||||
lastWidth(0)
|
lastWidth(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsList::~SettingsList()
|
SettingsList::~SettingsList()
|
||||||
@ -25,3 +26,13 @@ void SettingsList::resizeEvent(QResizeEvent* event)
|
|||||||
lastWidth = event->size().width();
|
lastWidth = event->size().width();
|
||||||
QListWidget::resizeEvent(event);
|
QListWidget::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRect SettingsList::visualRect(const QModelIndex& index) const
|
||||||
|
{
|
||||||
|
QRect res = QListWidget::visualRect(index);
|
||||||
|
if (index.isValid()) {
|
||||||
|
res.setWidth(lastWidth);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
QStyleOptionViewItem viewOptions() const override;
|
QStyleOptionViewItem viewOptions() const override;
|
||||||
void resizeEvent(QResizeEvent * event) override;
|
void resizeEvent(QResizeEvent * event) override;
|
||||||
|
QRect visualRect(const QModelIndex & index) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int lastWidth;
|
int lastWidth;
|
||||||
|
Loading…
Reference in New Issue
Block a user