make kwinrules kcm more user friendly

icc-effect-5.14.5
Thomas Lübking 2011-04-06 19:52:23 +02:00
parent 9bbed0335a
commit d233891da7
10 changed files with 1935 additions and 1566 deletions

View File

@ -1,7 +1,9 @@
ADD_DEFINITIONS(-DKCMRULES)
########### next target ###############
set(kwinrules_SRCS ruleswidget.cpp ruleslist.cpp kwinsrc.cpp detectwidget.cpp)
set (kwinrules_MOC_HDRS yesnobox.h)
qt4_wrap_cpp(kwinrules_MOC_SRCS ${kwinrules_MOC_HDRS})
set(kwinrules_SRCS ruleswidget.cpp ruleslist.cpp kwinsrc.cpp detectwidget.cpp ${kwinrules_MOC_SRCS})
kde4_add_ui_files(kwinrules_SRCS ruleslist.ui detectwidget.ui editshortcut.ui ruleswidgetbase.ui)
@ -10,7 +12,7 @@ set(kwin_rules_dialog_KDEINIT_SRCS main.cpp ${kwinrules_SRCS})
kde4_add_kdeinit_executable( kwin_rules_dialog ${kwin_rules_dialog_KDEINIT_SRCS})
target_link_libraries(kdeinit_kwin_rules_dialog ${KDE4_KDEUI_LIBS} ${X11_LIBRARIES})
target_link_libraries(kdeinit_kwin_rules_dialog ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${X11_LIBRARIES})
install(TARGETS kdeinit_kwin_rules_dialog ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(TARGETS kwin_rules_dialog DESTINATION ${LIBEXEC_INSTALL_DIR} )
@ -22,7 +24,7 @@ set(kcm_kwinrules_PART_SRCS kcm.cpp ${kwinrules_SRCS})
kde4_add_plugin(kcm_kwinrules ${kcm_kwinrules_PART_SRCS})
target_link_libraries(kcm_kwinrules ${KDE4_KDEUI_LIBS} ${X11_LIBRARIES})
target_link_libraries(kcm_kwinrules ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${X11_LIBRARIES})
install(TARGETS kcm_kwinrules DESTINATION ${PLUGIN_INSTALL_DIR} )

View File

@ -30,6 +30,7 @@
#include <QMouseEvent>
#include <QEvent>
#include <QByteArray>
#include <QTimer>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
@ -58,10 +59,10 @@ DetectDialog::DetectDialog(QWidget* parent, const char* name)
setMainWidget(widget);
}
void DetectDialog::detect(WId window)
void DetectDialog::detect(WId window, int secs)
{
if (window == 0)
selectWindow();
QTimer::singleShot(secs*1000, this, SLOT(selectWindow()));
else
readWindow(window);
}
@ -117,6 +118,10 @@ void DetectDialog::executeDialog()
widget->title_label->setText(title);
widget->extrarole_label->setText(extrarole);
widget->machine_label->setText(machine);
widget->adjustSize();
adjustSize();
if (width() < 4*height()/3)
resize(4*height()/3, height());
emit detectionDone(exec() == KDialog::Accepted);
}

View File

@ -47,7 +47,7 @@ class DetectDialog
Q_OBJECT
public:
explicit DetectDialog(QWidget* parent = NULL, const char* name = NULL);
void detect(WId window);
void detect(WId window, int secs = 0);
QByteArray selectedClass() const;
bool selectedWholeClass() const;
QByteArray selectedRole() const;
@ -61,8 +61,9 @@ signals:
void detectionDone(bool);
protected:
virtual bool eventFilter(QObject* o, QEvent* e);
private:
private slots:
void selectWindow();
private:
void readWindow(WId window);
void executeDialog();
WId findWindow();

View File

