mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-28 03:44:07 +00:00
Merge pull request #103 from dinvlad/master
Added full-screen mode for Mac OS X Lion
This commit is contained in:
commit
bdda29a267
|
@ -103,7 +103,8 @@ mac {
|
|||
-logg \
|
||||
-lhunspell-1.2
|
||||
INCLUDEPATH = maclibs/include
|
||||
LIBS += -Lmaclibs/lib
|
||||
LIBS += -Lmaclibs/lib -framework AppKit
|
||||
OBJECTIVE_SOURCES += lionsupport.mm
|
||||
ICON = icons/macicon.icns
|
||||
QMAKE_POST_LINK = mkdir -p GoldenDict.app/Contents/Frameworks & \
|
||||
cp -nR maclibs/lib/ GoldenDict.app/Contents/Frameworks/ & \
|
||||
|
|
20
lionsupport.h
Normal file
20
lionsupport.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef LIONSUPPORT_H
|
||||
#define LIONSUPPORT_H
|
||||
|
||||
#include "mainwindow.hh"
|
||||
|
||||
class LionSupport
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Returns whether the current system is Lion.
|
||||
*/
|
||||
static bool isLion();
|
||||
|
||||
/**
|
||||
* Adds fullscreen button to window for Lion.
|
||||
*/
|
||||
static void addFullscreen(MainWindow *window);
|
||||
};
|
||||
|
||||
#endif // LIONSUPPORT_H
|
22
lionsupport.mm
Normal file
22
lionsupport.mm
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "lionsupport.h"
|
||||
|
||||
bool LionSupport::isLion()
|
||||
{
|
||||
NSString *string = [NSString string];
|
||||
// this selector was added only in Lion. so we can check if it's responding, we are on Lion
|
||||
return [string respondsToSelector:@selector(linguisticTagsInRange:scheme:options:orthography:tokenRanges:)];
|
||||
}
|
||||
|
||||
void LionSupport::addFullscreen(MainWindow *window)
|
||||
{
|
||||
#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
if (isLion()) // checks if lion is running
|
||||
{
|
||||
NSView *nsview = (NSView *) window->winId();
|
||||
NSWindow *nswindow = [nsview window];
|
||||
[nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
}
|
||||
#else
|
||||
#warning No fullscreen support will be included in this build
|
||||
#endif
|
||||
}
|
|
@ -20,6 +20,10 @@
|
|||
#include "dprintf.hh"
|
||||
#include <QDebug>
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include "lionsupport.h"
|
||||
#endif
|
||||
|
||||
using std::set;
|
||||
using std::wstring;
|
||||
using std::map;
|
||||
|
@ -506,6 +510,10 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
doDeferredInit( dictionaries );
|
||||
|
||||
updateStatusLine();
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
LionSupport::addFullscreen(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::ctrlTabPressed()
|
||||
|
|
Loading…
Reference in a new issue