change layout to gridlayout

remove deprecated functions
This commit is contained in:
arcan1s 2014-09-08 00:36:55 +04:00
parent f91c80b5b1
commit ce761db924
5 changed files with 7 additions and 74 deletions

View File

@ -43,7 +43,7 @@
<x>0</x>
<y>0</y>
<width>677</width>
<height>665</height>
<height>590</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
@ -54,13 +54,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_layout">
<property name="text">
<string>Vertical layout</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_popup">
<property name="text">
@ -68,20 +61,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_leftStretch">
<property name="text">
<string>Add stretch to left/top of the layout</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_rightStretch">
<property name="text">
<string>Add stretch to right/bottom of the layout</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeFormat">
<item>

View File

@ -21,7 +21,7 @@
#include <Plasma/ToolTipManager>
#include <QDesktopServices>
#include <QDir>
#include <QGraphicsLinearLayout>
#include <QGraphicsGridLayout>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QNetworkInterface>
@ -194,12 +194,11 @@ void AwesomeWidget::init()
// body
createActions();
mainLayout = new QGraphicsLinearLayout();
mainLayout = new QGraphicsGridLayout();
mainLayout->setContentsMargins(1, 1, 1, 1);
mainLayout->setOrientation(Qt::Horizontal);
setLayout(mainLayout);
textLabel = new CustomLabel(this, debug);
textLabel->setWordWrap(false);
mainLayout->addItem(textLabel, 0, 0);
// read variables
configChanged();

View File

@ -31,7 +31,7 @@
class CustomLabel;
class QGraphicsLinearLayout;
class QGraphicsGridLayout;
class QGraphicsScene;
class AwesomeWidget : public Plasma::Applet
@ -90,11 +90,10 @@ protected:
private:
// functions
void createActions();
void initValues();
QStringList findKeys();
QStringList getKeys();
// ui
QGraphicsLinearLayout *mainLayout = nullptr;
QGraphicsGridLayout *mainLayout = nullptr;
CustomLabel *textLabel = nullptr;
QTimer *timer;
QList<QAction *> contextMenu;

View File

@ -150,22 +150,10 @@ void AwesomeWidget::createConfigurationInterface(KConfigDialog *parent)
uiAdvancedConfig.checkBox_background->setCheckState(Qt::Unchecked);
else
uiAdvancedConfig.checkBox_background->setCheckState(Qt::Checked);
if (configuration[QString("layout")].toInt() == 0)
uiAdvancedConfig.checkBox_layout->setCheckState(Qt::Unchecked);
else
uiAdvancedConfig.checkBox_layout->setCheckState(Qt::Checked);
if (configuration[QString("popup")].toInt() == 0)
uiAdvancedConfig.checkBox_popup->setCheckState(Qt::Unchecked);
else
uiAdvancedConfig.checkBox_popup->setCheckState(Qt::Checked);
if (configuration[QString("leftStretch")].toInt() == 0)
uiAdvancedConfig.checkBox_leftStretch->setCheckState(Qt::Unchecked);
else
uiAdvancedConfig.checkBox_leftStretch->setCheckState(Qt::Checked);
if (configuration[QString("rightStretch")].toInt() == 0)
uiAdvancedConfig.checkBox_rightStretch->setCheckState(Qt::Unchecked);
else
uiAdvancedConfig.checkBox_rightStretch->setCheckState(Qt::Checked);
uiAdvancedConfig.lineEdit_timeFormat->setText(configuration[QString("customTime")]);
uiAdvancedConfig.lineEdit_uptimeFormat->setText(configuration[QString("customUptime")]);
uiAdvancedConfig.comboBox_tempUnits->setCurrentIndex(
@ -422,10 +410,7 @@ void AwesomeWidget::configAccepted()
// advanced
cg.writeEntry("background", QString::number(uiAdvancedConfig.checkBox_background->checkState()));
cg.writeEntry("layout", QString::number(uiAdvancedConfig.checkBox_layout->checkState()));
cg.writeEntry("popup", QString::number(uiAdvancedConfig.checkBox_popup->checkState()));
cg.writeEntry("leftStretch", QString::number(uiAdvancedConfig.checkBox_leftStretch->checkState()));
cg.writeEntry("rightStretch", QString::number(uiAdvancedConfig.checkBox_rightStretch->checkState()));
cg.writeEntry("customTime", uiAdvancedConfig.lineEdit_timeFormat->text());
cg.writeEntry("customUptime", uiAdvancedConfig.lineEdit_uptimeFormat->text());
cg.writeEntry("tempUnits", uiAdvancedConfig.comboBox_tempUnits->currentText());
@ -523,10 +508,7 @@ void AwesomeWidget::configChanged()
// advanced
configuration[QString("background")] = cg.readEntry("background", "2");
configuration[QString("layout")] = cg.readEntry("layout", "2");
configuration[QString("popup")] = cg.readEntry("popup", "2");
configuration[QString("leftStretch")] = cg.readEntry("leftStretch", "2");
configuration[QString("rightStretch")] = cg.readEntry("rightStretch", "2");
configuration[QString("customTime")] = cg.readEntry("customTime", "$hh:$mm");
configuration[QString("customUptime")] = cg.readEntry("customUptime", "$dd,$hh,$mm");
configuration[QString("tempUnits")] = cg.readEntry("tempUnits", "Celsius");

View File

@ -19,7 +19,7 @@
#include <KNotification>
#include <Plasma/ToolTipManager>
#include <QGraphicsLinearLayout>
#include <QGraphicsGridLayout>
#include <QGraphicsView>
#include <math.h>
@ -27,48 +27,22 @@
#include <pdebug/pdebug.h>
void AwesomeWidget::initValues()
{
if (debug) qDebug() << PDEBUG;
}
void AwesomeWidget::reinit()
{
if (debug) qDebug() << PDEBUG;
mainLayout->removeItem(textLabel);
if (textLabel != nullptr) delete textLabel;
setLayout(0);
mainLayout = new QGraphicsLinearLayout();
mainLayout->setContentsMargins(1, 1, 1, 1);
if (configuration[QString("layout")].toInt() == 0)
mainLayout->setOrientation(Qt::Horizontal);
else
mainLayout->setOrientation(Qt::Vertical);
setLayout(mainLayout);
if (configuration[QString("background")].toInt() == 0)
setBackgroundHints(NoBackground);
else
setBackgroundHints(DefaultBackground);
if (configuration[QString("leftStretch")].toInt() == 2)
mainLayout->addStretch(1);
textLabel = new CustomLabel(this, debug);
if (configuration[QString("popup")].toInt() == 0)
textLabel->setPopupEnabled(false);
else
textLabel->setPopupEnabled(true);
mainLayout->addItem(textLabel);
updateText(true);
if (configuration[QString("rightStretch")].toInt() == 2)
mainLayout->addStretch(1);
resize(10, 10);
keys = getKeys();
foundKeys = findKeys();
initValues();
updateNetworkDevice();
connectToEngine();
}