@ -1,194 +1,219 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KWin::DetectWidget</class>
<widget class="QWidget" name="KWin::DetectWidget" >
<property name="geometry" >
<widget class="QWidget" name="KWin::DetectWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>417</width>
<height>362</height>
<width>428</width>
<height>318</height>
</rect>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" colspan="2" >
<widget class="QLabel" name="textLabel9" >
<property name="text" >
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="textLabel9">
<property name="text">
<string>Information About Selected Window</string>
</property>
<property name="wordWrap" >
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="Line" name="line1" >
<property name="frameShape" >
<item row="1" column="0" colspan="3">
<widget class="Line" name="line1">
<property name="frameShape">
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow" >
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<item row="2" column="0">
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Class:</string>
</property>
<property name="wordWrap" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLabel" name="class_label" >
<property name="text" >
<item row="2" column="1" colspan="2">
<widget class="QLabel" name="class_label">
<property name="text">
<string/>
</property>
<property name="wordWrap" >
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="textLabel3" >
<property name="text" >
<item row="3" column="0">
<widget class="QLabel" name="textLabel3">
<property name="text">
<string>Role:</string>
</property>
<property name="wordWrap" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QLabel" name="role_label" >
<property name="text" >
<item row="3" column="1" colspan="2">
<widget class="QLabel" name="role_label">
<property name="text">
<string/>
</property>
<property name="wordWrap" >
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="textLabel4" >
<property name="text" >
<item row="4" column="0">
<widget class="QLabel" name="textLabel4">
<property name="text">
<string>Type:</string>
</property>
<property name="wordWrap" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QLabel" name="type_label" >
<property name="text" >
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="type_label">
<property name="text">
<string/>
</property>
<property name="wordWrap" >
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="textLabel8" >
<property name="text" >
<item row="5" column="0">
<widget class="QLabel" name="textLabel8">
<property name="text">
<string>Title:</string>
</property>
<property name="wordWrap" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="1" >
<widget class="QLabel" name="title_label" >
<property name="text" >
<item row="5" column="1" colspan="2">
<widget class="QLabel" name="title_label">
<property name="text">
<string/>
</property>
<property name="wordWrap" >
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="textLabel11" >
<property name="text" >
<item row="6" column="0">
<widget class="QLabel" name="textLabel11">
<property name="text">
<string>Extra role:</string>
</property>
<property name="wordWrap" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="1" >
<widget class="QLabel" name="extrarole_label" >
<property name="text" >
<item row="6" column="1" colspan="2">
<widget class="QLabel" name="extrarole_label">
<property name="text">
<string/>
</property>
<property name="wordWrap" >
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="0" >
<widget class="QLabel" name="textLabel13" >
<property name="text" >
<item row="7" column="0">
<widget class="QLabel" name="textLabel13">
<property name="text">
<string>Machine:</string>
</property>
<property name="wordWrap" >
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="7" column="1" >
<widget class="QLabel" name="machine_label" >
<property name="text" >
<item row="7" column="1" colspan="2">
<widget class="QLabel" name="machine_label">
<property name="text">
<string/>
</property>
<property name="wordWrap" >
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2" >
<widget class="QGroupBox" name="groupBox" >
<layout class="QVBoxLayout" >
<item row="8" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Match Strategy</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="use_class" >
<property name="whatsThis" >
<widget class="QRadioButton" name="use_class">
<property name="whatsThis">
<string>For selecting all windows belonging to a specific application, selecting only window class should usually work.</string>
</property>
<property name="text" >
<property name="text">
<string>Use window &amp;class (whole application)</string>
</property>
<property name="checked" >
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="use_role" >
<property name="whatsThis" >
<widget class="QRadioButton" name="use_role">
<property name="whatsThis">
<string>For selecting a specific window in an application, both window class and window role should be selected. Window class will determine the application, and window role the specific window in the application; many applications do not provide useful window roles though.</string>
</property>
<property name="text" >
<property name="text">
<string>Use window class and window &amp;role (specific window)</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="use_whole_class" >
<property name="whatsThis" >
<widget class="QRadioButton" name="use_whole_class">
<property name="whatsThis">
<string>With some (non-KDE) applications whole window class can be sufficient for selecting a specific window in an application, as they set whole window class to contain both application and window role.</string>
</property>
<property name="text" >
<property name="text">
<string>Use &amp;whole window class (specific window)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="match_title" >
<property name="text" >
<widget class="QCheckBox" name="match_title">
<property name="text">
<string>Match also window &amp;title</string>
</property>
</widget>
@ -196,24 +221,24 @@
</layout>
</widget>
</item>
<item row="9" column="0" >
<item row="9" column="1">
<spacer>
<property name="orientation" >
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>161</height>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<resources/>
<connections/>
</ui>

View File

