diff --git a/kcm/src/CMakeLists.txt b/kcm/src/CMakeLists.txt --- a/kcm/src/CMakeLists.txt +++ b/kcm/src/CMakeLists.txt @@ -8,7 +8,6 @@ declarative/qmloutputcomponent.cpp declarative/qmlscreen.cpp - collapsablebutton.cpp controlpanel.cpp outputconfig.cpp unifiedoutputconfig.cpp diff --git a/kcm/src/collapsablebutton.h b/kcm/src/collapsablebutton.h deleted file mode 100644 --- a/kcm/src/collapsablebutton.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2013 Daniel Vrátil - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#ifndef COLLAPSABLE_BUTTON_H -#define COLLAPSABLE_BUTTON_H - -#include - -class CollapsableButton : public QWidget -{ - Q_OBJECT - - public: - explicit CollapsableButton(const QString &text, QWidget *parent = nullptr); - ~CollapsableButton() override; - - void setCollapsed(bool collapsed); - bool isCollapsed() const; - - void setWidget(QWidget *widget); - QWidget* widget() const; - - QLabel* label() const; - - public Q_SLOTS: - void toggle(); - - Q_SIGNALS: - void toggled(); - - protected: - void paintEvent(QPaintEvent *ev) override; - void mouseReleaseEvent(QMouseEvent *ev) override; - - private: - bool mCollapsed; - QLabel *mLabel; - QWidget *mWidget; -}; - -#endif // COLLAPSABLE_BUTTON_H diff --git a/kcm/src/collapsablebutton.cpp b/kcm/src/collapsablebutton.cpp deleted file mode 100644 --- a/kcm/src/collapsablebutton.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2013 Daniel Vrátil - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License or (at your option) version 3 or any later version - * accepted by the membership of KDE e.V. (or its successor approved - * by the membership of KDE e.V.), which shall act as a proxy - * defined in Section 14 of version 3 of the license. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -#include "collapsablebutton.h" - -#include -#include -#include -#include -#include - -CollapsableButton::CollapsableButton(const QString &text, QWidget *parent) - : QWidget(parent) - , mCollapsed(false) - , mWidget(nullptr) -{ - QHBoxLayout *layout = new QHBoxLayout(this); - mLabel = new QLabel(text, this); - layout->addWidget(mLabel); - QFont f = mLabel->font(); - f.setBold(true); - mLabel->setFont(f); - - mLabel->setIndent(20); -} - -CollapsableButton::~CollapsableButton() -{ -} - -void CollapsableButton::mouseReleaseEvent(QMouseEvent *ev) -{ - if (ev->button() == Qt::LeftButton) { - toggle(); - Q_EMIT toggled(); - } - - QWidget::mouseReleaseEvent(ev); -} - -void CollapsableButton::paintEvent(QPaintEvent *ev) -{ - QPainter painter(this); - - QStyleOption opt; - const int h = 20; - opt.rect = QRect(0, (height() - h) / 2, h, h); - opt.palette = palette(); - QStyle::PrimitiveElement pe = mCollapsed ? QStyle::PE_IndicatorArrowRight : QStyle::PE_IndicatorArrowDown; - - style()->drawPrimitive(pe, &opt, &painter); - painter.end(); - - QWidget::paintEvent(ev); -} - -bool CollapsableButton::isCollapsed() const -{ - return mCollapsed; -} - -void CollapsableButton::setCollapsed(bool collapsed) -{ - if (mCollapsed == collapsed) { - return; - } - - mCollapsed = collapsed; - if (mWidget) { - mWidget->setHidden(collapsed); - } - - update(); -} - -QLabel* CollapsableButton::label() const -{ - return mLabel; -} - -void CollapsableButton::setWidget(QWidget *widget) -{ - mWidget = widget; - if (mWidget) { - mWidget->setHidden(isCollapsed()); - } -} - -QWidget *CollapsableButton::widget() const -{ - return mWidget; -} - -void CollapsableButton::toggle() -{ - setCollapsed(!isCollapsed()); - Q_EMIT toggled(); -} diff --git a/kcm/src/outputconfig.h b/kcm/src/outputconfig.h --- a/kcm/src/outputconfig.h +++ b/kcm/src/outputconfig.h @@ -28,7 +28,6 @@ #include -class CollapsableButton; class QCheckBox; class ResolutionSlider; class QLabel; diff --git a/kcm/src/outputconfig.cpp b/kcm/src/outputconfig.cpp --- a/kcm/src/outputconfig.cpp +++ b/kcm/src/outputconfig.cpp @@ -21,7 +21,6 @@ #include "outputconfig.h" #include "resolutionslider.h" -#include "collapsablebutton.h" #include "utils.h" #include "kcm_screen_debug.h" @@ -139,21 +138,7 @@ formLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum)); } - CollapsableButton *advancedButton = new CollapsableButton(i18n("Advanced Settings"), this); - advancedButton->setCollapsed(true); - vbox->addWidget(advancedButton); - - QWidget *advancedWidget = new QWidget(this); - int leftMargin, topMargin, rightMargin, bottomMargin; - advancedWidget->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); - advancedWidget->setContentsMargins(25, topMargin, rightMargin, bottomMargin); - vbox->addWidget(advancedWidget); - advancedButton->setWidget(advancedWidget); - - formLayout = new QFormLayout(advancedWidget); - advancedWidget->setLayout(formLayout); - - mRefreshRate = new QComboBox(advancedWidget); + mRefreshRate = new QComboBox(this); mRefreshRate->addItem(i18n("Auto"), -1); formLayout->addRow(i18n("Refresh rate:"), mRefreshRate); slotResolutionChanged(mResolution->currentResolution()); diff --git a/kcm/src/unifiedoutputconfig.cpp b/kcm/src/unifiedoutputconfig.cpp --- a/kcm/src/unifiedoutputconfig.cpp +++ b/kcm/src/unifiedoutputconfig.cpp @@ -20,15 +20,15 @@ */ #include "unifiedoutputconfig.h" -#include "collapsablebutton.h" #include "resolutionslider.h" #include "utils.h" #include "kcm_screen_debug.h" #include #include #include +#include #include #include #include