some refactoring

update resizing
This commit is contained in:
arcan1s 2015-05-17 14:09:08 +03:00
parent c6cadba4b6
commit 396fa95ec3
5 changed files with 59 additions and 36 deletions

View File

@ -59,6 +59,7 @@ Item {
} }
signal needUpdate signal needUpdate
signal sizeUpdate
// init // init
@ -67,8 +68,7 @@ Item {
Layout.fillWidth: plasmoid.formFactor != PlasmaCore.Planar Layout.fillWidth: plasmoid.formFactor != PlasmaCore.Planar
Layout.fillHeight: plasmoid.formFactor != PlasmaCore.Planar Layout.fillHeight: plasmoid.formFactor != PlasmaCore.Planar
Layout.minimumHeight: plasmoid.configuration.height == 0 ? text.contentHeight : plasmoid.configuration.height Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
Layout.minimumWidth: plasmoid.configuration.width == 0 ? text.contentWidth : plasmoid.configuration.width
Plasmoid.icon: "utilities-system-monitor" Plasmoid.icon: "utilities-system-monitor"
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground" Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
@ -160,7 +160,7 @@ Item {
plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update") plasmoid.setAction("checkUpdates", i18n("Check updates"), "system-software-update")
// plasmoid.setAction("report", i18n("Mail to developers"), "email") // plasmoid.setAction("report", i18n("Mail to developers"), "email")
// init submodule // init submodule
Plasmoid.userConfiguringChanged(true) Plasmoid.userConfiguringChanged(false)
} }
onNeedUpdate: { onNeedUpdate: {
@ -168,13 +168,37 @@ Item {
text.text = AWKeys.parsePattern() text.text = AWKeys.parsePattern()
tooltip.text = AWKeys.toolTipImage() tooltip.text = AWKeys.toolTipImage()
sizeUpdate()
}
onSizeUpdate: {
if (debug) console.log("[main::onSizeUpdate]")
if (plasmoid.configuration.height == 0) {
Layout.minimumHeight = text.contentHeight
Layout.maximumHeight = -1
} else {
Layout.minimumHeight = plasmoid.configuration.height
Layout.maximumHeight = plasmoid.configuration.height
}
if (plasmoid.configuration.width == 0) {
Layout.minimumWidth = text.contentWidth
Layout.maximumWidth = -1
} else {
Layout.minimumWidth = plasmoid.configuration.width
Layout.maximumWidth = plasmoid.configuration.width
}
} }
Plasmoid.onUserConfiguringChanged: { Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.log("[main::onUserConfiguringChanged]") if (debug) console.log("[main::onUserConfiguringChanged]")
// init submodule // init submodule
AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings, plasmoid.configuration.notify) AWKeys.initKeys(plasmoid.configuration.text, tooltipSettings, plasmoid.configuration.notify)
needUpdate()
} }
function action_checkUpdates() { function action_checkUpdates() {

View File

@ -35,7 +35,6 @@ Item {
"tooltipType": plasmoid.configuration.tooltipType, "tooltipType": plasmoid.configuration.tooltipType,
"tooltipWidth": plasmoid.configuration.tooltipWidth "tooltipWidth": plasmoid.configuration.tooltipWidth
} }
property bool initializated: false
signal needUpdate signal needUpdate
signal needTooltipUpdate signal needTooltipUpdate
@ -46,6 +45,8 @@ Item {
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
Plasmoid.compactRepresentation: Plasmoid.fullRepresentation Plasmoid.compactRepresentation: Plasmoid.fullRepresentation
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
Plasmoid.icon: "utilities-system-monitor" Plasmoid.icon: "utilities-system-monitor"
Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground" Plasmoid.backgroundHints: plasmoid.configuration.background ? "DefaultBackground" : "NoBackground"
@ -127,7 +128,7 @@ Item {
repeater.itemAt(i).update() repeater.itemAt(i).update()
} }
if (!initializated) sizeUpdate() sizeUpdate()
needTooltipUpdate() needTooltipUpdate()
} }
@ -142,14 +143,26 @@ Item {
onSizeUpdate: { onSizeUpdate: {
if (debug) console.log("[main::onSizeUpdate]") if (debug) console.log("[main::onSizeUpdate]")
var newHeight = 0 if (plasmoid.configuration.height == 0) {
var newWidth = 0 var newHeight = 0
for (var i=0; i<repeater.count; i++) { for (var i=0; i<repeater.count; i++)
newHeight += plasmoid.configuration.height == 0 ? repeater.itemAt(i).contentHeight : plasmoid.configuration.height / repeater.count newHeight += repeater.itemAt(i).contentHeight
newWidth += plasmoid.configuration.width == 0 ? repeater.itemAt(i).contentWidth : plasmoid.configuration.width / repeater.count Layout.minimumHeight = newHeight
Layout.maximumHeight = -1
} else {
Layout.minimumHeight = plasmoid.configuration.height
Layout.maximumHeight = plasmoid.configuration.height
}
if (plasmoid.configuration.width == 0) {
var newWidth = 0
for (var i=0; i<repeater.count; i++)
newWidth += repeater.itemAt(i).contentWidth
Layout.minimumWidth = newWidth
Layout.maximumWidth = -1
} else {
Layout.minimumWidth = plasmoid.configuration.width
Layout.maximumWidth = plasmoid.configuration.width
} }
Layout.minimumHeight = newHeight
Layout.minimumWidth = newWidth
} }
Plasmoid.onActivated: { Plasmoid.onActivated: {
@ -159,22 +172,21 @@ Item {
} }
Plasmoid.onUserConfiguringChanged: { Plasmoid.onUserConfiguringChanged: {
if (plasmoid.userConfiguring) return
if (debug) console.log("[main::onUserConfiguringChanged]") if (debug) console.log("[main::onUserConfiguringChanged]")
initializated = false
DPAdds.setMark(plasmoid.configuration.mark) DPAdds.setMark(plasmoid.configuration.mark)
DPAdds.setPanelsToControl(plasmoid.configuration.panels) DPAdds.setPanelsToControl(plasmoid.configuration.panels)
DPAdds.setToolTipData(tooltipSettings) DPAdds.setToolTipData(tooltipSettings)
needUpdate() needUpdate()
initializated = true
} }
Component.onCompleted: { Component.onCompleted: {
if (debug) console.log("[main::onCompleted]") if (debug) console.log("[main::onCompleted]")
// init submodule // init submodule
Plasmoid.userConfiguringChanged(true) Plasmoid.userConfiguringChanged(false)
DPAdds.desktopChanged.connect(needUpdate) DPAdds.desktopChanged.connect(needUpdate)
DPAdds.windowListChanged.connect(needTooltipUpdate) DPAdds.windowListChanged.connect(needTooltipUpdate)
} }

View File

@ -256,10 +256,7 @@ int ExtQuotes::showConfiguration()
ui->lineEdit_comment->setText(m_comment); ui->lineEdit_comment->setText(m_comment);
ui->label_numberValue->setText(QString("%1").arg(m_number)); ui->label_numberValue->setText(QString("%1").arg(m_number));
ui->lineEdit_ticker->setText(m_ticker); ui->lineEdit_ticker->setText(m_ticker);
if (m_active) ui->checkBox_active->setCheckState(m_active ? Qt::Checked : Qt::Unchecked);
ui->checkBox_active->setCheckState(Qt::Checked);
else
ui->checkBox_active->setCheckState(Qt::Unchecked);
ui->spinBox_interval->setValue(m_interval); ui->spinBox_interval->setValue(m_interval);
int ret = exec(); int ret = exec();

View File

@ -320,14 +320,12 @@ QString ExtScript::run()
if (times == 1) { if (times == 1) {
QStringList cmdList; QStringList cmdList;
if (!m_prefix.isEmpty()) if (!m_prefix.isEmpty()) cmdList.append(m_prefix);
cmdList.append(m_prefix);
cmdList.append(m_executable); cmdList.append(m_executable);
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmdList.join(QChar(' ')); if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmdList.join(QChar(' '));
TaskResult process = runTask(cmdList.join(QChar(' '))); TaskResult process = runTask(cmdList.join(QChar(' ')));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode; if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0) if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString info = QString("%1 : %2").arg(process.exitCode) QString info = QString("%1 : %2").arg(process.exitCode)
.arg(QTextCodec::codecForMib(106)->toUnicode(process.error).trimmed()); .arg(QTextCodec::codecForMib(106)->toUnicode(process.error).trimmed());
@ -340,6 +338,7 @@ QString ExtScript::run()
case stderr2stdout: case stderr2stdout:
value = QString("%1\t%2").arg(info).arg(qoutput); value = QString("%1\t%2").arg(info).arg(qoutput);
break; break;
case nothing:
default: default:
if (debug) qDebug() << PDEBUG << ":" << "Debug" << info; if (debug) qDebug() << PDEBUG << ":" << "Debug" << info;
value = qoutput; value = qoutput;
@ -364,14 +363,8 @@ int ExtScript::showConfiguration()
ui->label_numberValue->setText(QString("%1").arg(m_number)); ui->label_numberValue->setText(QString("%1").arg(m_number));
ui->lineEdit_command->setText(m_executable); ui->lineEdit_command->setText(m_executable);
ui->lineEdit_prefix->setText(m_prefix); ui->lineEdit_prefix->setText(m_prefix);
if (m_active) ui->checkBox_active->setCheckState(m_active ? Qt::Checked : Qt::Unchecked);
ui->checkBox_active->setCheckState(Qt::Checked); ui->checkBox_output->setCheckState(m_output ? Qt::Checked : Qt::Unchecked);
else
ui->checkBox_active->setCheckState(Qt::Unchecked);
if (m_output)
ui->checkBox_output->setCheckState(Qt::Checked);
else
ui->checkBox_output->setCheckState(Qt::Unchecked);
ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect)); ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
ui->spinBox_interval->setValue(m_interval); ui->spinBox_interval->setValue(m_interval);
@ -423,7 +416,7 @@ void ExtScript::writeConfiguration()
settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion); settings.setValue(QString("X-AW-ApiVersion"), m_apiVersion);
settings.setValue(QString("X-AW-Prefix"), m_prefix); settings.setValue(QString("X-AW-Prefix"), m_prefix);
settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString()); settings.setValue(QString("X-AW-Active"), QVariant(m_active).toString());
settings.setValue(QString("X-AW-Output"), QVariant(m_active).toString()); settings.setValue(QString("X-AW-Output"), QVariant(m_output).toString());
settings.setValue(QString("X-AW-Redirect"), strRedirect()); settings.setValue(QString("X-AW-Redirect"), strRedirect());
settings.setValue(QString("X-AW-Interval"), m_interval); settings.setValue(QString("X-AW-Interval"), m_interval);
settings.setValue(QString("X-AW-Number"), m_number); settings.setValue(QString("X-AW-Number"), m_number);

View File

@ -270,10 +270,7 @@ int ExtUpgrade::showConfiguration()
ui->lineEdit_comment->setText(m_comment); ui->lineEdit_comment->setText(m_comment);
ui->label_numberValue->setText(QString("%1").arg(m_number)); ui->label_numberValue->setText(QString("%1").arg(m_number));
ui->lineEdit_command->setText(m_executable); ui->lineEdit_command->setText(m_executable);
if (m_active) ui->checkBox_active->setCheckState(m_active ? Qt::Checked : Qt::Unchecked);
ui->checkBox_active->setCheckState(Qt::Checked);
else
ui->checkBox_active->setCheckState(Qt::Unchecked);
ui->spinBox_null->setValue(m_null); ui->spinBox_null->setValue(m_null);
ui->spinBox_interval->setValue(m_interval); ui->spinBox_interval->setValue(m_interval);