Mac OS proxy icon.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-12-05 16:16:29 +02:00
parent 7054714114
commit 830c43a89d
8 changed files with 44 additions and 186 deletions

View File

@ -75,6 +75,8 @@
<array>
<string>vit</string>
</array>
<key>public.mime-type</key>
<string>text/xml</string>
</dict>
</dict>
<dict>
@ -95,6 +97,8 @@
<array>
<string>vst</string>
</array>
<key>public.mime-type</key>
<string>text/xml</string>
</dict>
</dict>
</array>

View File

@ -42,7 +42,7 @@
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<string>Viewer</string>
<key>CFBundleTypeIconFile</key>
<string>measurements.icns</string>
<key>LSItemContentTypes</key>
@ -52,11 +52,11 @@
<key>CFBundleTypeName</key>
<string>Valentina individual measurements</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<string>Alternate</string>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<string>Viewer</string>
<key>CFBundleTypeIconFile</key>
<string>measurements.icns</string>
<key>LSItemContentTypes</key>
@ -66,7 +66,7 @@
<key>CFBundleTypeName</key>
<string>Valentina standard measurements</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<string>Alternate</string>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
@ -89,6 +89,8 @@
<array>
<string>val</string>
</array>
<key>public.mime-type</key>
<string>text/xml</string>
</dict>
</dict>
<dict>
@ -109,6 +111,8 @@
<array>
<string>vit</string>
</array>
<key>public.mime-type</key>
<string>text/xml</string>
</dict>
</dict>
<dict>
@ -129,6 +133,8 @@
<array>
<string>vst</string>
</array>
<key>public.mime-type</key>
<string>text/xml</string>
</dict>
</dict>
</array>

View File

