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

Initialize pointer/value. Minor optimization

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