forked from qt-creator/qt-creator
Core: Remove unneeded ifdefs.
Replace compile-time checks for host OS by run-time checks. Change-Id: I9f237389171586786c2609f81314bcb1bc17b01e Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include "coreconstants.h"
|
||||
#include "id.h"
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDebug>
|
||||
@@ -424,7 +425,6 @@ void MenuActionContainer::removeMenu(QMenu *menu)
|
||||
m_menu->removeAction(menu->menuAction());
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
static bool menuInMenuBar(const QMenu *menu)
|
||||
{
|
||||
foreach (const QWidget *widget, menu->menuAction()->associatedWidgets()) {
|
||||
@@ -433,19 +433,18 @@ static bool menuInMenuBar(const QMenu *menu)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool MenuActionContainer::updateInternal()
|
||||
{
|
||||
if (onAllDisabledBehavior() == Show)
|
||||
return true;
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
// work around QTBUG-25544 which makes menus in the menu bar stay at their enabled state at startup
|
||||
// (so menus that are disabled at startup would stay disabled)
|
||||
if (menuInMenuBar(m_menu))
|
||||
return true;
|
||||
#endif
|
||||
if (Utils::HostOsInfo::isMacHost()) {
|
||||
// work around QTBUG-25544 which makes menus in the menu bar stay at their enabled state at startup
|
||||
// (so menus that are disabled at startup would stay disabled)
|
||||
if (menuInMenuBar(m_menu))
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hasitems = false;
|
||||
QList<QAction *> actions = m_menu->actions();
|
||||
|
||||
@@ -109,9 +109,7 @@ const char REMOVE_CURRENT_SPLIT[] = "QtCreator.RemoveCurrentSplit";
|
||||
const char REMOVE_ALL_SPLITS[] = "QtCreator.RemoveAllSplits";
|
||||
const char GOTO_OTHER_SPLIT[] = "QtCreator.GotoOtherSplit";
|
||||
const char CLOSE[] = "QtCreator.Close";
|
||||
#ifdef Q_OS_WIN
|
||||
const char CLOSE_ALTERNATIVE[] = "QtCreator.Close_Alternative"; // temporary, see QTCREATORBUG-72
|
||||
#endif
|
||||
const char CLOSEALL[] = "QtCreator.CloseAll";
|
||||
const char CLOSEOTHERS[] = "QtCreator.CloseOthers";
|
||||
const char GOTONEXT[] = "QtCreator.GotoNext";
|
||||
|
||||
@@ -320,14 +320,14 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
mfile->addAction(cmd, Constants::G_FILE_CLOSE);
|
||||
connect(d->m_closeCurrentEditorAction, SIGNAL(triggered()), this, SLOT(closeEditor()));
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
// workaround for QTCREATORBUG-72
|
||||
QShortcut *sc = new QShortcut(parent);
|
||||
cmd = ActionManager::registerShortcut(sc, Constants::CLOSE_ALTERNATIVE, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F4")));
|
||||
cmd->setDescription(EditorManager::tr("Close"));
|
||||
connect(sc, SIGNAL(activated()), this, SLOT(closeEditor()));
|
||||
#endif
|
||||
if (Utils::HostOsInfo::isWindowsHost()) {
|
||||
// workaround for QTCREATORBUG-72
|
||||
QShortcut *sc = new QShortcut(parent);
|
||||
cmd = ActionManager::registerShortcut(sc, Constants::CLOSE_ALTERNATIVE, editManagerContext);
|
||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F4")));
|
||||
cmd->setDescription(EditorManager::tr("Close"));
|
||||
connect(sc, SIGNAL(activated()), this, SLOT(closeEditor()));
|
||||
}
|
||||
|
||||
// Close All Action
|
||||
cmd = ActionManager::registerAction(d->m_closeAllEditorsAction, Constants::CLOSEALL, editManagerContext, true);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "fancyactionbar.h"
|
||||
#include "coreconstants.h"
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/stringutils.h>
|
||||
#include <utils/tooltip/tooltip.h>
|
||||
@@ -152,8 +153,9 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
|
||||
// draw borders
|
||||
bool isTitledAction = defaultAction()->property("titledAction").toBool();
|
||||
|
||||
#ifndef Q_OS_MAC // Mac UIs usually don't hover
|
||||
if (m_fader > 0 && isEnabled() && !isDown() && !isChecked()) {
|
||||
|
||||
if (!Utils::HostOsInfo::isMacHost() // Mac UIs usually don't hover
|
||||
&& m_fader > 0 && isEnabled() && !isDown() && !isChecked()) {
|
||||
painter.save();
|
||||
int fader = int(40 * m_fader);
|
||||
QLinearGradient grad(rect().topLeft(), rect().topRight());
|
||||
@@ -165,9 +167,7 @@ void FancyToolButton::paintEvent(QPaintEvent *event)
|
||||
painter.drawLine(rect().topLeft(), rect().topRight());
|
||||
painter.drawLine(rect().bottomLeft(), rect().bottomRight());
|
||||
painter.restore();
|
||||
} else
|
||||
#endif
|
||||
if (isDown() || isChecked()) {
|
||||
} else if (isDown() || isChecked()) {
|
||||
painter.save();
|
||||
QLinearGradient grad(rect().topLeft(), rect().topRight());
|
||||
grad.setColorAt(0, Qt::transparent);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "infobar.h"
|
||||
#include "editormanager/editormanager.h"
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/qtcolorbutton.h>
|
||||
#include <utils/consoleprocess.h>
|
||||
@@ -114,25 +115,25 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
|
||||
|
||||
m_page->colorButton->setColor(StyleHelper::requestedBaseColor());
|
||||
m_page->reloadBehavior->setCurrentIndex(EditorManager::instance()->reloadSetting());
|
||||
#ifdef Q_OS_UNIX
|
||||
const QStringList availableTerminals = ConsoleProcess::availableTerminalEmulators();
|
||||
const QString currentTerminal = ConsoleProcess::terminalEmulator(settings);
|
||||
m_page->terminalComboBox->addItems(availableTerminals);
|
||||
m_page->terminalComboBox->lineEdit()->setText(currentTerminal);
|
||||
#else
|
||||
m_page->terminalLabel->hide();
|
||||
m_page->terminalComboBox->hide();
|
||||
m_page->resetTerminalButton->hide();
|
||||
#endif
|
||||
if (HostOsInfo::isAnyUnixHost()) {
|
||||
const QStringList availableTerminals = ConsoleProcess::availableTerminalEmulators();
|
||||
const QString currentTerminal = ConsoleProcess::terminalEmulator(settings);
|
||||
m_page->terminalComboBox->addItems(availableTerminals);
|
||||
m_page->terminalComboBox->lineEdit()->setText(currentTerminal);
|
||||
} else {
|
||||
m_page->terminalLabel->hide();
|
||||
m_page->terminalComboBox->hide();
|
||||
m_page->resetTerminalButton->hide();
|
||||
}
|
||||
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||
m_page->externalFileBrowserEdit->setText(UnixUtils::fileBrowser(settings));
|
||||
#else
|
||||
m_page->externalFileBrowserLabel->hide();
|
||||
m_page->externalFileBrowserEdit->hide();
|
||||
m_page->resetFileBrowserButton->hide();
|
||||
m_page->helpExternalFileBrowserButton->hide();
|
||||
#endif
|
||||
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost()) {
|
||||
m_page->externalFileBrowserEdit->setText(UnixUtils::fileBrowser(settings));
|
||||
} else {
|
||||
m_page->externalFileBrowserLabel->hide();
|
||||
m_page->externalFileBrowserEdit->hide();
|
||||
m_page->resetFileBrowserButton->hide();
|
||||
m_page->helpExternalFileBrowserButton->hide();
|
||||
}
|
||||
|
||||
m_page->autoSaveCheckBox->setChecked(EditorManager::instance()->autoSaveEnabled());
|
||||
m_page->autoSaveInterval->setValue(EditorManager::instance()->autoSaveInterval());
|
||||
@@ -142,16 +143,14 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
|
||||
this, SLOT(resetInterfaceColor()));
|
||||
connect(m_page->resetWarningsButton, SIGNAL(clicked()),
|
||||
this, SLOT(resetWarnings()));
|
||||
#ifdef Q_OS_UNIX
|
||||
connect(m_page->resetTerminalButton, SIGNAL(clicked()),
|
||||
this, SLOT(resetTerminal()));
|
||||
#ifndef Q_OS_MAC
|
||||
connect(m_page->resetFileBrowserButton, SIGNAL(clicked()),
|
||||
this, SLOT(resetFileBrowser()));
|
||||
connect(m_page->helpExternalFileBrowserButton, SIGNAL(clicked()),
|
||||
this, SLOT(showHelpForFileBrowser()));
|
||||
#endif
|
||||
#endif
|
||||
if (HostOsInfo::isAnyUnixHost()) {
|
||||
connect(m_page->resetTerminalButton, SIGNAL(clicked()), this, SLOT(resetTerminal()));
|
||||
if (!HostOsInfo::isMacHost()) {
|
||||
connect(m_page->resetFileBrowserButton, SIGNAL(clicked()), this, SLOT(resetFileBrowser()));
|
||||
connect(m_page->helpExternalFileBrowserButton, SIGNAL(clicked()),
|
||||
this, SLOT(showHelpForFileBrowser()));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_searchKeywords.isEmpty()) {
|
||||
QLatin1Char sep(' ');
|
||||
@@ -181,13 +180,14 @@ void GeneralSettings::apply()
|
||||
// Apply the new base color if accepted
|
||||
StyleHelper::setBaseColor(m_page->colorButton->color());
|
||||
EditorManager::instance()->setReloadSetting(IDocument::ReloadSetting(m_page->reloadBehavior->currentIndex()));
|
||||
#ifdef Q_OS_UNIX
|
||||
ConsoleProcess::setTerminalEmulator(Core::ICore::settings(),
|
||||
m_page->terminalComboBox->lineEdit()->text());
|
||||
#ifndef Q_OS_MAC
|
||||
Utils::UnixUtils::setFileBrowser(Core::ICore::settings(), m_page->externalFileBrowserEdit->text());
|
||||
#endif
|
||||
#endif
|
||||
if (HostOsInfo::isAnyUnixHost()) {
|
||||
ConsoleProcess::setTerminalEmulator(Core::ICore::settings(),
|
||||
m_page->terminalComboBox->lineEdit()->text());
|
||||
if (!HostOsInfo::isMacHost()) {
|
||||
Utils::UnixUtils::setFileBrowser(Core::ICore::settings(),
|
||||
m_page->externalFileBrowserEdit->text());
|
||||
}
|
||||
}
|
||||
EditorManager::instance()->setAutoSaveEnabled(m_page->autoSaveCheckBox->isChecked());
|
||||
EditorManager::instance()->setAutoSaveInterval(m_page->autoSaveInterval->value());
|
||||
}
|
||||
@@ -213,16 +213,14 @@ void GeneralSettings::resetWarnings()
|
||||
|
||||
void GeneralSettings::resetTerminal()
|
||||
{
|
||||
#if defined(Q_OS_UNIX)
|
||||
m_page->terminalComboBox->lineEdit()->setText(ConsoleProcess::defaultTerminalEmulator());
|
||||
#endif
|
||||
if (HostOsInfo::isAnyUnixHost())
|
||||
m_page->terminalComboBox->lineEdit()->setText(ConsoleProcess::defaultTerminalEmulator());
|
||||
}
|
||||
|
||||
void GeneralSettings::resetFileBrowser()
|
||||
{
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||
m_page->externalFileBrowserEdit->setText(UnixUtils::defaultFileBrowser());
|
||||
#endif
|
||||
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
|
||||
m_page->externalFileBrowserEdit->setText(UnixUtils::defaultFileBrowser());
|
||||
}
|
||||
|
||||
|
||||
@@ -250,9 +248,8 @@ void GeneralSettings::variableHelpDialogCreator(const QString &helpText)
|
||||
|
||||
void GeneralSettings::showHelpForFileBrowser()
|
||||
{
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||
variableHelpDialogCreator(UnixUtils::fileBrowserHelpText());
|
||||
#endif
|
||||
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
|
||||
variableHelpDialogCreator(UnixUtils::fileBrowserHelpText());
|
||||
}
|
||||
|
||||
void GeneralSettings::resetLanguage()
|
||||
|
||||
@@ -346,6 +346,8 @@
|
||||
#include "mainwindow.h"
|
||||
#include "documentmanager.h"
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
@@ -483,15 +485,11 @@ QString ICore::userInterfaceLanguage()
|
||||
return qApp->property("qtc_locale").toString();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
# define SHARE_PATH "/../Resources"
|
||||
#else
|
||||
# define SHARE_PATH "/../share/qtcreator"
|
||||
#endif
|
||||
|
||||
QString ICore::resourcePath()
|
||||
{
|
||||
return QDir::cleanPath(QCoreApplication::applicationDirPath() + QLatin1String(SHARE_PATH));
|
||||
const QString sharePath = QLatin1String(Utils::HostOsInfo::isMacHost()
|
||||
? "/../Resources" : "/../share/qtcreator");
|
||||
return QDir::cleanPath(QCoreApplication::applicationDirPath() + sharePath);
|
||||
}
|
||||
|
||||
QString ICore::userResourcePath()
|
||||
|
||||
@@ -113,7 +113,6 @@
|
||||
#include <QStyleFactory>
|
||||
|
||||
/*
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <signal.h>
|
||||
extern "C" void handleSigInt(int sig)
|
||||
{
|
||||
@@ -121,7 +120,6 @@ extern "C" void handleSigInt(int sig)
|
||||
Core::ICore::exit();
|
||||
qDebug() << "SIGINT caught. Shutting down.";
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
using namespace Core;
|
||||
@@ -168,10 +166,8 @@ MainWindow::MainWindow() :
|
||||
m_optionsAction(0),
|
||||
m_toggleSideBarAction(0),
|
||||
m_toggleFullScreenAction(0),
|
||||
#ifdef Q_OS_MAC
|
||||
m_minimizeAction(0),
|
||||
m_zoomAction(0),
|
||||
#endif
|
||||
m_toggleSideBarButton(new QToolButton)
|
||||
{
|
||||
(void) new DocumentManager(this);
|
||||
@@ -230,9 +226,8 @@ MainWindow::MainWindow() :
|
||||
statusBar()->insertPermanentWidget(0, m_toggleSideBarButton);
|
||||
|
||||
// setUnifiedTitleAndToolBarOnMac(true);
|
||||
#ifdef Q_OS_UNIX
|
||||
//signal(SIGINT, handleSigInt);
|
||||
#endif
|
||||
//if (Utils::HostOsInfo::isAnyUnixHost())
|
||||
//signal(SIGINT, handleSigInt);
|
||||
|
||||
statusBar()->setProperty("p_styled", true);
|
||||
setAcceptDrops(true);
|
||||
@@ -265,7 +260,6 @@ void MainWindow::setOverrideColor(const QColor &color)
|
||||
m_overrideColor = color;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void MainWindow::setIsFullScreen(bool fullScreen)
|
||||
{
|
||||
if (fullScreen)
|
||||
@@ -273,7 +267,6 @@ void MainWindow::setIsFullScreen(bool fullScreen)
|
||||
else
|
||||
m_toggleFullScreenAction->setText(tr("Enter Full Screen"));
|
||||
}
|
||||
#endif
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
@@ -1095,16 +1088,16 @@ void MainWindow::changeEvent(QEvent *e)
|
||||
emit windowActivated();
|
||||
}
|
||||
} else if (e->type() == QEvent::WindowStateChange) {
|
||||
#ifdef Q_OS_MAC
|
||||
bool minimized = isMinimized();
|
||||
if (debugMainWindow)
|
||||
qDebug() << "main window state changed to minimized=" << minimized;
|
||||
m_minimizeAction->setEnabled(!minimized);
|
||||
m_zoomAction->setEnabled(!minimized);
|
||||
#else
|
||||
bool isFullScreen = (windowState() & Qt::WindowFullScreen) != 0;
|
||||
m_toggleFullScreenAction->setChecked(isFullScreen);
|
||||
#endif
|
||||
if (Utils::HostOsInfo::isMacHost()) {
|
||||
bool minimized = isMinimized();
|
||||
if (debugMainWindow)
|
||||
qDebug() << "main window state changed to minimized=" << minimized;
|
||||
m_minimizeAction->setEnabled(!minimized);
|
||||
m_zoomAction->setEnabled(!minimized);
|
||||
} else {
|
||||
bool isFullScreen = (windowState() & Qt::WindowFullScreen) != 0;
|
||||
m_toggleFullScreenAction->setChecked(isFullScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,9 +120,7 @@ public:
|
||||
|
||||
void setOverrideColor(const QColor &color);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void setIsFullScreen(bool fullScreen);
|
||||
#endif
|
||||
signals:
|
||||
void windowActivated();
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stylehelper.h>
|
||||
|
||||
@@ -902,13 +903,10 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
||||
if (mflags & (State_Sunken)) {
|
||||
QColor shade(0, 0, 0, 50);
|
||||
painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade);
|
||||
}
|
||||
#ifndef Q_OS_MAC
|
||||
else if (mflags & (State_MouseOver)) {
|
||||
} else if (!Utils::HostOsInfo::isMacHost() && (mflags & State_MouseOver)) {
|
||||
QColor shade(255, 255, 255, 50);
|
||||
painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
tool.rect = tool.rect.adjusted(2, 2, -2, -2);
|
||||
drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
|
||||
|
||||
@@ -591,16 +591,16 @@ int OutputPaneManager::currentIndex() const
|
||||
|
||||
static QString buttonStyleSheet()
|
||||
{
|
||||
return QLatin1String("QToolButton { border-image: url(:/core/images/panel_button.png) 2 2 2 19;"
|
||||
" border-width: 2px 2px 2px 19px; padding-left: -17; padding-right: 4 } "
|
||||
QString styleSheet = QLatin1String("QToolButton { border-image: url(:/core/images/panel_button.png) 2 2 2 19;"
|
||||
" border-width: 2px 2px 2px 19px; padding-left: -17; padding-right: 4 } "
|
||||
"QToolButton:checked { border-image: url(:/core/images/panel_button_checked.png) 2 2 2 19 } "
|
||||
"QToolButton::menu-indicator { width:0; height:0 }"
|
||||
#ifndef Q_OS_MAC // Mac UIs usually don't hover
|
||||
"QToolButton:checked:hover { border-image: url(:/core/images/panel_button_checked_hover.png) 2 2 2 19 } "
|
||||
"QToolButton:pressed:hover { border-image: url(:/core/images/panel_button_pressed.png) 2 2 2 19 } "
|
||||
"QToolButton:hover { border-image: url(:/core/images/panel_button_hover.png) 2 2 2 19 } "
|
||||
#endif
|
||||
);
|
||||
"QToolButton::menu-indicator { width:0; height:0 }");
|
||||
if (!Utils::HostOsInfo::isMacHost()) { // Mac UIs usually don't hover
|
||||
styleSheet += QLatin1String("QToolButton:checked:hover { border-image: url(:/core/images/panel_button_checked_hover.png) 2 2 2 19 } "
|
||||
"QToolButton:pressed:hover { border-image: url(:/core/images/panel_button_pressed.png) 2 2 2 19 } "
|
||||
"QToolButton:hover { border-image: url(:/core/images/panel_button_hover.png) 2 2 2 19 } ");
|
||||
}
|
||||
return styleSheet;
|
||||
}
|
||||
|
||||
OutputPaneToggleButton::OutputPaneToggleButton(int number, const QString &text,
|
||||
|
||||
Reference in New Issue
Block a user