Commit 9c9ffacb authored by Janis Born's avatar Janis Born

fix double deletion of dialog widget

parent 4bb72212
Pipeline #1392 skipped
#include "DidYouKnowPlugin.hh"
DidYouKnowPlugin::DidYouKnowPlugin()
DidYouKnowPlugin::DidYouKnowPlugin() :
mDidYouKnowWidget(new DidYouKnowWidget())
{
}
......@@ -13,9 +14,9 @@ void DidYouKnowPlugin::initializePlugin()
}
void DidYouKnowPlugin::pluginsInitialized() {
mDidYouKnowWidget.show();
mDidYouKnowWidget.raise();
mDidYouKnowWidget.activateWindow();
mDidYouKnowWidget->show();
mDidYouKnowWidget->raise();
mDidYouKnowWidget->activateWindow();
}
#if QT_VERSION < 0x050000
......
......@@ -33,7 +33,7 @@ public slots:
QString version() { return QString("1.0"); }
private:
DidYouKnowWidget mDidYouKnowWidget;
DidYouKnowWidget* mDidYouKnowWidget;
};
#endif //DIDYOUKNOWPLUGIN_HH
......@@ -17,35 +17,43 @@
#include <iostream>
DidYouKnowWidget::DidYouKnowWidget(QWidget* _parent)
DidYouKnowWidget::DidYouKnowWidget(QWidget* _parent) :
QDialog(_parent)
{
setWindowTitle("Tip of the Day");
setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
mVBoxLayoutGlobal = new QVBoxLayout();
mHBoxLayoutBottomRow = new QHBoxLayout();
QSize labelSize(420, 200);
mLabelTip.setText("Did you know...");
mLabelTip.setMinimumSize(labelSize);
mLabelTip.setMaximumSize(labelSize);
mLabelTip.setAlignment(Qt::AlignTop);
mLabelTip.setWordWrap(true);
mLabelTip = new QLabel();
mLabelTip->setText("Did you know...");
mLabelTip->setMinimumSize(labelSize);
mLabelTip->setMaximumSize(labelSize);
mLabelTip->setAlignment(Qt::AlignTop);
mLabelTip->setWordWrap(true);
mCheckBoxShowTipsOnStartup.setText("&Show tips at startup");
mCheckBoxShowTipsOnStartup.setChecked(true);
mCheckBoxShowTipsOnStartup = new QCheckBox();
mCheckBoxShowTipsOnStartup->setText("&Show tips at startup");
mCheckBoxShowTipsOnStartup->setChecked(true);
mPushButtonNextTip.setText("&Tell me more!");
connect(&mPushButtonNextTip, SIGNAL(clicked(bool)), this, SLOT(displayNextTip()));
mPushButtonNextTip = new QPushButton();
mPushButtonNextTip->setText("&Tell me more!");
connect(mPushButtonNextTip, SIGNAL(clicked(bool)), this, SLOT(displayNextTip()));
mPushButtonClose.setText("Thank y&ou!");
connect(&mPushButtonClose, SIGNAL(clicked(bool)), this, SLOT(close()));
mPushButtonClose = new QPushButton();
mPushButtonClose->setText("Thank y&ou!");
connect(mPushButtonClose, SIGNAL(clicked(bool)), this, SLOT(close()));
mHBoxLayoutBottomRow.addWidget(&mCheckBoxShowTipsOnStartup);
mHBoxLayoutBottomRow.addWidget(&mPushButtonNextTip);
mHBoxLayoutBottomRow.addWidget(&mPushButtonClose);
mHBoxLayoutBottomRow->addWidget(mCheckBoxShowTipsOnStartup);
mHBoxLayoutBottomRow->addWidget(mPushButtonNextTip);
mHBoxLayoutBottomRow->addWidget(mPushButtonClose);
mVBoxLayoutGlobal.addWidget(&mLabelTip);
mVBoxLayoutGlobal.addLayout(&mHBoxLayoutBottomRow);
mVBoxLayoutGlobal->addWidget(mLabelTip);
mVBoxLayoutGlobal->addLayout(mHBoxLayoutBottomRow);
setLayout(&mVBoxLayoutGlobal);
setLayout(mVBoxLayoutGlobal);
setFixedSize(sizeHint());
try {
......@@ -131,7 +139,7 @@ void DidYouKnowWidget::displayTip(std::size_t _tipIndex)
text += "<h1><img src=\"" + OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator() + "lightbulb.png\"> Did you know...</h1>";
text += "<hr>";
text += mTips[_tipIndex];
mLabelTip.setText(text);
mLabelTip->setText(text);
}
}
......
......@@ -38,12 +38,12 @@ private:
std::vector<QString> mTips;
std::size_t mCurrentTipIndex;
QVBoxLayout mVBoxLayoutGlobal;
QHBoxLayout mHBoxLayoutBottomRow;
QLabel mLabelTip;
QPushButton mPushButtonNextTip;
QPushButton mPushButtonClose;
QCheckBox mCheckBoxShowTipsOnStartup;
QVBoxLayout* mVBoxLayoutGlobal;
QHBoxLayout* mHBoxLayoutBottomRow;
QLabel* mLabelTip;
QPushButton* mPushButtonNextTip;
QPushButton* mPushButtonClose;
QCheckBox* mCheckBoxShowTipsOnStartup;
};
#endif //DIDYOUKNOWWIDGET_HH
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