diff --git a/desktop-widgets/preferences.cpp b/desktop-widgets/preferences.cpp deleted file mode 100644 index 29e9d2458..000000000 --- a/desktop-widgets/preferences.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include "preferences.h" -#include "mainwindow.h" -#include "models.h" -#include "divelocationmodel.h" -#include "prefs-macros.h" -#include "qthelper.h" -#include "subsurfacestartup.h" - -#include -#include -#include -#include -#include -#include - -#include "subsurfacewebservices.h" - -#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) -#include "socialnetworks.h" -#include -#endif - -PreferencesDialog *PreferencesDialog::instance() -{ - static PreferencesDialog *dialog = new PreferencesDialog(MainWindow::instance()); - return dialog; -} - -PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) -{ - ui.setupUi(this); - setAttribute(Qt::WA_QuitOnClose, false); - -#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) - FacebookManager *fb = FacebookManager::instance(); - facebookWebView = new QWebView(this); - ui.fbWebviewContainer->layout()->addWidget(facebookWebView); - if (fb->loggedIn()) { - facebookLoggedIn(); - } else { - facebookDisconnect(); - } - connect(facebookWebView, &QWebView::urlChanged, fb, &FacebookManager::tryLogin); - connect(fb, &FacebookManager::justLoggedIn, this, &PreferencesDialog::facebookLoggedIn); - connect(ui.fbDisconnect, &QPushButton::clicked, fb, &FacebookManager::logout); - connect(fb, &FacebookManager::justLoggedOut, this, &PreferencesDialog::facebookDisconnect); -#endif - - connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); - - // connect(ui.defaultSetpoint, SIGNAL(valueChanged(double)), this, SLOT(defaultSetpointChanged(double))); - QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); - connect(close, SIGNAL(activated()), this, SLOT(close())); - QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); - connect(quit, SIGNAL(activated()), parent, SLOT(close())); - loadSettings(); - setUiFromPrefs(); - rememberPrefs(); -} - -void PreferencesDialog::facebookLoggedIn() -{ -#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) - ui.fbDisconnect->show(); - ui.fbWebviewContainer->hide(); - ui.fbWebviewContainer->setEnabled(false); - ui.FBLabel->setText(tr("To disconnect Subsurface from your Facebook account, use the button below")); -#endif -} - -void PreferencesDialog::facebookDisconnect() -{ -#if !defined(Q_OS_ANDROID) && defined(FBSUPPORT) - // remove the connect/disconnect button - // and instead add the login view - ui.fbDisconnect->hide(); - ui.fbWebviewContainer->show(); - ui.fbWebviewContainer->setEnabled(true); - ui.FBLabel->setText(tr("To connect to Facebook, please log in. This enables Subsurface to publish dives to your timeline")); - if (facebookWebView) { - facebookWebView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar()); - facebookWebView->setUrl(FacebookManager::instance()->connectUrl()); - } -#endif -} - -void PreferencesDialog::showEvent(QShowEvent *event) -{ - setUiFromPrefs(); - rememberPrefs(); - QDialog::showEvent(event); -} - -void PreferencesDialog::setUiFromPrefs() -{ - -} - -void PreferencesDialog::restorePrefs() -{ - prefs = oldPrefs; - setUiFromPrefs(); -} - -void PreferencesDialog::rememberPrefs() -{ - oldPrefs = prefs; -} - -void PreferencesDialog::syncSettings() -{ -} - -void PreferencesDialog::loadSettings() -{ - // This code was on the mainwindow, it should belong nowhere, but since we didn't - // correctly fixed this code yet ( too much stuff on the code calling preferences ) - // force this here. - loadPreferences(); - QSettings s; - QVariant v; -} - -void PreferencesDialog::buttonClicked(QAbstractButton *button) -{ - switch (ui.buttonBox->standardButton(button)) { - case QDialogButtonBox::Discard: - restorePrefs(); - syncSettings(); - close(); - break; - case QDialogButtonBox::Apply: - syncSettings(); - break; - case QDialogButtonBox::FirstButton: - syncSettings(); - close(); - break; - default: - break; // ignore warnings. - } -} -#undef SB - -#if 0 -// TODO: Copy this later. -void PreferencesDialog::on_resetSettings_clicked() -{ - QSettings s; - QMessageBox response(this); - response.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - response.setDefaultButton(QMessageBox::Cancel); - response.setWindowTitle(tr("Warning")); - response.setText(tr("If you click OK, all settings of Subsurface will be reset to their default values. This will be applied immediately.")); - response.setWindowModality(Qt::WindowModal); - - int result = response.exec(); - if (result == QMessageBox::Ok) { - copy_prefs(&default_prefs, &prefs); - setUiFromPrefs(); - Q_FOREACH (QString key, s.allKeys()) { - s.remove(key); - } - syncSettings(); - close(); - } -} -#endif - -void PreferencesDialog::emitSettingsChanged() -{ - emit settingsChanged(); -} diff --git a/desktop-widgets/preferences.ui b/desktop-widgets/preferences.ui deleted file mode 100644 index 8d0b18900..000000000 --- a/desktop-widgets/preferences.ui +++ /dev/null @@ -1,241 +0,0 @@ - - - PreferencesDialog - - - - 0 - 0 - 835 - 698 - - - - Preferences - - - - :/subsurface-icon - - - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - 120 - 16777215 - - - - - 24 - 24 - - - - Qt::ElideNone - - - QListView::Static - - - true - - - QListView::Batched - - - 0 - - - - 110 - 40 - - - - QListView::ListMode - - - true - - - true - - - -1 - - - - Facebook - - - - :/facebook - - - - - - - - - - 0 - 0 - - - - 0 - - - - - 0 - 0 - - - - - 5 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - - - - 0 - 0 - - - - Connect to facebook text placeholder - - - - - - - - - - - - Disconnect - - - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Apply|QDialogButtonBox::Discard|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - PreferencesDialog - accept() - - - 264 - 720 - - - 157 - 274 - - - - - buttonBox - rejected() - PreferencesDialog - reject() - - - 332 - 720 - - - 286 - 274 - - - - - listWidget - currentRowChanged(int) - stackedWidget - setCurrentIndex(int) - - - 37 - 97 - - - 282 - 18 - - - - - diff --git a/subsurface-core/isocialnetworkintegration.cpp b/subsurface-core/isocialnetworkintegration.cpp new file mode 100644 index 000000000..4a2ccdf71 --- /dev/null +++ b/subsurface-core/isocialnetworkintegration.cpp @@ -0,0 +1,6 @@ +#include "isocialnetworkintegration.h" + +//Hack for moc. +ISocialNetworkIntegration::ISocialNetworkIntegration(QObject* parent) +{ +}