From 830c43a89d4bdf6c8518eca5e481597ff7cd6821 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 5 Dec 2015 16:16:29 +0200 Subject: [PATCH] Mac OS proxy icon. --HG-- branch : develop --- dist/macx/tape/Info.plist | 4 + dist/macx/valentina/Info.plist | 14 +++- src/app/tape/mapplication.cpp | 2 + src/app/tape/tmainwindow.cpp | 76 +------------------ src/app/tape/tmainwindow.h | 3 - src/app/valentina/main.cpp | 2 + src/app/valentina/mainwindow.cpp | 125 +++++++------------------------ src/app/valentina/mainwindow.h | 4 - 8 files changed, 44 insertions(+), 186 deletions(-) diff --git a/dist/macx/tape/Info.plist b/dist/macx/tape/Info.plist index 4ff7c2383..c81c44fd7 100755 --- a/dist/macx/tape/Info.plist +++ b/dist/macx/tape/Info.plist @@ -75,6 +75,8 @@ vit + public.mime-type + text/xml @@ -95,6 +97,8 @@ vst + public.mime-type + text/xml diff --git a/dist/macx/valentina/Info.plist b/dist/macx/valentina/Info.plist index b4e4c3f11..1f2dd83ac 100755 --- a/dist/macx/valentina/Info.plist +++ b/dist/macx/valentina/Info.plist @@ -42,7 +42,7 @@ CFBundleTypeRole - Editor + Viewer CFBundleTypeIconFile measurements.icns LSItemContentTypes @@ -52,11 +52,11 @@ CFBundleTypeName Valentina individual measurements LSHandlerRank - Owner + Alternate CFBundleTypeRole - Editor + Viewer CFBundleTypeIconFile measurements.icns LSItemContentTypes @@ -66,7 +66,7 @@ CFBundleTypeName Valentina standard measurements LSHandlerRank - Owner + Alternate UTExportedTypeDeclarations @@ -89,6 +89,8 @@ val + public.mime-type + text/xml @@ -109,6 +111,8 @@ vit + public.mime-type + text/xml @@ -129,6 +133,8 @@ vst + public.mime-type + text/xml diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index 96e944bdd..e5ef2ec4c 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -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) } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index bbe2441e9..dc10d2c7a 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -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::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() + diff --git a/src/app/tape/tmainwindow.h b/src/app/tape/tmainwindow.h index 2b4f6b967..e55f40ffd 100644 --- a/src/app/tape/tmainwindow.h +++ b/src/app/tape/tmainwindow.h @@ -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(); diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 01c96b0f9..35c429c19 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -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())); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 314931425..035edef0c 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -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::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) } diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 923365c98..1be677abf 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -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: