All public files has lxqt prefix
authorAlexander Sokolov <sokoloff.a@gmail.com>
Sun, 6 Oct 2013 15:08:20 +0000 (19:08 +0400)
committerAlexander Sokolov <sokoloff.a@gmail.com>
Sun, 6 Oct 2013 15:08:20 +0000 (19:08 +0400)
43 files changed:
CMakeLists.txt
aboutdialog/LxQtAboutDialog [deleted file]
aboutdialog/lxqtaboutdialog.cpp
addplugindialog/addplugindialog.cpp [deleted file]
addplugindialog/addplugindialog.h [deleted file]
addplugindialog/addplugindialog.ui [deleted file]
addplugindialog/lxqtaddplugindialog.cpp [new file with mode: 0644]
addplugindialog/lxqtaddplugindialog.h [new file with mode: 0644]
addplugindialog/lxqtaddplugindialog.ui [new file with mode: 0644]
cmake/create_portable_headers.cmake [new file with mode: 0644]
configdialog/configdialog.cpp [deleted file]
configdialog/configdialog.h [deleted file]
configdialog/configdialog.ui [deleted file]
configdialog/lxqtconfigdialog.cpp [new file with mode: 0644]
configdialog/lxqtconfigdialog.h [new file with mode: 0644]
configdialog/lxqtconfigdialog.ui [new file with mode: 0644]
configdialog/lxqtpageselectwidget.cpp [new file with mode: 0644]
configdialog/lxqtpageselectwidget.h [new file with mode: 0644]
configdialog/pageselectwidget.cpp [deleted file]
configdialog/pageselectwidget.h [deleted file]
libtranslate.h [deleted file]
lxqtlibtranslate.h [new file with mode: 0644]
lxqtpowermanager.cpp [new file with mode: 0644]
lxqtpowermanager.h [new file with mode: 0644]
lxqtprogramfinder.cpp [new file with mode: 0644]
lxqtprogramfinder.h [new file with mode: 0644]
lxqtrotatedwidget.cpp [new file with mode: 0644]
lxqtrotatedwidget.h [new file with mode: 0644]
lxqtscreensaver.cpp [new file with mode: 0644]
lxqtscreensaver.h [new file with mode: 0644]
lxqtxfitman.cpp [new file with mode: 0644]
lxqtxfitman.h [new file with mode: 0644]
powermanager.cpp [deleted file]
powermanager.h [deleted file]
programfinder.cpp [deleted file]
programfinder.h [deleted file]
razorshortcutbutton_p.h [deleted file]
rotatedwidget.cpp [deleted file]
rotatedwidget.h [deleted file]
screensaver.cpp [deleted file]
screensaver.h [deleted file]
xfitman.cpp [deleted file]
xfitman.h [deleted file]

index d8652db..38442fe 100644 (file)
@@ -10,50 +10,67 @@ set(LXQT_PATCH_VERSION 0)
 set(PUB_HDRS
     aboutdialog/lxqtaboutdialog.h
     lxqtsettings.h
-    xfitman.h
+    lxqtxfitman.h
     lxqtplugininfo.h
-    powermanager.h
-    addplugindialog/addplugindialog.h
-    screensaver.h
+    lxqtpowermanager.h
+    addplugindialog/lxqtaddplugindialog.h
+    lxqtscreensaver.h
     lxqtapplication.h
-    libtranslate.h
-    programfinder.h
+    lxqtlibtranslate.h
+    lxqtprogramfinder.h
 
-    configdialog/configdialog.h
-    configdialog/pageselectwidget.h
+    configdialog/lxqtconfigdialog.h
+    configdialog/lxqtpageselectwidget.h
 
     lxqtpower/lxqtpower.h
     lxqtnotification.h
     lxqtautostartentry.h
-    translatorsinfo/translatorsinfo.h
     lxqtgridlayout.h
-    rotatedwidget.h
+    lxqtrotatedwidget.h
 )
 
-set(PUB_LINKS
-
-    aboutdialog/LxQtAboutDialog
+set(PUBLIC_CLASSES
+    LxQtAboutDialog
+    LxQtSettings
+    LxQtXfitMan
+    LxQtPluginInfo
+    LxQtPowerManager
+    LxQtAddPluginDialog
+    LxQtScreenSaver
+    LxQtApplication
+    LxQtLibTranslate
+    LxQtProgramFinder
+
+    LxQtConfigDialog
+    LxQtPageSelectWidget
+
+    LxQtPower
+    LxQtNotification
+    LxQtAutostartEntry
+    LxQtGridLayout
+    LxQtRotatedWidget
 )
 
 set(PRIV_HDRS
     aboutdialog/lxqtaboutdialog_p.h
     aboutdialog/technicalinfo.h
+    translatorsinfo/translatorsinfo.h
 )
 
 set(SRCS
     aboutdialog/lxqtaboutdialog.cpp
     aboutdialog/technicalinfo.cpp
-    xfitman.cpp
+    lxqtxfitman.cpp
     lxqtplugininfo.cpp
-    powermanager.cpp
-    addplugindialog/addplugindialog.cpp
+    lxqtpowermanager.cpp
+    addplugindialog/lxqtaddplugindialog.cpp
     lxqtsettings.cpp
-    screensaver.cpp
+    lxqtscreensaver.cpp
     lxqtapplication.cpp
-    programfinder.cpp
+    lxqtprogramfinder.cpp
 
-    configdialog/configdialog.cpp
-    configdialog/pageselectwidget.cpp
+    configdialog/lxqtconfigdialog.cpp
+    configdialog/lxqtpageselectwidget.cpp
 
     lxqtpower/lxqtpower.cpp
     lxqtpower/lxqtpowerproviders.cpp
@@ -61,37 +78,39 @@ set(SRCS
     lxqtautostartentry.cpp
     translatorsinfo/translatorsinfo.cpp
     lxqtgridlayout.cpp
-    rotatedwidget.cpp
+    lxqtrotatedwidget.cpp
 )
 
 set(MOCS
     aboutdialog/lxqtaboutdialog.h
     aboutdialog/lxqtaboutdialog_p.h
-    powermanager.h
-    addplugindialog/addplugindialog.h
+    lxqtpowermanager.h
+    addplugindialog/lxqtaddplugindialog.h
     lxqtsettings.h
-    screensaver.h
+    lxqtscreensaver.h
     lxqtapplication.h
 
-    configdialog/configdialog.h
-    configdialog/pageselectwidget.h
+    configdialog/lxqtconfigdialog.h
+    configdialog/lxqtpageselectwidget.h
 
     lxqtnotification.h
     lxqtnotification_p.h
     lxqtpower/lxqtpower.h
     lxqtpower/lxqtpowerproviders.h
     lxqtgridlayout.h
-    rotatedwidget.h
+    lxqtrotatedwidget.h
 )
 
 set(FORMS
     aboutdialog/lxqtaboutdialog.ui
 
-    configdialog/configdialog.ui
+    configdialog/lxqtconfigdialog.ui
 
-    addplugindialog/addplugindialog.ui
+    addplugindialog/lxqtaddplugindialog.ui
 )
 
+# additional cmake files
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
 
 find_package(Qt4 REQUIRED QUIET)
 include(${QT_USE_FILE})
@@ -157,6 +176,10 @@ razor_translate_ts(QM_FILES
 
 #************************************************
 
+# create the portable headers *******************
+include(create_portable_headers)
+create_portable_headers(PORTABLE_HEADERS ${PUBLIC_CLASSES})
+#************************************************
 
 QT4_WRAP_CPP(MOCS ${MOCS})
 QT4_WRAP_UI(UIS ${FORMS})
@@ -188,7 +211,7 @@ set_target_properties(lxqt PROPERTIES
 
 install(TARGETS lxqt DESTINATION lib${LIB_SUFFIX})
 install(FILES ${PUB_HDRS}  DESTINATION ${LXQT_INCLUDE_DIR})
-install(FILES ${PUB_LINKS} DESTINATION ${LXQT_INCLUDE_DIR})
+install(FILES ${PORTABLE_HEADERS} DESTINATION ${LXQT_INCLUDE_DIR})
 
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lxqt-config.cmake DESTINATION share/cmake/lxqt)
 install(FILES cmake/lxqt_use.cmake DESTINATION share/cmake/lxqt)
diff --git a/aboutdialog/LxQtAboutDialog b/aboutdialog/LxQtAboutDialog
deleted file mode 100644 (file)
index 853aca5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "razoraboutdlg.h"
index e0b9d70..a2df7ea 100644 (file)
@@ -28,7 +28,7 @@
 #include "lxqtaboutdialog.h"
 #include "ui_lxqtaboutdialog.h"
 #include "lxqtaboutdialog_p.h"
-#include "libtranslate.h"
+#include "lxqtlibtranslate.h"
 #include "technicalinfo.h"
 #include "translatorsinfo/translatorsinfo.h"
 #include <QDebug>
diff --git a/addplugindialog/addplugindialog.cpp b/addplugindialog/addplugindialog.cpp
deleted file mode 100644 (file)
index aaaacfb..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Alexander Sokoloff <sokoloff.a@gmail.com>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-
-#include "addplugindialog.h"
-#include "ui_addplugindialog.h"
-#include <qtxdg/xdgicon.h>
-#include <QtGui/QListWidgetItem>
-#include <QtGui/QItemDelegate>
-#include <QtGui/QTextDocument>
-#include <QStyledItemDelegate>
-#include <QtGui/QIcon>
-#include <QPainter>
-#include <QDebug>
-#include <QTextBrowser>
-#include <QAbstractTextDocumentLayout>
-
-#include <QLineEdit>
-#include "libtranslate.h"
-
-using namespace LxQt;
-
-#define SEARCH_ROLE  Qt::UserRole
-#define INDEX_ROLE   SEARCH_ROLE+1
-
-class HtmlDelegate : public QStyledItemDelegate
-{
-public:
-    HtmlDelegate(const QSize iconSize, QObject* parent = 0):
-        QStyledItemDelegate(parent),
-        mIconSize(iconSize)
-    {}
-    void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
-    virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
-private:
-    QSize mIconSize;
-};
-
-
-/************************************************
-
- ************************************************/
-void HtmlDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
-{
-    if (!index.isValid())
-        return;
-
-    QStyleOptionViewItemV4 options = option;
-    initStyleOption(&options, index);
-
-    painter->save();
-
-    QTextDocument doc;
-    doc.setHtml(options.text);
-    QIcon icon = options.icon;
-
-    options.text = "";
-    options.icon = QIcon();
-    options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
-
-    // Draw icon ................................
-    QSize iconSize = icon.actualSize(mIconSize);
-    painter->translate(options.rect.left(), options.rect.top());
-    QRect iconRect = QRect(4, 4, iconSize.width(), iconSize.height());
-
-    icon.paint(painter, iconRect);
-
-    doc.setTextWidth(options.rect.width() - iconRect.right() - 10);
-
-    // shift text right to make icon visible
-    painter->translate(iconRect.right() + 8, 0);
-    QRect clip(0, 0, options.rect.width()-iconRect.right()- 10, options.rect.height());
-
-
-    painter->setClipRect(clip);
-    QAbstractTextDocumentLayout::PaintContext ctx;
-    // set text color to red for selected item
-    if (option.state & QStyle::State_Selected)
-    {
-        ctx.palette.setColor(QPalette::Text, option.palette.color(QPalette::HighlightedText));
-    }
-    ctx.clip = clip;
-    doc.documentLayout()->draw(painter, ctx);
-
-    painter->restore();
-}
-
-
-/************************************************
-
- ************************************************/
-QSize HtmlDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
-{
-    QStyleOptionViewItemV4 options = option;
-    initStyleOption(&options, index);
-
-    QSize iconSize = QIcon().actualSize(mIconSize);
-    QRect iconRect = QRect(4, 4, iconSize.width(), iconSize.height());
-
-    QTextDocument doc;
-    doc.setHtml(options.text);
-    doc.setTextWidth(options.rect.width()-iconRect.right()- 10);
-    return QSize(doc.idealWidth(), doc.size().height() + 8);
-}
-
-
-/************************************************
-
- ************************************************/
-bool pluginDescriptionLessThan(const PluginInfo &p1, const PluginInfo &p2)
-{
-    int cmp = QString::compare(p1.name(), p2.name());
-    if (cmp != 0)
-        return cmp < 0;
-
-    return p1.comment() < p2.comment();
-}
-
-
-/************************************************
-
- ************************************************/
-AddPluginDialog::AddPluginDialog(const QStringList& desktopFilesDirs,
-                                 const QString &serviceType,
-                                 const QString &nameFilter,
-                                 QWidget *parent):
-    QDialog(parent),
-    ui(new Ui::AddPluginDialog),
-    mTimerId(0)
-{
-    libTranslate("librazorqt");
-    ui->setupUi(this);
-
-    mPlugins = PluginInfo::search(desktopFilesDirs, serviceType, nameFilter);
-    qSort(mPlugins.begin(), mPlugins.end(), pluginDescriptionLessThan);
-    
-    ui->pluginList->setItemDelegate(new HtmlDelegate(QSize(32, 32), ui->pluginList));
-
-    init();
-    
-    connect(ui->pluginList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(emitPluginSelected()));
-    connect(ui->pluginList, SIGNAL(itemSelectionChanged()), this, SLOT(toggleAddButtonState()));
-    connect(ui->searchEdit, SIGNAL(textEdited(QString)), this, SLOT(searchEditTexChanged(QString)));
-    connect(ui->addButton, SIGNAL(clicked(bool)), this, SLOT(emitPluginSelected()));
-}
-
-void AddPluginDialog::setPluginsInUse(const PluginInfoList pluginsInUse)
-{
-    mPluginsInUse = pluginsInUse;
-    init();
-}
-
-void AddPluginDialog::init()
-{
-    QListWidget* pluginList = ui->pluginList;
-    
-    pluginList->clear();
-
-    QIcon fallIco = XdgIcon::fromTheme("preferences-plugin");
-
-    for (int i=0; i< mPlugins.length(); ++i)
-    {
-        bool count = mPluginsInUse.count(mPlugins.at(i));
-        QString countStr;
-        if (count)
-            countStr = tr("(%1 active)").arg(count);
-
-        const PluginInfo &plugin = mPlugins.at(i);
-        QListWidgetItem* item = new QListWidgetItem(ui->pluginList);
-        item->setText(QString("<b>%1 %2</b><br>\n%3\n").arg(plugin.name(), countStr, plugin.comment()));
-        item->setIcon(plugin.icon(fallIco));
-        item->setData(INDEX_ROLE, i);
-        item->setData(SEARCH_ROLE, QString("%1 %2 %3 %4").arg(
-                        plugin.name(),
-                        plugin.comment(),
-                        plugin.value("Name").toString(),
-                        plugin.value("Comment").toString()
-                       )
-                     );
-    }
-
-    ui->addButton->setEnabled(false);
-}
-
-/************************************************
-
- ************************************************/
-AddPluginDialog::~AddPluginDialog()
-{
-    delete ui;
-}
-
-
-/************************************************
-
- ************************************************/
-void AddPluginDialog::searchEditTexChanged(const QString& text)
-{
-    if (mTimerId)
-        killTimer(mTimerId);
-
-    mTimerId = startTimer(SEARCH_DELAY);
-}
-
-
-/************************************************
-
- ************************************************/
-void AddPluginDialog::timerEvent(QTimerEvent* event)
-{
-    if (event->timerId() == mTimerId)
-    {
-        killTimer(mTimerId);
-        QListWidget* pluginList = ui->pluginList;
-        QString s = ui->searchEdit->text();
-
-        for (int i=0; i < pluginList->count(); ++i)
-        {
-            QListWidgetItem* item = pluginList->item(i);
-            item->setHidden(! item->data(SEARCH_ROLE).toString().contains(s, Qt::CaseInsensitive));
-        }
-    }
-}
-
-
-
-/************************************************
-
- ************************************************/
-void AddPluginDialog::emitPluginSelected()
-{
-    QListWidget* pluginList = ui->pluginList;
-    if (pluginList->currentItem() && pluginList->currentItem()->isSelected())
-    {
-        PluginInfo plugin = mPlugins.at(pluginList->currentItem()->data(INDEX_ROLE).toInt());
-        emit pluginSelected(plugin);
-    }
-}
-
-/************************************************
-
- ************************************************/
-void AddPluginDialog::toggleAddButtonState()
-{
-    ui->addButton->setEnabled(ui->pluginList->currentItem() && ui->pluginList->currentItem()->isSelected());
-}
diff --git a/addplugindialog/addplugindialog.h b/addplugindialog/addplugindialog.h
deleted file mode 100644 (file)
index 23ccc14..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Alexander Sokoloff <sokoloff.a@gmail.com>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-
-#ifndef ADDPLUGINDIALOG_H
-#define ADDPLUGINDIALOG_H
-
-#include <QDialog>
-#include <lxqtplugininfo.h>
-
-#define SEARCH_DELAY 125
-
-namespace Ui {
-    class AddPluginDialog;
-}
-
-
-namespace LxQt
-{
-
-/*! The AddPluginDialog class provides a dialog that allow users to add plugins.
- */
-class AddPluginDialog : public QDialog
-{
-    Q_OBJECT
-
-public:
-    /*! Constructs a dialog with the given parent that initially displays
-       PluginInfo objects for the matched files in the directories
-      @param desktopFilesDirs - list of the scanned directories names.
-      @param serviceType - type of the plugin, for example "RazorPanel/Plugin".
-      @param nameFilter  - wildcard filter that understands * and ? wildcards. */
-    AddPluginDialog(const QStringList& desktopFilesDirs,
-                    const QString& serviceType,
-                    const QString& nameFilter="*",
-                    QWidget *parent = 0);
-
-    ~AddPluginDialog();
-
-    void setPluginsInUse(const PluginInfoList pluginsInUse);
-
-signals:
-    void pluginSelected(const PluginInfo &plugin);
-
-protected:
-    void timerEvent(QTimerEvent* event);
-
-private:
-    void init();
-    Ui::AddPluginDialog *ui;
-    PluginInfoList mPlugins;
-    PluginInfoList mPluginsInUse;
-    int mTimerId;
-
-private slots:
-    void emitPluginSelected();
-    void searchEditTexChanged(const QString& text);
-    void toggleAddButtonState();
-};
-
-} // namecpase LxQt
-
-#endif // ADDPLUGINDIALOG_H
diff --git a/addplugindialog/addplugindialog.ui b/addplugindialog/addplugindialog.ui
deleted file mode 100644 (file)
index 85fb574..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>AddPluginDialog</class>
- <widget class="QDialog" name="AddPluginDialog">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>400</width>
-    <height>359</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string/>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <widget class="QLabel" name="searchLabel">
-       <property name="text">
-        <string>Search:</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QLineEdit" name="searchEdit"/>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <widget class="QListWidget" name="pluginList"/>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout_2">
-     <item>
-      <spacer name="horizontalSpacer">
-       <property name="orientation">
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0">
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="addButton">
-       <property name="text">
-        <string>Add Widget</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="closeButton">
-       <property name="text">
-        <string>Close</string>
-       </property>
-       <property name="autoDefault">
-        <bool>false</bool>
-       </property>
-       <property name="default">
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-  </layout>
- </widget>
- <tabstops>
-  <tabstop>pluginList</tabstop>
-  <tabstop>addButton</tabstop>
-  <tabstop>closeButton</tabstop>
-  <tabstop>searchEdit</tabstop>
- </tabstops>
- <resources/>
- <connections>
-  <connection>
-   <sender>closeButton</sender>
-   <signal>clicked()</signal>
-   <receiver>AddPluginDialog</receiver>
-   <slot>close()</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>380</x>
-     <y>279</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>118</x>
-     <y>270</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
-</ui>
diff --git a/addplugindialog/lxqtaddplugindialog.cpp b/addplugindialog/lxqtaddplugindialog.cpp
new file mode 100644 (file)
index 0000000..d34746b
--- /dev/null
@@ -0,0 +1,270 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Alexander Sokoloff <sokoloff.a@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+
+#include "lxqtaddplugindialog.h"
+#include "ui_lxqtaddplugindialog.h"
+#include <qtxdg/xdgicon.h>
+#include <QtGui/QListWidgetItem>
+#include <QtGui/QItemDelegate>
+#include <QtGui/QTextDocument>
+#include <QStyledItemDelegate>
+#include <QtGui/QIcon>
+#include <QPainter>
+#include <QDebug>
+#include <QTextBrowser>
+#include <QAbstractTextDocumentLayout>
+
+#include <QLineEdit>
+#include "lxqtlibtranslate.h"
+
+using namespace LxQt;
+
+#define SEARCH_ROLE  Qt::UserRole
+#define INDEX_ROLE   SEARCH_ROLE+1
+
+class HtmlDelegate : public QStyledItemDelegate
+{
+public:
+    HtmlDelegate(const QSize iconSize, QObject* parent = 0):
+        QStyledItemDelegate(parent),
+        mIconSize(iconSize)
+    {}
+    void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
+    virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
+private:
+    QSize mIconSize;
+};
+
+
+/************************************************
+
+ ************************************************/
+void HtmlDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
+{
+    if (!index.isValid())
+        return;
+
+    QStyleOptionViewItemV4 options = option;
+    initStyleOption(&options, index);
+
+    painter->save();
+
+    QTextDocument doc;
+    doc.setHtml(options.text);
+    QIcon icon = options.icon;
+
+    options.text = "";
+    options.icon = QIcon();
+    options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
+
+    // Draw icon ................................
+    QSize iconSize = icon.actualSize(mIconSize);
+    painter->translate(options.rect.left(), options.rect.top());
+    QRect iconRect = QRect(4, 4, iconSize.width(), iconSize.height());
+
+    icon.paint(painter, iconRect);
+
+    doc.setTextWidth(options.rect.width() - iconRect.right() - 10);
+
+    // shift text right to make icon visible
+    painter->translate(iconRect.right() + 8, 0);
+    QRect clip(0, 0, options.rect.width()-iconRect.right()- 10, options.rect.height());
+
+
+    painter->setClipRect(clip);
+    QAbstractTextDocumentLayout::PaintContext ctx;
+    // set text color to red for selected item
+    if (option.state & QStyle::State_Selected)
+    {
+        ctx.palette.setColor(QPalette::Text, option.palette.color(QPalette::HighlightedText));
+    }
+    ctx.clip = clip;
+    doc.documentLayout()->draw(painter, ctx);
+
+    painter->restore();
+}
+
+
+/************************************************
+
+ ************************************************/
+QSize HtmlDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
+{
+    QStyleOptionViewItemV4 options = option;
+    initStyleOption(&options, index);
+
+    QSize iconSize = QIcon().actualSize(mIconSize);
+    QRect iconRect = QRect(4, 4, iconSize.width(), iconSize.height());
+
+    QTextDocument doc;
+    doc.setHtml(options.text);
+    doc.setTextWidth(options.rect.width()-iconRect.right()- 10);
+    return QSize(doc.idealWidth(), doc.size().height() + 8);
+}
+
+
+/************************************************
+
+ ************************************************/
+bool pluginDescriptionLessThan(const PluginInfo &p1, const PluginInfo &p2)
+{
+    int cmp = QString::compare(p1.name(), p2.name());
+    if (cmp != 0)
+        return cmp < 0;
+
+    return p1.comment() < p2.comment();
+}
+
+
+/************************************************
+
+ ************************************************/
+AddPluginDialog::AddPluginDialog(const QStringList& desktopFilesDirs,
+                                 const QString &serviceType,
+                                 const QString &nameFilter,
+                                 QWidget *parent):
+    QDialog(parent),
+    ui(new Ui::AddPluginDialog),
+    mTimerId(0)
+{
+    libTranslate("librazorqt");
+    ui->setupUi(this);
+
+    mPlugins = PluginInfo::search(desktopFilesDirs, serviceType, nameFilter);
+    qSort(mPlugins.begin(), mPlugins.end(), pluginDescriptionLessThan);
+    
+    ui->pluginList->setItemDelegate(new HtmlDelegate(QSize(32, 32), ui->pluginList));
+
+    init();
+    
+    connect(ui->pluginList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(emitPluginSelected()));
+    connect(ui->pluginList, SIGNAL(itemSelectionChanged()), this, SLOT(toggleAddButtonState()));
+    connect(ui->searchEdit, SIGNAL(textEdited(QString)), this, SLOT(searchEditTexChanged(QString)));
+    connect(ui->addButton, SIGNAL(clicked(bool)), this, SLOT(emitPluginSelected()));
+}
+
+void AddPluginDialog::setPluginsInUse(const PluginInfoList pluginsInUse)
+{
+    mPluginsInUse = pluginsInUse;
+    init();
+}
+
+void AddPluginDialog::init()
+{
+    QListWidget* pluginList = ui->pluginList;
+    
+    pluginList->clear();
+
+    QIcon fallIco = XdgIcon::fromTheme("preferences-plugin");
+
+    for (int i=0; i< mPlugins.length(); ++i)
+    {
+        bool count = mPluginsInUse.count(mPlugins.at(i));
+        QString countStr;
+        if (count)
+            countStr = tr("(%1 active)").arg(count);
+
+        const PluginInfo &plugin = mPlugins.at(i);
+        QListWidgetItem* item = new QListWidgetItem(ui->pluginList);
+        item->setText(QString("<b>%1 %2</b><br>\n%3\n").arg(plugin.name(), countStr, plugin.comment()));
+        item->setIcon(plugin.icon(fallIco));
+        item->setData(INDEX_ROLE, i);
+        item->setData(SEARCH_ROLE, QString("%1 %2 %3 %4").arg(
+                        plugin.name(),
+                        plugin.comment(),
+                        plugin.value("Name").toString(),
+                        plugin.value("Comment").toString()
+                       )
+                     );
+    }
+
+    ui->addButton->setEnabled(false);
+}
+
+/************************************************
+
+ ************************************************/
+AddPluginDialog::~AddPluginDialog()
+{
+    delete ui;
+}
+
+
+/************************************************
+
+ ************************************************/
+void AddPluginDialog::searchEditTexChanged(const QString& text)
+{
+    if (mTimerId)
+        killTimer(mTimerId);
+
+    mTimerId = startTimer(SEARCH_DELAY);
+}
+
+
+/************************************************
+
+ ************************************************/
+void AddPluginDialog::timerEvent(QTimerEvent* event)
+{
+    if (event->timerId() == mTimerId)
+    {
+        killTimer(mTimerId);
+        QListWidget* pluginList = ui->pluginList;
+        QString s = ui->searchEdit->text();
+
+        for (int i=0; i < pluginList->count(); ++i)
+        {
+            QListWidgetItem* item = pluginList->item(i);
+            item->setHidden(! item->data(SEARCH_ROLE).toString().contains(s, Qt::CaseInsensitive));
+        }
+    }
+}
+
+
+
+/************************************************
+
+ ************************************************/
+void AddPluginDialog::emitPluginSelected()
+{
+    QListWidget* pluginList = ui->pluginList;
+    if (pluginList->currentItem() && pluginList->currentItem()->isSelected())
+    {
+        PluginInfo plugin = mPlugins.at(pluginList->currentItem()->data(INDEX_ROLE).toInt());
+        emit pluginSelected(plugin);
+    }
+}
+
+/************************************************
+
+ ************************************************/
+void AddPluginDialog::toggleAddButtonState()
+{
+    ui->addButton->setEnabled(ui->pluginList->currentItem() && ui->pluginList->currentItem()->isSelected());
+}
diff --git a/addplugindialog/lxqtaddplugindialog.h b/addplugindialog/lxqtaddplugindialog.h
new file mode 100644 (file)
index 0000000..6f6c083
--- /dev/null
@@ -0,0 +1,87 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Alexander Sokoloff <sokoloff.a@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+
+#ifndef LXQTADDPLUGINDIALOG_H
+#define LXQTADDPLUGINDIALOG_H
+
+#include <QDialog>
+#include <lxqtplugininfo.h>
+
+#define SEARCH_DELAY 125
+
+namespace Ui {
+    class AddPluginDialog;
+}
+
+
+namespace LxQt
+{
+
+/*! The AddPluginDialog class provides a dialog that allow users to add plugins.
+ */
+class AddPluginDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    /*! Constructs a dialog with the given parent that initially displays
+       PluginInfo objects for the matched files in the directories
+      @param desktopFilesDirs - list of the scanned directories names.
+      @param serviceType - type of the plugin, for example "RazorPanel/Plugin".
+      @param nameFilter  - wildcard filter that understands * and ? wildcards. */
+    AddPluginDialog(const QStringList& desktopFilesDirs,
+                    const QString& serviceType,
+                    const QString& nameFilter="*",
+                    QWidget *parent = 0);
+
+    ~AddPluginDialog();
+
+    void setPluginsInUse(const PluginInfoList pluginsInUse);
+
+signals:
+    void pluginSelected(const PluginInfo &plugin);
+
+protected:
+    void timerEvent(QTimerEvent* event);
+
+private:
+    void init();
+    Ui::AddPluginDialog *ui;
+    PluginInfoList mPlugins;
+    PluginInfoList mPluginsInUse;
+    int mTimerId;
+
+private slots:
+    void emitPluginSelected();
+    void searchEditTexChanged(const QString& text);
+    void toggleAddButtonState();
+};
+
+} // namecpase LxQt
+
+#endif // LXQTADDPLUGINDIALOG_H
diff --git a/addplugindialog/lxqtaddplugindialog.ui b/addplugindialog/lxqtaddplugindialog.ui
new file mode 100644 (file)
index 0000000..85fb574
--- /dev/null
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AddPluginDialog</class>
+ <widget class="QDialog" name="AddPluginDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>359</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string/>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="QLabel" name="searchLabel">
+       <property name="text">
+        <string>Search:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="searchEdit"/>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QListWidget" name="pluginList"/>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="addButton">
+       <property name="text">
+        <string>Add Widget</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="closeButton">
+       <property name="text">
+        <string>Close</string>
+       </property>
+       <property name="autoDefault">
+        <bool>false</bool>
+       </property>
+       <property name="default">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>pluginList</tabstop>
+  <tabstop>addButton</tabstop>
+  <tabstop>closeButton</tabstop>
+  <tabstop>searchEdit</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>closeButton</sender>
+   <signal>clicked()</signal>
+   <receiver>AddPluginDialog</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>380</x>
+     <y>279</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>118</x>
+     <y>270</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/cmake/create_portable_headers.cmake b/cmake/create_portable_headers.cmake
new file mode 100644 (file)
index 0000000..6d49726
--- /dev/null
@@ -0,0 +1,30 @@
+# Creates portable headers; e.g.:
+#     Creates XdgAction from xdgaction.h
+#     XdgAction contents:
+#     #include "xdgaction.h"
+#
+# Use:
+# set(PUBLIC_CLASSES MyClass YourClass)
+# create_portable_headers(PORTABLE_HEADERS ${PUBLIC_CLASSES})
+# PORTABLE_HEADER is an return value that contains the full name of the
+#   generated headers.
+
+function(create_portable_headers outfiles)
+    set(options)
+    set(oneValueArgs)
+    set(multiValueArgs)
+
+    cmake_parse_arguments(_CREATE_PORTABLE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+    set(class_list ${_CREATE_PORTABLE_HEADERS_UNPARSED_ARGUMENTS})
+    foreach(f ${class_list})
+        string(TOLOWER "${f}.h" _filename)
+
+        file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/portableHeders/${f}
+            "#include \"${_filename}\"")
+
+        list(APPEND ${outfiles} ${CMAKE_CURRENT_BINARY_DIR}/portableHeders/${f})
+    endforeach()
+
+    set(${outfiles} ${${outfiles}} PARENT_SCOPE)
+endfunction()
+
diff --git a/configdialog/configdialog.cpp b/configdialog/configdialog.cpp
deleted file mode 100644 (file)
index 538518d..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright (C) 2012  Alec Moskvin <alecm@gmx.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#include "configdialog.h"
-#include "ui_configdialog.h"
-
-#include <qtxdg/xdgicon.h>
-#include <QtGui/QPushButton>
-
-using namespace LxQt;
-
-ConfigDialog::ConfigDialog(const QString& title, Settings* settings, QWidget* parent) :
-    QDialog(parent),
-    mSettings(settings),
-    mCache(new SettingsCache(settings)),
-    ui(new Ui::ConfigDialog)
-{
-    ui->setupUi(this);
-    setWindowTitle(title);
-    connect(ui->buttons, SIGNAL(clicked(QAbstractButton*)), SLOT(dialogButtonsAction(QAbstractButton*)));
-    ui->moduleList->setVisible(false);
-    connect(Settings::globalSettings(), SIGNAL(settingsChanged()), this, SLOT(updateIcons()));
-    foreach(QPushButton* button, ui->buttons->findChildren<QPushButton*>())
-        button->setAutoDefault(false);
-}
-
-void ConfigDialog::addPage(QWidget* page, const QString& name, const QString& iconName)
-{
-    addPage(page, name, QStringList() << iconName);
-}
-
-void ConfigDialog::addPage(QWidget* page, const QString& name, const QStringList& iconNames)
-{
-    QStringList icons = QStringList(iconNames) << "application-x-executable";
-    new QListWidgetItem(XdgIcon::fromTheme(icons), name, ui->moduleList);
-    mIcons.append(icons);
-    ui->stackedWidget->addWidget(page);
-    if(ui->stackedWidget->count() > 1)
-    {
-        ui->moduleList->setVisible(true);
-        ui->moduleList->setCurrentRow(0);
-        mMaxSize = QSize(qMax(page->geometry().width() + ui->moduleList->geometry().width(), mMaxSize.width()),
-                         qMax(page->geometry().height() + ui->buttons->geometry().height(), mMaxSize.height()));
-    }
-    else
-    {
-        mMaxSize = page->geometry().size();
-    }
-    resize(mMaxSize);
-}
-
-void ConfigDialog::closeEvent(QCloseEvent* event)
-{
-    emit save();
-    mSettings->sync();
-}
-
-void ConfigDialog::dialogButtonsAction(QAbstractButton* button)
-{
-    QDialogButtonBox::ButtonRole role = ui->buttons->buttonRole(button);
-    if (role == QDialogButtonBox::ResetRole)
-    {
-        mCache->loadToSettings();
-        emit reset();
-    }
-    else
-    {
-        close();
-    }
-}
-
-void ConfigDialog::updateIcons()
-{
-    for (int ix = 0; ix < mIcons.size(); ix++)
-        ui->moduleList->item(ix)->setIcon(XdgIcon::fromTheme(mIcons.at(ix)));
-    update();
-}
-
-ConfigDialog::~ConfigDialog()
-{
-    delete ui;
-    delete mCache;
-}
diff --git a/configdialog/configdialog.h b/configdialog/configdialog.h
deleted file mode 100644 (file)
index 14e5a99..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright (C) 2012  Alec Moskvin <alecm@gmx.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#ifndef RAZORCONFIGDIALOG_H
-#define RAZORCONFIGDIALOG_H
-
-#include <lxqtsettings.h>
-
-#include <QtGui/QDialog>
-#include <QtGui/QAbstractButton>
-
-namespace Ui {
-class ConfigDialog;
-}
-
-namespace LxQt
-{
-
-class ConfigDialog : public QDialog
-{
-    Q_OBJECT
-
-public:
-    explicit ConfigDialog(const QString& title, Settings* settings, QWidget* parent = 0);
-    ~ConfigDialog();
-
-    /*!
-     * Add a page to the configure dialog
-     */
-    void addPage(QWidget* page, const QString& name, const QString& iconName="application-x-executable");
-
-    /*!
-     * Add a page to the configure dialog, attempting several alternative icons to find one in the theme
-     */
-    void addPage(QWidget* page, const QString& name, const QStringList& iconNames);
-
-signals:
-    /*!
-     * This signal is emitted when the user pressed the "Reset" button.
-     * Settings should be re-read and the widgets should be set accordingly.
-     */
-    void reset();
-
-    /*!
-     * This is emitted whenever the window is closed and settings need to be saved.
-     * It is only necessary if additional actions need to be performed - Settings are handled automatically.
-     */
-    void save();
-
-protected:
-    Settings* mSettings;
-    virtual void closeEvent(QCloseEvent* event);
-
-private:
-    SettingsCache* mCache;
-    QList<QStringList> mIcons;
-    QSize mMaxSize;
-    Ui::ConfigDialog* ui;
-
-private slots:
-    void dialogButtonsAction(QAbstractButton* button);
-    void updateIcons();
-
-};
-
-} // namespace LxQt
-#endif // RAZORCONFIGDIALOG_H
diff --git a/configdialog/configdialog.ui b/configdialog/configdialog.ui
deleted file mode 100644 (file)
index c952c2a..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>ConfigDialog</class>
- <widget class="QWidget" name="ConfigDialog">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>272</width>
-    <height>231</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>Dialog</string>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <widget class="LxQt::PageSelectWidget" name="moduleList">
-       <property name="horizontalScrollBarPolicy">
-        <enum>Qt::ScrollBarAlwaysOff</enum>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" name="verticalLayout_3">
-       <item>
-        <widget class="QStackedWidget" name="stackedWidget">
-         <property name="currentIndex">
-          <number>-1</number>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <widget class="QDialogButtonBox" name="buttons">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="standardButtons">
-      <set>QDialogButtonBox::Close|QDialogButtonBox::Reset</set>
-     </property>
-    </widget>
-   </item>
-  </layout>
- </widget>
- <customwidgets>
-  <customwidget>
-   <class>LxQt::PageSelectWidget</class>
-   <extends>QListWidget</extends>
-   <header location="global">configdialog/pageselectwidget.h</header>
-  </customwidget>
- </customwidgets>
- <tabstops>
-  <tabstop>moduleList</tabstop>
-  <tabstop>buttons</tabstop>
- </tabstops>
- <resources/>
- <connections>
-  <connection>
-   <sender>moduleList</sender>
-   <signal>currentRowChanged(int)</signal>
-   <receiver>stackedWidget</receiver>
-   <slot>setCurrentIndex(int)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>150</x>
-     <y>123</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>344</x>
-     <y>117</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
-</ui>
diff --git a/configdialog/lxqtconfigdialog.cpp b/configdialog/lxqtconfigdialog.cpp
new file mode 100644 (file)
index 0000000..1dcee92
--- /dev/null
@@ -0,0 +1,104 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright (C) 2012  Alec Moskvin <alecm@gmx.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#include "lxqtconfigdialog.h"
+#include "ui_lxqtconfigdialog.h"
+
+#include <qtxdg/xdgicon.h>
+#include <QtGui/QPushButton>
+
+using namespace LxQt;
+
+ConfigDialog::ConfigDialog(const QString& title, Settings* settings, QWidget* parent) :
+    QDialog(parent),
+    mSettings(settings),
+    mCache(new SettingsCache(settings)),
+    ui(new Ui::ConfigDialog)
+{
+    ui->setupUi(this);
+    setWindowTitle(title);
+    connect(ui->buttons, SIGNAL(clicked(QAbstractButton*)), SLOT(dialogButtonsAction(QAbstractButton*)));
+    ui->moduleList->setVisible(false);
+    connect(Settings::globalSettings(), SIGNAL(settingsChanged()), this, SLOT(updateIcons()));
+    foreach(QPushButton* button, ui->buttons->findChildren<QPushButton*>())
+        button->setAutoDefault(false);
+}
+
+void ConfigDialog::addPage(QWidget* page, const QString& name, const QString& iconName)
+{
+    addPage(page, name, QStringList() << iconName);
+}
+
+void ConfigDialog::addPage(QWidget* page, const QString& name, const QStringList& iconNames)
+{
+    QStringList icons = QStringList(iconNames) << "application-x-executable";
+    new QListWidgetItem(XdgIcon::fromTheme(icons), name, ui->moduleList);
+    mIcons.append(icons);
+    ui->stackedWidget->addWidget(page);
+    if(ui->stackedWidget->count() > 1)
+    {
+        ui->moduleList->setVisible(true);
+        ui->moduleList->setCurrentRow(0);
+        mMaxSize = QSize(qMax(page->geometry().width() + ui->moduleList->geometry().width(), mMaxSize.width()),
+                         qMax(page->geometry().height() + ui->buttons->geometry().height(), mMaxSize.height()));
+    }
+    else
+    {
+        mMaxSize = page->geometry().size();
+    }
+    resize(mMaxSize);
+}
+
+void ConfigDialog::closeEvent(QCloseEvent* event)
+{
+    emit save();
+    mSettings->sync();
+}
+
+void ConfigDialog::dialogButtonsAction(QAbstractButton* button)
+{
+    QDialogButtonBox::ButtonRole role = ui->buttons->buttonRole(button);
+    if (role == QDialogButtonBox::ResetRole)
+    {
+        mCache->loadToSettings();
+        emit reset();
+    }
+    else
+    {
+        close();
+    }
+}
+
+void ConfigDialog::updateIcons()
+{
+    for (int ix = 0; ix < mIcons.size(); ix++)
+        ui->moduleList->item(ix)->setIcon(XdgIcon::fromTheme(mIcons.at(ix)));
+    update();
+}
+
+ConfigDialog::~ConfigDialog()
+{
+    delete ui;
+    delete mCache;
+}
diff --git a/configdialog/lxqtconfigdialog.h b/configdialog/lxqtconfigdialog.h
new file mode 100644 (file)
index 0000000..1db99f9
--- /dev/null
@@ -0,0 +1,88 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright (C) 2012  Alec Moskvin <alecm@gmx.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#ifndef LXQTCONFIGDIALOG_H
+#define LXQTCONFIGDIALOG_H
+
+#include <lxqtsettings.h>
+
+#include <QtGui/QDialog>
+#include <QtGui/QAbstractButton>
+
+namespace Ui {
+class ConfigDialog;
+}
+
+namespace LxQt
+{
+
+class ConfigDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit ConfigDialog(const QString& title, Settings* settings, QWidget* parent = 0);
+    ~ConfigDialog();
+
+    /*!
+     * Add a page to the configure dialog
+     */
+    void addPage(QWidget* page, const QString& name, const QString& iconName="application-x-executable");
+
+    /*!
+     * Add a page to the configure dialog, attempting several alternative icons to find one in the theme
+     */
+    void addPage(QWidget* page, const QString& name, const QStringList& iconNames);
+
+signals:
+    /*!
+     * This signal is emitted when the user pressed the "Reset" button.
+     * Settings should be re-read and the widgets should be set accordingly.
+     */
+    void reset();
+
+    /*!
+     * This is emitted whenever the window is closed and settings need to be saved.
+     * It is only necessary if additional actions need to be performed - Settings are handled automatically.
+     */
+    void save();
+
+protected:
+    Settings* mSettings;
+    virtual void closeEvent(QCloseEvent* event);
+
+private:
+    SettingsCache* mCache;
+    QList<QStringList> mIcons;
+    QSize mMaxSize;
+    Ui::ConfigDialog* ui;
+
+private slots:
+    void dialogButtonsAction(QAbstractButton* button);
+    void updateIcons();
+
+};
+
+} // namespace LxQt
+#endif // LXQTCONFIGDIALOG_H
diff --git a/configdialog/lxqtconfigdialog.ui b/configdialog/lxqtconfigdialog.ui
new file mode 100644 (file)
index 0000000..105466f
--- /dev/null
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ConfigDialog</class>
+ <widget class="QWidget" name="ConfigDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>272</width>
+    <height>231</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout">
+     <item>
+      <widget class="LxQt::PageSelectWidget" name="moduleList">
+       <property name="horizontalScrollBarPolicy">
+        <enum>Qt::ScrollBarAlwaysOff</enum>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_3">
+       <item>
+        <widget class="QStackedWidget" name="stackedWidget">
+         <property name="currentIndex">
+          <number>-1</number>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttons">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Close|QDialogButtonBox::Reset</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>LxQt::PageSelectWidget</class>
+   <extends>QListWidget</extends>
+   <header location="global">configdialog/lxqtpageselectwidget.h</header>
+  </customwidget>
+ </customwidgets>
+ <tabstops>
+  <tabstop>moduleList</tabstop>
+  <tabstop>buttons</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>moduleList</sender>
+   <signal>currentRowChanged(int)</signal>
+   <receiver>stackedWidget</receiver>
+   <slot>setCurrentIndex(int)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>150</x>
+     <y>123</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>344</x>
+     <y>117</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/configdialog/lxqtpageselectwidget.cpp b/configdialog/lxqtpageselectwidget.cpp
new file mode 100644 (file)
index 0000000..846a448
--- /dev/null
@@ -0,0 +1,113 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Alexander Sokoloff <sokoloff.a@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+
+#include "lxqtpageselectwidget.h"
+#include <QtGui/QStyledItemDelegate>
+#include <QtCore/QDebug>
+#include <QtGui/QScrollBar>
+
+using namespace LxQt;
+
+class PageSelectWidgetItemDelegate: public QStyledItemDelegate
+{
+public:
+    explicit PageSelectWidgetItemDelegate(PageSelectWidget *parent = 0);
+    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
+
+private:
+    PageSelectWidget* mView;
+};
+
+
+/************************************************
+
+ ************************************************/
+PageSelectWidgetItemDelegate::PageSelectWidgetItemDelegate(PageSelectWidget *parent):
+    QStyledItemDelegate(parent),
+    mView(parent)
+{
+}
+
+
+/************************************************
+
+ ************************************************/
+QSize PageSelectWidgetItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+    QSize size = QStyledItemDelegate::sizeHint(option, index);
+    size.setWidth(mView->viewport()->width() - 2*mView->spacing());
+    return size;
+}
+
+
+
+/************************************************
+
+ ************************************************/
+PageSelectWidget::PageSelectWidget(QWidget *parent) :
+    QListWidget(parent)
+{
+    setSelectionRectVisible(false);
+    setViewMode(IconMode);
+    setSpacing(2);
+    setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
+    setWordWrap(true);
+    setDragEnabled(NoDragDrop);
+    setEditTriggers(NoEditTriggers);
+    setTextElideMode(Qt::ElideNone);
+
+    setItemDelegate(new PageSelectWidgetItemDelegate(this));
+}
+
+
+/************************************************
+
+ ************************************************/
+PageSelectWidget::~PageSelectWidget()
+{
+}
+
+
+/************************************************
+
+ ************************************************/
+QSize PageSelectWidget::sizeHint() const
+{
+    QSize size = QListWidget::sizeHint();
+    int w = 0;
+    for(int i=0; i< count(); ++i)
+    {
+        QRect rect = fontMetrics().boundingRect(QRect(), Qt::AlignLeft | Qt::TextWordWrap, item(i)->text());
+        w = qMax(w, rect.width());
+    }
+
+    if (horizontalScrollBar()->isVisible())
+        w += horizontalScrollBar()->width();
+    size.setWidth(w + frameWidth() + spacing()*2 + 10);
+    return size;
+}
diff --git a/configdialog/lxqtpageselectwidget.h b/configdialog/lxqtpageselectwidget.h
new file mode 100644 (file)
index 0000000..81eff63
--- /dev/null
@@ -0,0 +1,48 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Alexander Sokoloff <sokoloff.a@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+
+#ifndef LXQTPAGESELECTWIDGET_H
+#define LXQTPAGESELECTWIDGET_H
+
+#include <QtGui/QListWidget>
+namespace LxQt
+{
+
+class PageSelectWidget : public QListWidget
+{
+    Q_OBJECT
+public:
+    explicit PageSelectWidget(QWidget *parent = 0);
+    virtual ~PageSelectWidget();
+
+protected:
+    QSize sizeHint() const;
+};
+
+} // namespace LxQt
+#endif // PAGESELECTWIDGET_H
diff --git a/configdialog/pageselectwidget.cpp b/configdialog/pageselectwidget.cpp
deleted file mode 100644 (file)
index 52f0f94..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Alexander Sokoloff <sokoloff.a@gmail.com>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-
-#include "pageselectwidget.h"
-#include <QtGui/QStyledItemDelegate>
-#include <QtCore/QDebug>
-#include <QtGui/QScrollBar>
-
-using namespace LxQt;
-
-class PageSelectWidgetItemDelegate: public QStyledItemDelegate
-{
-public:
-    explicit PageSelectWidgetItemDelegate(PageSelectWidget *parent = 0);
-    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
-
-private:
-    PageSelectWidget* mView;
-};
-
-
-/************************************************
-
- ************************************************/
-PageSelectWidgetItemDelegate::PageSelectWidgetItemDelegate(PageSelectWidget *parent):
-    QStyledItemDelegate(parent),
-    mView(parent)
-{
-}
-
-
-/************************************************
-
- ************************************************/
-QSize PageSelectWidgetItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
-{
-    QSize size = QStyledItemDelegate::sizeHint(option, index);
-    size.setWidth(mView->viewport()->width() - 2*mView->spacing());
-    return size;
-}
-
-
-
-/************************************************
-
- ************************************************/
-PageSelectWidget::PageSelectWidget(QWidget *parent) :
-    QListWidget(parent)
-{
-    setSelectionRectVisible(false);
-    setViewMode(IconMode);
-    setSpacing(2);
-    setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
-    setWordWrap(true);
-    setDragEnabled(NoDragDrop);
-    setEditTriggers(NoEditTriggers);
-    setTextElideMode(Qt::ElideNone);
-
-    setItemDelegate(new PageSelectWidgetItemDelegate(this));
-}
-
-
-/************************************************
-
- ************************************************/
-PageSelectWidget::~PageSelectWidget()
-{
-}
-
-
-/************************************************
-
- ************************************************/
-QSize PageSelectWidget::sizeHint() const
-{
-    QSize size = QListWidget::sizeHint();
-    int w = 0;
-    for(int i=0; i< count(); ++i)
-    {
-        QRect rect = fontMetrics().boundingRect(QRect(), Qt::AlignLeft | Qt::TextWordWrap, item(i)->text());
-        w = qMax(w, rect.width());
-    }
-
-    if (horizontalScrollBar()->isVisible())
-        w += horizontalScrollBar()->width();
-    size.setWidth(w + frameWidth() + spacing()*2 + 10);
-    return size;
-}
diff --git a/configdialog/pageselectwidget.h b/configdialog/pageselectwidget.h
deleted file mode 100644 (file)
index f5ab6fb..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Alexander Sokoloff <sokoloff.a@gmail.com>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-
-#ifndef PAGESELECTWIDGET_H
-#define PAGESELECTWIDGET_H
-
-#include <QtGui/QListWidget>
-namespace LxQt
-{
-
-class PageSelectWidget : public QListWidget
-{
-    Q_OBJECT
-public:
-    explicit PageSelectWidget(QWidget *parent = 0);
-    virtual ~PageSelectWidget();
-
-protected:
-    QSize sizeHint() const;
-};
-
-} // namespace LxQt
-#endif // PAGESELECTWIDGET_H
diff --git a/libtranslate.h b/libtranslate.h
deleted file mode 100644 (file)
index c568879..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2011 Razor team
- * Authors:
- *   Alexander Sokoloff <sokoloff.a@gmail.com>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#ifndef LIBTRANSLATE_H
-#define LIBTRANSLATE_H
-
-#include <QtCore/QTranslator>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QLocale>
-#include <QtCore/QSet>
-namespace LxQt
-{
-
-inline void libTranslate(const QString &name)
-{
-    static QSet<QString> loadedLibs;
-
-    if (loadedLibs.contains(name))
-        return;
-
-    loadedLibs.insert(name);
-
-    QString locale = QLocale::system().name();
-    QTranslator *translator = new QTranslator(qApp);
-    translator->load(QString("%1/%2_%3.qm").arg(TRANSLATIONS_DIR, name, locale));
-
-    QCoreApplication::installTranslator(translator);
-}
-
-} // namecpase LxQt
-#endif // LIBTRANSLATE_H
diff --git a/lxqtlibtranslate.h b/lxqtlibtranslate.h
new file mode 100644 (file)
index 0000000..c568879
--- /dev/null
@@ -0,0 +1,55 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2011 Razor team
+ * Authors:
+ *   Alexander Sokoloff <sokoloff.a@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#ifndef LIBTRANSLATE_H
+#define LIBTRANSLATE_H
+
+#include <QtCore/QTranslator>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QLocale>
+#include <QtCore/QSet>
+namespace LxQt
+{
+
+inline void libTranslate(const QString &name)
+{
+    static QSet<QString> loadedLibs;
+
+    if (loadedLibs.contains(name))
+        return;
+
+    loadedLibs.insert(name);
+
+    QString locale = QLocale::system().name();
+    QTranslator *translator = new QTranslator(qApp);
+    translator->load(QString("%1/%2_%3.qm").arg(TRANSLATIONS_DIR, name, locale));
+
+    QCoreApplication::installTranslator(translator);
+}
+
+} // namecpase LxQt
+#endif // LIBTRANSLATE_H
diff --git a/lxqtpowermanager.cpp b/lxqtpowermanager.cpp
new file mode 100644 (file)
index 0000000..aa4596d
--- /dev/null
@@ -0,0 +1,202 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Petr Vanek <petr@scribus.info>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#include "lxqtpowermanager.h"
+#include "lxqtpower/lxqtpower.h"
+#include <qtxdg/xdgicon.h>
+#include <QDBusInterface>
+#include <QMessageBox>
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QtDebug>
+#include "lxqtlibtranslate.h"
+
+using namespace LxQt;
+
+class MessageBox: public QMessageBox
+{
+public:
+    explicit MessageBox(QWidget *parent = 0): QMessageBox(parent) {}
+
+    static QWidget *parentWidget()
+    {
+        QWidgetList widgets = QApplication::topLevelWidgets();
+
+        if (widgets.count())
+            return widgets.at(0);
+        else
+            return 0;
+    }
+
+    static bool question(const QString& title, const QString& text)
+    {
+        MessageBox msgBox(parentWidget());
+        msgBox.setWindowTitle(title);
+        msgBox.setText(text);
+        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+
+        return (msgBox.exec() == QMessageBox::Yes);
+    }
+
+
+    static void warning(const QString& title, const QString& text)
+    {
+        QMessageBox::warning(parentWidget(), tr("Razor Power Manager Error"), tr("Hibernate failed."));
+    }
+
+
+protected:
+    virtual void resizeEvent(QResizeEvent* event)
+    {
+        QRect screen = QApplication::desktop()->screenGeometry();
+        move((screen.width()  - this->width()) / 2,
+             (screen.height() - this->height()) / 2);
+
+    }
+};
+
+PowerManager::PowerManager(QObject * parent, bool skipWarning)
+    : QObject(parent),
+        m_skipWarning(skipWarning)
+{
+    libTranslate("librazorqt");
+    m_power = new Power(this);
+//    connect(m_power, SIGNAL(suspendFail()), this, SLOT(suspendFailed()));
+//    connect(m_power, SIGNAL(hibernateFail()), this, SLOT(hibernateFailed()));
+//    connect(m_power, SIGNAL(monitoring(const QString &)),
+//            this, SLOT(monitoring(const QString&)));
+}
+
+PowerManager::~PowerManager()
+{
+//    delete m_power;
+}
+
+QList<QAction*> PowerManager::availableActions()
+{
+    QList<QAction*> ret;
+    QAction * act;
+
+    // TODO/FIXME: icons
+    if (m_power->canHibernate())
+    {
+        act = new QAction(XdgIcon::fromTheme("system-suspend-hibernate"), tr("Hibernate"), this);
+        connect(act, SIGNAL(triggered()), this, SLOT(hibernate()));
+        ret.append(act);
+    }
+
+    if (m_power->canSuspend())
+    {
+        act = new QAction(XdgIcon::fromTheme("system-suspend"), tr("Suspend"), this);
+        connect(act, SIGNAL(triggered()), this, SLOT(suspend()));
+        ret.append(act);
+    }
+
+    if (m_power->canReboot())
+    {
+        act = new QAction(XdgIcon::fromTheme("system-reboot"), tr("Reboot"), this);
+        connect(act, SIGNAL(triggered()), this, SLOT(reboot()));
+        ret.append(act);
+    }
+
+    if (m_power->canShutdown())
+    {
+        act = new QAction(XdgIcon::fromTheme("system-shutdown"), tr("Shutdown"), this);
+        connect(act, SIGNAL(triggered()), this, SLOT(shutdown()));
+        ret.append(act);
+    }
+
+    if (m_power->canLogout())
+    {
+        act = new QAction(XdgIcon::fromTheme("system-log-out"), tr("Logout"), this);
+        connect(act, SIGNAL(triggered()), this, SLOT(logout()));
+        ret.append(act);
+    }
+
+    return ret;
+}
+    
+
+void PowerManager::suspend()
+{
+     if (m_skipWarning ||
+         MessageBox::question(tr("Razor Session Suspend"),
+                              tr("Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost.")))
+    {
+        m_power->suspend();
+    }
+}
+
+void PowerManager::hibernate()
+{
+    if (m_skipWarning ||
+        MessageBox::question(tr("Razor Session Hibernate"),
+                             tr("Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost.")))
+    {
+        m_power->hibernate();
+    }
+}
+
+void PowerManager::reboot()
+{
+    if (m_skipWarning ||
+        MessageBox::question(tr("Razor Session Reboot"),
+                             tr("Do you want to really restart your computer? All unsaved work will be lost...")))
+    {
+        m_power->reboot();
+    }
+}
+
+void PowerManager::shutdown()
+{
+    if (m_skipWarning ||
+        MessageBox::question(tr("Razor Session Shutdown"),
+                             tr("Do you want to really switch off your computer? All unsaved work will be lost...")))
+    {
+        m_power->shutdown();
+    }
+}
+
+void PowerManager::logout()
+{
+    if (m_skipWarning ||
+        MessageBox::question(tr("Razor Session Logout"),
+                             tr("Do you want to really logout? All unsaved work will be lost...")))
+    {
+        m_power->logout();
+    }
+}
+
+void PowerManager::hibernateFailed()
+{
+    MessageBox::warning(tr("Razor Power Manager Error"), tr("Hibernate failed."));
+}
+
+void PowerManager::suspendFailed()
+{
+    MessageBox::warning(tr("Razor Power Manager Error"), tr("Suspend failed."));
+}
diff --git a/lxqtpowermanager.h b/lxqtpowermanager.h
new file mode 100644 (file)
index 0000000..3d1763d
--- /dev/null
@@ -0,0 +1,70 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Petr Vanek <petr@scribus.info>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#ifndef LXQTPOWERMANAGER_H
+#define LXQTPOWERMANAGER_H
+
+#include <QObject>
+#include <QAction>
+
+namespace LxQt
+{
+class Power;
+}
+/*! QAction centric menu aware wrapper around razorpower
+*/
+class PowerManager : public QObject
+{
+    Q_OBJECT
+
+public:
+    PowerManager(QObject * parent, bool skipWarning = false);
+    ~PowerManager();
+    QList<QAction*> availableActions();
+
+public slots:
+    // power management
+    void suspend();
+    void hibernate();
+    void reboot();
+    void shutdown();
+    // razor session
+    void logout();
+
+public:
+    bool skipWarning() const { return m_skipWarning; }
+
+private:
+    LxQt::Power * m_power;
+    bool m_skipWarning;
+
+private slots:
+    void hibernateFailed();
+    void suspendFailed();
+};
+
+#endif // LXQTPOWERMANAGER_H
diff --git a/lxqtprogramfinder.cpp b/lxqtprogramfinder.cpp
new file mode 100644 (file)
index 0000000..1c1e39d
--- /dev/null
@@ -0,0 +1,67 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright (C) 2013  Alec Moskvin <alecm@gmx.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#include "lxqtprogramfinder.h"
+#include <wordexp.h>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
+
+using namespace LxQt;
+
+bool ProgramFinder::programExists(const QString& command)
+{
+    QString program = programName(command);
+    if (program[0] == QChar('/'))
+    {
+        QFileInfo fi(program);
+        return fi.isExecutable() && fi.isFile();
+    }
+
+    QString path = qgetenv("PATH");
+    foreach (const QString& dirName, path.split(":", QString::SkipEmptyParts))
+    {
+        QFileInfo fi(QDir(dirName), program);
+        if (fi.isExecutable() && fi.isFile())
+            return true;
+    }
+    return false;
+}
+
+QStringList ProgramFinder::findPrograms(const QStringList& programs)
+{
+    QStringList availPrograms;
+    foreach (const QString& program, programs)
+        if (programExists(program))
+            availPrograms.append(program);
+    return availPrograms;
+}
+
+QString ProgramFinder::programName(const QString& command)
+{
+    wordexp_t we;
+    if (wordexp(command.toLocal8Bit().constData(), &we, WRDE_NOCMD) == 0)
+        if (we.we_wordc > 0)
+            return QString(we.we_wordv[0]);
+    return QString();
+}
diff --git a/lxqtprogramfinder.h b/lxqtprogramfinder.h
new file mode 100644 (file)
index 0000000..830b057
--- /dev/null
@@ -0,0 +1,59 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright (C) 2013  Alec Moskvin <alecm@gmx.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#ifndef LXQTPROGRAMFINDER_H
+#define LXQTPROGRAMFINDER_H
+
+#include <QtCore/QStringList>
+namespace LxQt
+{
+
+namespace ProgramFinder
+{
+    /*!
+     * \brief programExists Checks if the program needed to execute the given
+     *        command is installed
+     * \param command
+     * \return True if the program exists
+     */
+    bool programExists(const QString& command);
+
+    /*!
+     * \brief findPrograms Filters a list of commands (with arguments) based on
+     *        which programs are installed
+     * \param commands Commands to check
+     * \return List of commands which are installed
+     */
+    QStringList findPrograms(const QStringList& commands);
+
+    /*!
+     * \brief programName Returns the program name given a command
+     * \param command
+     * \return
+     */
+    QString programName(const QString& command);
+}
+
+} // namespace LxQt
+#endif // LXQTPROGRAMFINDER_H
diff --git a/lxqtrotatedwidget.cpp b/lxqtrotatedwidget.cpp
new file mode 100644 (file)
index 0000000..a3e27fd
--- /dev/null
@@ -0,0 +1,326 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2013 Razor team
+ * Authors:
+ *   Kuzma Shapran <kuzma.shapran@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+
+#include "lxqtrotatedwidget.h"
+
+#include <QPainter>
+#include <QImage>
+
+#include <QApplication>
+
+#include <QMouseEvent>
+
+#ifndef QT_NO_WHEELEVENT
+#include <QWheelEvent>
+#endif
+
+#include <QResizeEvent>
+
+using namespace LxQt;
+
+RotatedWidget::RotatedWidget(QWidget &content, QWidget *parent, Qt::WindowFlags f)
+    : QWidget(parent, f)
+    , mContent(&content)
+    , mOrigin(Qt::TopLeftCorner)
+    , mTransferMousePressEvent(false)
+    , mTransferMouseReleaseEvent(false)
+    , mTransferMouseDoubleClickEvent(false)
+    , mTransferMouseMoveEvent(false)
+#ifndef QT_NO_WHEELEVENT
+    , mTransferWheelEvent(false)
+#endif
+    , mTransferEnterEvent(false)
+    , mTransferLeaveEvent(false)
+{
+    mContent->setParent(this);
+}
+
+Qt::Corner RotatedWidget::origin() const
+{
+    return mOrigin;
+}
+
+void RotatedWidget::setOrigin(Qt::Corner newOrigin)
+{
+    if (mOrigin != newOrigin)
+    {
+        if (mOrigin == Qt::TopLeftCorner)
+            mContent->hide();
+
+        mOrigin = newOrigin;
+        adjustContentSize();
+        update();
+
+        if (mOrigin == Qt::TopLeftCorner)
+            mContent->show();
+    }
+}
+
+QWidget * RotatedWidget::content() const
+{
+    return mContent;
+}
+
+void RotatedWidget::adjustContentSize()
+{
+    mContent->adjustSize();
+
+    QSize before = size();
+
+    adjustSize();
+
+    if (before != size())
+        updateGeometry();
+}
+
+QSize RotatedWidget::adjustedSize(QSize size) const
+{
+    switch (mOrigin)
+    {
+    case Qt::TopLeftCorner:
+    case Qt::BottomRightCorner:
+        break;
+
+    case Qt::TopRightCorner:
+    case Qt::BottomLeftCorner:
+        size.transpose();
+        break;
+    }
+
+    return size;
+}
+
+QPoint RotatedWidget::adjustedPoint(QPoint point) const
+{
+    switch (mOrigin)
+    {
+    case Qt::TopLeftCorner:
+    case Qt::BottomRightCorner:
+        break;
+
+    case Qt::TopRightCorner:
+    case Qt::BottomLeftCorner:
+        point = QPoint(point.y(), point.x());
+        break;
+    }
+
+    return point;
+}
+
+QSize RotatedWidget::minimumSizeHint() const
+{
+    return adjustedSize(mContent->minimumSizeHint());
+}
+
+QSize RotatedWidget::sizeHint() const
+{
+    return adjustedSize(mContent->sizeHint());
+}
+
+void RotatedWidget::paintEvent(QPaintEvent */*event*/)
+{
+    if (mOrigin == Qt::TopLeftCorner)
+        return;
+
+    QSize sz = mContent->size();
+
+    QPainter painter(this);
+
+    QTransform transform;
+    QPoint originPoint;
+    switch (mOrigin)
+    {
+    case Qt::TopLeftCorner:
+//        transform.rotate(0.0);
+//        originPoint = QPoint(0.0, 0.0);
+        break;
+
+    case Qt::TopRightCorner:
+        transform.rotate(90.0);
+        originPoint = QPoint(0.0, -sz.height());
+        break;
+
+    case Qt::BottomRightCorner:
+        transform.rotate(180.0);
+        originPoint = QPoint(-sz.width(), -sz.height());
+        break;
+
+    case Qt::BottomLeftCorner:
+        transform.rotate(270.0);
+        originPoint = QPoint(-sz.width(), 0.0);
+        break;
+    }
+    painter.setTransform(transform);
+    mContent->render(&painter, originPoint, QRegion(), RenderFlags(DrawChildren));
+}
+
+void RotatedWidget::mousePressEvent(QMouseEvent *event)
+{
+    if (!mTransferMousePressEvent)
+    {
+        event->ignore();
+        return;
+    }
+
+    static bool cascadeCall = false;
+    if (cascadeCall)
+        return;
+    cascadeCall = true;
+
+    QMouseEvent contentEvent(event->type(), adjustedPoint(event->pos()), event->globalPos(), event->button(), event->buttons(), event->modifiers());
+    QApplication::sendEvent(mContent, &contentEvent);
+
+    cascadeCall = false;
+}
+
+void RotatedWidget::mouseReleaseEvent(QMouseEvent *event)
+{
+    if (!mTransferMouseReleaseEvent)
+    {
+        event->ignore();
+        return;
+    }
+
+    static bool cascadeCall = false;
+    if (cascadeCall)
+        return;
+    cascadeCall = true;
+
+    QMouseEvent contentEvent(event->type(), adjustedPoint(event->pos()), event->globalPos(), event->button(), event->buttons(), event->modifiers());
+    QApplication::sendEvent(mContent, &contentEvent);
+
+    cascadeCall = false;
+}
+
+void RotatedWidget::mouseDoubleClickEvent(QMouseEvent *event)
+{
+    if (!mTransferMouseDoubleClickEvent)
+    {
+        event->ignore();
+        return;
+    }
+
+    static bool cascadeCall = false;
+    if (cascadeCall)
+        return;
+    cascadeCall = true;
+
+    QMouseEvent contentEvent(event->type(), adjustedPoint(event->pos()), event->globalPos(), event->button(), event->buttons(), event->modifiers());
+    QApplication::sendEvent(mContent, &contentEvent);
+
+    cascadeCall = false;
+}
+
+void RotatedWidget::mouseMoveEvent(QMouseEvent *event)
+{
+    if (!mTransferMouseMoveEvent)
+    {
+        event->ignore();
+        return;
+    }
+
+    static bool cascadeCall = false;
+    if (cascadeCall)
+        return;
+    cascadeCall = true;
+
+    QMouseEvent contentEvent(event->type(), adjustedPoint(event->pos()), event->globalPos(), event->button(), event->buttons(), event->modifiers());
+    QApplication::sendEvent(mContent, &contentEvent);
+
+    cascadeCall = false;
+}
+
+#ifndef QT_NO_WHEELEVENT
+void RotatedWidget::wheelEvent(QWheelEvent *event)
+{
+    if (!mTransferWheelEvent)
+    {
+        event->ignore();
+        return;
+    }
+
+    static bool cascadeCall = false;
+    if (cascadeCall)
+        return;
+    cascadeCall = true;
+
+    QWheelEvent contentEvent(adjustedPoint(event->pos()), event->globalPos(), event->delta(), event->buttons(), event->modifiers(), event->orientation());
+    QApplication::sendEvent(mContent, &contentEvent);
+
+    cascadeCall = false;
+}
+#endif
+
+void RotatedWidget::enterEvent(QEvent *event)
+{
+    if (!mTransferEnterEvent)
+    {
+        event->ignore();
+        return;
+    }
+
+    static bool cascadeCall = false;
+    if (cascadeCall)
+        return;
+    cascadeCall = true;
+
+    QApplication::sendEvent(mContent, event);
+
+    cascadeCall = false;
+}
+
+void RotatedWidget::leaveEvent(QEvent *event)
+{
+    if (!mTransferLeaveEvent)
+    {
+        event->ignore();
+        return;
+    }
+
+    static bool cascadeCall = false;
+    if (cascadeCall)
+        return;
+    cascadeCall = true;
+
+    QApplication::sendEvent(mContent, event);
+
+    cascadeCall = false;
+}
+
+void RotatedWidget::resizeEvent(QResizeEvent *event)
+{
+    static bool cascadeCall = false;
+    if (cascadeCall)
+        return;
+    cascadeCall = true;
+
+    QResizeEvent contentEvent(adjustedSize(event->size()), adjustedSize(event->oldSize()));
+    QApplication::sendEvent(mContent, &contentEvent);
+
+    cascadeCall = false;
+}
diff --git a/lxqtrotatedwidget.h b/lxqtrotatedwidget.h
new file mode 100644 (file)
index 0000000..c763939
--- /dev/null
@@ -0,0 +1,125 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2013 Razor team
+ * Authors:
+ *   Kuzma Shapran <kuzma.shapran@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#ifndef LXQTROTATED_WIDGET_H
+#define LXQTROTATED_WIDGET_H
+
+#include <QWidget>
+
+namespace LxQt
+{
+
+class RotatedWidget: public QWidget
+{
+    Q_OBJECT
+
+    Q_PROPERTY(Qt::Corner origin READ origin WRITE setOrigin)
+
+    Q_PROPERTY(bool transferMousePressEvent READ transferMousePressEvent WRITE setTransferMousePressEvent)
+    Q_PROPERTY(bool transferMouseReleaseEvent READ transferMouseReleaseEvent WRITE setTransferMouseReleaseEvent)
+    Q_PROPERTY(bool transferMouseDoubleClickEvent READ transferMouseDoubleClickEvent WRITE setTransferMouseDoubleClickEvent)
+    Q_PROPERTY(bool transferMouseMoveEvent READ transferMouseMoveEvent WRITE setTransferMouseMoveEvent)
+#ifndef QT_NO_WHEELEVENT
+    Q_PROPERTY(bool transferWheelEvent READ transferWheelEvent WRITE setTransferWheelEvent)
+#endif
+
+    Q_PROPERTY(bool transferEnterEvent READ transferEnterEvent WRITE setTransferEnterEvent)
+    Q_PROPERTY(bool transferLeaveEvent READ transferLeaveEvent WRITE setTransferLeaveEvent)
+
+public:
+    explicit RotatedWidget(QWidget &content, QWidget* parent = 0, Qt::WindowFlags f = 0);
+
+    Qt::Corner origin() const;
+    void setOrigin(Qt::Corner);
+
+    QWidget * content() const;
+
+    void adjustContentSize();
+
+    virtual QSize minimumSizeHint() const;
+    virtual QSize sizeHint() const;
+
+    QSize adjustedSize(QSize) const;
+    QPoint adjustedPoint(QPoint) const;
+
+
+    bool transferMousePressEvent() const { return mTransferMousePressEvent; }
+    void setTransferMousePressEvent(bool value) { mTransferMousePressEvent = value; }
+
+    bool transferMouseReleaseEvent() const { return mTransferMouseReleaseEvent; }
+    void setTransferMouseReleaseEvent(bool value) { mTransferMouseReleaseEvent = value; }
+
+    bool transferMouseDoubleClickEvent() const { return mTransferMouseDoubleClickEvent; }
+    void setTransferMouseDoubleClickEvent(bool value) { mTransferMouseDoubleClickEvent = value; }
+
+    bool transferMouseMoveEvent() const { return mTransferMouseMoveEvent; }
+    void setTransferMouseMoveEvent(bool value) { mTransferMouseMoveEvent = value; }
+
+#ifndef QT_NO_WHEELEVENT
+    bool transferWheelEvent() const { return mTransferWheelEvent; }
+    void setTransferWheelEvent(bool value) { mTransferWheelEvent = value; }
+#endif
+
+    bool transferEnterEvent() const { return mTransferEnterEvent; }
+    void setTransferEnterEvent(bool value) { mTransferEnterEvent = value; }
+
+    bool transferLeaveEvent() const { return mTransferLeaveEvent; }
+    void setTransferLeaveEvent(bool value) { mTransferLeaveEvent = value; }
+
+protected:
+    virtual void paintEvent(QPaintEvent *);
+
+    // Transition event handlers
+    virtual void mousePressEvent(QMouseEvent *);
+    virtual void mouseReleaseEvent(QMouseEvent *);
+    virtual void mouseDoubleClickEvent(QMouseEvent *);
+    virtual void mouseMoveEvent(QMouseEvent *);
+#ifndef QT_NO_WHEELEVENT
+    virtual void wheelEvent(QWheelEvent *);
+#endif
+    virtual void enterEvent(QEvent *);
+    virtual void leaveEvent(QEvent *);
+
+    virtual void resizeEvent(QResizeEvent *);
+
+private:
+    QWidget *mContent;
+    Qt::Corner mOrigin;
+
+    bool mTransferMousePressEvent;
+    bool mTransferMouseReleaseEvent;
+    bool mTransferMouseDoubleClickEvent;
+    bool mTransferMouseMoveEvent;
+#ifndef QT_NO_WHEELEVENT
+    bool mTransferWheelEvent;
+#endif
+    bool mTransferEnterEvent;
+    bool mTransferLeaveEvent;
+};
+
+} // namespace LxQt
+#endif // LXQTROTATEDWIDGET_H
diff --git a/lxqtscreensaver.cpp b/lxqtscreensaver.cpp
new file mode 100644 (file)
index 0000000..7373c53
--- /dev/null
@@ -0,0 +1,129 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Petr Vanek <petr@scribus.info>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#include <QtCore/QProcess>
+#include <QtGui/QMessageBox>
+
+#include <qtxdg/xdgicon.h>
+#include "lxqtscreensaver.h"
+#include "lxqtlibtranslate.h"
+
+using namespace LxQt;
+
+ScreenSaver::ScreenSaver(QObject * parent)
+    : QObject(parent)
+{
+    LxQt::libTranslate("librazorqt");
+    m_xdgProcess = new QProcess(this);
+    connect(m_xdgProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
+            this, SLOT(xdgProcess_finished(int,QProcess::ExitStatus)));
+}
+
+QList<QAction*> ScreenSaver::availableActions()
+{
+    QList<QAction*> ret;
+    QAction * act;
+
+    act = new QAction(XdgIcon::fromTheme("system-lock-screen", "lock"), tr("Lock Screen"), this);
+    connect(act, SIGNAL(triggered()), this, SLOT(lockScreen()));
+    ret.append(act);
+
+    return ret;
+}
+
+void ScreenSaver::lockScreen()
+{
+    m_xdgProcess->start("xdg-screensaver", QStringList() << "lock");
+}
+
+void ScreenSaver::xdgProcess_finished(int err, QProcess::ExitStatus status)
+{
+    QWidget *p = qobject_cast<QWidget*>(parent());
+
+    if (status == QProcess::CrashExit)
+    {
+        QMessageBox::warning(p,
+                             tr("Screen Saver Activation Error"),
+                             tr("An error occurred starting screensaver. "
+                                "xdg-screensaver cannot be started due its crash.")
+                            );
+    }
+    else if (err == -2)
+    {
+        QMessageBox::warning(p,  
+                             tr("Screen Saver Activation Error"),
+                             tr("An error occurred starting screensaver. "
+                                "xdg-screensaver is not installed correctly.")
+                            );  
+    }
+    else if (err == -1)
+    {
+        QMessageBox::warning(p,
+                             tr("Screen Saver Activation Error"),
+                             tr("An error occurred starting screensaver. "
+                                "xdg-screensaver cannot be started.")
+                            );
+    }
+    else if (err == 0)
+    {
+        emit activated();
+    }
+    else if (err == 1)
+    {
+        QMessageBox::warning(p,  
+                             tr("Screen Saver Activation Error"),
+                             tr("An error occurred starting screensaver. "
+                                "Syntax error in xdg-screensaver arguments.")
+                            );
+    }
+    else if (err == 3)
+    {
+        QMessageBox::warning(p,  
+                             tr("Screen Saver Activation Error"),
+                             tr("An error occurred starting screensaver. "
+                                "Ensure you have xscreensaver installed and running.")
+                            );
+    }
+    else if (err == 4)
+    {
+        QMessageBox::warning(p,  
+                             tr("Screen Saver Activation Error"),
+                             tr("An error occurred starting screensaver. "
+                                "Action 'activate' failed. "
+                                "Ensure you have xscreensaver installed and running.")
+                            );
+    }
+    else
+    {
+        QMessageBox::warning(p,  
+                             tr("Screen Saver Activation Error"),
+                             tr("An error occurred starting screensaver. "
+                                "Unknown error - undocumented return value from xdg-screensaver=%1.").arg(err)
+                            );
+    }
+}
+
diff --git a/lxqtscreensaver.h b/lxqtscreensaver.h
new file mode 100644 (file)
index 0000000..5726dc1
--- /dev/null
@@ -0,0 +1,66 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Petr Vanek <petr@scribus.info>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#ifndef SCREENSAVER_H
+#define SCREENSAVER_H
+
+#include <QtCore/QProcess>
+#include <QtCore/QObject>
+#include <QtGui/QAction>
+
+
+class QProcess;
+
+namespace LxQt
+{
+
+class ScreenSaver : public QObject
+{
+    Q_OBJECT
+
+public:
+    ScreenSaver(QObject * parent=0);
+
+    QList<QAction*> availableActions();
+
+signals:
+    void activated();
+
+public slots:
+    void lockScreen();
+
+private:
+    QProcess * m_xdgProcess;
+
+private slots:
+    void xdgProcess_finished(int err, QProcess::ExitStatus status);
+
+};
+
+} // namespace LxQt
+#endif
+
diff --git a/lxqtxfitman.cpp b/lxqtxfitman.cpp
new file mode 100644 (file)
index 0000000..6c7cc14
--- /dev/null
@@ -0,0 +1,977 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Christopher "VdoP" Regali
+ *   Alexander Sokoloff <sokoloff.a@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+
+
+#include <QtGui/QX11Info>
+#include <QtCore/QList>
+#include <QtGui/QApplication>
+#include <QtCore/QDebug>
+#include <QtGui/QDesktopWidget>
+
+#include <stdint.h>
+#include "lxqtxfitman.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/Xutil.h>
+#include <assert.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+
+#include <QtGui/QWidget>
+#include <QtGui/QIcon>
+/**
+ * @file xfitman.cpp
+ * @brief implements class Xfitman
+ * @author Christopher "VdoP" Regali
+ */
+
+/*
+ Some requests from Clients include type of the Client, for example the _NET_ACTIVE_WINDOW
+ message. Currently the types can be 1 for normal applications, and 2 for pagers.
+ See http://standards.freedesktop.org/wm-spec/latest/ar01s09.html#sourceindication
+ */
+#define SOURCE_NORMAL   1
+#define SOURCE_PAGER    2
+
+/*
+  _NET_WM_STATE actions
+ */
+#define _NET_WM_STATE_REMOVE    0    // remove/unset property
+#define _NET_WM_STATE_ADD       1    // add/set property
+#define _NET_WM_STATE_TOGGLE    2    // toggle property
+
+using namespace LxQt;
+
+const XfitMan&  xfitMan()
+{
+    static XfitMan instance;
+    return instance;
+}
+
+/**
+ * @brief constructor: gets Display vars and registers us
+ */
+XfitMan::XfitMan()
+{
+    root = QX11Info::appRootWindow();
+}
+
+/**
+ * @brief moves a window to a new position
+ */
+
+void XfitMan::moveWindow(Window _win, int _x, int _y) const
+{
+    XMoveWindow(QX11Info::display(), _win, _x, _y);
+}
+
+/************************************************
+
+ ************************************************/
+bool XfitMan::getWindowProperty(Window window,
+                       Atom atom,               // property
+                       Atom reqType,            // req_type
+                       unsigned long* resultLen,// nitems_return
+                       unsigned char** result   // prop_return
+                      ) const
+{
+    int  format;
+    unsigned long type, rest;
+    return XGetWindowProperty(QX11Info::display(), window, atom, 0, 4096, false,
+                              reqType, &type, &format, resultLen, &rest,
+                              result)  == Success;
+}
+
+
+/************************************************
+
+ ************************************************/
+bool XfitMan::getRootWindowProperty(Atom atom,    // property
+                           Atom reqType,            // req_type
+                           unsigned long* resultLen,// nitems_return
+                           unsigned char** result   // prop_return
+                          ) const
+{
+    return getWindowProperty(root, atom, reqType, resultLen, result);
+}
+
+
+/**
+ * @brief this one gets the active application window.
+ */
+Window XfitMan::getActiveAppWindow() const
+{
+    Window window = getActiveWindow();
+    if (window == 0)
+        return 0;
+
+    if (acceptWindow(window))
+        return window;
+
+    Window transFor = None;
+    if (XGetTransientForHint(QX11Info::display(), window, &transFor))
+        return transFor;
+
+    return 0;
+}
+
+/**
+ * @brief returns the window that currently has inputfocus
+ */
+Window XfitMan::getActiveWindow() const
+{
+    unsigned long len;
+    unsigned long *data;
+    if (!getWindowProperty(root, atom("_NET_ACTIVE_WINDOW"), XA_WINDOW,
+                          &len, (unsigned char**) &data)
+       )
+        return 0;
+
+    Window result = 0;
+    if (len)
+        result = data[0];
+
+    XFree(data);
+    return result;
+}
+
+
+/**
+ * @brief Get the number of desktops
+ */
+
+int XfitMan::getNumDesktop() const
+{
+    unsigned long length, *data;
+    getRootWindowProperty(atom("_NET_NUMBER_OF_DESKTOPS"), XA_CARDINAL, &length, (unsigned char**) &data);
+    if (data)
+    {
+        int res = data[0];
+        XFree(data);
+        return res;
+    }
+    return 0;
+}
+
+QStringList XfitMan::getDesktopNames() const
+{  
+    QStringList ret;
+    unsigned long length;
+    unsigned char *data = 0;
+
+    if (getRootWindowProperty(atom("_NET_DESKTOP_NAMES"), atom("UTF8_STRING"), &length, &data))
+    {
+        if (data)
+        {
+            char* c = (char*)data;
+            char* end = (char*)data + length;
+            while (c < end)
+            {
+                ret << QString::fromUtf8(c);
+                c += strlen(c) + 1; // for trailing \0
+            }
+
+            XFree(data);
+        }
+    }
+
+
+    return ret;
+}
+
+
+QString XfitMan::getDesktopName(int desktopNum, const QString &defaultName) const
+{
+    QStringList names = getDesktopNames();
+    if (desktopNum<0 || desktopNum>names.count()-1)
+        return defaultName;
+
+    return names.at(desktopNum);
+}
+
+/**
+ * @brief resizes a window to the given dimensions
+ */
+void XfitMan::resizeWindow(Window _wid, int _width, int _height) const
+{
+    XResizeWindow(QX11Info::display(), _wid, _width, _height);
+}
+
+
+
+/**
+ * @brief gets a windowpixmap from a window
+ */
+
+bool XfitMan::getClientIcon(Window _wid, QPixmap& _pixreturn) const
+{
+    int format;
+    ulong type, nitems, extra;
+    ulong* data = 0;
+
+    XGetWindowProperty(QX11Info::display(), _wid, atom("_NET_WM_ICON"),
+                       0, LONG_MAX, False, AnyPropertyType,
+                       &type, &format, &nitems, &extra,
+                       (uchar**)&data);
+    if (!data)
+    {
+        return false;
+    }
+
+    QImage img (data[0], data[1], QImage::Format_ARGB32);
+    for (int i=0; i<img.byteCount()/4; ++i)
+        ((uint*)img.bits())[i] = data[i+2];
+
+    _pixreturn = QPixmap::fromImage(img);
+    XFree(data);
+
+    return true;
+}
+
+bool XfitMan::getClientIcon(Window _wid, QIcon *icon) const
+{
+    int format;
+    ulong type, nitems, extra;
+    ulong* data = 0;
+
+    XGetWindowProperty(QX11Info::display(), _wid, atom("_NET_WM_ICON"),
+                       0, LONG_MAX, False, AnyPropertyType,
+                       &type, &format, &nitems, &extra,
+                       (uchar**)&data);
+    if (!data)
+    {
+        return false;
+    }
+
+    ulong* d = data;
+    while (d < data + nitems)
+    {
+        QImage img (d[0], d[1], QImage::Format_ARGB32);
+        d+=2;
+        for (int i=0; i<img.byteCount()/4; ++i, ++d)
+            ((uint*)img.bits())[i] = *d;
+
+        icon->addPixmap(QPixmap::fromImage(img));
+    }
+
+    XFree(data);
+    return true;
+}
+
+
+
+/**
+ * @brief destructor
+ */
+XfitMan::~XfitMan()
+{
+}
+/**
+ * @brief returns a windowname and sets _nameSource to the finally used Atom
+ */
+
+//i got the idea for this from taskbar-plugin of LXPanel - so credits fly out :)
+QString XfitMan::getWindowTitle(Window _wid) const
+{
+    QString name = "";
+    //first try the modern net-wm ones
+    unsigned long length;
+    unsigned char *data = NULL;
+    Atom utf8Atom = atom("UTF8_STRING");
+
+    if (getWindowProperty(_wid, atom("_NET_WM_VISIBLE_NAME"), utf8Atom, &length, &data))
+    {
+        name = QString::fromUtf8((char*) data);
+        XFree(data);
+
+    }
+
+    if (name.isEmpty())
+    {
+        if (getWindowProperty(_wid, atom("_NET_WM_NAME"), utf8Atom, &length, &data))
+        {
+            name = QString::fromUtf8((char*) data);
+            XFree(data);
+        }
+    }
+
+    if (name.isEmpty())
+    {
+        if (getWindowProperty(_wid, atom("XA_WM_NAME"), XA_STRING, &length, &data))
+        {
+            name = (char*) data;
+            XFree(data);
+        }
+    }
+
+    if (name.isEmpty())
+    {
+        Status ok = XFetchName(QX11Info::display(), _wid, (char**) &data);
+        name = QString((char*) data);
+        if (0 != ok) XFree(data);
+    }
+
+    if (name.isEmpty())
+    {
+        XTextProperty prop;
+        if (XGetWMName(QX11Info::display(), _wid, &prop))
+        {
+            name = QString::fromUtf8((char*) prop.value);
+            XFree(prop.value);
+        }
+    }
+
+    return name;
+}
+
+QString XfitMan::getApplicationName(Window _wid) const
+{
+    XClassHint hint;
+    QString ret;
+
+    if (XGetClassHint(QX11Info::display(), _wid, &hint))
+    {
+        if (hint.res_name)
+        {
+            ret = hint.res_name;
+            XFree(hint.res_name);
+        }
+        if (hint.res_class)
+        {
+            XFree(hint.res_class);
+        }
+    }
+
+    return ret;
+}
+
+/**
+ * @brief sends a clientmessage to a window
+ */
+int XfitMan::clientMessage(Window _wid, Atom _msg,
+                            unsigned long data0,
+                            unsigned long data1,
+                            unsigned long data2,
+                            unsigned long data3,
+                            unsigned long data4) const
+{
+    XClientMessageEvent msg;
+    msg.window = _wid;
+    msg.type = ClientMessage;
+    msg.message_type = _msg;
+    msg.send_event = true;
+    msg.display = QX11Info::display();
+    msg.format = 32;
+    msg.data.l[0] = data0;
+    msg.data.l[1] = data1;
+    msg.data.l[2] = data2;
+    msg.data.l[3] = data3;
+    msg.data.l[4] = data4;
+    if (XSendEvent(QX11Info::display(), root, FALSE, (SubstructureRedirectMask | SubstructureNotifyMask) , (XEvent *) &msg) == Success)
+        return EXIT_SUCCESS;
+    else
+        return EXIT_FAILURE;
+}
+
+
+/***********************************************
+
+ ***********************************************/
+WindowAllowedActions XfitMan::getAllowedActions(Window window) const
+{
+    WindowAllowedActions actions = { };
+
+    unsigned long len;
+    unsigned long *data;
+    if (getWindowProperty(window, atom("_NET_WM_ALLOWED_ACTIONS"), XA_ATOM, &len, (unsigned char**) &data))
+    {
+        for (unsigned long i=0; i<len; ++i)
+        {
+            if (data[i] == atom("_NET_WM_ACTION_MOVE"))             actions.Move = true;            else
+            if (data[i] == atom("_NET_WM_ACTION_RESIZE"))           actions.Resize = true;          else
+            if (data[i] == atom("_NET_WM_ACTION_MINIMIZE"))         actions.Minimize = true;        else
+            if (data[i] == atom("_NET_WM_ACTION_SHADE"))            actions.Shade = true;           else
+            if (data[i] == atom("_NET_WM_ACTION_STICK"))            actions.Stick = true;           else
+            if (data[i] == atom("_NET_WM_ACTION_MAXIMIZE_HORZ"))    actions.MaximizeHoriz = true;   else
+            if (data[i] == atom("_NET_WM_ACTION_MAXIMIZE_VERT"))    actions.MaximizeVert = true;    else
+            if (data[i] == atom("_NET_WM_ACTION_FULLSCREEN"))       actions.FullScreen = true;      else
+            if (data[i] == atom("_NET_WM_ACTION_CHANGE_DESKTOP"))   actions.ChangeDesktop = true;   else
+            if (data[i] == atom("_NET_WM_ACTION_CLOSE"))            actions.Close = true;           else
+            if (data[i] == atom("_NET_WM_ACTION_ABOVE"))            actions.AboveLayer = true;      else
+            if (data[i] == atom("_NET_WM_ACTION_BELOW"))            actions.BelowLayer = true;
+        }
+        XFree(data);
+    }
+
+    return actions;
+}
+
+
+WindowState XfitMan::getWindowState(Window window) const
+{
+    WindowState state = { };
+
+    unsigned long len;
+    unsigned long *data;
+    if (getWindowProperty(window, atom("_NET_WM_STATE"), XA_ATOM, &len, (unsigned char**) &data))
+    {
+        for (unsigned long i=0; i<len; ++i)
+        {
+            if (data[i] == atom("_NET_WM_STATE_MODAL"))             state.Modal = true;             else
+            if (data[i] == atom("_NET_WM_STATE_STICKY"))            state.Sticky = true;            else
+            if (data[i] == atom("_NET_WM_STATE_MAXIMIZED_VERT"))    state.MaximizedVert = true;     else
+            if (data[i] == atom("_NET_WM_STATE_MAXIMIZED_HORZ"))    state.MaximizedHoriz = true;    else
+            if (data[i] == atom("_NET_WM_STATE_SHADED"))            state.Shaded = true;            else
+            if (data[i] == atom("_NET_WM_STATE_SKIP_TASKBAR"))      state.SkipTaskBar = true;       else
+            if (data[i] == atom("_NET_WM_STATE_SKIP_PAGER"))        state.SkipPager = true;         else
+            if (data[i] == atom("_NET_WM_STATE_HIDDEN"))            state.Hidden = true;            else
+            if (data[i] == atom("_NET_WM_STATE_FULLSCREEN"))        state.FullScreen = true;        else
+            if (data[i] == atom("_NET_WM_STATE_ABOVE"))             state.AboveLayer = true;        else
+            if (data[i] == atom("_NET_WM_STATE_BELOW"))             state.BelowLayer = true;        else
+            if (data[i] == atom("_NET_WM_STATE_DEMANDS_ATTENTION")) state.Attention = true;
+        }
+        XFree(data);
+    }
+
+    return state;
+
+}
+
+
+
+/**
+ * @brief returns true if a window has its hidden_flag set
+ */
+
+bool XfitMan::isHidden(Window _wid) const
+{
+    return getWindowState(_wid).Hidden;
+}
+
+Atom XfitMan::atom(const char* atomName)
+{
+    static QHash<QString, Atom> hash;
+
+    if (hash.contains(atomName))
+        return hash.value(atomName);
+
+    Atom atom = XInternAtom(QX11Info::display(), atomName, false);
+    hash[atomName] = atom;
+    return atom;
+}
+
+AtomList XfitMan::getWindowType(Window window) const
+{
+    AtomList result;
+
+    unsigned long length, *data;
+    length=0;
+    if (!getWindowProperty(window, atom("_NET_WM_WINDOW_TYPE"), (Atom)AnyPropertyType, &length, (unsigned char**) &data))
+        return result;
+
+    for (unsigned int i = 0; i < length; i++)
+        result.append(data[i]);
+
+    XFree(data);
+    return result;
+}
+
+
+/**
+ * @brief rejects a window from beeing listed
+ */
+bool XfitMan::acceptWindow(Window window) const
+{
+    {
+        AtomList types = getWindowType(window);
+        AtomList ignoreList;
+        ignoreList  << atom("_NET_WM_WINDOW_TYPE_DESKTOP")
+                    << atom("_NET_WM_WINDOW_TYPE_DOCK")
+                    << atom("_NET_WM_WINDOW_TYPE_SPLASH")
+                    << atom("_NET_WM_WINDOW_TYPE_TOOLBAR")
+                    << atom("_NET_WM_WINDOW_TYPE_MENU")
+                    // for qlipper - using qpopup as a main window
+                    << atom("_NET_WM_WINDOW_TYPE_POPUP_MENU");
+        // issue #284: qmmp its not registered in window list panel
+        // qmmp has _KDE_NET_WM_WINDOW_TYPE_OVERRIDE in its
+        // _NET_WM_WINDOW_TYPE(ATOM) = _KDE_NET_WM_WINDOW_TYPE_OVERRIDE, _NET_WM_WINDOW_TYPE_NORMAL
+        // Let's expect that _KDE_NET_WM_WINDOW_TYPE_OVERRIDE can be set for
+        // regular windows too. If it should be hidden we should expect
+        // one of atoms listed above.
+//                    << atom("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
+
+        foreach (Atom i, ignoreList)
+        {
+            if (types.contains(i))
+                return false;
+        }
+
+        WindowState state = getWindowState(window);
+        if (state.SkipTaskBar)  return false;
+    }
+
+    Window transFor = None;
+    // WM_TRANSIENT_FOR hint not set - normal window
+    if (!XGetTransientForHint(QX11Info::display(), window, &transFor))
+        return true;
+
+    if (transFor == 0)      return true;
+    if (transFor == window) return true;
+    if (transFor == root)   return true;
+
+     AtomList transForTypes = getWindowType(transFor);
+     return !transForTypes.contains(atom("_NET_WM_WINDOW_TYPE_NORMAL"));
+}
+
+
+
+/**
+ * @brief gets a client list
+ */
+WindowList XfitMan::getClientList() const
+{
+    //initialize the parameters for the XGetWindowProperty call
+    unsigned long length, *data;
+    length=0;
+
+    /**
+     * @todo maybe support multiple desktops here!
+     */
+    QList<Window> output;
+
+    if (getRootWindowProperty(atom("_NET_CLIENT_LIST"), (Atom)AnyPropertyType, &length,  (unsigned char**) &data))
+    {
+        for (unsigned int i = 0; i < length; i ++)
+            output.append(data[i]);
+        XFree(data);
+    }
+
+    return output;
+}
+
+
+/**
+ * @brief returns the current desktop
+ */
+int XfitMan::getActiveDesktop() const
+{
+    int res = -2;
+    unsigned long length, *data;
+    if (getRootWindowProperty(atom("_NET_CURRENT_DESKTOP"), XA_CARDINAL, &length, (unsigned char**) &data))
+    {
+        if (data)
+        {
+            res = data[0];
+            XFree(data);
+        }
+    }
+
+    return res;
+}
+
+
+/**
+ * @brief gets the desktop of the windows _wid
+ */
+int XfitMan::getWindowDesktop(Window _wid) const
+{
+    int  res = -1;
+    unsigned long length, *data;
+    // so we try to use net_wm_desktop first, but if the
+    // system does not use net_wm standard we use win_workspace!
+    if (getWindowProperty(_wid, atom("_NET_WM_DESKTOP"), XA_CARDINAL, &length, (unsigned char**) &data))
+    {
+        if (!data)
+            return res;
+        res = data[0];
+        XFree(data);
+    }
+    else
+    {
+        if (getWindowProperty(_wid, atom("_WIN_WORKSPACE"), XA_CARDINAL, &length, (unsigned char**) &data))
+        {
+            if (!data)
+                return res;
+            res = data[0];
+            XFree(data);
+        }
+    }
+
+    return res;
+}
+
+
+/**
+ * @brief moves a window to a specified desktop
+ */
+
+void XfitMan::moveWindowToDesktop(Window _wid, int _display) const
+{
+    clientMessage(_wid, atom("_NET_WM_DESKTOP"), (unsigned long) _display,0,0,0,0);
+}
+
+
+/**
+ * @brief raises windows _wid
+ */
+void XfitMan::raiseWindow(Window _wid) const
+{
+    clientMessage(_wid, atom("_NET_ACTIVE_WINDOW"),
+                  SOURCE_PAGER);
+}
+
+
+/************************************************
+
+ ************************************************/
+void XfitMan::minimizeWindow(Window _wid) const
+{
+    clientMessage(_wid, atom("WM_CHANGE_STATE"),
+                  IconicState);
+}
+
+
+/************************************************
+
+ ************************************************/
+void XfitMan::maximizeWindow(Window _wid, MaximizeDirection direction) const
+{
+    Atom atom1 = 0, atom2= 0;
+    switch (direction)
+    {
+        case MaximizeHoriz:
+            atom1 = atom("_NET_WM_STATE_MAXIMIZED_HORZ");
+            break;
+
+        case MaximizeVert:
+            atom1 = atom("_NET_WM_STATE_MAXIMIZED_VERT");
+            break;
+
+        case MaximizeBoth:
+            atom1 = atom("_NET_WM_STATE_MAXIMIZED_VERT");
+            atom2 = atom("_NET_WM_STATE_MAXIMIZED_HORZ");
+            break;
+
+    }
+
+    clientMessage(_wid, atom("_NET_WM_STATE"),
+                  _NET_WM_STATE_ADD,
+                  atom1, atom2,
+                  SOURCE_PAGER);
+    raiseWindow(_wid);
+}
+
+
+/************************************************
+
+ ************************************************/
+void XfitMan::deMaximizeWindow(Window _wid) const
+{
+    clientMessage(_wid, atom("_NET_WM_STATE"),
+                  _NET_WM_STATE_REMOVE,
+                  atom("_NET_WM_STATE_MAXIMIZED_VERT"),
+                  atom("_NET_WM_STATE_MAXIMIZED_HORZ"),
+                  SOURCE_PAGER);
+}
+
+/************************************************
+
+ ************************************************/
+void XfitMan::shadeWindow(Window _wid, bool shade) const
+{
+    clientMessage(_wid, atom("_NET_WM_STATE"),
+                  shade ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE,
+                  atom("_NET_WM_STATE_SHADED"),
+                  0,
+                  SOURCE_PAGER);
+}
+
+
+/************************************************
+
+ ************************************************/
+void XfitMan::closeWindow(Window _wid) const
+{
+    clientMessage(_wid, atom("_NET_CLOSE_WINDOW"),
+                  0, // Timestamp
+                  SOURCE_PAGER);
+}
+
+
+/************************************************
+
+ ************************************************/
+void XfitMan::setWindowLayer(Window _wid, XfitMan::Layer layer) const
+{
+    ulong aboveAction = (layer == LayerAbove) ?
+        _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
+
+    ulong belowAction = (layer == LayerBelow) ?
+        _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
+
+    clientMessage(_wid, atom("_NET_WM_STATE"),
+                  aboveAction,
+                  atom("_NET_WM_STATE_ABOVE"),
+                  0,
+                  SOURCE_PAGER);
+
+    clientMessage(_wid, atom("_NET_WM_STATE"),
+                  belowAction,
+                  atom("_NET_WM_STATE_BELOW"),
+                  0,
+                  SOURCE_PAGER);
+}
+
+/**
+ * @brief changes active desktop to _desktop
+ */
+void XfitMan::setActiveDesktop(int _desktop) const
+{
+    clientMessage(root, atom("_NET_CURRENT_DESKTOP"), (unsigned long) _desktop,0,0,0,0);
+}
+
+/**
+ * @brief sets net_wm_strut_partial = our reserved panelspace for the mainbar!
+ */
+void XfitMan::setStrut(Window _wid,
+                       int left, int right,
+                       int top,  int bottom,
+
+                       int leftStartY,   int leftEndY,
+                       int rightStartY,  int rightEndY,
+                       int topStartX,    int topEndX,
+                       int bottomStartX, int bottomEndX
+                       ) const
+{
+    //qDebug() << "XfitMan: Trying to set STRUT_PARTIAL for panel!";
+    unsigned long desstrut[12];
+    memset(desstrut,0,sizeof(desstrut));
+    //prepare the array
+    //it has format:
+    /*
+     * left, right, top, bottom, left_start_y, left_end_y,
+     * right_start_y, right_end_y, top_start_x, top_end_x, bottom_start_x,
+     * bottom_end_x
+     *
+     */
+
+    //so we take our panelsize from the bottom up
+    desstrut[0] = left; desstrut[1] = right;
+    desstrut[2] = top;  desstrut[3] = bottom;
+
+    desstrut[4] = leftStartY;    desstrut[5] = leftEndY;
+    desstrut[6] = rightStartY;   desstrut[7] = rightEndY;
+    desstrut[8] = topStartX;     desstrut[9] = topEndX;
+    desstrut[10] = bottomStartX; desstrut[11] = bottomEndX;
+
+    //now we can change that property right
+    XChangeProperty(QX11Info::display(), _wid , atom("_NET_WM_STRUT_PARTIAL"),
+                    XA_CARDINAL, 32, PropModeReplace,  (unsigned char *) desstrut, 12  );
+
+    //now some wm do not support net_wm_strut_partial but only net_wm_strut, so we also
+    // send that one too xdg-std says: if you get a strut_partial ignore all following
+    // struts! so if this msg is recognized its ok if not, we dont care either
+
+    XChangeProperty(QX11Info::display(), _wid, atom("_NET_WM_STRUT"),
+                    XA_CARDINAL, 32, PropModeReplace, (unsigned char*) desstrut, 4);
+}
+
+
+#ifdef DEBUG
+/************************************************
+
+ ************************************************/
+QString XfitMan::debugWindow(Window wnd)
+{
+    if (!wnd)
+        return QString("[%1]").arg(wnd,8, 16);
+
+    QString typeStr;
+    int  format;
+    unsigned long type, length, rest, *data;
+    length=0;
+    if (XGetWindowProperty(QX11Info::display(), wnd, XInternAtom(QX11Info::display(), "_NET_WM_WINDOW_TYPE", False),
+                           0, 4096, FALSE, AnyPropertyType, &type, &format,
+                           &length, &rest,(unsigned char**) &data) == Success)
+    {
+        for (unsigned int i = 0; i < length; i++)
+        {
+            char* aname = XGetAtomName(QX11Info::display(), data[i]);
+            typeStr = typeStr + " " + aname;
+            XFree(aname);
+        }
+    }
+    else
+        typeStr ="ERROR";
+
+    return QString("[%1] %2 %3").arg(wnd,8, 16).arg(xfitMan().getWindowTitle(wnd)).arg(typeStr);
+}
+#endif
+
+
+/************************************************
+
+ ************************************************/
+const QRect XfitMan::availableGeometry(int screen) const
+{
+    QDesktopWidget *d = QApplication::desktop();
+
+    if (screen < 0 || screen >= d->screenCount())
+        screen = d->primaryScreen();
+
+    QRect available = d->screenGeometry(screen);
+
+    // Iterate over all the client windows and subtract from the available
+    // area the space they reserved on the edges (struts).
+    // Note: _NET_WORKAREA is not reliable as it exposes only one
+    // rectangular area spanning all screens.
+    Display *display = QX11Info::display();
+    int x11Screen = d->isVirtualDesktop() ? DefaultScreen(display) : screen;
+
+    Atom ret;
+    int format, status;
+    uchar* data = 0;
+    ulong nitems, after;
+
+    status = XGetWindowProperty(display, QX11Info::appRootWindow(x11Screen),
+                                atom("_NET_CLIENT_LIST"), 0L, ~0L, False, XA_WINDOW,
+                                &ret, &format, &nitems, &after, &data);
+
+    if (status == Success && ret == XA_WINDOW && format == 32 && nitems)
+    {
+        const QRect desktopGeometry = d->rect();
+
+        Window* xids = (Window*) data;
+        for (quint32 i = 0; i < nitems; ++i)
+        {
+            ulong nitems2;
+            uchar* data2 = 0;
+            status = XGetWindowProperty(display, xids[i],
+                                        atom("_NET_WM_STRUT_PARTIAL"), 0, 12, False, XA_CARDINAL,
+                                        &ret, &format, &nitems2, &after, &data2);
+
+            if (status == Success && ret == XA_CARDINAL && format == 32 && nitems2 == 12)
+            {
+                ulong* struts = (ulong*) data2;
+
+                QRect left(desktopGeometry.x(),
+                           desktopGeometry.y() + struts[4],
+                           struts[0],
+                           struts[5] - struts[4]);
+                if (available.intersects(left))
+                    available.setX(left.width());
+
+                QRect right(desktopGeometry.x() + desktopGeometry.width() - struts[1],
+                            desktopGeometry.y() + struts[6],
+                            struts[1],
+                            struts[7] - struts[6]);
+                if (available.intersects(right))
+                    available.setWidth(right.x() - available.x());
+
+                QRect top(desktopGeometry.x() + struts[8],
+                          desktopGeometry.y(),
+                          struts[9] - struts[8],
+                          struts[2]);
+                if (available.intersects(top))
+                    available.setY(top.height());
+
+                QRect bottom(desktopGeometry.x() + struts[10],
+                             desktopGeometry.y() + desktopGeometry.height() - struts[3],
+                             struts[11] - struts[10],
+                             struts[3]);
+                if (available.intersects(bottom))
+                    available.setHeight(bottom.y() - available.y());
+            }
+            if (data2)
+                XFree(data2);
+        }
+    }
+    if (data)
+        XFree(data);
+
+    return available;
+}
+
+
+/************************************************
+
+ ************************************************/
+const QRect XfitMan::availableGeometry(const QWidget *widget) const
+{
+    if (!widget)
+    {
+        qWarning("XfitMan::availableGeometry(): Attempt "
+                 "to get the available geometry of a null widget");
+        return QRect();
+    }
+
+    return availableGeometry(QApplication::desktop()->screenNumber(widget));
+}
+
+
+/************************************************
+
+ ************************************************/
+const QRect XfitMan::availableGeometry(const QPoint &point) const
+{
+    return availableGeometry(QApplication::desktop()->screenNumber(point));
+}
+
+
+/************************************************
+ The Window Manager MUST set this property on the root window to be the ID of a child
+ window created by himself, to indicate that a compliant window manager is active.
+
+ http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#id2550836
+ ************************************************/
+bool XfitMan::isWindowManagerActive() const
+{
+    //Window *wins;
+
+    //getRootWindowProperty(atom("_NET_SUPPORTING_WM_CHECK"), XA_WINDOW, &length, (unsigned char**) &wins);
+
+    Atom type;
+    unsigned long length;
+    Window *wins;
+    int format;
+    unsigned long after;
+
+    XGetWindowProperty(QX11Info::display(), root, atom("_NET_SUPPORTING_WM_CHECK"),
+                       0, LONG_MAX,
+                       false, XA_WINDOW, &type, &format, &length,
+                       &after, (unsigned char **)&wins);
+
+    if ( type == XA_WINDOW && length > 0 && wins[0] != None )
+    {
+        XFree(wins);
+        return true;
+    }
+    return false;
+}
diff --git a/lxqtxfitman.h b/lxqtxfitman.h
new file mode 100644 (file)
index 0000000..9f282f5
--- /dev/null
@@ -0,0 +1,243 @@
+/* BEGIN_COMMON_COPYRIGHT_HEADER
+ * (c)LGPL2+
+ *
+ * Razor - a lightweight, Qt based, desktop toolset
+ * http://razor-qt.org
+ *
+ * Copyright: 2010-2011 Razor team
+ * Authors:
+ *   Christopher "VdoP" Regali
+ *   Alexander Sokoloff <sokoloff.a@gmail.com>
+ *
+ * This program or library is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * END_COMMON_COPYRIGHT_HEADER */
+
+#ifndef LXQTXFITMAN_H
+#define LXQTXFITMAN_H
+
+#include <QtCore/QList>
+#include <QtGui/QPixmap>
+#include <QtCore/QString>
+#include <QtCore/QMap>
+#include <X11/Xlib.h>
+
+//some net_wm state-operations we need here
+#define _NET_WM_STATE_TOGGLE 2
+#define _NET_WM_STATE_ADD 1
+#define _NET_WM_STATE_REMOVE 0
+
+/**
+ * @file xfitman.h
+ * @author Christopher "VdoP" Regali
+ * @brief handles all of our xlib-calls.
+ */
+
+namespace LxQt
+{
+
+typedef QList<Atom> AtomList;
+typedef QList<Window> WindowList;
+
+// A list of atoms indicating user operations that the Window Manager supports
+// for this window.
+// See http://standards.freedesktop.org/wm-spec/latest/ar01s05.html#id2569373
+struct WindowAllowedActions
+{
+    bool Move;          // indicates that the window may be moved around the screen.
+    bool Resize;        // indicates that the window may be resized.
+    bool Minimize;      // indicates that the window may be iconified.
+    bool Shade;         // indicates that the window may be shaded.
+    bool Stick;         // indicates that the window may have its sticky state toggled.
+    bool MaximizeHoriz; // indicates that the window may be maximized horizontally.
+    bool MaximizeVert;  // indicates that the window may be maximized vertically.
+    bool FullScreen;    // indicates that the window may be brought to fullscreen state.
+    bool ChangeDesktop; // indicates that the window may be moved between desktops.
+    bool Close;         // indicates that the window may be closed.
+    bool AboveLayer;    // indicates that the window may placed in the "above" layer of windows
+    bool BelowLayer;    // indicates that the window may placed in the "below" layer of windows
+};
+
+// A list of hints describing the window state.
+// http://standards.freedesktop.org/wm-spec/latest/ar01s05.html#id2569140
+struct WindowState
+{
+    bool Modal;         // indicates that this is a modal dialog box.
+    bool Sticky;        // indicates that the Window Manager SHOULD keep the window's position
+                        // fixed on the screen, even when the virtual desktop scrolls.
+    bool MaximizedVert; // indicates that the window is vertically maximized.
+    bool MaximizedHoriz;// indicates that the window is horizontally maximized.
+    bool Shaded;        // indicates that the window is shaded.
+    bool SkipTaskBar;   // indicates that the window should not be included on a taskbar.
+    bool SkipPager;     // indicates that the window should not be included on a Pager.
+    bool Hidden;        // indicates that a window would not be visible on the screen
+    bool FullScreen;    // indicates that the window should fill the entire screen.
+    bool AboveLayer;    // indicates that the window should be on top of most windows.
+    bool BelowLayer;    // indicates that the window should be below most windows.
+    bool Attention;     // indicates that some action in or with the window happened.
+};
+
+
+/**
+ * @brief manages the Xlib apicalls
+ */
+class XfitMan
+{
+public:
+
+    enum Layer
+    {
+        LayerAbove,
+        LayerNormal,
+        LayerBelow
+    };
+
+    enum MaximizeDirection
+    {
+        MaximizeHoriz,
+        MaximizeVert,
+        MaximizeBoth
+    };
+
+    ~XfitMan();
+    XfitMan();
+    void moveWindow(Window _win, int _x, int _y) const;
+
+    // See
+    void setStrut(Window _wid,
+                  int left, int right,
+                  int top,  int bottom,
+
+                  int leftStartY,   int leftEndY,
+                  int rightStartY,  int rightEndY,
+                  int topStartX,    int topEndX,
+                  int bottomStartX, int bottomEndX
+                  ) const;
+    WindowList getClientList() const;
+    bool getClientIcon(Window _wid, QPixmap& _pixreturn) const;
+    bool getClientIcon(Window _wid, QIcon *icon) const;
+    int getWindowDesktop(Window _wid) const;
+    void moveWindowToDesktop(Window _wid, int _display) const;
+
+    void raiseWindow(Window _wid) const;
+    void minimizeWindow(Window _wid) const;
+    void maximizeWindow(Window _wid, MaximizeDirection direction = MaximizeBoth) const;
+    void deMaximizeWindow(Window _wid) const;
+    void shadeWindow(Window _wid, bool shade) const;
+    void resizeWindow(Window _wid, int _width, int _height) const;
+    void closeWindow(Window _wid) const;
+    void setWindowLayer(Window _wid, Layer layer) const;
+
+    void setActiveDesktop(int _desktop) const;
+    bool isHidden(Window _wid) const;
+    WindowAllowedActions getAllowedActions(Window window) const;
+    WindowState getWindowState(Window window) const;
+    int getActiveDesktop() const;
+    Window getActiveAppWindow() const;
+    Window getActiveWindow() const;
+    int getNumDesktop() const;
+
+    /*!
+     * Returns the names of all virtual desktops. This is a list of UTF-8 encoding strings.
+     *
+     * Note: The number of names could be different from getNumDesktop(). If it is less
+     * than getNumDesktop(), then the desktops with high numbers are unnamed. If it is
+     * larger than getNumDesktop(), then the excess names outside of the getNumDesktop()
+     * are considered to be reserved in case the number of desktops is increased.
+     */
+    QStringList getDesktopNames() const;
+
+    /*!
+     * Returns the name of virtual desktop.
+     */
+    QString getDesktopName(int desktopNum, const QString &defaultName=QString()) const;
+
+    /*! Returns window title if available
+     *
+     */
+    QString getWindowTitle(Window _wid) const;
+
+    /*! Returns window title if available
+     *
+     */
+    QString getApplicationName(Window _wid) const;
+
+    bool acceptWindow(Window _wid) const;
+
+    AtomList getWindowType(Window window) const;
+#ifdef DEBUG
+    static QString debugWindow(Window wnd);
+#endif
+    static Atom atom(const char* atomName);
+
+    /*!
+     *   QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
+     *   This workaraund this problem.
+     */
+    const QRect availableGeometry(int screen = -1) const;
+
+    /*!
+     *   QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
+     *   This workaraund this problem.
+     */
+    const QRect availableGeometry(const QWidget *widget) const;
+
+    /*!
+     *   QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
+     *   This workaraund this problem.
+     */
+    const QRect availableGeometry(const QPoint &point) const;
+
+    int clientMessage(Window _wid, Atom _msg,
+                      long unsigned int data0,
+                      long unsigned int data1 = 0,
+                      long unsigned int data2 = 0,
+                      long unsigned int data3 = 0,
+                      long unsigned int data4 = 0) const;
+
+    /*!
+     * Returns true if the Window Manager is running; otherwise returns false.
+     */
+    bool isWindowManagerActive() const;
+
+private:
+
+    /** \warning Do not forget to XFree(result) after data are processed!
+    */
+    bool getWindowProperty(Window window,
+                           Atom atom,               // property
+                           Atom reqType,            // req_type
+                           unsigned long* resultLen,// nitems_return
+                           unsigned char** result   // prop_return
+                          ) const;
+
+    /** \warning Do not forget to XFree(result) after data are processed!
+    */
+    bool getRootWindowProperty(Atom atom,               // property
+                               Atom reqType,            // req_type
+                               unsigned long* resultLen,// nitems_return
+                               unsigned char** result   // prop_return
+                              ) const;
+
+
+    Window  root; //the actual root window on the used screen
+};
+
+
+const XfitMan& xfitMan();
+
+} //namespace LxQt
+#endif LXQTXFITMAN_H
diff --git a/powermanager.cpp b/powermanager.cpp
deleted file mode 100644 (file)
index 8585d9c..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Petr Vanek <petr@scribus.info>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#include "powermanager.h"
-#include "lxqtpower/lxqtpower.h"
-#include <qtxdg/xdgicon.h>
-#include <QDBusInterface>
-#include <QMessageBox>
-#include <QApplication>
-#include <QDesktopWidget>
-#include <QtDebug>
-#include "libtranslate.h"
-
-using namespace LxQt;
-
-class MessageBox: public QMessageBox
-{
-public:
-    explicit MessageBox(QWidget *parent = 0): QMessageBox(parent) {}
-
-    static QWidget *parentWidget()
-    {
-        QWidgetList widgets = QApplication::topLevelWidgets();
-
-        if (widgets.count())
-            return widgets.at(0);
-        else
-            return 0;
-    }
-
-    static bool question(const QString& title, const QString& text)
-    {
-        MessageBox msgBox(parentWidget());
-        msgBox.setWindowTitle(title);
-        msgBox.setText(text);
-        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
-
-        return (msgBox.exec() == QMessageBox::Yes);
-    }
-
-
-    static void warning(const QString& title, const QString& text)
-    {
-        QMessageBox::warning(parentWidget(), tr("Razor Power Manager Error"), tr("Hibernate failed."));
-    }
-
-
-protected:
-    virtual void resizeEvent(QResizeEvent* event)
-    {
-        QRect screen = QApplication::desktop()->screenGeometry();
-        move((screen.width()  - this->width()) / 2,
-             (screen.height() - this->height()) / 2);
-
-    }
-};
-
-PowerManager::PowerManager(QObject * parent, bool skipWarning)
-    : QObject(parent),
-        m_skipWarning(skipWarning)
-{
-    libTranslate("librazorqt");
-    m_power = new Power(this);
-//    connect(m_power, SIGNAL(suspendFail()), this, SLOT(suspendFailed()));
-//    connect(m_power, SIGNAL(hibernateFail()), this, SLOT(hibernateFailed()));
-//    connect(m_power, SIGNAL(monitoring(const QString &)),
-//            this, SLOT(monitoring(const QString&)));
-}
-
-PowerManager::~PowerManager()
-{
-//    delete m_power;
-}
-
-QList<QAction*> PowerManager::availableActions()
-{
-    QList<QAction*> ret;
-    QAction * act;
-
-    // TODO/FIXME: icons
-    if (m_power->canHibernate())
-    {
-        act = new QAction(XdgIcon::fromTheme("system-suspend-hibernate"), tr("Hibernate"), this);
-        connect(act, SIGNAL(triggered()), this, SLOT(hibernate()));
-        ret.append(act);
-    }
-
-    if (m_power->canSuspend())
-    {
-        act = new QAction(XdgIcon::fromTheme("system-suspend"), tr("Suspend"), this);
-        connect(act, SIGNAL(triggered()), this, SLOT(suspend()));
-        ret.append(act);
-    }
-
-    if (m_power->canReboot())
-    {
-        act = new QAction(XdgIcon::fromTheme("system-reboot"), tr("Reboot"), this);
-        connect(act, SIGNAL(triggered()), this, SLOT(reboot()));
-        ret.append(act);
-    }
-
-    if (m_power->canShutdown())
-    {
-        act = new QAction(XdgIcon::fromTheme("system-shutdown"), tr("Shutdown"), this);
-        connect(act, SIGNAL(triggered()), this, SLOT(shutdown()));
-        ret.append(act);
-    }
-
-    if (m_power->canLogout())
-    {
-        act = new QAction(XdgIcon::fromTheme("system-log-out"), tr("Logout"), this);
-        connect(act, SIGNAL(triggered()), this, SLOT(logout()));
-        ret.append(act);
-    }
-
-    return ret;
-}
-    
-
-void PowerManager::suspend()
-{
-     if (m_skipWarning ||
-         MessageBox::question(tr("Razor Session Suspend"),
-                              tr("Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost.")))
-    {
-        m_power->suspend();
-    }
-}
-
-void PowerManager::hibernate()
-{
-    if (m_skipWarning ||
-        MessageBox::question(tr("Razor Session Hibernate"),
-                             tr("Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost.")))
-    {
-        m_power->hibernate();
-    }
-}
-
-void PowerManager::reboot()
-{
-    if (m_skipWarning ||
-        MessageBox::question(tr("Razor Session Reboot"),
-                             tr("Do you want to really restart your computer? All unsaved work will be lost...")))
-    {
-        m_power->reboot();
-    }
-}
-
-void PowerManager::shutdown()
-{
-    if (m_skipWarning ||
-        MessageBox::question(tr("Razor Session Shutdown"),
-                             tr("Do you want to really switch off your computer? All unsaved work will be lost...")))
-    {
-        m_power->shutdown();
-    }
-}
-
-void PowerManager::logout()
-{
-    if (m_skipWarning ||
-        MessageBox::question(tr("Razor Session Logout"),
-                             tr("Do you want to really logout? All unsaved work will be lost...")))
-    {
-        m_power->logout();
-    }
-}
-
-void PowerManager::hibernateFailed()
-{
-    MessageBox::warning(tr("Razor Power Manager Error"), tr("Hibernate failed."));
-}
-
-void PowerManager::suspendFailed()
-{
-    MessageBox::warning(tr("Razor Power Manager Error"), tr("Suspend failed."));
-}
diff --git a/powermanager.h b/powermanager.h
deleted file mode 100644 (file)
index f3c17dd..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Petr Vanek <petr@scribus.info>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#ifndef POWERMANAGER_H
-#define POWERMANAGER_H
-
-#include <QObject>
-#include <QAction>
-
-namespace LxQt
-{
-class Power;
-}
-/*! QAction centric menu aware wrapper around razorpower
-*/
-class PowerManager : public QObject
-{
-    Q_OBJECT
-
-public:
-    PowerManager(QObject * parent, bool skipWarning = false);
-    ~PowerManager();
-    QList<QAction*> availableActions();
-
-public slots:
-    // power management
-    void suspend();
-    void hibernate();
-    void reboot();
-    void shutdown();
-    // razor session
-    void logout();
-
-public:
-    bool skipWarning() const { return m_skipWarning; }
-
-private:
-    LxQt::Power * m_power;
-    bool m_skipWarning;
-
-private slots:
-    void hibernateFailed();
-    void suspendFailed();
-};
-
-#endif
diff --git a/programfinder.cpp b/programfinder.cpp
deleted file mode 100644 (file)
index 5ccbf96..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright (C) 2013  Alec Moskvin <alecm@gmx.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#include "programfinder.h"
-#include <wordexp.h>
-#include <QtCore/QDir>
-#include <QtCore/QFileInfo>
-
-using namespace LxQt;
-
-bool ProgramFinder::programExists(const QString& command)
-{
-    QString program = programName(command);
-    if (program[0] == QChar('/'))
-    {
-        QFileInfo fi(program);
-        return fi.isExecutable() && fi.isFile();
-    }
-
-    QString path = qgetenv("PATH");
-    foreach (const QString& dirName, path.split(":", QString::SkipEmptyParts))
-    {
-        QFileInfo fi(QDir(dirName), program);
-        if (fi.isExecutable() && fi.isFile())
-            return true;
-    }
-    return false;
-}
-
-QStringList ProgramFinder::findPrograms(const QStringList& programs)
-{
-    QStringList availPrograms;
-    foreach (const QString& program, programs)
-        if (programExists(program))
-            availPrograms.append(program);
-    return availPrograms;
-}
-
-QString ProgramFinder::programName(const QString& command)
-{
-    wordexp_t we;
-    if (wordexp(command.toLocal8Bit().constData(), &we, WRDE_NOCMD) == 0)
-        if (we.we_wordc > 0)
-            return QString(we.we_wordv[0]);
-    return QString();
-}
diff --git a/programfinder.h b/programfinder.h
deleted file mode 100644 (file)
index fa11115..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright (C) 2013  Alec Moskvin <alecm@gmx.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#ifndef PROGRAMFINDER_H
-#define PROGRAMFINDER_H
-
-#include <QtCore/QStringList>
-namespace LxQt
-{
-
-namespace ProgramFinder
-{
-    /*!
-     * \brief programExists Checks if the program needed to execute the given
-     *        command is installed
-     * \param command
-     * \return True if the program exists
-     */
-    bool programExists(const QString& command);
-
-    /*!
-     * \brief findPrograms Filters a list of commands (with arguments) based on
-     *        which programs are installed
-     * \param commands Commands to check
-     * \return List of commands which are installed
-     */
-    QStringList findPrograms(const QStringList& commands);
-
-    /*!
-     * \brief programName Returns the program name given a command
-     * \param command
-     * \return
-     */
-    QString programName(const QString& command);
-}
-
-} // namespace LxQt
-#endif // PROGRAMFINDER_H
diff --git a/razorshortcutbutton_p.h b/razorshortcutbutton_p.h
deleted file mode 100644 (file)
index 0e875ef..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Alexander Sokoloff <sokoloff.a@gmail.com>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-
-#ifndef RAZORSHORTCUTBUTTON_P_H
-#define RAZORSHORTCUTBUTTON_P_H
-
-#include "razorshortcutbutton.h"
-#include <QtGui/QMenu>
-
-class QKeyEvent;
-
-class RazorShortcutButtonPrivate: public QObject
-{
-    Q_OBJECT
-public:
-    explicit RazorShortcutButtonPrivate(RazorShortcutButton *parent);
-
-    bool keyPressEvent(QKeyEvent *event);
-    bool keyReleaseEvent(QKeyEvent *event);
-
-public slots:
-    void clear();
-    void activate(bool active);
-
-private:
-    RazorShortcutButton* const q_ptr;
-    Q_DECLARE_PUBLIC(RazorShortcutButton);
-
-    QKeySequence mSequence;
-    QMenu mMenu;
-    int mKeysCount;
-};
-
-#endif // RAZORSHORTCUTBUTTON_P_H
diff --git a/rotatedwidget.cpp b/rotatedwidget.cpp
deleted file mode 100644 (file)
index bf96ea4..0000000
+++ /dev/null
@@ -1,326 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2013 Razor team
- * Authors:
- *   Kuzma Shapran <kuzma.shapran@gmail.com>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-
-#include "rotatedwidget.h"
-
-#include <QPainter>
-#include <QImage>
-
-#include <QApplication>
-
-#include <QMouseEvent>
-
-#ifndef QT_NO_WHEELEVENT
-#include <QWheelEvent>
-#endif
-
-#include <QResizeEvent>
-
-using namespace LxQt;
-
-RotatedWidget::RotatedWidget(QWidget &content, QWidget *parent, Qt::WindowFlags f)
-    : QWidget(parent, f)
-    , mContent(&content)
-    , mOrigin(Qt::TopLeftCorner)
-    , mTransferMousePressEvent(false)
-    , mTransferMouseReleaseEvent(false)
-    , mTransferMouseDoubleClickEvent(false)
-    , mTransferMouseMoveEvent(false)
-#ifndef QT_NO_WHEELEVENT
-    , mTransferWheelEvent(false)
-#endif
-    , mTransferEnterEvent(false)
-    , mTransferLeaveEvent(false)
-{
-    mContent->setParent(this);
-}
-
-Qt::Corner RotatedWidget::origin() const
-{
-    return mOrigin;
-}
-
-void RotatedWidget::setOrigin(Qt::Corner newOrigin)
-{
-    if (mOrigin != newOrigin)
-    {
-        if (mOrigin == Qt::TopLeftCorner)
-            mContent->hide();
-
-        mOrigin = newOrigin;
-        adjustContentSize();
-        update();
-
-        if (mOrigin == Qt::TopLeftCorner)
-            mContent->show();
-    }
-}
-
-QWidget * RotatedWidget::content() const
-{
-    return mContent;
-}
-
-void RotatedWidget::adjustContentSize()
-{
-    mContent->adjustSize();
-
-    QSize before = size();
-
-    adjustSize();
-
-    if (before != size())
-        updateGeometry();
-}
-
-QSize RotatedWidget::adjustedSize(QSize size) const
-{
-    switch (mOrigin)
-    {
-    case Qt::TopLeftCorner:
-    case Qt::BottomRightCorner:
-        break;
-
-    case Qt::TopRightCorner:
-    case Qt::BottomLeftCorner:
-        size.transpose();
-        break;
-    }
-
-    return size;
-}
-
-QPoint RotatedWidget::adjustedPoint(QPoint point) const
-{
-    switch (mOrigin)
-    {
-    case Qt::TopLeftCorner:
-    case Qt::BottomRightCorner:
-        break;
-
-    case Qt::TopRightCorner:
-    case Qt::BottomLeftCorner:
-        point = QPoint(point.y(), point.x());
-        break;
-    }
-
-    return point;
-}
-
-QSize RotatedWidget::minimumSizeHint() const
-{
-    return adjustedSize(mContent->minimumSizeHint());
-}
-
-QSize RotatedWidget::sizeHint() const
-{
-    return adjustedSize(mContent->sizeHint());
-}
-
-void RotatedWidget::paintEvent(QPaintEvent */*event*/)
-{
-    if (mOrigin == Qt::TopLeftCorner)
-        return;
-
-    QSize sz = mContent->size();
-
-    QPainter painter(this);
-
-    QTransform transform;
-    QPoint originPoint;
-    switch (mOrigin)
-    {
-    case Qt::TopLeftCorner:
-//        transform.rotate(0.0);
-//        originPoint = QPoint(0.0, 0.0);
-        break;
-
-    case Qt::TopRightCorner:
-        transform.rotate(90.0);
-        originPoint = QPoint(0.0, -sz.height());
-        break;
-
-    case Qt::BottomRightCorner:
-        transform.rotate(180.0);
-        originPoint = QPoint(-sz.width(), -sz.height());
-        break;
-
-    case Qt::BottomLeftCorner:
-        transform.rotate(270.0);
-        originPoint = QPoint(-sz.width(), 0.0);
-        break;
-    }
-    painter.setTransform(transform);
-    mContent->render(&painter, originPoint, QRegion(), RenderFlags(DrawChildren));
-}
-
-void RotatedWidget::mousePressEvent(QMouseEvent *event)
-{
-    if (!mTransferMousePressEvent)
-    {
-        event->ignore();
-        return;
-    }
-
-    static bool cascadeCall = false;
-    if (cascadeCall)
-        return;
-    cascadeCall = true;
-
-    QMouseEvent contentEvent(event->type(), adjustedPoint(event->pos()), event->globalPos(), event->button(), event->buttons(), event->modifiers());
-    QApplication::sendEvent(mContent, &contentEvent);
-
-    cascadeCall = false;
-}
-
-void RotatedWidget::mouseReleaseEvent(QMouseEvent *event)
-{
-    if (!mTransferMouseReleaseEvent)
-    {
-        event->ignore();
-        return;
-    }
-
-    static bool cascadeCall = false;
-    if (cascadeCall)
-        return;
-    cascadeCall = true;
-
-    QMouseEvent contentEvent(event->type(), adjustedPoint(event->pos()), event->globalPos(), event->button(), event->buttons(), event->modifiers());
-    QApplication::sendEvent(mContent, &contentEvent);
-
-    cascadeCall = false;
-}
-
-void RotatedWidget::mouseDoubleClickEvent(QMouseEvent *event)
-{
-    if (!mTransferMouseDoubleClickEvent)
-    {
-        event->ignore();
-        return;
-    }
-
-    static bool cascadeCall = false;
-    if (cascadeCall)
-        return;
-    cascadeCall = true;
-
-    QMouseEvent contentEvent(event->type(), adjustedPoint(event->pos()), event->globalPos(), event->button(), event->buttons(), event->modifiers());
-    QApplication::sendEvent(mContent, &contentEvent);
-
-    cascadeCall = false;
-}
-
-void RotatedWidget::mouseMoveEvent(QMouseEvent *event)
-{
-    if (!mTransferMouseMoveEvent)
-    {
-        event->ignore();
-        return;
-    }
-
-    static bool cascadeCall = false;
-    if (cascadeCall)
-        return;
-    cascadeCall = true;
-
-    QMouseEvent contentEvent(event->type(), adjustedPoint(event->pos()), event->globalPos(), event->button(), event->buttons(), event->modifiers());
-    QApplication::sendEvent(mContent, &contentEvent);
-
-    cascadeCall = false;
-}
-
-#ifndef QT_NO_WHEELEVENT
-void RotatedWidget::wheelEvent(QWheelEvent *event)
-{
-    if (!mTransferWheelEvent)
-    {
-        event->ignore();
-        return;
-    }
-
-    static bool cascadeCall = false;
-    if (cascadeCall)
-        return;
-    cascadeCall = true;
-
-    QWheelEvent contentEvent(adjustedPoint(event->pos()), event->globalPos(), event->delta(), event->buttons(), event->modifiers(), event->orientation());
-    QApplication::sendEvent(mContent, &contentEvent);
-
-    cascadeCall = false;
-}
-#endif
-
-void RotatedWidget::enterEvent(QEvent *event)
-{
-    if (!mTransferEnterEvent)
-    {
-        event->ignore();
-        return;
-    }
-
-    static bool cascadeCall = false;
-    if (cascadeCall)
-        return;
-    cascadeCall = true;
-
-    QApplication::sendEvent(mContent, event);
-
-    cascadeCall = false;
-}
-
-void RotatedWidget::leaveEvent(QEvent *event)
-{
-    if (!mTransferLeaveEvent)
-    {
-        event->ignore();
-        return;
-    }
-
-    static bool cascadeCall = false;
-    if (cascadeCall)
-        return;
-    cascadeCall = true;
-
-    QApplication::sendEvent(mContent, event);
-
-    cascadeCall = false;
-}
-
-void RotatedWidget::resizeEvent(QResizeEvent *event)
-{
-    static bool cascadeCall = false;
-    if (cascadeCall)
-        return;
-    cascadeCall = true;
-
-    QResizeEvent contentEvent(adjustedSize(event->size()), adjustedSize(event->oldSize()));
-    QApplication::sendEvent(mContent, &contentEvent);
-
-    cascadeCall = false;
-}
diff --git a/rotatedwidget.h b/rotatedwidget.h
deleted file mode 100644 (file)
index 36fbd09..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2013 Razor team
- * Authors:
- *   Kuzma Shapran <kuzma.shapran@gmail.com>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#ifndef ROTATED_WIDGET_H
-#define ROTATED_WIDGET_H
-
-#include <QWidget>
-
-namespace LxQt
-{
-
-class RotatedWidget: public QWidget
-{
-    Q_OBJECT
-
-    Q_PROPERTY(Qt::Corner origin READ origin WRITE setOrigin)
-
-    Q_PROPERTY(bool transferMousePressEvent READ transferMousePressEvent WRITE setTransferMousePressEvent)
-    Q_PROPERTY(bool transferMouseReleaseEvent READ transferMouseReleaseEvent WRITE setTransferMouseReleaseEvent)
-    Q_PROPERTY(bool transferMouseDoubleClickEvent READ transferMouseDoubleClickEvent WRITE setTransferMouseDoubleClickEvent)
-    Q_PROPERTY(bool transferMouseMoveEvent READ transferMouseMoveEvent WRITE setTransferMouseMoveEvent)
-#ifndef QT_NO_WHEELEVENT
-    Q_PROPERTY(bool transferWheelEvent READ transferWheelEvent WRITE setTransferWheelEvent)
-#endif
-
-    Q_PROPERTY(bool transferEnterEvent READ transferEnterEvent WRITE setTransferEnterEvent)
-    Q_PROPERTY(bool transferLeaveEvent READ transferLeaveEvent WRITE setTransferLeaveEvent)
-
-public:
-    explicit RotatedWidget(QWidget &content, QWidget* parent = 0, Qt::WindowFlags f = 0);
-
-    Qt::Corner origin() const;
-    void setOrigin(Qt::Corner);
-
-    QWidget * content() const;
-
-    void adjustContentSize();
-
-    virtual QSize minimumSizeHint() const;
-    virtual QSize sizeHint() const;
-
-    QSize adjustedSize(QSize) const;
-    QPoint adjustedPoint(QPoint) const;
-
-
-    bool transferMousePressEvent() const { return mTransferMousePressEvent; }
-    void setTransferMousePressEvent(bool value) { mTransferMousePressEvent = value; }
-
-    bool transferMouseReleaseEvent() const { return mTransferMouseReleaseEvent; }
-    void setTransferMouseReleaseEvent(bool value) { mTransferMouseReleaseEvent = value; }
-
-    bool transferMouseDoubleClickEvent() const { return mTransferMouseDoubleClickEvent; }
-    void setTransferMouseDoubleClickEvent(bool value) { mTransferMouseDoubleClickEvent = value; }
-
-    bool transferMouseMoveEvent() const { return mTransferMouseMoveEvent; }
-    void setTransferMouseMoveEvent(bool value) { mTransferMouseMoveEvent = value; }
-
-#ifndef QT_NO_WHEELEVENT
-    bool transferWheelEvent() const { return mTransferWheelEvent; }
-    void setTransferWheelEvent(bool value) { mTransferWheelEvent = value; }
-#endif
-
-    bool transferEnterEvent() const { return mTransferEnterEvent; }
-    void setTransferEnterEvent(bool value) { mTransferEnterEvent = value; }
-
-    bool transferLeaveEvent() const { return mTransferLeaveEvent; }
-    void setTransferLeaveEvent(bool value) { mTransferLeaveEvent = value; }
-
-protected:
-    virtual void paintEvent(QPaintEvent *);
-
-    // Transition event handlers
-    virtual void mousePressEvent(QMouseEvent *);
-    virtual void mouseReleaseEvent(QMouseEvent *);
-    virtual void mouseDoubleClickEvent(QMouseEvent *);
-    virtual void mouseMoveEvent(QMouseEvent *);
-#ifndef QT_NO_WHEELEVENT
-    virtual void wheelEvent(QWheelEvent *);
-#endif
-    virtual void enterEvent(QEvent *);
-    virtual void leaveEvent(QEvent *);
-
-    virtual void resizeEvent(QResizeEvent *);
-
-private:
-    QWidget *mContent;
-    Qt::Corner mOrigin;
-
-    bool mTransferMousePressEvent;
-    bool mTransferMouseReleaseEvent;
-    bool mTransferMouseDoubleClickEvent;
-    bool mTransferMouseMoveEvent;
-#ifndef QT_NO_WHEELEVENT
-    bool mTransferWheelEvent;
-#endif
-    bool mTransferEnterEvent;
-    bool mTransferLeaveEvent;
-};
-
-} // namespace LxQt
-#endif
diff --git a/screensaver.cpp b/screensaver.cpp
deleted file mode 100644 (file)
index 5a8046d..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Petr Vanek <petr@scribus.info>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#include <QtCore/QProcess>
-#include <QtGui/QMessageBox>
-
-#include <qtxdg/xdgicon.h>
-#include "screensaver.h"
-#include "libtranslate.h"
-
-using namespace LxQt;
-
-ScreenSaver::ScreenSaver(QObject * parent)
-    : QObject(parent)
-{
-    LxQt::libTranslate("librazorqt");
-    m_xdgProcess = new QProcess(this);
-    connect(m_xdgProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
-            this, SLOT(xdgProcess_finished(int,QProcess::ExitStatus)));
-}
-
-QList<QAction*> ScreenSaver::availableActions()
-{
-    QList<QAction*> ret;
-    QAction * act;
-
-    act = new QAction(XdgIcon::fromTheme("system-lock-screen", "lock"), tr("Lock Screen"), this);
-    connect(act, SIGNAL(triggered()), this, SLOT(lockScreen()));
-    ret.append(act);
-
-    return ret;
-}
-
-void ScreenSaver::lockScreen()
-{
-    m_xdgProcess->start("xdg-screensaver", QStringList() << "lock");
-}
-
-void ScreenSaver::xdgProcess_finished(int err, QProcess::ExitStatus status)
-{
-    QWidget *p = qobject_cast<QWidget*>(parent());
-
-    if (status == QProcess::CrashExit)
-    {
-        QMessageBox::warning(p,
-                             tr("Screen Saver Activation Error"),
-                             tr("An error occurred starting screensaver. "
-                                "xdg-screensaver cannot be started due its crash.")
-                            );
-    }
-    else if (err == -2)
-    {
-        QMessageBox::warning(p,  
-                             tr("Screen Saver Activation Error"),
-                             tr("An error occurred starting screensaver. "
-                                "xdg-screensaver is not installed correctly.")
-                            );  
-    }
-    else if (err == -1)
-    {
-        QMessageBox::warning(p,
-                             tr("Screen Saver Activation Error"),
-                             tr("An error occurred starting screensaver. "
-                                "xdg-screensaver cannot be started.")
-                            );
-    }
-    else if (err == 0)
-    {
-        emit activated();
-    }
-    else if (err == 1)
-    {
-        QMessageBox::warning(p,  
-                             tr("Screen Saver Activation Error"),
-                             tr("An error occurred starting screensaver. "
-                                "Syntax error in xdg-screensaver arguments.")
-                            );
-    }
-    else if (err == 3)
-    {
-        QMessageBox::warning(p,  
-                             tr("Screen Saver Activation Error"),
-                             tr("An error occurred starting screensaver. "
-                                "Ensure you have xscreensaver installed and running.")
-                            );
-    }
-    else if (err == 4)
-    {
-        QMessageBox::warning(p,  
-                             tr("Screen Saver Activation Error"),
-                             tr("An error occurred starting screensaver. "
-                                "Action 'activate' failed. "
-                                "Ensure you have xscreensaver installed and running.")
-                            );
-    }
-    else
-    {
-        QMessageBox::warning(p,  
-                             tr("Screen Saver Activation Error"),
-                             tr("An error occurred starting screensaver. "
-                                "Unknown error - undocumented return value from xdg-screensaver=%1.").arg(err)
-                            );
-    }
-}
-
diff --git a/screensaver.h b/screensaver.h
deleted file mode 100644 (file)
index 5726dc1..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Petr Vanek <petr@scribus.info>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#ifndef SCREENSAVER_H
-#define SCREENSAVER_H
-
-#include <QtCore/QProcess>
-#include <QtCore/QObject>
-#include <QtGui/QAction>
-
-
-class QProcess;
-
-namespace LxQt
-{
-
-class ScreenSaver : public QObject
-{
-    Q_OBJECT
-
-public:
-    ScreenSaver(QObject * parent=0);
-
-    QList<QAction*> availableActions();
-
-signals:
-    void activated();
-
-public slots:
-    void lockScreen();
-
-private:
-    QProcess * m_xdgProcess;
-
-private slots:
-    void xdgProcess_finished(int err, QProcess::ExitStatus status);
-
-};
-
-} // namespace LxQt
-#endif
-
diff --git a/xfitman.cpp b/xfitman.cpp
deleted file mode 100644 (file)
index 1692c9d..0000000
+++ /dev/null
@@ -1,977 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Christopher "VdoP" Regali
- *   Alexander Sokoloff <sokoloff.a@gmail.com>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-
-
-#include <QtGui/QX11Info>
-#include <QtCore/QList>
-#include <QtGui/QApplication>
-#include <QtCore/QDebug>
-#include <QtGui/QDesktopWidget>
-
-#include <stdint.h>
-#include "xfitman.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <X11/Xutil.h>
-#include <assert.h>
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-
-#include <QtGui/QWidget>
-#include <QtGui/QIcon>
-/**
- * @file xfitman.cpp
- * @brief implements class Xfitman
- * @author Christopher "VdoP" Regali
- */
-
-/*
- Some requests from Clients include type of the Client, for example the _NET_ACTIVE_WINDOW
- message. Currently the types can be 1 for normal applications, and 2 for pagers.
- See http://standards.freedesktop.org/wm-spec/latest/ar01s09.html#sourceindication
- */
-#define SOURCE_NORMAL   1
-#define SOURCE_PAGER    2
-
-/*
-  _NET_WM_STATE actions
- */
-#define _NET_WM_STATE_REMOVE    0    // remove/unset property
-#define _NET_WM_STATE_ADD       1    // add/set property
-#define _NET_WM_STATE_TOGGLE    2    // toggle property
-
-using namespace LxQt;
-
-const XfitMan&  xfitMan()
-{
-    static XfitMan instance;
-    return instance;
-}
-
-/**
- * @brief constructor: gets Display vars and registers us
- */
-XfitMan::XfitMan()
-{
-    root = QX11Info::appRootWindow();
-}
-
-/**
- * @brief moves a window to a new position
- */
-
-void XfitMan::moveWindow(Window _win, int _x, int _y) const
-{
-    XMoveWindow(QX11Info::display(), _win, _x, _y);
-}
-
-/************************************************
-
- ************************************************/
-bool XfitMan::getWindowProperty(Window window,
-                       Atom atom,               // property
-                       Atom reqType,            // req_type
-                       unsigned long* resultLen,// nitems_return
-                       unsigned char** result   // prop_return
-                      ) const
-{
-    int  format;
-    unsigned long type, rest;
-    return XGetWindowProperty(QX11Info::display(), window, atom, 0, 4096, false,
-                              reqType, &type, &format, resultLen, &rest,
-                              result)  == Success;
-}
-
-
-/************************************************
-
- ************************************************/
-bool XfitMan::getRootWindowProperty(Atom atom,    // property
-                           Atom reqType,            // req_type
-                           unsigned long* resultLen,// nitems_return
-                           unsigned char** result   // prop_return
-                          ) const
-{
-    return getWindowProperty(root, atom, reqType, resultLen, result);
-}
-
-
-/**
- * @brief this one gets the active application window.
- */
-Window XfitMan::getActiveAppWindow() const
-{
-    Window window = getActiveWindow();
-    if (window == 0)
-        return 0;
-
-    if (acceptWindow(window))
-        return window;
-
-    Window transFor = None;
-    if (XGetTransientForHint(QX11Info::display(), window, &transFor))
-        return transFor;
-
-    return 0;
-}
-
-/**
- * @brief returns the window that currently has inputfocus
- */
-Window XfitMan::getActiveWindow() const
-{
-    unsigned long len;
-    unsigned long *data;
-    if (!getWindowProperty(root, atom("_NET_ACTIVE_WINDOW"), XA_WINDOW,
-                          &len, (unsigned char**) &data)
-       )
-        return 0;
-
-    Window result = 0;
-    if (len)
-        result = data[0];
-
-    XFree(data);
-    return result;
-}
-
-
-/**
- * @brief Get the number of desktops
- */
-
-int XfitMan::getNumDesktop() const
-{
-    unsigned long length, *data;
-    getRootWindowProperty(atom("_NET_NUMBER_OF_DESKTOPS"), XA_CARDINAL, &length, (unsigned char**) &data);
-    if (data)
-    {
-        int res = data[0];
-        XFree(data);
-        return res;
-    }
-    return 0;
-}
-
-QStringList XfitMan::getDesktopNames() const
-{  
-    QStringList ret;
-    unsigned long length;
-    unsigned char *data = 0;
-
-    if (getRootWindowProperty(atom("_NET_DESKTOP_NAMES"), atom("UTF8_STRING"), &length, &data))
-    {
-        if (data)
-        {
-            char* c = (char*)data;
-            char* end = (char*)data + length;
-            while (c < end)
-            {
-                ret << QString::fromUtf8(c);
-                c += strlen(c) + 1; // for trailing \0
-            }
-
-            XFree(data);
-        }
-    }
-
-
-    return ret;
-}
-
-
-QString XfitMan::getDesktopName(int desktopNum, const QString &defaultName) const
-{
-    QStringList names = getDesktopNames();
-    if (desktopNum<0 || desktopNum>names.count()-1)
-        return defaultName;
-
-    return names.at(desktopNum);
-}
-
-/**
- * @brief resizes a window to the given dimensions
- */
-void XfitMan::resizeWindow(Window _wid, int _width, int _height) const
-{
-    XResizeWindow(QX11Info::display(), _wid, _width, _height);
-}
-
-
-
-/**
- * @brief gets a windowpixmap from a window
- */
-
-bool XfitMan::getClientIcon(Window _wid, QPixmap& _pixreturn) const
-{
-    int format;
-    ulong type, nitems, extra;
-    ulong* data = 0;
-
-    XGetWindowProperty(QX11Info::display(), _wid, atom("_NET_WM_ICON"),
-                       0, LONG_MAX, False, AnyPropertyType,
-                       &type, &format, &nitems, &extra,
-                       (uchar**)&data);
-    if (!data)
-    {
-        return false;
-    }
-
-    QImage img (data[0], data[1], QImage::Format_ARGB32);
-    for (int i=0; i<img.byteCount()/4; ++i)
-        ((uint*)img.bits())[i] = data[i+2];
-
-    _pixreturn = QPixmap::fromImage(img);
-    XFree(data);
-
-    return true;
-}
-
-bool XfitMan::getClientIcon(Window _wid, QIcon *icon) const
-{
-    int format;
-    ulong type, nitems, extra;
-    ulong* data = 0;
-
-    XGetWindowProperty(QX11Info::display(), _wid, atom("_NET_WM_ICON"),
-                       0, LONG_MAX, False, AnyPropertyType,
-                       &type, &format, &nitems, &extra,
-                       (uchar**)&data);
-    if (!data)
-    {
-        return false;
-    }
-
-    ulong* d = data;
-    while (d < data + nitems)
-    {
-        QImage img (d[0], d[1], QImage::Format_ARGB32);
-        d+=2;
-        for (int i=0; i<img.byteCount()/4; ++i, ++d)
-            ((uint*)img.bits())[i] = *d;
-
-        icon->addPixmap(QPixmap::fromImage(img));
-    }
-
-    XFree(data);
-    return true;
-}
-
-
-
-/**
- * @brief destructor
- */
-XfitMan::~XfitMan()
-{
-}
-/**
- * @brief returns a windowname and sets _nameSource to the finally used Atom
- */
-
-//i got the idea for this from taskbar-plugin of LXPanel - so credits fly out :)
-QString XfitMan::getWindowTitle(Window _wid) const
-{
-    QString name = "";
-    //first try the modern net-wm ones
-    unsigned long length;
-    unsigned char *data = NULL;
-    Atom utf8Atom = atom("UTF8_STRING");
-
-    if (getWindowProperty(_wid, atom("_NET_WM_VISIBLE_NAME"), utf8Atom, &length, &data))
-    {
-        name = QString::fromUtf8((char*) data);
-        XFree(data);
-
-    }
-
-    if (name.isEmpty())
-    {
-        if (getWindowProperty(_wid, atom("_NET_WM_NAME"), utf8Atom, &length, &data))
-        {
-            name = QString::fromUtf8((char*) data);
-            XFree(data);
-        }
-    }
-
-    if (name.isEmpty())
-    {
-        if (getWindowProperty(_wid, atom("XA_WM_NAME"), XA_STRING, &length, &data))
-        {
-            name = (char*) data;
-            XFree(data);
-        }
-    }
-
-    if (name.isEmpty())
-    {
-        Status ok = XFetchName(QX11Info::display(), _wid, (char**) &data);
-        name = QString((char*) data);
-        if (0 != ok) XFree(data);
-    }
-
-    if (name.isEmpty())
-    {
-        XTextProperty prop;
-        if (XGetWMName(QX11Info::display(), _wid, &prop))
-        {
-            name = QString::fromUtf8((char*) prop.value);
-            XFree(prop.value);
-        }
-    }
-
-    return name;
-}
-
-QString XfitMan::getApplicationName(Window _wid) const
-{
-    XClassHint hint;
-    QString ret;
-
-    if (XGetClassHint(QX11Info::display(), _wid, &hint))
-    {
-        if (hint.res_name)
-        {
-            ret = hint.res_name;
-            XFree(hint.res_name);
-        }
-        if (hint.res_class)
-        {
-            XFree(hint.res_class);
-        }
-    }
-
-    return ret;
-}
-
-/**
- * @brief sends a clientmessage to a window
- */
-int XfitMan::clientMessage(Window _wid, Atom _msg,
-                            unsigned long data0,
-                            unsigned long data1,
-                            unsigned long data2,
-                            unsigned long data3,
-                            unsigned long data4) const
-{
-    XClientMessageEvent msg;
-    msg.window = _wid;
-    msg.type = ClientMessage;
-    msg.message_type = _msg;
-    msg.send_event = true;
-    msg.display = QX11Info::display();
-    msg.format = 32;
-    msg.data.l[0] = data0;
-    msg.data.l[1] = data1;
-    msg.data.l[2] = data2;
-    msg.data.l[3] = data3;
-    msg.data.l[4] = data4;
-    if (XSendEvent(QX11Info::display(), root, FALSE, (SubstructureRedirectMask | SubstructureNotifyMask) , (XEvent *) &msg) == Success)
-        return EXIT_SUCCESS;
-    else
-        return EXIT_FAILURE;
-}
-
-
-/***********************************************
-
- ***********************************************/
-WindowAllowedActions XfitMan::getAllowedActions(Window window) const
-{
-    WindowAllowedActions actions = { };
-
-    unsigned long len;
-    unsigned long *data;
-    if (getWindowProperty(window, atom("_NET_WM_ALLOWED_ACTIONS"), XA_ATOM, &len, (unsigned char**) &data))
-    {
-        for (unsigned long i=0; i<len; ++i)
-        {
-            if (data[i] == atom("_NET_WM_ACTION_MOVE"))             actions.Move = true;            else
-            if (data[i] == atom("_NET_WM_ACTION_RESIZE"))           actions.Resize = true;          else
-            if (data[i] == atom("_NET_WM_ACTION_MINIMIZE"))         actions.Minimize = true;        else
-            if (data[i] == atom("_NET_WM_ACTION_SHADE"))            actions.Shade = true;           else
-            if (data[i] == atom("_NET_WM_ACTION_STICK"))            actions.Stick = true;           else
-            if (data[i] == atom("_NET_WM_ACTION_MAXIMIZE_HORZ"))    actions.MaximizeHoriz = true;   else
-            if (data[i] == atom("_NET_WM_ACTION_MAXIMIZE_VERT"))    actions.MaximizeVert = true;    else
-            if (data[i] == atom("_NET_WM_ACTION_FULLSCREEN"))       actions.FullScreen = true;      else
-            if (data[i] == atom("_NET_WM_ACTION_CHANGE_DESKTOP"))   actions.ChangeDesktop = true;   else
-            if (data[i] == atom("_NET_WM_ACTION_CLOSE"))            actions.Close = true;           else
-            if (data[i] == atom("_NET_WM_ACTION_ABOVE"))            actions.AboveLayer = true;      else
-            if (data[i] == atom("_NET_WM_ACTION_BELOW"))            actions.BelowLayer = true;
-        }
-        XFree(data);
-    }
-
-    return actions;
-}
-
-
-WindowState XfitMan::getWindowState(Window window) const
-{
-    WindowState state = { };
-
-    unsigned long len;
-    unsigned long *data;
-    if (getWindowProperty(window, atom("_NET_WM_STATE"), XA_ATOM, &len, (unsigned char**) &data))
-    {
-        for (unsigned long i=0; i<len; ++i)
-        {
-            if (data[i] == atom("_NET_WM_STATE_MODAL"))             state.Modal = true;             else
-            if (data[i] == atom("_NET_WM_STATE_STICKY"))            state.Sticky = true;            else
-            if (data[i] == atom("_NET_WM_STATE_MAXIMIZED_VERT"))    state.MaximizedVert = true;     else
-            if (data[i] == atom("_NET_WM_STATE_MAXIMIZED_HORZ"))    state.MaximizedHoriz = true;    else
-            if (data[i] == atom("_NET_WM_STATE_SHADED"))            state.Shaded = true;            else
-            if (data[i] == atom("_NET_WM_STATE_SKIP_TASKBAR"))      state.SkipTaskBar = true;       else
-            if (data[i] == atom("_NET_WM_STATE_SKIP_PAGER"))        state.SkipPager = true;         else
-            if (data[i] == atom("_NET_WM_STATE_HIDDEN"))            state.Hidden = true;            else
-            if (data[i] == atom("_NET_WM_STATE_FULLSCREEN"))        state.FullScreen = true;        else
-            if (data[i] == atom("_NET_WM_STATE_ABOVE"))             state.AboveLayer = true;        else
-            if (data[i] == atom("_NET_WM_STATE_BELOW"))             state.BelowLayer = true;        else
-            if (data[i] == atom("_NET_WM_STATE_DEMANDS_ATTENTION")) state.Attention = true;
-        }
-        XFree(data);
-    }
-
-    return state;
-
-}
-
-
-
-/**
- * @brief returns true if a window has its hidden_flag set
- */
-
-bool XfitMan::isHidden(Window _wid) const
-{
-    return getWindowState(_wid).Hidden;
-}
-
-Atom XfitMan::atom(const char* atomName)
-{
-    static QHash<QString, Atom> hash;
-
-    if (hash.contains(atomName))
-        return hash.value(atomName);
-
-    Atom atom = XInternAtom(QX11Info::display(), atomName, false);
-    hash[atomName] = atom;
-    return atom;
-}
-
-AtomList XfitMan::getWindowType(Window window) const
-{
-    AtomList result;
-
-    unsigned long length, *data;
-    length=0;
-    if (!getWindowProperty(window, atom("_NET_WM_WINDOW_TYPE"), (Atom)AnyPropertyType, &length, (unsigned char**) &data))
-        return result;
-
-    for (unsigned int i = 0; i < length; i++)
-        result.append(data[i]);
-
-    XFree(data);
-    return result;
-}
-
-
-/**
- * @brief rejects a window from beeing listed
- */
-bool XfitMan::acceptWindow(Window window) const
-{
-    {
-        AtomList types = getWindowType(window);
-        AtomList ignoreList;
-        ignoreList  << atom("_NET_WM_WINDOW_TYPE_DESKTOP")
-                    << atom("_NET_WM_WINDOW_TYPE_DOCK")
-                    << atom("_NET_WM_WINDOW_TYPE_SPLASH")
-                    << atom("_NET_WM_WINDOW_TYPE_TOOLBAR")
-                    << atom("_NET_WM_WINDOW_TYPE_MENU")
-                    // for qlipper - using qpopup as a main window
-                    << atom("_NET_WM_WINDOW_TYPE_POPUP_MENU");
-        // issue #284: qmmp its not registered in window list panel
-        // qmmp has _KDE_NET_WM_WINDOW_TYPE_OVERRIDE in its
-        // _NET_WM_WINDOW_TYPE(ATOM) = _KDE_NET_WM_WINDOW_TYPE_OVERRIDE, _NET_WM_WINDOW_TYPE_NORMAL
-        // Let's expect that _KDE_NET_WM_WINDOW_TYPE_OVERRIDE can be set for
-        // regular windows too. If it should be hidden we should expect
-        // one of atoms listed above.
-//                    << atom("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE");
-
-        foreach (Atom i, ignoreList)
-        {
-            if (types.contains(i))
-                return false;
-        }
-
-        WindowState state = getWindowState(window);
-        if (state.SkipTaskBar)  return false;
-    }
-
-    Window transFor = None;
-    // WM_TRANSIENT_FOR hint not set - normal window
-    if (!XGetTransientForHint(QX11Info::display(), window, &transFor))
-        return true;
-
-    if (transFor == 0)      return true;
-    if (transFor == window) return true;
-    if (transFor == root)   return true;
-
-     AtomList transForTypes = getWindowType(transFor);
-     return !transForTypes.contains(atom("_NET_WM_WINDOW_TYPE_NORMAL"));
-}
-
-
-
-/**
- * @brief gets a client list
- */
-WindowList XfitMan::getClientList() const
-{
-    //initialize the parameters for the XGetWindowProperty call
-    unsigned long length, *data;
-    length=0;
-
-    /**
-     * @todo maybe support multiple desktops here!
-     */
-    QList<Window> output;
-
-    if (getRootWindowProperty(atom("_NET_CLIENT_LIST"), (Atom)AnyPropertyType, &length,  (unsigned char**) &data))
-    {
-        for (unsigned int i = 0; i < length; i ++)
-            output.append(data[i]);
-        XFree(data);
-    }
-
-    return output;
-}
-
-
-/**
- * @brief returns the current desktop
- */
-int XfitMan::getActiveDesktop() const
-{
-    int res = -2;
-    unsigned long length, *data;
-    if (getRootWindowProperty(atom("_NET_CURRENT_DESKTOP"), XA_CARDINAL, &length, (unsigned char**) &data))
-    {
-        if (data)
-        {
-            res = data[0];
-            XFree(data);
-        }
-    }
-
-    return res;
-}
-
-
-/**
- * @brief gets the desktop of the windows _wid
- */
-int XfitMan::getWindowDesktop(Window _wid) const
-{
-    int  res = -1;
-    unsigned long length, *data;
-    // so we try to use net_wm_desktop first, but if the
-    // system does not use net_wm standard we use win_workspace!
-    if (getWindowProperty(_wid, atom("_NET_WM_DESKTOP"), XA_CARDINAL, &length, (unsigned char**) &data))
-    {
-        if (!data)
-            return res;
-        res = data[0];
-        XFree(data);
-    }
-    else
-    {
-        if (getWindowProperty(_wid, atom("_WIN_WORKSPACE"), XA_CARDINAL, &length, (unsigned char**) &data))
-        {
-            if (!data)
-                return res;
-            res = data[0];
-            XFree(data);
-        }
-    }
-
-    return res;
-}
-
-
-/**
- * @brief moves a window to a specified desktop
- */
-
-void XfitMan::moveWindowToDesktop(Window _wid, int _display) const
-{
-    clientMessage(_wid, atom("_NET_WM_DESKTOP"), (unsigned long) _display,0,0,0,0);
-}
-
-
-/**
- * @brief raises windows _wid
- */
-void XfitMan::raiseWindow(Window _wid) const
-{
-    clientMessage(_wid, atom("_NET_ACTIVE_WINDOW"),
-                  SOURCE_PAGER);
-}
-
-
-/************************************************
-
- ************************************************/
-void XfitMan::minimizeWindow(Window _wid) const
-{
-    clientMessage(_wid, atom("WM_CHANGE_STATE"),
-                  IconicState);
-}
-
-
-/************************************************
-
- ************************************************/
-void XfitMan::maximizeWindow(Window _wid, MaximizeDirection direction) const
-{
-    Atom atom1 = 0, atom2= 0;
-    switch (direction)
-    {
-        case MaximizeHoriz:
-            atom1 = atom("_NET_WM_STATE_MAXIMIZED_HORZ");
-            break;
-
-        case MaximizeVert:
-            atom1 = atom("_NET_WM_STATE_MAXIMIZED_VERT");
-            break;
-
-        case MaximizeBoth:
-            atom1 = atom("_NET_WM_STATE_MAXIMIZED_VERT");
-            atom2 = atom("_NET_WM_STATE_MAXIMIZED_HORZ");
-            break;
-
-    }
-
-    clientMessage(_wid, atom("_NET_WM_STATE"),
-                  _NET_WM_STATE_ADD,
-                  atom1, atom2,
-                  SOURCE_PAGER);
-    raiseWindow(_wid);
-}
-
-
-/************************************************
-
- ************************************************/
-void XfitMan::deMaximizeWindow(Window _wid) const
-{
-    clientMessage(_wid, atom("_NET_WM_STATE"),
-                  _NET_WM_STATE_REMOVE,
-                  atom("_NET_WM_STATE_MAXIMIZED_VERT"),
-                  atom("_NET_WM_STATE_MAXIMIZED_HORZ"),
-                  SOURCE_PAGER);
-}
-
-/************************************************
-
- ************************************************/
-void XfitMan::shadeWindow(Window _wid, bool shade) const
-{
-    clientMessage(_wid, atom("_NET_WM_STATE"),
-                  shade ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE,
-                  atom("_NET_WM_STATE_SHADED"),
-                  0,
-                  SOURCE_PAGER);
-}
-
-
-/************************************************
-
- ************************************************/
-void XfitMan::closeWindow(Window _wid) const
-{
-    clientMessage(_wid, atom("_NET_CLOSE_WINDOW"),
-                  0, // Timestamp
-                  SOURCE_PAGER);
-}
-
-
-/************************************************
-
- ************************************************/
-void XfitMan::setWindowLayer(Window _wid, XfitMan::Layer layer) const
-{
-    ulong aboveAction = (layer == LayerAbove) ?
-        _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
-
-    ulong belowAction = (layer == LayerBelow) ?
-        _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
-
-    clientMessage(_wid, atom("_NET_WM_STATE"),
-                  aboveAction,
-                  atom("_NET_WM_STATE_ABOVE"),
-                  0,
-                  SOURCE_PAGER);
-
-    clientMessage(_wid, atom("_NET_WM_STATE"),
-                  belowAction,
-                  atom("_NET_WM_STATE_BELOW"),
-                  0,
-                  SOURCE_PAGER);
-}
-
-/**
- * @brief changes active desktop to _desktop
- */
-void XfitMan::setActiveDesktop(int _desktop) const
-{
-    clientMessage(root, atom("_NET_CURRENT_DESKTOP"), (unsigned long) _desktop,0,0,0,0);
-}
-
-/**
- * @brief sets net_wm_strut_partial = our reserved panelspace for the mainbar!
- */
-void XfitMan::setStrut(Window _wid,
-                       int left, int right,
-                       int top,  int bottom,
-
-                       int leftStartY,   int leftEndY,
-                       int rightStartY,  int rightEndY,
-                       int topStartX,    int topEndX,
-                       int bottomStartX, int bottomEndX
-                       ) const
-{
-    //qDebug() << "XfitMan: Trying to set STRUT_PARTIAL for panel!";
-    unsigned long desstrut[12];
-    memset(desstrut,0,sizeof(desstrut));
-    //prepare the array
-    //it has format:
-    /*
-     * left, right, top, bottom, left_start_y, left_end_y,
-     * right_start_y, right_end_y, top_start_x, top_end_x, bottom_start_x,
-     * bottom_end_x
-     *
-     */
-
-    //so we take our panelsize from the bottom up
-    desstrut[0] = left; desstrut[1] = right;
-    desstrut[2] = top;  desstrut[3] = bottom;
-
-    desstrut[4] = leftStartY;    desstrut[5] = leftEndY;
-    desstrut[6] = rightStartY;   desstrut[7] = rightEndY;
-    desstrut[8] = topStartX;     desstrut[9] = topEndX;
-    desstrut[10] = bottomStartX; desstrut[11] = bottomEndX;
-
-    //now we can change that property right
-    XChangeProperty(QX11Info::display(), _wid , atom("_NET_WM_STRUT_PARTIAL"),
-                    XA_CARDINAL, 32, PropModeReplace,  (unsigned char *) desstrut, 12  );
-
-    //now some wm do not support net_wm_strut_partial but only net_wm_strut, so we also
-    // send that one too xdg-std says: if you get a strut_partial ignore all following
-    // struts! so if this msg is recognized its ok if not, we dont care either
-
-    XChangeProperty(QX11Info::display(), _wid, atom("_NET_WM_STRUT"),
-                    XA_CARDINAL, 32, PropModeReplace, (unsigned char*) desstrut, 4);
-}
-
-
-#ifdef DEBUG
-/************************************************
-
- ************************************************/
-QString XfitMan::debugWindow(Window wnd)
-{
-    if (!wnd)
-        return QString("[%1]").arg(wnd,8, 16);
-
-    QString typeStr;
-    int  format;
-    unsigned long type, length, rest, *data;
-    length=0;
-    if (XGetWindowProperty(QX11Info::display(), wnd, XInternAtom(QX11Info::display(), "_NET_WM_WINDOW_TYPE", False),
-                           0, 4096, FALSE, AnyPropertyType, &type, &format,
-                           &length, &rest,(unsigned char**) &data) == Success)
-    {
-        for (unsigned int i = 0; i < length; i++)
-        {
-            char* aname = XGetAtomName(QX11Info::display(), data[i]);
-            typeStr = typeStr + " " + aname;
-            XFree(aname);
-        }
-    }
-    else
-        typeStr ="ERROR";
-
-    return QString("[%1] %2 %3").arg(wnd,8, 16).arg(xfitMan().getWindowTitle(wnd)).arg(typeStr);
-}
-#endif
-
-
-/************************************************
-
- ************************************************/
-const QRect XfitMan::availableGeometry(int screen) const
-{
-    QDesktopWidget *d = QApplication::desktop();
-
-    if (screen < 0 || screen >= d->screenCount())
-        screen = d->primaryScreen();
-
-    QRect available = d->screenGeometry(screen);
-
-    // Iterate over all the client windows and subtract from the available
-    // area the space they reserved on the edges (struts).
-    // Note: _NET_WORKAREA is not reliable as it exposes only one
-    // rectangular area spanning all screens.
-    Display *display = QX11Info::display();
-    int x11Screen = d->isVirtualDesktop() ? DefaultScreen(display) : screen;
-
-    Atom ret;
-    int format, status;
-    uchar* data = 0;
-    ulong nitems, after;
-
-    status = XGetWindowProperty(display, QX11Info::appRootWindow(x11Screen),
-                                atom("_NET_CLIENT_LIST"), 0L, ~0L, False, XA_WINDOW,
-                                &ret, &format, &nitems, &after, &data);
-
-    if (status == Success && ret == XA_WINDOW && format == 32 && nitems)
-    {
-        const QRect desktopGeometry = d->rect();
-
-        Window* xids = (Window*) data;
-        for (quint32 i = 0; i < nitems; ++i)
-        {
-            ulong nitems2;
-            uchar* data2 = 0;
-            status = XGetWindowProperty(display, xids[i],
-                                        atom("_NET_WM_STRUT_PARTIAL"), 0, 12, False, XA_CARDINAL,
-                                        &ret, &format, &nitems2, &after, &data2);
-
-            if (status == Success && ret == XA_CARDINAL && format == 32 && nitems2 == 12)
-            {
-                ulong* struts = (ulong*) data2;
-
-                QRect left(desktopGeometry.x(),
-                           desktopGeometry.y() + struts[4],
-                           struts[0],
-                           struts[5] - struts[4]);
-                if (available.intersects(left))
-                    available.setX(left.width());
-
-                QRect right(desktopGeometry.x() + desktopGeometry.width() - struts[1],
-                            desktopGeometry.y() + struts[6],
-                            struts[1],
-                            struts[7] - struts[6]);
-                if (available.intersects(right))
-                    available.setWidth(right.x() - available.x());
-
-                QRect top(desktopGeometry.x() + struts[8],
-                          desktopGeometry.y(),
-                          struts[9] - struts[8],
-                          struts[2]);
-                if (available.intersects(top))
-                    available.setY(top.height());
-
-                QRect bottom(desktopGeometry.x() + struts[10],
-                             desktopGeometry.y() + desktopGeometry.height() - struts[3],
-                             struts[11] - struts[10],
-                             struts[3]);
-                if (available.intersects(bottom))
-                    available.setHeight(bottom.y() - available.y());
-            }
-            if (data2)
-                XFree(data2);
-        }
-    }
-    if (data)
-        XFree(data);
-
-    return available;
-}
-
-
-/************************************************
-
- ************************************************/
-const QRect XfitMan::availableGeometry(const QWidget *widget) const
-{
-    if (!widget)
-    {
-        qWarning("XfitMan::availableGeometry(): Attempt "
-                 "to get the available geometry of a null widget");
-        return QRect();
-    }
-
-    return availableGeometry(QApplication::desktop()->screenNumber(widget));
-}
-
-
-/************************************************
-
- ************************************************/
-const QRect XfitMan::availableGeometry(const QPoint &point) const
-{
-    return availableGeometry(QApplication::desktop()->screenNumber(point));
-}
-
-
-/************************************************
- The Window Manager MUST set this property on the root window to be the ID of a child
- window created by himself, to indicate that a compliant window manager is active.
-
- http://standards.freedesktop.org/wm-spec/wm-spec-latest.html#id2550836
- ************************************************/
-bool XfitMan::isWindowManagerActive() const
-{
-    //Window *wins;
-
-    //getRootWindowProperty(atom("_NET_SUPPORTING_WM_CHECK"), XA_WINDOW, &length, (unsigned char**) &wins);
-
-    Atom type;
-    unsigned long length;
-    Window *wins;
-    int format;
-    unsigned long after;
-
-    XGetWindowProperty(QX11Info::display(), root, atom("_NET_SUPPORTING_WM_CHECK"),
-                       0, LONG_MAX,
-                       false, XA_WINDOW, &type, &format, &length,
-                       &after, (unsigned char **)&wins);
-
-    if ( type == XA_WINDOW && length > 0 && wins[0] != None )
-    {
-        XFree(wins);
-        return true;
-    }
-    return false;
-}
diff --git a/xfitman.h b/xfitman.h
deleted file mode 100644 (file)
index 27f10b0..0000000
--- a/xfitman.h
+++ /dev/null
@@ -1,243 +0,0 @@
-/* BEGIN_COMMON_COPYRIGHT_HEADER
- * (c)LGPL2+
- *
- * Razor - a lightweight, Qt based, desktop toolset
- * http://razor-qt.org
- *
- * Copyright: 2010-2011 Razor team
- * Authors:
- *   Christopher "VdoP" Regali
- *   Alexander Sokoloff <sokoloff.a@gmail.com>
- *
- * This program or library is free software; you can redistribute it
- * and/or modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * END_COMMON_COPYRIGHT_HEADER */
-
-#ifndef XFITMAN_H
-#define XFITMAN_H
-
-#include <QtCore/QList>
-#include <QtGui/QPixmap>
-#include <QtCore/QString>
-#include <QtCore/QMap>
-#include <X11/Xlib.h>
-
-//some net_wm state-operations we need here
-#define _NET_WM_STATE_TOGGLE 2
-#define _NET_WM_STATE_ADD 1
-#define _NET_WM_STATE_REMOVE 0
-
-/**
- * @file xfitman.h
- * @author Christopher "VdoP" Regali
- * @brief handles all of our xlib-calls.
- */
-
-namespace LxQt
-{
-
-typedef QList<Atom> AtomList;
-typedef QList<Window> WindowList;
-
-// A list of atoms indicating user operations that the Window Manager supports
-// for this window.
-// See http://standards.freedesktop.org/wm-spec/latest/ar01s05.html#id2569373
-struct WindowAllowedActions
-{
-    bool Move;          // indicates that the window may be moved around the screen.
-    bool Resize;        // indicates that the window may be resized.
-    bool Minimize;      // indicates that the window may be iconified.
-    bool Shade;         // indicates that the window may be shaded.
-    bool Stick;         // indicates that the window may have its sticky state toggled.
-    bool MaximizeHoriz; // indicates that the window may be maximized horizontally.
-    bool MaximizeVert;  // indicates that the window may be maximized vertically.
-    bool FullScreen;    // indicates that the window may be brought to fullscreen state.
-    bool ChangeDesktop; // indicates that the window may be moved between desktops.
-    bool Close;         // indicates that the window may be closed.
-    bool AboveLayer;    // indicates that the window may placed in the "above" layer of windows
-    bool BelowLayer;    // indicates that the window may placed in the "below" layer of windows
-};
-
-// A list of hints describing the window state.
-// http://standards.freedesktop.org/wm-spec/latest/ar01s05.html#id2569140
-struct WindowState
-{
-    bool Modal;         // indicates that this is a modal dialog box.
-    bool Sticky;        // indicates that the Window Manager SHOULD keep the window's position
-                        // fixed on the screen, even when the virtual desktop scrolls.
-    bool MaximizedVert; // indicates that the window is vertically maximized.
-    bool MaximizedHoriz;// indicates that the window is horizontally maximized.
-    bool Shaded;        // indicates that the window is shaded.
-    bool SkipTaskBar;   // indicates that the window should not be included on a taskbar.
-    bool SkipPager;     // indicates that the window should not be included on a Pager.
-    bool Hidden;        // indicates that a window would not be visible on the screen
-    bool FullScreen;    // indicates that the window should fill the entire screen.
-    bool AboveLayer;    // indicates that the window should be on top of most windows.
-    bool BelowLayer;    // indicates that the window should be below most windows.
-    bool Attention;     // indicates that some action in or with the window happened.
-};
-
-
-/**
- * @brief manages the Xlib apicalls
- */
-class XfitMan
-{
-public:
-
-    enum Layer
-    {
-        LayerAbove,
-        LayerNormal,
-        LayerBelow
-    };
-
-    enum MaximizeDirection
-    {
-        MaximizeHoriz,
-        MaximizeVert,
-        MaximizeBoth
-    };
-
-    ~XfitMan();
-    XfitMan();
-    void moveWindow(Window _win, int _x, int _y) const;
-
-    // See
-    void setStrut(Window _wid,
-                  int left, int right,
-                  int top,  int bottom,
-
-                  int leftStartY,   int leftEndY,
-                  int rightStartY,  int rightEndY,
-                  int topStartX,    int topEndX,
-                  int bottomStartX, int bottomEndX
-                  ) const;
-    WindowList getClientList() const;
-    bool getClientIcon(Window _wid, QPixmap& _pixreturn) const;
-    bool getClientIcon(Window _wid, QIcon *icon) const;
-    int getWindowDesktop(Window _wid) const;
-    void moveWindowToDesktop(Window _wid, int _display) const;
-
-    void raiseWindow(Window _wid) const;
-    void minimizeWindow(Window _wid) const;
-    void maximizeWindow(Window _wid, MaximizeDirection direction = MaximizeBoth) const;
-    void deMaximizeWindow(Window _wid) const;
-    void shadeWindow(Window _wid, bool shade) const;
-    void resizeWindow(Window _wid, int _width, int _height) const;
-    void closeWindow(Window _wid) const;
-    void setWindowLayer(Window _wid, Layer layer) const;
-
-    void setActiveDesktop(int _desktop) const;
-    bool isHidden(Window _wid) const;
-    WindowAllowedActions getAllowedActions(Window window) const;
-    WindowState getWindowState(Window window) const;
-    int getActiveDesktop() const;
-    Window getActiveAppWindow() const;
-    Window getActiveWindow() const;
-    int getNumDesktop() const;
-
-    /*!
-     * Returns the names of all virtual desktops. This is a list of UTF-8 encoding strings.
-     *
-     * Note: The number of names could be different from getNumDesktop(). If it is less
-     * than getNumDesktop(), then the desktops with high numbers are unnamed. If it is
-     * larger than getNumDesktop(), then the excess names outside of the getNumDesktop()
-     * are considered to be reserved in case the number of desktops is increased.
-     */
-    QStringList getDesktopNames() const;
-
-    /*!
-     * Returns the name of virtual desktop.
-     */
-    QString getDesktopName(int desktopNum, const QString &defaultName=QString()) const;
-
-    /*! Returns window title if available
-     *
-     */
-    QString getWindowTitle(Window _wid) const;
-
-    /*! Returns window title if available
-     *
-     */
-    QString getApplicationName(Window _wid) const;
-
-    bool acceptWindow(Window _wid) const;
-
-    AtomList getWindowType(Window window) const;
-#ifdef DEBUG
-    static QString debugWindow(Window wnd);
-#endif
-    static Atom atom(const char* atomName);
-
-    /*!
-     *   QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
-     *   This workaraund this problem.
-     */
-    const QRect availableGeometry(int screen = -1) const;
-
-    /*!
-     *   QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
-     *   This workaraund this problem.
-     */
-    const QRect availableGeometry(const QWidget *widget) const;
-
-    /*!
-     *   QDesktopWidget have a bug http://bugreports.qt.nokia.com/browse/QTBUG-18380
-     *   This workaraund this problem.
-     */
-    const QRect availableGeometry(const QPoint &point) const;
-
-    int clientMessage(Window _wid, Atom _msg,
-                      long unsigned int data0,
-                      long unsigned int data1 = 0,
-                      long unsigned int data2 = 0,
-                      long unsigned int data3 = 0,
-                      long unsigned int data4 = 0) const;
-
-    /*!
-     * Returns true if the Window Manager is running; otherwise returns false.
-     */
-    bool isWindowManagerActive() const;
-
-private:
-
-    /** \warning Do not forget to XFree(result) after data are processed!
-    */
-    bool getWindowProperty(Window window,
-                           Atom atom,               // property
-                           Atom reqType,            // req_type
-                           unsigned long* resultLen,// nitems_return
-                           unsigned char** result   // prop_return
-                          ) const;
-
-    /** \warning Do not forget to XFree(result) after data are processed!
-    */
-    bool getRootWindowProperty(Atom atom,               // property
-                               Atom reqType,            // req_type
-                               unsigned long* resultLen,// nitems_return
-                               unsigned char** result   // prop_return
-                              ) const;
-
-
-    Window  root; //the actual root window on the used screen
-};
-
-
-const XfitMan& xfitMan();
-
-} //namespace LxQt
-#endif