mirror of https://github.com/vitalif/openscad
Move software update menu handling to AutoUpdater. This should fix #714
parent
e518cb9089
commit
40aae17c0e
|
@ -8,4 +8,5 @@ sparkle {
|
|||
LIBS += -framework Sparkle
|
||||
HEADERS += src/SparkleAutoUpdater.h
|
||||
OBJECTIVE_SOURCES += src/SparkleAutoUpdater.mm
|
||||
DEFINES += OPENSCAD_UPDATER
|
||||
}
|
||||
|
|
|
@ -1,3 +1,23 @@
|
|||
#include "AutoUpdater.h"
|
||||
#include <QAction>
|
||||
#include <QMenuBar>
|
||||
|
||||
AutoUpdater *AutoUpdater::updater_instance = NULL;
|
||||
|
||||
void AutoUpdater::init()
|
||||
{
|
||||
#ifdef OPENSCAD_UPDATER
|
||||
if (!this->updateAction) {
|
||||
QMenuBar *mb = new QMenuBar();
|
||||
this->updateMenu = mb->addMenu("special");
|
||||
this->updateAction = new QAction("Check for Update..", this);
|
||||
// Add to application menu
|
||||
this->updateAction->setMenuRole(QAction::ApplicationSpecificRole);
|
||||
this->updateAction->setEnabled(true);
|
||||
this->connect(this->updateAction, SIGNAL(triggered()), this, SLOT(checkForUpdates()));
|
||||
|
||||
this->updateMenu->addAction(this->updateAction);
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,22 +1,34 @@
|
|||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
class AutoUpdater
|
||||
class AutoUpdater : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
AutoUpdater() : updateAction(NULL) {}
|
||||
virtual ~AutoUpdater() {}
|
||||
|
||||
virtual void checkForUpdates() = 0;
|
||||
virtual void setAutomaticallyChecksForUpdates(bool on) = 0;
|
||||
virtual bool automaticallyChecksForUpdates() = 0;
|
||||
virtual void setEnableSnapshots(bool on) = 0;
|
||||
virtual bool enableSnapshots() = 0;
|
||||
virtual QString lastUpdateCheckDate() = 0;
|
||||
virtual void init();
|
||||
|
||||
static AutoUpdater *updater() { return updater_instance; }
|
||||
static void setUpdater(AutoUpdater *updater) { updater_instance = updater; }
|
||||
|
||||
public slots:
|
||||
virtual void checkForUpdates() = 0;
|
||||
|
||||
|
||||
public:
|
||||
class QAction *updateAction;
|
||||
class QMenu *updateMenu;
|
||||
|
||||
protected:
|
||||
static AutoUpdater *updater_instance;
|
||||
};
|
||||
|
|
|
@ -119,7 +119,6 @@ private:
|
|||
class FontListDialog *font_list_dialog;
|
||||
|
||||
private slots:
|
||||
void actionUpdateCheck();
|
||||
void actionNew();
|
||||
void actionOpen();
|
||||
void actionOpenRecent();
|
||||
|
|
|
@ -15,7 +15,16 @@
|
|||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -30,7 +39,16 @@
|
|||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -64,7 +82,16 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayoutAnimate">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -143,7 +170,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1397</width>
|
||||
<height>33</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
|
@ -280,7 +307,6 @@
|
|||
<addaction name="helpActionManual"/>
|
||||
<addaction name="helpActionLibraryInfo"/>
|
||||
<addaction name="helpActionFontInfo"/>
|
||||
<addaction name="appActionUpdateCheck"/>
|
||||
</widget>
|
||||
<addaction name="menu_File"/>
|
||||
<addaction name="menu_Edit"/>
|
||||
|
@ -298,7 +324,16 @@
|
|||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -418,7 +453,16 @@
|
|||
</attribute>
|
||||
<widget class="QWidget" name="consoleDockContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
|
@ -1013,14 +1057,6 @@
|
|||
<string>Library info</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="appActionUpdateCheck">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Check for Update..</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="fileShowLibraryFolder">
|
||||
<property name="text">
|
||||
<string>Show Library Folder...</string>
|
||||
|
|
|
@ -113,7 +113,7 @@ void Preferences::init() {
|
|||
QActionGroup *group = new QActionGroup(this);
|
||||
addPrefPage(group, prefsAction3DView, page3DView);
|
||||
addPrefPage(group, prefsActionEditor, pageEditor);
|
||||
#if defined(OPENSCAD_DEPLOY) && defined(Q_OS_MAC)
|
||||
#ifdef OPENSCAD_UPDATER
|
||||
addPrefPage(group, prefsActionUpdate, pageUpdate);
|
||||
#else
|
||||
this->toolBar->removeAction(prefsActionUpdate);
|
||||
|
@ -307,7 +307,7 @@ void Preferences::on_snapshotCheckBox_toggled(bool on)
|
|||
|
||||
void Preferences::on_checkNowButton_clicked()
|
||||
{
|
||||
if (AutoUpdater *updater =AutoUpdater::updater()) {
|
||||
if (AutoUpdater *updater = AutoUpdater::updater()) {
|
||||
updater->checkForUpdates();
|
||||
} else {
|
||||
unimplemented_msg();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
class SparkleAutoUpdater : public AutoUpdater
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
SparkleAutoUpdater();
|
||||
~SparkleAutoUpdater();
|
||||
|
|
|
@ -56,11 +56,13 @@
|
|||
#include "ThrownTogetherRenderer.h"
|
||||
#include "csgtermnormalizer.h"
|
||||
#include "QGLView.h"
|
||||
#include "AutoUpdater.h"
|
||||
#ifdef Q_OS_MAC
|
||||
#include "CocoaUtils.h"
|
||||
#endif
|
||||
#include "PlatformUtils.h"
|
||||
#ifdef OPENSCAD_UPDATER
|
||||
#include "AutoUpdater.h"
|
||||
#endif
|
||||
|
||||
#include <QMenu>
|
||||
#include <QTime>
|
||||
|
@ -276,17 +278,6 @@ MainWindow::MainWindow(const QString &filename)
|
|||
animate_panel->hide();
|
||||
find_panel->hide();
|
||||
|
||||
// Application menu
|
||||
#ifdef DEBUG
|
||||
this->appActionUpdateCheck->setEnabled(false);
|
||||
#else
|
||||
#ifdef Q_OS_MAC
|
||||
this->appActionUpdateCheck->setMenuRole(QAction::ApplicationSpecificRole);
|
||||
this->appActionUpdateCheck->setEnabled(true);
|
||||
connect(this->appActionUpdateCheck, SIGNAL(triggered()), this, SLOT(actionUpdateCheck()));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// File menu
|
||||
connect(this->fileActionNew, SIGNAL(triggered()), this, SLOT(actionNew()));
|
||||
connect(this->fileActionOpen, SIGNAL(triggered()), this, SLOT(actionOpen()));
|
||||
|
@ -410,6 +401,10 @@ MainWindow::MainWindow(const QString &filename)
|
|||
connect(this->helpActionLibraryInfo, SIGNAL(triggered()), this, SLOT(helpLibrary()));
|
||||
connect(this->helpActionFontInfo, SIGNAL(triggered()), this, SLOT(helpFontInfo()));
|
||||
|
||||
#ifdef OPENSCAD_UPDATER
|
||||
this->menuBar()->addMenu(AutoUpdater::updater()->updateMenu);
|
||||
#endif
|
||||
|
||||
setCurrentOutput();
|
||||
|
||||
PRINT(helptitle);
|
||||
|
@ -1136,13 +1131,6 @@ void MainWindow::compileCSG(bool procevents)
|
|||
if (procevents) QApplication::processEvents();
|
||||
}
|
||||
|
||||
void MainWindow::actionUpdateCheck()
|
||||
{
|
||||
if (AutoUpdater *updater =AutoUpdater::updater()) {
|
||||
updater->checkForUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::actionNew()
|
||||
{
|
||||
if (MainWindow::mdiMode) {
|
||||
|
|
|
@ -65,9 +65,9 @@
|
|||
|
||||
#ifdef __APPLE__
|
||||
#include "AppleEvents.h"
|
||||
#ifdef OPENSCAD_DEPLOY
|
||||
#include "SparkleAutoUpdater.h"
|
||||
#endif
|
||||
#ifdef OPENSCAD_UPDATER
|
||||
#include "SparkleAutoUpdater.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -556,10 +556,11 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
|
|||
installAppleEventHandlers();
|
||||
#endif
|
||||
|
||||
#if defined(OPENSCAD_DEPLOY) && defined(Q_OS_MAC)
|
||||
// AutoUpdater *updater = new SparkleAutoUpdater;
|
||||
// AutoUpdater::setUpdater(updater);
|
||||
// if (updater->automaticallyChecksForUpdates()) updater->checkForUpdates();
|
||||
#ifdef OPENSCAD_UPDATER
|
||||
AutoUpdater *updater = new SparkleAutoUpdater;
|
||||
AutoUpdater::setUpdater(updater);
|
||||
if (updater->automaticallyChecksForUpdates()) updater->checkForUpdates();
|
||||
updater->init();
|
||||
#endif
|
||||
|
||||
#if 0 /*** disabled by clifford wolf: adds rendering artefacts with OpenCSG ***/
|
||||
|
|
Loading…
Reference in New Issue