Commit c2f85dd2 authored by Laurent Montel's avatar Laurent Montel 😁

Initialize pointer/value. Minor optimization

parent 8a3be290
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
CollapsableButton::CollapsableButton(const QString &text, QWidget *parent) CollapsableButton::CollapsableButton(const QString &text, QWidget *parent)
: QWidget(parent) : QWidget(parent)
, mCollapsed(false) , mCollapsed(false)
, mWidget(0) , mWidget(nullptr)
{ {
QHBoxLayout *layout = new QHBoxLayout(this); QHBoxLayout *layout = new QHBoxLayout(this);
mLabel = new QLabel(text, this); mLabel = new QLabel(text, this);
......
...@@ -40,7 +40,7 @@ class ControlPanel : public QFrame ...@@ -40,7 +40,7 @@ class ControlPanel : public QFrame
Q_OBJECT Q_OBJECT
public: public:
explicit ControlPanel(QWidget *parent = 0); explicit ControlPanel(QWidget *parent = nullptr);
virtual ~ControlPanel(); virtual ~ControlPanel();
void setConfig(const KScreen::ConfigPtr &config); void setConfig(const KScreen::ConfigPtr &config);
......
...@@ -44,16 +44,13 @@ QMLOutputComponent::~QMLOutputComponent() ...@@ -44,16 +44,13 @@ QMLOutputComponent::~QMLOutputComponent()
QMLOutput* QMLOutputComponent::createForOutput(const KScreen::OutputPtr &output) QMLOutput* QMLOutputComponent::createForOutput(const KScreen::OutputPtr &output)
{ {
QObject *instance; QObject *instance = beginCreate(m_engine->rootContext());
instance = beginCreate(m_engine->rootContext());
if (!instance) { if (!instance) {
qWarning() << errorString(); qWarning() << errorString();
return 0; return nullptr;
} }
bool success = false; bool success = instance->setProperty("outputPtr", QVariant::fromValue(output));
success = instance->setProperty("outputPtr", QVariant::fromValue(output));
Q_ASSERT(success); Q_ASSERT(success);
success = instance->setProperty("screen", QVariant::fromValue(qobject_cast<QMLScreen*>(parent()))); success = instance->setProperty("screen", QVariant::fromValue(qobject_cast<QMLScreen*>(parent())));
Q_ASSERT(success); Q_ASSERT(success);
......
...@@ -33,13 +33,13 @@ ...@@ -33,13 +33,13 @@
QMLScreen::QMLScreen(QQuickItem *parent): QMLScreen::QMLScreen(QQuickItem *parent):
QQuickItem(parent), QQuickItem(parent),
m_config(0), m_config(nullptr),
m_connectedOutputsCount(0), m_connectedOutputsCount(0),
m_enabledOutputsCount(0), m_enabledOutputsCount(0),
m_leftmost(0), m_leftmost(nullptr),
m_topmost(0), m_topmost(nullptr),
m_rightmost(0), m_rightmost(nullptr),
m_bottommost(0) m_bottommost(nullptr)
{ {
connect(this, &QMLScreen::widthChanged, this, &QMLScreen::viewSizeChanged); connect(this, &QMLScreen::widthChanged, this, &QMLScreen::viewSizeChanged);
connect(this, &QMLScreen::heightChanged, this, &QMLScreen::viewSizeChanged); connect(this, &QMLScreen::heightChanged, this, &QMLScreen::viewSizeChanged);
......
...@@ -56,7 +56,7 @@ class QMLScreen : public QQuickItem ...@@ -56,7 +56,7 @@ class QMLScreen : public QQuickItem
MEMBER m_engine) MEMBER m_engine)
public: public:
explicit QMLScreen(QQuickItem *parent = 0); explicit QMLScreen(QQuickItem *parent = nullptr);
virtual ~QMLScreen(); virtual ~QMLScreen();
...@@ -111,8 +111,11 @@ class QMLScreen : public QQuickItem ...@@ -111,8 +111,11 @@ class QMLScreen : public QQuickItem
int m_connectedOutputsCount; int m_connectedOutputsCount;
int m_enabledOutputsCount; int m_enabledOutputsCount;
QQmlEngine* m_engine; QQmlEngine* m_engine = nullptr;
QMLOutput *m_leftmost, *m_topmost, *m_rightmost, *m_bottommost; QMLOutput *m_leftmost = nullptr;
QMLOutput *m_topmost = nullptr;
QMLOutput *m_rightmost = nullptr;
QMLOutput *m_bottommost = nullptr;
}; };
......
...@@ -34,7 +34,7 @@ class KCMKScreen : public KCModule ...@@ -34,7 +34,7 @@ class KCMKScreen : public KCModule
Q_OBJECT Q_OBJECT
public: public:
explicit KCMKScreen (QWidget* parent = 0, const QVariantList& args = QVariantList()); explicit KCMKScreen (QWidget* parent = nullptr, const QVariantList& args = QVariantList());
virtual ~KCMKScreen(); virtual ~KCMKScreen();
virtual QSize sizeHint() const Q_DECL_OVERRIDE; virtual QSize sizeHint() const Q_DECL_OVERRIDE;
...@@ -48,7 +48,7 @@ class KCMKScreen : public KCModule ...@@ -48,7 +48,7 @@ class KCMKScreen : public KCModule
private: private:
void configReady(KScreen::ConfigOperation *op); void configReady(KScreen::ConfigOperation *op);
Widget *mKScreenWidget; Widget *mKScreenWidget = nullptr;
bool m_blockChanges = false; bool m_blockChanges = false;
QHBoxLayout *mMainLayout = nullptr; QHBoxLayout *mMainLayout = nullptr;
......
...@@ -40,7 +40,7 @@ class OutputConfig : public QWidget ...@@ -40,7 +40,7 @@ class OutputConfig : public QWidget
public: public:
explicit OutputConfig(QWidget *parent); explicit OutputConfig(QWidget *parent);
explicit OutputConfig(const KScreen::OutputPtr &output, QWidget *parent = 0); explicit OutputConfig(const KScreen::OutputPtr &output, QWidget *parent = nullptr);
virtual ~OutputConfig(); virtual ~OutputConfig();
virtual void setOutput(const KScreen::OutputPtr &output); virtual void setOutput(const KScreen::OutputPtr &output);
...@@ -63,13 +63,13 @@ class OutputConfig : public QWidget ...@@ -63,13 +63,13 @@ class OutputConfig : public QWidget
virtual void initUi(); virtual void initUi();
protected: protected:
QLabel *mTitle; QLabel *mTitle = nullptr;
KScreen::OutputPtr mOutput; KScreen::OutputPtr mOutput;
QCheckBox *mEnabled; QCheckBox *mEnabled = nullptr;
ResolutionSlider *mResolution; ResolutionSlider *mResolution = nullptr;
QComboBox *mRotation; QComboBox *mRotation = nullptr;
QComboBox *mScale; QComboBox *mScale = nullptr;
QComboBox *mRefreshRate; QComboBox *mRefreshRate = nullptr;
bool mShowScaleOption = false; bool mShowScaleOption = false;
}; };
......
...@@ -28,7 +28,7 @@ class PreviewWidget : public QLabel ...@@ -28,7 +28,7 @@ class PreviewWidget : public QLabel
{ {
Q_OBJECT Q_OBJECT
public: public:
PreviewWidget(QWidget *parent=0); explicit PreviewWidget(QWidget *parent=nullptr);
~PreviewWidget(); ~PreviewWidget();
void setScale(qreal scale); void setScale(qreal scale);
public Q_SLOTS: public Q_SLOTS:
...@@ -36,7 +36,7 @@ public Q_SLOTS: ...@@ -36,7 +36,7 @@ public Q_SLOTS:
private: private:
qreal pointSizeToPixelSize(qreal pointSize) const; qreal pointSizeToPixelSize(qreal pointSize) const;
qreal m_scale; qreal m_scale;
QWidget *m_internalPreview; QWidget *m_internalPreview = nullptr;
}; };
#endif // PREVIEWWIDGET_H #endif // PREVIEWWIDGET_H
...@@ -30,7 +30,7 @@ class PrimaryOutputCombo : public QComboBox ...@@ -30,7 +30,7 @@ class PrimaryOutputCombo : public QComboBox
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit PrimaryOutputCombo(QWidget *parent = 0); explicit PrimaryOutputCombo(QWidget *parent = nullptr);
virtual ~PrimaryOutputCombo(); virtual ~PrimaryOutputCombo();
void setConfig(const KScreen::ConfigPtr &config); void setConfig(const KScreen::ConfigPtr &config);
...@@ -55,4 +55,4 @@ private: ...@@ -55,4 +55,4 @@ private:
KScreen::ConfigPtr mConfig; KScreen::ConfigPtr mConfig;
}; };
#endif #endif
\ No newline at end of file
...@@ -36,7 +36,7 @@ class ResolutionSlider : public QWidget ...@@ -36,7 +36,7 @@ class ResolutionSlider : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit ResolutionSlider(const KScreen::OutputPtr &output, QWidget *parent = 0); explicit ResolutionSlider(const KScreen::OutputPtr &output, QWidget *parent = nullptr);
virtual ~ResolutionSlider(); virtual ~ResolutionSlider();
QSize currentResolution() const; QSize currentResolution() const;
...@@ -53,11 +53,11 @@ class ResolutionSlider : public QWidget ...@@ -53,11 +53,11 @@ class ResolutionSlider : public QWidget
QList<QSize> mModes; QList<QSize> mModes;
QLabel *mSmallestLabel; QLabel *mSmallestLabel = nullptr;
QLabel *mBiggestLabel; QLabel *mBiggestLabel = nullptr;
QLabel *mCurrentLabel; QLabel *mCurrentLabel = nullptr;
QSlider *mSlider; QSlider *mSlider = nullptr;
QComboBox *mComboBox; QComboBox *mComboBox = nullptr;
}; };
#endif // RESOLUTIONSLIDER_H #endif // RESOLUTIONSLIDER_H
...@@ -190,7 +190,7 @@ void Widget::setConfig(const KScreen::ConfigPtr &config) ...@@ -190,7 +190,7 @@ void Widget::setConfig(const KScreen::ConfigPtr &config)
if (qmlOutput) { if (qmlOutput) {
mScreen->setActiveOutput(qmlOutput); mScreen->setActiveOutput(qmlOutput);
} else { } else {
if (mScreen->outputs().count() > 0) { if (!mScreen->outputs().isEmpty()) {
mScreen->setActiveOutput(mScreen->outputs()[0]); mScreen->setActiveOutput(mScreen->outputs()[0]);
} }
} }
......
...@@ -46,7 +46,7 @@ class Widget : public QWidget ...@@ -46,7 +46,7 @@ class Widget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit Widget(QWidget *parent = 0); explicit Widget(QWidget *parent = nullptr);
virtual ~Widget(); virtual ~Widget();
void setConfig(const KScreen::ConfigPtr &config); void setConfig(const KScreen::ConfigPtr &config);
...@@ -80,23 +80,23 @@ class Widget : public QWidget ...@@ -80,23 +80,23 @@ class Widget : public QWidget
KScreen::OutputPtr findOutput(const KScreen::ConfigPtr &config, const QVariantMap &info); KScreen::OutputPtr findOutput(const KScreen::ConfigPtr &config, const QVariantMap &info);
private: private:
QMLScreen *mScreen; QMLScreen *mScreen = nullptr;
KScreen::ConfigPtr mConfig; KScreen::ConfigPtr mConfig;
KScreen::ConfigPtr mPrevConfig; KScreen::ConfigPtr mPrevConfig;
QQuickView *mDeclarativeView; QQuickView *mDeclarativeView = nullptr;
ControlPanel *mControlPanel; ControlPanel *mControlPanel = nullptr;
ProfilesModel *mProfilesModel; ProfilesModel *mProfilesModel = nullptr;
PrimaryOutputCombo *mPrimaryCombo; PrimaryOutputCombo *mPrimaryCombo = nullptr;
QComboBox *mProfilesCombo; QComboBox *mProfilesCombo = nullptr;
QPushButton *mScaleAllOutputsButton; QPushButton *mScaleAllOutputsButton = nullptr;
QPushButton *mUnifyButton; QPushButton *mUnifyButton = nullptr;
QPushButton *mSaveProfileButton; QPushButton *mSaveProfileButton = nullptr;
QList<QQuickView*> mOutputIdentifiers; QList<QQuickView*> mOutputIdentifiers;
QTimer *mOutputTimer; QTimer *mOutputTimer = nullptr;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment