2009-09-15 07:12:54 +00:00
|
|
|
#ifndef oxygendetectwidget_h
|
|
|
|
#define oxygendetectwidget_h
|
2009-09-13 16:43:26 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
2009-09-15 07:12:54 +00:00
|
|
|
// oxygendetectwidget.h
|
2009-09-13 16:43:26 +00:00
|
|
|
// Note: this class is a stripped down version of
|
|
|
|
// /kdebase/workspace/kwin/kcmkwin/kwinrules/detectwidget.h
|
|
|
|
// Copyright (c) 2004 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
// -------------------
|
|
|
|
//
|
|
|
|
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to
|
|
|
|
// deal in the Software without restriction, including without limitation the
|
|
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
// IN THE SOFTWARE.
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <KDialog>
|
2009-09-20 07:42:03 +00:00
|
|
|
#include <QtCore/QEvent>
|
|
|
|
#include <QtCore/QByteArray>
|
|
|
|
#include <QtGui/QCheckBox>
|
|
|
|
#include <QtGui/QLabel>
|
2009-09-13 16:43:26 +00:00
|
|
|
|
|
|
|
#include <kwindowsystem.h>
|
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
#include "../oxygenexception.h"
|
2009-10-29 02:55:41 +00:00
|
|
|
#include "ui_oxygendetectwidget.h"
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2009-09-15 07:12:54 +00:00
|
|
|
namespace Oxygen
|
2009-09-13 16:43:26 +00:00
|
|
|
{
|
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
class DetectDialog : public KDialog
|
|
|
|
{
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
Q_OBJECT
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
public:
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! constructor
|
|
|
|
DetectDialog( QWidget* );
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! read window properties or select one from mouse grab
|
|
|
|
void detect( WId window );
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! selected class
|
|
|
|
QByteArray selectedClass() const;
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! window information
|
|
|
|
const KWindowInfo& windowInfo() const
|
2011-02-24 16:47:38 +00:00
|
|
|
{ return _info; }
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! exception type
|
|
|
|
Exception::Type exceptionType() const
|
|
|
|
{
|
|
|
|
if( ui.windowClassCheckBox->isChecked() ) return Exception::WindowClassName;
|
|
|
|
else if( ui.windowTitleCheckBox->isChecked() ) return Exception::WindowTitle;
|
|
|
|
else return Exception::WindowClassName;
|
|
|
|
}
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
signals:
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
void detectionDone( bool );
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
protected:
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
virtual bool eventFilter( QObject* o, QEvent* e );
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
private:
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! select window from grab
|
|
|
|
void selectWindow();
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! read window properties
|
|
|
|
void readWindow( WId window );
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! find window under cursor
|
|
|
|
WId findWindow();
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! execute
|
|
|
|
void executeDialog( void );
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! window machine
|
|
|
|
QString machine;
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! main widget
|
|
|
|
Ui_DetectWidget ui;
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! invisible dialog used to grab mouse
|
2011-02-24 16:47:38 +00:00
|
|
|
KDialog* _grabber;
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
//! current window information
|
2011-02-24 16:47:38 +00:00
|
|
|
KWindowInfo _info;
|
2009-09-13 16:43:26 +00:00
|
|
|
|
2010-05-02 18:34:08 +00:00
|
|
|
};
|
2009-09-13 16:43:26 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|