Added support Mac OS Dock Menu.
--HG-- branch : develop
This commit is contained in:
parent
61eec32420
commit
33087b2fe8
|
@ -111,7 +111,27 @@ TMainWindow::TMainWindow(QWidget *parent)
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
// On Mac deafault icon size is 32x32.
|
// On Mac deafault icon size is 32x32.
|
||||||
ui->toolBarGradation->setIconSize(QSize(24, 24));
|
ui->toolBarGradation->setIconSize(QSize(24, 24));
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 2)
|
||||||
|
// Mac OS Dock Menu
|
||||||
|
QMenu *menu = new QMenu(this);
|
||||||
|
|
||||||
|
CreateWindowMenu(ui->menuWindow);
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
|
||||||
|
menu->addAction(ui->actionOpenIndividual);
|
||||||
|
menu->addAction(ui->actionOpenStandard);
|
||||||
|
menu->addAction(ui->actionOpenTemplate);
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
|
||||||
|
menu->addAction(ui->actionPreferences);
|
||||||
|
|
||||||
|
extern void qt_mac_set_dock_menu(QMenu *);
|
||||||
|
qt_mac_set_dock_menu(menu);
|
||||||
#endif
|
#endif
|
||||||
|
#endif //defined(Q_OS_MAC)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -652,31 +672,7 @@ void TMainWindow::FileSaveAs()
|
||||||
void TMainWindow::AboutToShowWindowMenu()
|
void TMainWindow::AboutToShowWindowMenu()
|
||||||
{
|
{
|
||||||
ui->menuWindow->clear();
|
ui->menuWindow->clear();
|
||||||
QAction *action = ui->menuWindow->addAction(tr("&New Window"), this, SLOT(NewWindow()));
|
CreateWindowMenu(ui->menuWindow);
|
||||||
action->setMenuRole(QAction::NoRole);
|
|
||||||
ui->menuWindow->addSeparator();
|
|
||||||
|
|
||||||
QList<TMainWindow*> windows = qApp->MainWindows();
|
|
||||||
for (int i = 0; i < windows.count(); ++i)
|
|
||||||
{
|
|
||||||
TMainWindow *window = windows.at(i);
|
|
||||||
|
|
||||||
QString title = window->windowTitle();
|
|
||||||
const int index = title.lastIndexOf("[*]");
|
|
||||||
if (index != -1)
|
|
||||||
{
|
|
||||||
window->isWindowModified() ? title.replace(index, 3, "*") : title.replace(index, 3, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
QAction *action = ui->menuWindow->addAction(title, this, SLOT(ShowWindow()));
|
|
||||||
action->setData(i);
|
|
||||||
action->setCheckable(true);
|
|
||||||
action->setMenuRole(QAction::NoRole);
|
|
||||||
if (window == this)
|
|
||||||
{
|
|
||||||
action->setChecked(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2629,6 +2625,38 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void TMainWindow::CreateWindowMenu(QMenu *menu)
|
||||||
|
{
|
||||||
|
SCASSERT(menu != nullptr);
|
||||||
|
|
||||||
|
QAction *action = menu->addAction(tr("&New Window"), this, SLOT(NewWindow()));
|
||||||
|
action->setMenuRole(QAction::NoRole);
|
||||||
|
menu->addSeparator();
|
||||||
|
|
||||||
|
QList<TMainWindow*> windows = qApp->MainWindows();
|
||||||
|
for (int i = 0; i < windows.count(); ++i)
|
||||||
|
{
|
||||||
|
TMainWindow *window = windows.at(i);
|
||||||
|
|
||||||
|
QString title = window->windowTitle();
|
||||||
|
const int index = title.lastIndexOf("[*]");
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
window->isWindowModified() ? title.replace(index, 3, "*") : title.replace(index, 3, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
QAction *action = menu->addAction(title, this, SLOT(ShowWindow()));
|
||||||
|
action->setData(i);
|
||||||
|
action->setCheckable(true);
|
||||||
|
action->setMenuRole(QAction::NoRole);
|
||||||
|
if (window == this)
|
||||||
|
{
|
||||||
|
action->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void TMainWindow::SetDecimals()
|
void TMainWindow::SetDecimals()
|
||||||
{
|
{
|
||||||
|
|
|
@ -193,6 +193,8 @@ private:
|
||||||
void UpdatePatternUnit();
|
void UpdatePatternUnit();
|
||||||
|
|
||||||
bool LoadFromExistingFile(const QString &path);
|
bool LoadFromExistingFile(const QString &path);
|
||||||
|
|
||||||
|
void CreateWindowMenu(QMenu *menu);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TMAINWINDOW_H
|
#endif // TMAINWINDOW_H
|
||||||
|
|
|
@ -138,6 +138,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
setCurrentFile("");
|
setCurrentFile("");
|
||||||
WindowsLocale();
|
WindowsLocale();
|
||||||
|
|
||||||
|
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &MainWindow::ShowPaper);
|
||||||
|
ui->dockWidgetLayoutPages->setVisible(false);
|
||||||
|
|
||||||
|
connect(watcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::MeasurementsChanged);
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
// On Mac deafault icon size is 32x32.
|
// On Mac deafault icon size is 32x32.
|
||||||
ui->toolBarArrows->setIconSize(QSize(24, 24));
|
ui->toolBarArrows->setIconSize(QSize(24, 24));
|
||||||
|
@ -145,12 +150,29 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
ui->toolBarOption->setIconSize(QSize(24, 24));
|
ui->toolBarOption->setIconSize(QSize(24, 24));
|
||||||
ui->toolBarStages->setIconSize(QSize(24, 24));
|
ui->toolBarStages->setIconSize(QSize(24, 24));
|
||||||
ui->toolBarTools->setIconSize(QSize(24, 24));
|
ui->toolBarTools->setIconSize(QSize(24, 24));
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 2)
|
||||||
|
// Mac OS Dock Menu
|
||||||
|
QMenu *menu = new QMenu(this);
|
||||||
|
|
||||||
|
QAction *actionNewPattern = menu->addAction(tr("New pattern"));
|
||||||
|
actionNewPattern->setMenuRole(QAction::NoRole);
|
||||||
|
connect(actionNewPattern, &QAction::triggered, this, &MainWindow::New);
|
||||||
|
|
||||||
|
QAction *actionOpenPattern = menu->addAction(tr("Open pattern"));
|
||||||
|
actionOpenPattern->setMenuRole(QAction::NoRole);
|
||||||
|
connect(actionOpenPattern, &QAction::triggered, this, &MainWindow::Open);
|
||||||
|
|
||||||
|
QAction *actionOpenTape = menu->addAction(tr("Create/Edit measurements"));
|
||||||
|
actionOpenTape->setMenuRole(QAction::NoRole);
|
||||||
|
connect(actionOpenTape, &QAction::triggered, this, &MainWindow::CreateMeasurements);
|
||||||
|
|
||||||
|
menu->addAction(ui->actionPreferences);
|
||||||
|
|
||||||
|
extern void qt_mac_set_dock_menu(QMenu *);
|
||||||
|
qt_mac_set_dock_menu(menu);
|
||||||
#endif
|
#endif
|
||||||
|
#endif //defined(Q_OS_MAC)
|
||||||
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &MainWindow::ShowPaper);
|
|
||||||
ui->dockWidgetLayoutPages->setVisible(false);
|
|
||||||
|
|
||||||
connect(watcher, &QFileSystemWatcher::fileChanged, this, &MainWindow::MeasurementsChanged);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -375,7 +375,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>117</width>
|
<width>130</width>
|
||||||
<height>58</height>
|
<height>58</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -461,7 +461,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>117</width>
|
<width>130</width>
|
||||||
<height>156</height>
|
<height>156</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -625,7 +625,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>117</width>
|
<width>130</width>
|
||||||
<height>196</height>
|
<height>196</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -867,7 +867,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>117</width>
|
<width>130</width>
|
||||||
<height>58</height>
|
<height>58</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -2118,8 +2118,8 @@
|
||||||
<tabstop>toolButtonSplinePath</tabstop>
|
<tabstop>toolButtonSplinePath</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
|
|
||||||
<include location="share/resources/toolicon.qrc"/>
|
<include location="share/resources/toolicon.qrc"/>
|
||||||
|
<include location="../../libs/vmisc/share/resources/icon.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user