mirror of
https://github.com/KDE/latte-dock.git
synced 2025-02-11 01:58:44 +03:00
screensdialog:introduce deselectAll
--accept proper input events from primitive checkbox area
This commit is contained in:
parent
0125752084
commit
e7dba6be58
@ -36,12 +36,26 @@ bool CheckBox::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyl
|
||||
Q_ASSERT(event);
|
||||
Q_ASSERT(model);
|
||||
|
||||
if (event->type() == QEvent::MouseButtonDblClick) {
|
||||
if (!option.rect.contains(static_cast<QMouseEvent *>(event)->pos()))
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
//! single click on checkbox, changes state
|
||||
QStyleOptionButton checkopt;
|
||||
checkopt.text = "";
|
||||
checkopt.rect = option.rect;
|
||||
QRect remained = Latte::remainedFromCheckBox(checkopt);
|
||||
QRegion checkregion = QRegion(option.rect).subtracted(remained);
|
||||
|
||||
if (!(checkregion.boundingRect().contains(static_cast<QMouseEvent *>(event)->pos()))) {
|
||||
return false;
|
||||
}
|
||||
} else if (event->type() == QEvent::MouseButtonDblClick) {
|
||||
//! double click on checkbox text, changes state
|
||||
if (!option.rect.contains(static_cast<QMouseEvent *>(event)->pos())) {
|
||||
return false;
|
||||
}
|
||||
} else if (event->type() == QEvent::KeyPress) {
|
||||
if (static_cast<QKeyEvent *>(event)->key() != Qt::Key_Space && static_cast<QKeyEvent *>(event)->key() != Qt::Key_Select)
|
||||
if (static_cast<QKeyEvent *>(event)->key() != Qt::Key_Space && static_cast<QKeyEvent *>(event)->key() != Qt::Key_Select) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -59,7 +59,6 @@ void ScreensDialog::init()
|
||||
|
||||
void ScreensDialog::initButtons()
|
||||
{
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Reset)->setEnabled(false);
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Cancel), &QPushButton::clicked,
|
||||
this, &ScreensDialog::onCancel);
|
||||
}
|
||||
@ -87,7 +86,6 @@ QPushButton *ScreensDialog::removeNowButton() const
|
||||
|
||||
void ScreensDialog::onDataChanged()
|
||||
{
|
||||
//m_ui->buttonBox->button(QDialogButtonBox::Reset)->setEnabled(!m_handler->inDefaultValues());
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,6 +53,30 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="deselectAllBtn">
|
||||
<property name="text">
|
||||
<string>Deselect All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="noteLbl">
|
||||
<property name="text">
|
||||
@ -108,7 +132,7 @@
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Reset</set>
|
||||
<set>QDialogButtonBox::Cancel</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -57,7 +57,7 @@ void ScreensHandler::init()
|
||||
m_ui->screensTable->setItemDelegateForColumn(Model::Screens::SCREENCOLUMN, new Settings::Screens::Delegate::CheckBox(this));
|
||||
|
||||
//! Buttons
|
||||
connect(m_ui->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked, this, &ScreensHandler::reset);
|
||||
connect(m_ui->deselectAllBtn, &QPushButton::clicked, this, &ScreensHandler::deselectAll);
|
||||
|
||||
//! load data
|
||||
m_screensModel->setData(m_dialog->layoutsController()->screensData());
|
||||
@ -73,6 +73,11 @@ bool ScreensHandler::inDefaultValues() const
|
||||
return m_screensModel->inDefaultValues();
|
||||
}
|
||||
|
||||
void ScreensHandler::deselectAll()
|
||||
{
|
||||
m_screensModel->deselectAll();
|
||||
}
|
||||
|
||||
void ScreensHandler::reset()
|
||||
{
|
||||
if (m_screensModel->hasChangedData()) {
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
Latte::Data::ScreensTable currentData() const;
|
||||
|
||||
public slots:
|
||||
void deselectAll();
|
||||
void reset() override;
|
||||
void resetDefaults() override;
|
||||
void save() override;
|
||||
|
@ -84,6 +84,19 @@ void Screens::clear()
|
||||
}
|
||||
}
|
||||
|
||||
void Screens::deselectAll()
|
||||
{
|
||||
QVector<int> roles;
|
||||
roles << Qt::CheckStateRole;
|
||||
|
||||
for(int i=0; i<c_screens.rowCount(); ++i) {
|
||||
c_screens[i].isSelected = false;
|
||||
}
|
||||
|
||||
emit dataChanged(index(0, SCREENCOLUMN), index(c_screens.rowCount()-1, SCREENCOLUMN), roles);
|
||||
emit screensDataChanged();
|
||||
}
|
||||
|
||||
void Screens::reset()
|
||||
{
|
||||
c_screens = o_screens;
|
||||
|
@ -69,7 +69,8 @@ public:
|
||||
|
||||
Latte::Data::ScreensTable selectedScreens();
|
||||
|
||||
void reset();
|
||||
void deselectAll();
|
||||
void reset();
|
||||
|
||||
signals:
|
||||
void screensDataChanged();
|
||||
|
Loading…
x
Reference in New Issue
Block a user