Skip to content
This repository has been archived by the owner on Aug 20, 2023. It is now read-only.

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
PCMan committed Nov 8, 2013
0 parents commit 012d326
Show file tree
Hide file tree
Showing 10 changed files with 1,097 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
@@ -0,0 +1 @@
Hong Jen Yee (PCMan) <pcman.tw@gmail.com>, LXDE developers
63 changes: 63 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,63 @@
project(compton-conf)

cmake_minimum_required(VERSION 2.8.6)

# Qt
find_package(Qt4 REQUIRED QtCore QtGui)

# libconfig using pkg-config
find_package(PkgConfig)
pkg_check_modules(LIBCONFIG REQUIRED
libconfig
)

set(CMAKE_CXX_FLAGS "-DQT_NO_KEYWORDS -fno-exceptions")

include_directories(
${QT_INCLUDES}
${LIBCONFIG_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
)

set(CMAKE_AUTOMOC TRUE)

set(compton-conf_SRCS
maindialog.cpp
compton-conf.cpp
)

set(compton-conf_UIS
maindialog.ui
)

qt4_wrap_ui(compton-conf_UI_H
${compton-conf_UIS}
)

add_executable(compton-conf
${compton-conf_SRCS}
${compton-conf_UI_H}
)

target_link_libraries(compton-conf
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${LIBCONFIG_LIBRARIES}
)

install(TARGETS compton-conf RUNTIME DESTINATION bin)

# building tarball with CPack -------------------------------------------------
# To create a source distribution, type:
# make package_source
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README")
set (CPACK_PACKAGE_VENDOR "")
set (CPACK_PACKAGE_VERSION_MAJOR "0")
set (CPACK_PACKAGE_VERSION_MINOR "1")
set (CPACK_PACKAGE_VERSION_PATCH "0")
set (CPACK_GENERATOR TBZ2)
set (CPACK_SOURCE_GENERATOR TBZ2)
set (CPACK_SOURCE_IGNORE_FILES /build/;.gitignore;.*~;.git;.kdev4;temp)
include (CPack)
510 changes: 510 additions & 0 deletions COPYING

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions README
@@ -0,0 +1 @@
GUI configuration tool for compton X composite manager.
33 changes: 33 additions & 0 deletions compton-conf.cpp
@@ -0,0 +1,33 @@
#include "compton-conf.h"
#include <QApplication>
#include <QDir>
#include <QFile>
#include "maindialog.h"
#include <libconfig.h>
#include <stdio.h>

int main(int argc, char** argv) {
QApplication app(argc, argv);

// find config file
QString userConfigFile = qgetenv("XDG_CONFIG_HOME");
if(userConfigFile.isEmpty()) {
userConfigFile = QDir::homePath();
userConfigFile += "/.config";
}
// QDir configDir = QDir(userConfigFile);
// if(!configDir.exists())
userConfigFile += "/compton.conf";

// load config file
config_t cfg;
config_init(&cfg);
if(config_read_file(&cfg, userConfigFile.toLocal8Bit().constData()) == CONFIG_FALSE) {
// loading user config file failed
// try our default example
}

MainDialog dlg(&cfg);
dlg.exec();
return 0;
}
5 changes: 5 additions & 0 deletions compton-conf.h
@@ -0,0 +1,5 @@
#ifndef _COMPTON_CONF_H_
#define _COMPTON_CONF_H_


#endif // _COMPTON_CONF_H_
4 changes: 4 additions & 0 deletions compton-conf.kdev4
@@ -0,0 +1,4 @@
[Project]
Name=compton-conf
Manager=KDevCMakeManager
VersionControl=
69 changes: 69 additions & 0 deletions maindialog.cpp
@@ -0,0 +1,69 @@
/*
* <one line to give the library's name and an idea of what it does.>
* Copyright (C) 2013 <copyright holder> <email>
*
* 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
*
*/

#include "maindialog.h"
#include "ui_maindialog.h"
#include <QDebug>

MainDialog::MainDialog(config_t* cfg) : config_(cfg) {
ui = new Ui::MainDialog;
ui->setupUi(this);

// set up signal handlers
Q_FOREACH(QWidget* child, findChildren<QWidget*>()) {
if(!child->isWidgetType() || child->objectName().isEmpty())
continue;
QString keyName = child->objectName().replace('_', '-');
if(child->inherits("QCheckBox")) {
int val;
if(config_lookup_bool(config_, keyName.toLatin1().constData(), &val) == CONFIG_TRUE)
static_cast<QCheckBox*>(child)->setChecked((bool)val);
connect(child, SIGNAL(toggled(bool)), SLOT(onButtonToggled(bool)));
}
else if(child->inherits("QDoubleSpinBox")) {
double val;
if(config_lookup_float(config_, keyName.toLatin1().constData(), &val) == CONFIG_TRUE)
static_cast<QDoubleSpinBox*>(child)->setValue(val);
connect(child, SIGNAL(valueChanged(double)), SLOT(onSpinValueChanged(double)));
}
else if(child->inherits("QSpinBox")) {
int val;
if(config_lookup_int(config_, keyName.toLatin1().constData(), &val) == CONFIG_TRUE)
static_cast<QSpinBox*>(child)->setValue(val);
connect(child, SIGNAL(valueChanged(int)), SLOT(onSpinValueChanged(int)));
}
}
}

MainDialog::~MainDialog() {
delete ui;
}

void MainDialog::onButtonToggled(bool checked) {
qDebug() << "toggled: " << sender()->objectName();
}

void MainDialog::onSpinValueChanged(double d) {
qDebug() << "changed: " << sender()->objectName() << ": " << d;
}

void MainDialog::onSpinValueChanged(int i) {
qDebug() << "changed: " << sender()->objectName() << ": " << i;
}
49 changes: 49 additions & 0 deletions maindialog.h
@@ -0,0 +1,49 @@
/*
* <one line to give the library's name and an idea of what it does.>
* Copyright (C) 2013 <copyright holder> <email>
*
* 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
*
*/

#ifndef MAINDIALOG_H
#define MAINDIALOG_H

#include <QDialog>
#include <libconfig.h>

namespace Ui
{
class MainDialog;
}

class MainDialog : public QDialog
{
Q_OBJECT
public:
MainDialog(config_t* cfg);
~MainDialog();

private Q_SLOTS:
void onButtonToggled(bool checked);
void onSpinValueChanged(double d);
void onSpinValueChanged(int i);

private:
Ui::MainDialog* ui;
config_t* config_;
};

#endif // MAINDIALOG_H

0 comments on commit 012d326

Please sign in to comment.