@ -23,6 +23,7 @@
#include <assert.h>
#include <kdebug.h>
#include <kconfig.h>
#include <KFileDialog>
#include "ruleswidget.h"
@ -48,6 +49,10 @@ KCMRulesList::KCMRulesList(QWidget* parent)
SLOT(moveupClicked()));
connect(movedown_button, SIGNAL(clicked()),
SLOT(movedownClicked()));
connect(export_button, SIGNAL(clicked()),
SLOT(exportClicked()));
connect(import_button, SIGNAL(clicked()),
SLOT(importClicked()));
connect(rules_listbox, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
SLOT(modifyClicked()));
load();
@ -71,6 +76,7 @@ void KCMRulesList::activeChanged()
rules_listbox->setCurrentItem(item, QItemSelectionModel::ClearAndSelect);
modify_button->setEnabled(item != NULL);
delete_button->setEnabled(item != NULL);
export_button->setEnabled(item != NULL);
moveup_button->setEnabled(item != NULL && itemRow > 0);
movedown_button->setEnabled(item != NULL && itemRow < (rules_listbox->count() - 1));
}
@ -142,6 +148,67 @@ void KCMRulesList::movedownClicked()
emit changed(true);
}
void KCMRulesList::exportClicked()
{
int pos = rules_listbox->currentRow();
assert(pos != -1);
QString path = KFileDialog::getSaveFileName(KUrl(), "*.kwinrule", this, i18n("Export Rule"), 0);
if (path.isEmpty())
return;
KConfig config(path, KConfig::SimpleConfig);
KConfigGroup group(&config, rules[pos]->description);
group.deleteGroup();
rules[pos]->write(group);
}
void KCMRulesList::importClicked()
{
QString path = KFileDialog::getOpenFileName(KUrl(), "*.kwinrule", this, i18n("Import Rules"));
if (path.isEmpty())
return;
KConfig config(path, KConfig::SimpleConfig);
QStringList groups = config.groupList();
if (groups.isEmpty())
return;
int pos = qMax(0, rules_listbox->currentRow());
foreach (QString group, groups) {
KConfigGroup grp(&config, group);
const bool remove = grp.readEntry("DeleteRule", false);
Rules* new_rule = new Rules(grp);
// try to replace existing rule first
for (int i = 0; i < rules.count(); ++i) {
if (rules[i]->description == new_rule->description) {
delete rules[i];
if (remove) {
rules.remove(i);
delete rules_listbox->takeItem(i);
delete new_rule;
pos = qMax(0, rules_listbox->currentRow()); // might have changed!
}
else
rules[i] = new_rule;
new_rule = 0;
break;
}
}
// don't add "to be deleted" if not present
if (remove) {
delete new_rule;
new_rule = 0;
}
// plain insertion
if (new_rule) {
rules.insert(pos, new_rule);
rules_listbox->insertItem(pos++, new_rule->description);
}
}
emit changed(true);
}
void KCMRulesList::load()
{
rules_listbox->clear();

View File

@ -45,6 +45,8 @@ private slots:
void deleteClicked();
void moveupClicked();
void movedownClicked();
void exportClicked();
void importClicked();
void activeChanged();
private:
QVector< Rules* > rules;

View File

@ -1,85 +1,128 @@
<ui version="4.0" stdsetdef="1" >
<class>KWin::KCMRulesList</class>
<widget class="QWidget" name="KWin::KCMRulesList" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>480</height>
</rect>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<item rowspan="6" row="0" column="0" colspan="1" >
<widget class="KListWidget" name="rules_listbox" />
</item>
<item row="0" column="1" >
<widget class="KPushButton" name="new_button" >
<property name="text" >
<string>&amp;New...</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KPushButton" name="modify_button" >
<property name="text" >
<string>&amp;Modify...</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="KPushButton" name="delete_button" >
<property name="text" >
<string>Delete</string>
</property>
<property name="shortcut" >
<string/>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="KPushButton" name="moveup_button" >
<property name="text" >
<string>Move &amp;Up</string>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="KPushButton" name="movedown_button" >
<property name="text" >
<string>Move &amp;Down</string>
</property>
</widget>
</item>
<item row="5" column="1" >
<spacer name="spacer1" >
<property name="sizeHint" >
<size>
<width>20</width>
<height>294</height>
</size>
</property>
<property name="sizeType" >
<enum>Expanding</enum>
</property>
<property name="orientation" >
<enum>Vertical</enum>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KListWidget</class>
<extends>QListWidget</extends>
<header>klistwidget.h</header>
</customwidget>
</customwidgets>
<includes>
<include location="local" >kdialog.h</include>
</includes>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KWin::KCMRulesList</class>
<widget class="QWidget" name="KWin::KCMRulesList">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>480</height>
</rect>
</property>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0" rowspan="14">
<widget class="KListWidget" name="rules_listbox"/>
</item>
<item row="0" column="1">
<widget class="KPushButton" name="new_button">
<property name="text">
<string>&amp;New...</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KPushButton" name="modify_button">
<property name="text">
<string>&amp;Modify...</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="KPushButton" name="delete_button">
<property name="text">
<string>Delete</string>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="KPushButton" name="moveup_button">
<property name="text">
<string>Move &amp;Up</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="KPushButton" name="movedown_button">
<property name="text">
<string>Move &amp;Down</string>
</property>
</widget>
</item>
<item row="13" column="1">
<spacer name="spacer1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>294</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="1">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="import_button">
<property name="text">
<string>&amp;Import</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="export_button">
<property name="text">
<string>&amp;Export</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KListWidget</class>
<extends>QListWidget</extends>
<header>klistwidget.h</header>
</customwidget>
<customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
</customwidgets>
<includes>
<include location="local">kdialog.h</include>
</includes>
<resources/>
<connections/>
</ui>

View File

@ -331,7 +331,12 @@ static Options::MoveResizeMode comboToMoveResize(int val)
static int typeToCombo(NET::WindowType type)
{
if (type < NET::Normal || type > NET::Splash)
if (type < NET::Normal || type > NET::Splash ||
type == NET::Override) // The user must NOT set a window to be unmanaged.
// This case is not handled in KWin and will lead to segfaults.
// Even iff it was supported, it would mean to allow the user to shoot himself
// since an unmanaged window has to manage itself, what is probably not the case when the hint is not set.
// Rule opportunity might be a relict from the Motif Hint window times of KDE1
return 0; // Normal
static const int conv[] = {
0, // Normal
@ -340,7 +345,7 @@ static int typeToCombo(NET::WindowType type)
4, // Toolbar
5, // Menu
1, // Dialog
8, // Override
8, // Override - ignored.
9, // TopMenu
2, // Utility
6 // Splash
@ -359,7 +364,6 @@ static NET::WindowType comboToType(int val)
NET::Menu,
NET::Splash,
NET::Desktop,
NET::Override,
NET::TopMenu
};
return conv[ val ];
@ -387,6 +391,7 @@ static NET::WindowType comboToType(int val)
#define CHECKBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, setChecked, setChecked( false ))
#define LINEEDIT_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, setText, setText( "" ))
#define COMBOBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, setCurrentIndex, setCurrentIndex( 0 ))
#define SPINBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, setValue, setValue(0))
void RulesWidget::setRules(Rules* rules)
{
@ -440,8 +445,8 @@ void RulesWidget::setRules(Rules* rules)
CHECKBOX_FORCE_RULE(autogroup,);
CHECKBOX_FORCE_RULE(autogroupfg,);
LINEEDIT_FORCE_RULE(autogroupid,);
LINEEDIT_FORCE_RULE(opacityactive, intToStr);
LINEEDIT_FORCE_RULE(opacityinactive, intToStr);
SPINBOX_FORCE_RULE(opacityactive,);
SPINBOX_FORCE_RULE(opacityinactive,);
COMBOBOX_FORCE_RULE(tilingoption, tilingToCombo);
LINEEDIT_SET_RULE(shortcut,);
COMBOBOX_FORCE_RULE(fsplevel,);
@ -462,6 +467,7 @@ void RulesWidget::setRules(Rules* rules)
#undef CHECKBOX_FORCE_RULE
#undef LINEEDIT_FORCE_RULE
#undef COMBOBOX_FORCE_RULE
#undef SPINBOX_FORCE_RULE
#define GENERIC_RULE( var, func, Type, type, uimethod ) \
if ( enable_##var->isChecked() && rule_##var->currentIndex() >= 0) \
@ -478,6 +484,7 @@ void RulesWidget::setRules(Rules* rules)
#define CHECKBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, isChecked )
#define LINEEDIT_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, text )
#define COMBOBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, currentIndex )
#define SPINBOX_FORCE_RULE( var, func ) GENERIC_RULE( var, func, Force, force, value)
Rules* RulesWidget::rules() const
{
@ -535,8 +542,8 @@ Rules* RulesWidget::rules() const
CHECKBOX_FORCE_RULE(autogroup,);
CHECKBOX_FORCE_RULE(autogroupfg,);
LINEEDIT_FORCE_RULE(autogroupid,);
LINEEDIT_FORCE_RULE(opacityactive, strToInt);
LINEEDIT_FORCE_RULE(opacityinactive, strToInt);
SPINBOX_FORCE_RULE(opacityactive,);
SPINBOX_FORCE_RULE(opacityinactive,);
COMBOBOX_FORCE_RULE(tilingoption, comboToTiling);
LINEEDIT_SET_RULE(shortcut,);
COMBOBOX_FORCE_RULE(fsplevel,);
@ -558,6 +565,7 @@ Rules* RulesWidget::rules() const
#undef CHECKBOX_FORCE_RULE
#undef LINEEDIT_FORCE_RULE
#undef COMBOBOX_FORCE_RULE
#undef SPINBOX_FORCE_RULE
#define STRING_MATCH_COMBO( type ) \
void RulesWidget::type##MatchChanged() \
@ -579,7 +587,7 @@ void RulesWidget::detectClicked()
assert(detect_dlg == NULL);
detect_dlg = new DetectDialog;
connect(detect_dlg, SIGNAL(detectionDone(bool)), this, SLOT(detected(bool)));
detect_dlg->detect(0);
detect_dlg->detect(0, Ui::RulesWidgetBase::detection_delay->value());
}
void RulesWidget::detected(bool ok)
@ -630,6 +638,7 @@ void RulesWidget::detected(bool ok)
#define CHECKBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setChecked )
#define LINEEDIT_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setText )
#define COMBOBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setCurrentIndex )
#define SPINBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setValue )
void RulesWidget::prefillUnusedValues(const KWindowInfo& info)
{
@ -654,8 +663,8 @@ void RulesWidget::prefillUnusedValues(const KWindowInfo& info)
//CHECKBOX_PREFILL( autogroup, );
//CHECKBOX_PREFILL( autogroupfg, );
//LINEEDIT_PREFILL( autogroupid, );
LINEEDIT_PREFILL(opacityactive, intToStr, 100 /*get the actual opacity somehow*/);
LINEEDIT_PREFILL(opacityinactive, intToStr, 100 /*get the actual opacity somehow*/);
SPINBOX_PREFILL(opacityactive, , 100 /*get the actual opacity somehow*/);
SPINBOX_PREFILL(opacityinactive, , 100 /*get the actual opacity somehow*/);
COMBOBOX_PREFILL(tilingoption, tilingToCombo, 0);
//LINEEDIT_PREFILL( shortcut, );
//COMBOBOX_PREFILL( fsplevel, );
@ -673,6 +682,7 @@ void RulesWidget::prefillUnusedValues(const KWindowInfo& info)
#undef CHECKBOX_PREFILL
#undef LINEEDIT_PREFILL
#undef COMBOBOX_PREFILL
#undef SPINBOX_PREFILL
bool RulesWidget::finalCheck()
{

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) 2011 Thomas Lübking <thomas.luebking@web.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef YESNOBOX_H
#define YESNOBOX_H
#include <QHBoxLayout>
#include <QRadioButton>
#include <klocale.h>
class YesNoBox : public QWidget {
Q_OBJECT
public:
YesNoBox( QWidget *parent ) : QWidget(parent)
{
QHBoxLayout *l = new QHBoxLayout(this);
l->setContentsMargins(0, 0, 0, 0);
l->addWidget(yes = new QRadioButton(i18n("Yes"), this));
l->addWidget(no = new QRadioButton(i18n("No"), this));
l->addStretch(100);
no->setChecked(true);
connect(yes, SIGNAL(clicked(bool)), this, SIGNAL(clicked(bool)));
connect(yes, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
connect(no, SIGNAL(clicked(bool)), this, SLOT(noClicked(bool)));
}
bool isChecked() { return yes->isChecked(); }
public slots:
void setChecked(bool b) { yes->setChecked(b); }
void toggle() { yes->toggle(); }
signals:
void clicked(bool checked = false);
void toggled(bool checked);
private slots:
void noClicked(bool checked) { emit clicked(!checked); }
private:
QRadioButton *yes, *no;
};
#endif // YESNOBOX_H