Merge branch 'KDE/4.8'
Conflicts: kwin/tabbox/tabboxhandler.cpp
This commit is contained in:
commit
9e943bf39e
1 changed files with 137 additions and 0 deletions
|
@ -192,6 +192,143 @@ void TabBoxHandlerPrivate::endHighlightWindows(bool abort)
|
||||||
XDeleteProperty(dpy, config.isShowTabBox() && m_declarativeView ? m_declarativeView->winId() : QX11Info::appRootWindow(), atom);
|
XDeleteProperty(dpy, config.isShowTabBox() && m_declarativeView ? m_declarativeView->winId() : QX11Info::appRootWindow(), atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***********************************************************
|
||||||
|
* Based on the implementation of Kopete's
|
||||||
|
* contaclistlayoutmanager.cpp by Nikolaj Hald Nielsen and
|
||||||
|
* Roman Jarosz
|
||||||
|
***********************************************************/
|
||||||
|
void TabBoxHandlerPrivate::parseConfig(const QString& fileName)
|
||||||
|
{
|
||||||
|
// open the file
|
||||||
|
if (!QFile::exists(fileName)) {
|
||||||
|
kDebug(1212) << "File " << fileName << " does not exist";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QDomDocument doc("Layouts");
|
||||||
|
QFile file(fileName);
|
||||||
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
|
kDebug(1212) << "Error reading file " << fileName;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!doc.setContent(&file)) {
|
||||||
|
kDebug(1212) << "Error parsing file " << fileName;
|
||||||
|
file.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
QDomElement layouts_element = doc.firstChildElement("tabbox_layouts");
|
||||||
|
QDomNodeList layouts = layouts_element.elementsByTagName("layout");
|
||||||
|
|
||||||
|
for (int i = 0; i < layouts.size(); i++) {
|
||||||
|
QDomNode layout = layouts.item(i);
|
||||||
|
ItemLayoutConfig currentLayout;
|
||||||
|
|
||||||
|
// parse top elements
|
||||||
|
QDomElement element = layout.toElement();
|
||||||
|
QString layoutName = element.attribute("name", "");
|
||||||
|
|
||||||
|
const bool highlightIcon = (element.attribute("highlight_selected_icon", "true").compare("true", Qt::CaseInsensitive) == 0);
|
||||||
|
currentLayout.setHighlightSelectedIcons(highlightIcon);
|
||||||
|
|
||||||
|
const bool grayscaleIcon = (element.attribute("grayscale_deselected_icon", "false").compare("true", Qt::CaseInsensitive) == 0);
|
||||||
|
currentLayout.setGrayscaleDeselectedIcons(grayscaleIcon);
|
||||||
|
|
||||||
|
// rows
|
||||||
|
QDomNodeList rows = element.elementsByTagName("row");
|
||||||
|
for (int j = 0; j < rows.size(); j++) {
|
||||||
|
QDomNode rowNode = rows.item(j);
|
||||||
|
|
||||||
|
ItemLayoutConfigRow row;
|
||||||
|
|
||||||
|
QDomNodeList elements = rowNode.toElement().elementsByTagName("element");
|
||||||
|
for (int k = 0; k < elements.size(); k++) {
|
||||||
|
QDomNode elementNode = elements.item(k);
|
||||||
|
QDomElement currentElement = elementNode.toElement();
|
||||||
|
|
||||||
|
ItemLayoutConfigRowElement::ElementType type = ItemLayoutConfigRowElement::ElementType(currentElement.attribute(
|
||||||
|
"type", int(ItemLayoutConfigRowElement::ElementClientName)).toInt());
|
||||||
|
ItemLayoutConfigRowElement currentRowElement;
|
||||||
|
currentRowElement.setType(type);
|
||||||
|
|
||||||
|
// width - used by all types
|
||||||
|
qreal width = currentElement.attribute("width", "0.0").toDouble();
|
||||||
|
currentRowElement.setWidth(width);
|
||||||
|
switch(type) {
|
||||||
|
case ItemLayoutConfigRowElement::ElementEmpty:
|
||||||
|
row.addElement(currentRowElement);
|
||||||
|
break;
|
||||||
|
case ItemLayoutConfigRowElement::ElementIcon: {
|
||||||
|
qreal iconWidth = currentElement.attribute("icon_size", "16.0").toDouble();
|
||||||
|
currentRowElement.setIconSize(QSizeF(iconWidth, iconWidth));
|
||||||
|
currentRowElement.setRowSpan(currentElement.attribute("row_span", "true").compare(
|
||||||
|
"true", Qt::CaseInsensitive) == 0);
|
||||||
|
row.addElement(currentRowElement);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ItemLayoutConfigRowElement::ElementClientList: {
|
||||||
|
currentRowElement.setStretch(currentElement.attribute("stretch", "false").compare(
|
||||||
|
"true", Qt::CaseInsensitive) == 0);
|
||||||
|
currentRowElement.setClientListLayoutName(currentElement.attribute("layout_name", ""));
|
||||||
|
QString layoutMode = currentElement.attribute("layout_mode", "horizontal");
|
||||||
|
if (layoutMode.compare("horizontal", Qt::CaseInsensitive) == 0)
|
||||||
|
currentRowElement.setClientListLayoutMode(TabBoxConfig::HorizontalLayout);
|
||||||
|
else if (layoutMode.compare("vertical", Qt::CaseInsensitive) == 0)
|
||||||
|
currentRowElement.setClientListLayoutMode(TabBoxConfig::VerticalLayout);
|
||||||
|
else if (layoutMode.compare("tabular", Qt::CaseInsensitive) == 0)
|
||||||
|
currentRowElement.setClientListLayoutMode(TabBoxConfig::HorizontalVerticalLayout);
|
||||||
|
row.addElement(currentRowElement);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: { // text elements
|
||||||
|
currentRowElement.setStretch(currentElement.attribute("stretch", "false").compare(
|
||||||
|
"true", Qt::CaseInsensitive) == 0);
|
||||||
|
currentRowElement.setSmallTextSize(currentElement.attribute("small", "false").compare(
|
||||||
|
"true", Qt::CaseInsensitive) == 0);
|
||||||
|
currentRowElement.setBold(currentElement.attribute("bold", "false").compare(
|
||||||
|
"true", Qt::CaseInsensitive) == 0);
|
||||||
|
currentRowElement.setItalic(currentElement.attribute("italic", "false").compare(
|
||||||
|
"true", Qt::CaseInsensitive) == 0);
|
||||||
|
currentRowElement.setItalicMinimized(currentElement.attribute("italic_minimized", "true").compare(
|
||||||
|
"true", Qt::CaseInsensitive) == 0);
|
||||||
|
|
||||||
|
currentRowElement.setPrefix(currentElement.attribute("prefix", ""));
|
||||||
|
currentRowElement.setSuffix(currentElement.attribute("suffix", ""));
|
||||||
|
currentRowElement.setPrefixMinimized(currentElement.attribute("prefix_minimized", ""));
|
||||||
|
currentRowElement.setSuffixMinimzed(currentElement.attribute("suffix_minimized", ""));
|
||||||
|
|
||||||
|
QString halign = currentElement.attribute("horizontal_alignment", "left");
|
||||||
|
Qt::Alignment alignment;
|
||||||
|
if (halign.compare("left", Qt::CaseInsensitive) == 0)
|
||||||
|
alignment = Qt::AlignLeft;
|
||||||
|
else if (halign.compare("right", Qt::CaseInsensitive) == 0)
|
||||||
|
alignment = Qt::AlignRight;
|
||||||
|
else
|
||||||
|
alignment = Qt::AlignCenter;
|
||||||
|
QString valign = currentElement.attribute("vertical_alignment", "center");
|
||||||
|
if (valign.compare("top", Qt::CaseInsensitive) == 0)
|
||||||
|
alignment = alignment | Qt::AlignTop;
|
||||||
|
else if (valign.compare("bottom", Qt::CaseInsensitive) == 0)
|
||||||
|
alignment = alignment | Qt::AlignBottom;
|
||||||
|
else
|
||||||
|
alignment = alignment | Qt::AlignVCenter;
|
||||||
|
currentRowElement.setAlignment(alignment);
|
||||||
|
|
||||||
|
row.addElement(currentRowElement);
|
||||||
|
break;
|
||||||
|
}// case default
|
||||||
|
} // switch type
|
||||||
|
} // for loop elements
|
||||||
|
|
||||||
|
currentLayout.addRow(row);
|
||||||
|
} // for loop rows
|
||||||
|
if (!layoutName.isEmpty()) {
|
||||||
|
tabBoxLayouts.insert(layoutName, currentLayout);
|
||||||
|
}
|
||||||
|
} // for loop layouts
|
||||||
|
>>>>>>> KDE/4.8
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************
|
/***********************************************
|
||||||
* TabBoxHandler
|
* TabBoxHandler
|
||||||
***********************************************/
|
***********************************************/
|
||||||
|
|
Loading…
Reference in a new issue