Utils: Introduce HostOsInfo class.

The class' member functions are intended to be used
instead of the Q_OS_* macros in all contexts where
the latter are not syntactically required.
This lowers the likelihood of changes made on one
platform breaking the build on another, e.g. due to
the code model missing symbols in #ifdef'ed out code
when refactoring.

Change-Id: I4a54788591b4c8f8d589b8368a6c683d4155c9fa
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Christian Kandeler
2012-08-23 15:53:58 +02:00
committed by hjk
parent b674b59b3d
commit e669f05406
109 changed files with 1281 additions and 1249 deletions

View File

@@ -36,6 +36,7 @@
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
#include <utils/hostosinfo.h>
#include <QAction>
#include <QHBoxLayout>
@@ -143,17 +144,17 @@ ExternalHelpWindow::ExternalHelpWindow(QWidget *parent)
tr("Show Sidebar"), this);
connect(action, SIGNAL(triggered()), this, SIGNAL(showHideSidebar()));
#ifdef Q_OS_MAC
reset->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
ctrlTab->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Tab));
ctrlShiftTab->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Tab));
#else
reset->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
ctrlTab->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab));
ctrlShiftTab->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
#endif
if (Utils::HostOsInfo::isMacHost()) {
reset->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
ctrlTab->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Tab));
ctrlShiftTab->setShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_Tab));
} else {
reset->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_0));
action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_0));
ctrlTab->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab));
ctrlShiftTab->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
}
QToolButton *button = new QToolButton;
button->setDefaultAction(action);

View File

@@ -67,6 +67,7 @@
#include <extensionsystem/pluginmanager.h>
#include <find/findplugin.h>
#include <texteditor/texteditorconstants.h>
#include <utils/hostosinfo.h>
#include <utils/styledbar.h>
#include <QDir>
@@ -251,12 +252,12 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
cmd->setDefaultKeySequence(QKeySequence(Qt::Key_F1));
connect(action, SIGNAL(triggered()), this, SLOT(activateContext()));
#ifndef Q_OS_MAC
action = new QAction(this);
action->setSeparator(true);
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Separator"), globalcontext);
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
#endif
if (!Utils::HostOsInfo::isMacHost()) {
action = new QAction(this);
action->setSeparator(true);
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Separator"), globalcontext);
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
}
action = new QAction(tr("Technical Support"), this);
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.TechSupport"), globalcontext);
@@ -268,12 +269,12 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
connect(action, SIGNAL(triggered()), this, SLOT(slotReportBug()));
#ifndef Q_OS_MAC
action = new QAction(this);
action->setSeparator(true);
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Separator2"), globalcontext);
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
#endif
if (!Utils::HostOsInfo::isMacHost()) {
action = new QAction(this);
action->setSeparator(true);
cmd = Core::ActionManager::registerAction(action, Core::Id("Help.Separator2"), globalcontext);
Core::ActionManager::actionContainer(Core::Constants::M_HELP)->addAction(cmd, Core::Constants::G_HELP_HELP);
}
action = new QAction(this);
Core::ActionManager::registerAction(action, Core::Constants::PRINT, modecontext);

View File

@@ -36,6 +36,8 @@
#include "helpviewer_p.h"
#include "localhelpmanager.h"
#include <utils/hostosinfo.h>
#include <QApplication>
#include <QClipboard>
#include <QContextMenuEvent>
@@ -286,19 +288,15 @@ void HelpViewer::wheelEvent(QWheelEvent *e)
void HelpViewer::mousePressEvent(QMouseEvent *e)
{
#ifdef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(e))
if (Utils::HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(e))
return;
#endif
QTextBrowser::mousePressEvent(e);
}
void HelpViewer::mouseReleaseEvent(QMouseEvent *e)
{
#ifndef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(e))
if (!Utils::HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(e))
return;
#endif
bool controlPressed = e->modifiers() & Qt::ControlModifier;
if ((controlPressed && d->hasAnchorAt(this, e->pos())) ||

View File

@@ -37,6 +37,8 @@
#include "localhelpmanager.h"
#include "openpagesmanager.h"
#include <utils/hostosinfo.h>
#include <QDebug>
#include <QFileInfo>
#include <QString>
@@ -529,10 +531,8 @@ void HelpViewer::wheelEvent(QWheelEvent *event)
void HelpViewer::mousePressEvent(QMouseEvent *event)
{
#ifdef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(event))
if (Utils::HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(event))
return;
#endif
if (HelpPage *currentPage = static_cast<HelpPage*> (page())) {
currentPage->m_pressedButtons = event->buttons();
@@ -544,10 +544,8 @@ void HelpViewer::mousePressEvent(QMouseEvent *event)
void HelpViewer::mouseReleaseEvent(QMouseEvent *event)
{
#ifndef Q_OS_LINUX
if (handleForwardBackwardMouseButtons(event))
if (!Utils::HostOsInfo::isLinuxHost() && handleForwardBackwardMouseButtons(event))
return;
#endif
QWebView::mouseReleaseEvent(event);
}

View File

@@ -34,6 +34,8 @@
#include "openpagesmodel.h"
#include "openpageswidget.h"
#include <utils/hostosinfo.h>
#include <QEvent>
#include <QKeyEvent>
@@ -54,9 +56,8 @@ OpenPagesSwitcher::OpenPagesSwitcher(OpenPagesModel *model)
// We disable the frame on this list view and use a QFrame around it instead.
// This improves the look with QGTKStyle.
#ifndef Q_OS_MAC
setFrameStyle(m_openPagesWidget->frameStyle());
#endif
if (!Utils::HostOsInfo::isMacHost())
setFrameStyle(m_openPagesWidget->frameStyle());
m_openPagesWidget->setFrameStyle(QFrame::NoFrame);
m_openPagesWidget->allowContextMenu(false);
@@ -125,11 +126,8 @@ bool OpenPagesSwitcher::eventFilter(QObject *object, QEvent *event)
emit setCurrentPage(m_openPagesWidget->currentIndex());
return true;
}
#ifdef Q_OS_MAC
const Qt::KeyboardModifier modifier = Qt::AltModifier;
#else
const Qt::KeyboardModifier modifier = Qt::ControlModifier;
#endif
const Qt::KeyboardModifiers modifier = Utils::HostOsInfo::isMacHost()
? Qt::AltModifier : Qt::ControlModifier;
if (key == Qt::Key_Backtab
&& (ke->modifiers() == (modifier | Qt::ShiftModifier)))
gotoNextPage();