Skip to content

Commit

Permalink
icon theme config - initial revision
Browse files Browse the repository at this point in the history
  • Loading branch information
pvanek committed Oct 13, 2011
1 parent d6e419d commit 6efe4e2
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 0 deletions.
2 changes: 2 additions & 0 deletions razorqt-config/CMakeLists.txt
@@ -1,3 +1,5 @@

add_subdirectory(src)
add_subdirectory(razor-config-mouse)
add_subdirectory(razor-config-icons)

34 changes: 34 additions & 0 deletions razorqt-config/razor-config-icons/CMakeLists.txt
@@ -0,0 +1,34 @@

include_directories (
${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR}
${QT_QTDBUS_INCLUDE_DIR} ${QT_QTXML_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/librazorqt/
.
)

set ( razor-config-icons_HDRS
mainwindow.h
)

set ( razor-config-icons_SRCS
mainwindow.cpp
main.cpp
)


QT4_WRAP_UI(razor-config-icons_UIS mainwindow.ui)
QT4_WRAP_CPP(razor-config-icons_MOCS ${razor-config-icons_HDRS})

add_executable ( razor-config-icons ${razor-config-icons_SRCS} ${razor-config-icons_UIS} ${razor-config-icons_MOCS} )
add_dependencies( razor-config-icons razorqt qtxdg)
target_link_libraries ( razor-config-icons ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}
razorqt qtxdg)
# not needed probably ${X11_Xfixes_LIB})

INSTALL(TARGETS razor-config-icons RUNTIME DESTINATION bin)
install(FILES razor-config-icons.desktop DESTINATION ${CMAKE_INSTALL_PREFIX}/share/applications)

razor_config_register(razor-config-icons.desktop)


41 changes: 41 additions & 0 deletions razorqt-config/razor-config-icons/main.cpp
@@ -0,0 +1,41 @@
/* BEGIN_COMMON_COPYRIGHT_HEADER
*
* 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 3 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 <QApplication>

#include "mainwindow.h"


int main (int argc, char **argv)
{
QApplication app(argc, argv);
app.setWindowIcon(QIcon(QString(SHARE_DIR) + "/graphics/razor_logo.png"));

MainWindow *mw = new MainWindow();
mw->show();
return app.exec();
}

122 changes: 122 additions & 0 deletions razorqt-config/razor-config-icons/mainwindow.cpp
@@ -0,0 +1,122 @@
/* BEGIN_COMMON_COPYRIGHT_HEADER
*
* 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 3 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 "mainwindow.h"

#include <QtCore/QSettings>
#include <qtxdg/xdgdirs.h>
#include <qtxdg/xdgicon.h>
#include <razorqt/razorsettings.h>


MainWindow::MainWindow()
{
setupUi(this);
listWidget->setIconSize(QSize(64,64));

m_settings = new RazorSettings("razor", this);
m_cache = new RazorSettingsCache(m_settings);

// qDebug() << "START" << XdgDirs::dataDirs();

QDir d;
foreach(QString basedir, XdgDirs::dataDirs())
{
// // TODO/FIXME: think about this "optimization"
if (basedir == "/usr/share")
basedir = "/usr/share/icons";

// qDebug() << "BASEDIR" << basedir;
QDirIterator it(basedir, QStringList() << "index.theme", QDir::Files, QDirIterator::Subdirectories);
while (it.hasNext())
{
QFileInfo fi(it.next());
qDebug() << fi.filePath();
QSettings check(fi.filePath(), QSettings::IniFormat);
if (check.childGroups().contains("Icon Theme"))
{
if (d.exists(fi.canonicalPath() + "/" + "cursors"))
{
// qDebug() << " mouse theme. Skipped";
}
else
{
// qDebug() << " ADD" << fi.dir().dirName();
XdgIcon::setThemeName(fi.dir().dirName());
QString sample = check.value("Icon Theme/Example", "application-exit").toString();
new QListWidgetItem(XdgIcon::fromTheme(sample), fi.dir().dirName(), listWidget);
}
}
}
}

restoreSettings();

connect(buttons, SIGNAL(clicked(QAbstractButton*)),
this, SLOT(dialogButtonsAction(QAbstractButton*)));
connect(listWidget, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(listWidget_currentTextChanged(const QString &)));
}

MainWindow::~MainWindow()
{
delete m_cache;
}

void MainWindow::listWidget_currentTextChanged(const QString &text)
{
// qDebug() << "listWidget_currentTextChanged" << text;
if (text.isNull())
return;

m_settings->setValue("icon_theme", text);
}

void MainWindow::restoreSettings()
{
QString theme = m_settings->value("icon_theme", "oxygen").toString();
// qDebug() << "SETTINGS" << theme;
foreach (QListWidgetItem *item, listWidget->findItems(theme, Qt::MatchFixedString))
{
// qDebug() << "FOUND" << item;
listWidget->setCurrentItem(item);
break;
}
}

void MainWindow::dialogButtonsAction(QAbstractButton *btn)
{
if (buttons->buttonRole(btn) == QDialogButtonBox::ResetRole)
{
m_cache->loadToSettings();
restoreSettings();
}
else
{
close();
}
}

56 changes: 56 additions & 0 deletions razorqt-config/razor-config-icons/mainwindow.h
@@ -0,0 +1,56 @@
/* BEGIN_COMMON_COPYRIGHT_HEADER
*
* 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 3 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 MAINWINDOW_H
#define MAINWINDOW_H

#include <QtCore/QDirIterator>
#include <QtDebug>
#include "ui_mainwindow.h"

class RazorSettings;
class RazorSettingsCache;


class MainWindow : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT

public:
MainWindow();
~MainWindow();

private:
RazorSettings *m_settings;
RazorSettingsCache *m_cache;

private slots:
void restoreSettings();
void dialogButtonsAction(QAbstractButton *btn);
void listWidget_currentTextChanged(const QString &text);
};

#endif
37 changes: 37 additions & 0 deletions razorqt-config/razor-config-icons/mainwindow.ui
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>452</width>
<height>329</height>
</rect>
</property>
<property name="windowTitle">
<string>Razor Icon Theme Configuration</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QListWidget" name="listWidget">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="buttons">
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Reset</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
12 changes: 12 additions & 0 deletions razorqt-config/razor-config-icons/razor-config-icons.desktop
@@ -0,0 +1,12 @@
[Desktop Entry]
X-SuSE-translate=true
OnlyShowIn=X-RAZOR;
Type=Application
Exec=razor-config-icons
Terminal=false
Categories=Settings;DesktopSettings;Qt;X-RAZOR;
Icon=preferences-desktop-icons
Name=Razor Icon Theme Configuration
Comment=Configure Icon Theme for Razor desktop
GenericName=Razor Icon Theme Configuration

0 comments on commit 6efe4e2

Please sign in to comment.