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

View File

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

View File

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

View File

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

View File

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