@ -223,7 +223,9 @@ MApplication::MApplication(int &argc, char **argv)
setOrganizationDomain(VER_COMPANYDOMAIN_STR);
// Setting the Application version
setApplicationVersion(APP_VERSION_STR);
#if !defined(Q_OS_MAC)
setWindowIcon(QIcon(":/tapeicon/64x64/logo.png"));
#endif // !defined(Q_OS_MAC)
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -553,81 +553,6 @@ void TMainWindow::showEvent(QShowEvent *event)
isInitialized = true;//first show windows are held
}
//---------------------------------------------------------------------------------------------------------------------
#if defined(Q_OS_MAC)
bool TMainWindow::event(QEvent *event)
{
if (not isActiveWindow())
{
return QMainWindow::event(event);
}
switch (event->type())
{
case QEvent::IconDrag:
{
event->accept();
const Qt::KeyboardModifiers currentModifiers = qApp->keyboardModifiers();
if (currentModifiers == Qt::NoModifier)
{
QDrag *drag = new QDrag(this);
QMimeData *data = new QMimeData();
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(curFile));
drag->setMimeData(data);
const QPixmap cursorPixmap = style()->standardPixmap(QStyle::SP_FileIcon, 0, this);
drag->setPixmap(cursorPixmap);
QPoint hotspot(cursorPixmap.width() - 5, 5);
drag->setHotSpot(hotspot);
drag->start(Qt::LinkAction | Qt::CopyAction);
}
else if (currentModifiers == Qt::ControlModifier)
{
QMenu menu(this);
connect(&menu, &QMenu::triggered, this, &TMainWindow::OpenAt);
QFileInfo info(curFile);
QAction *action = menu.addAction(info.fileName());
action->setIcon(QIcon(QApplication::applicationDirPath() +
QLatin1Literal("/../Resources/measurements.icns")));
const QStringList folders = info.absolutePath().split('/');
QStringListIterator it(folders);
it.toBack();
while (it.hasPrevious())
{
QString string = it.previous();
QIcon icon;
if (not string.isEmpty())
{
icon = style()->standardIcon(QStyle::SP_DirClosedIcon, 0, this);
}
else
{ // At the root
string = "/";
icon = style()->standardIcon(QStyle::SP_DriveHDIcon, 0, this);
}
action = menu.addAction(string);
action->setIcon(icon);
}
QPoint pos(QCursor::pos().x() - 20, frameGeometry().y());
menu.exec(pos);
}
else
{
event->ignore();
}
return true;
}
default:
return QMainWindow::event(event);
}
}
#endif //defined(Q_OS_MAC)
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::FileSave()
{
@ -2094,6 +2019,7 @@ void TMainWindow::SetCurrentFile(const QString &fileName)
}
shownName += "[*]";
setWindowTitle(shownName);
setWindowFilePath(curFile);
#if defined(Q_OS_MAC)
static QIcon fileIcon = QIcon(QApplication::applicationDirPath() +

View File

@ -74,9 +74,6 @@ protected:
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
#if defined(Q_OS_MAC)
virtual bool event(QEvent *event) Q_DECL_OVERRIDE;
#endif //defined(Q_OS_MAC)
private slots:
void FileSave();

View File

@ -56,7 +56,9 @@ int main(int argc, char *argv[])
app.InitOptions();
MainWindow w;
#if !defined(Q_OS_MAC)
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
#endif // !defined(Q_OS_MAC)
app.setMainWindow(&w);
QTimer::singleShot(0, &w, SLOT(ProcessCMD()));

View File

@ -1122,82 +1122,6 @@ void MainWindow::customEvent(QEvent *event)
}
}
//---------------------------------------------------------------------------------------------------------------------
#if defined(Q_OS_MAC)
bool MainWindow::event(QEvent *event)
{
if (not isActiveWindow())
{
return MainWindowsNoGUI::event(event);
}
switch (event->type())
{
case QEvent::IconDrag:
{
event->accept();
const Qt::KeyboardModifiers currentModifiers = qApp->keyboardModifiers();
if (currentModifiers == Qt::NoModifier)
{
QDrag *drag = new QDrag(this);
QMimeData *data = new QMimeData();
data->setUrls(QList<QUrl>() << QUrl::fromLocalFile(curFile));
drag->setMimeData(data);
const QPixmap cursorPixmap = style()->standardPixmap(QStyle::SP_FileIcon, 0, this);
drag->setPixmap(cursorPixmap);
QPoint hotspot(cursorPixmap.width() - 5, 5);
drag->setHotSpot(hotspot);
drag->start(Qt::LinkAction | Qt::CopyAction);
}
else if (currentModifiers == Qt::ControlModifier)
{
QMenu menu(this);
connect(&menu, &QMenu::triggered, this, &MainWindow::OpenAt);
QFileInfo info(curFile);
QAction *action = menu.addAction(info.fileName());
action->setIcon(QIcon(QApplication::applicationDirPath() +
QLatin1Literal("/../Resources/measurements.icns")));
const QStringList folders = info.absolutePath().split('/');
QStringListIterator it(folders);
it.toBack();
while (it.hasPrevious())
{
QString string = it.previous();
QIcon icon;
if (not string.isEmpty())
{
icon = style()->standardIcon(QStyle::SP_DirClosedIcon, 0, this);
}
else
{ // At the root
string = "/";
icon = style()->standardIcon(QStyle::SP_DriveHDIcon, 0, this);
}
action = menu.addAction(string);
action->setIcon(icon);
}
QPoint pos(QCursor::pos().x() - 20, frameGeometry().y());
menu.exec(pos);
}
else
{
event->ignore();
}
return true;
}
default:
return MainWindowsNoGUI::event(event);
}
}
#endif //defined(Q_OS_MAC)
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::CleanLayout()
{
@ -2980,30 +2904,6 @@ void MainWindow::setCurrentFile(const QString &fileName)
settings->SetRestoreFileList(restoreFiles);
}
#if defined(Q_OS_MAC)
static QIcon fileIcon = QIcon(QApplication::applicationDirPath() +
QLatin1Literal("/../Resources/measurements.icns"));
QIcon icon;
if (not curFile.isEmpty())
{
if (not isWindowModified())
{
icon = fileIcon;
}
else
{
static QIcon darkIcon;
if (darkIcon.isNull())
{
darkIcon = QIcon(darkenPixmap(fileIcon.pixmap(16, 16)));
}
icon = darkIcon;
}
}
setWindowIcon(icon);
#endif //defined(Q_OS_MAC)
UpdateWindowTitle();
}
@ -4131,4 +4031,29 @@ QString MainWindow::GetMeasurementFileName()
void MainWindow::UpdateWindowTitle()
{
setWindowTitle(GetPatternFileName()+GetMeasurementFileName());
setWindowFilePath(curFile);
#if defined(Q_OS_MAC)
static QIcon fileIcon = QIcon(QApplication::applicationDirPath() +
QLatin1Literal("/../Resources/Valentina.icns"));
QIcon icon;
if (not curFile.isEmpty())
{
if (not isWindowModified())
{
icon = fileIcon;
}
else
{
static QIcon darkIcon;
if (darkIcon.isNull())
{
darkIcon = QIcon(darkenPixmap(fileIcon.pixmap(16, 16)));
}
icon = darkIcon;
}
}
setWindowIcon(icon);
#endif //defined(Q_OS_MAC)
}

View File

@ -159,10 +159,6 @@ protected:
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
virtual void customEvent(QEvent * event) Q_DECL_OVERRIDE;
#if defined(Q_OS_MAC)
virtual bool event(QEvent *event) Q_DECL_OVERRIDE;
#endif //defined(Q_OS_MAC)
virtual void CleanLayout() Q_DECL_OVERRIDE;
virtual void PrepareSceneList() Q_DECL_OVERRIDE;
private slots: