Commit c74835d5 authored by hjk's avatar hjk Committed by hjk
Browse files

Tooltip: Remove TipFactory



It's not really used as such.

Change-Id: Ia748cdb5273d661dfea9f8f39a17a872d3ee4de6
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 66985fa8
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "tipfactory.h"
#include "tipcontents.h"
#include "tips.h"
#include <utils/qtcassert.h>
#include <QVBoxLayout>
using namespace Utils;
using namespace Internal;
TipFactory::TipFactory()
{}
TipFactory::~TipFactory()
{}
Internal::QTipLabel *TipFactory::createTip(const TipContent &content, QWidget *w)
{
if (content.typeId() == TextContent::TEXT_CONTENT_ID)
return new TextTip(w);
if (content.typeId() == ColorContent::COLOR_CONTENT_ID)
return new ColorTip(w);
if (content.typeId() == WidgetContent::WIDGET_CONTENT_ID)
return new WidgetTip(w);
QTC_CHECK(false);
return 0;
}
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef TIPFACTORY_H
#define TIPFACTORY_H
#include <QWidget>
namespace Utils {
class TipContent;
namespace Internal {
class QTipLabel;
class TipFactory
{
public:
TipFactory();
virtual ~TipFactory();
Q_DISABLE_COPY(TipFactory)
virtual QTipLabel *createTip(const TipContent &content, QWidget *w);
};
} // namespace Internal
} // namespace Utils
#endif // TIPFACTORY_H
......@@ -30,7 +30,6 @@
#include "tooltip.h"
#include "tips.h"
#include "tipcontents.h"
#include "tipfactory.h"
#include "effects.h"
#include "reuse.h"
......@@ -41,6 +40,7 @@
#include <QApplication>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QWidget>
#include <QMenu>
#include <QDebug>
......@@ -48,7 +48,7 @@
using namespace Utils;
using namespace Internal;
ToolTip::ToolTip() : m_tipFactory(new TipFactory), m_tip(0), m_widget(0)
ToolTip::ToolTip() : m_tip(0), m_widget(0)
{
connect(&m_showTimer, SIGNAL(timeout()), this, SLOT(hideTipImmediately()));
connect(&m_hideDelayTimer, SIGNAL(timeout()), this, SLOT(hideTipImmediately()));
......@@ -57,7 +57,6 @@ ToolTip::ToolTip() : m_tipFactory(new TipFactory), m_tip(0), m_widget(0)
ToolTip::~ToolTip()
{
m_tip = 0;
delete m_tipFactory;
}
ToolTip *ToolTip::instance()
......@@ -69,12 +68,23 @@ ToolTip *ToolTip::instance()
void ToolTip::show(const QPoint &pos, const TipContent &content, QWidget *w, const QRect &rect)
{
if (acceptShow(content, pos, w, rect)) {
#ifndef Q_OS_WIN
m_tip = m_tipFactory->createTip(content, w);
#else
m_tip = m_tipFactory->createTip(
content, QApplication::desktop()->screen(Internal::screenNumber(pos, w)));
#endif
QWidget *target = 0;
if (HostOsInfo::isWindowsHost())
target = QApplication::desktop()->screen(Internal::screenNumber(pos, w));
else
target = w;
switch (content.typeId()) {
case TextContent::TEXT_CONTENT_ID:
m_tip = new TextTip(target);
break;
case ColorContent::COLOR_CONTENT_ID:
m_tip = new ColorTip(target);
break;
case WidgetContent::WIDGET_CONTENT_ID:
m_tip = new WidgetTip(target);
break;
}
setUp(pos, content, w, rect);
qApp->installEventFilter(this);
showTip();
......
......@@ -53,11 +53,7 @@ class QWidget;
QT_END_NAMESPACE
namespace Utils {
namespace Internal {
class TipFactory;
class QTipLabel;
}
namespace Internal { class QTipLabel; }
class TipContent;
......@@ -95,7 +91,6 @@ private:
void showTip();
void hideTipWithDelay();
Internal::TipFactory *m_tipFactory;
Internal::QTipLabel *m_tip;
QWidget *m_widget;
QRect m_rect;
......
......@@ -84,7 +84,6 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/tooltip/tooltip.cpp \
$$PWD/tooltip/tips.cpp \
$$PWD/tooltip/tipcontents.cpp \
$$PWD/tooltip/tipfactory.cpp \
$$PWD/unixutils.cpp
win32 {
......@@ -174,7 +173,6 @@ HEADERS += \
$$PWD/tooltip/tipcontents.h \
$$PWD/tooltip/reuse.h \
$$PWD/tooltip/effects.h \
$$PWD/tooltip/tipfactory.h \
$$PWD/unixutils.h
FORMS += $$PWD/filewizardpage.ui \
......
......@@ -188,8 +188,6 @@ QtcLibrary {
"reuse.h",
"tipcontents.cpp",
"tipcontents.h",
"tipfactory.cpp",
"tipfactory.h",
"tips.cpp",
"tips.h",
"tooltip.cpp",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment