~jackweirdy/vidalia/680192

« back to all changes in this revision

Viewing changes to src/vidalia/MainWindow.cpp

  • Committer: Package Import Robot
  • Author(s): Ulises Vitulli
  • Date: 2011-11-15 17:14:07 UTC
  • mfrom: (1.4.6) (8.2.11 sid)
  • Revision ID: package-import@ubuntu.com-20111115171407-acvo6bilao12x2oh
Tags: 0.2.15-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <QTimer>
40
40
#include <QTextStream>
41
41
 
 
42
#ifdef Q_WS_MAC
 
43
#include <Carbon/Carbon.h>
 
44
#endif
 
45
 
42
46
#define IMG_BWGRAPH        ":/images/16x16/utilities-system-monitor.png"
43
47
#define IMG_CONTROL_PANEL  ":/images/16x16/system-run.png"
44
48
#define IMG_MESSAGELOG     ":/images/16x16/format-justify-fill.png"
215
219
    show(); 
216
220
  /* Optimistically hope that the tray icon gets added. */
217
221
  _trayIcon.show();
 
222
 
 
223
#if defined(Q_WS_MAC)
 
224
  /* Display OSX dock icon if icon preference is not set to "Tray Only" */
 
225
  if (settings.getIconPref() != VidaliaSettings::Tray) {
 
226
      ProcessSerialNumber psn = { 0, kCurrentProcess };
 
227
      TransformProcessType(&psn, kProcessTransformToForegroundApplication);
 
228
  }
 
229
  /* Vidalia launched in background (LSUIElement=true). Bring to foreground. */
 
230
  VidaliaWindow::setVisible(true);
 
231
#endif
218
232
}
219
233
 
220
234
/** Destructor. */
572
586
MainWindow::setTrayIcon(const QString &iconFile)
573
587
{
574
588
#if defined(Q_WS_MAC)
 
589
  VidaliaSettings settings;
575
590
  QApplication::setWindowIcon(QPixmap(iconFile));
576
 
#endif
 
591
  /* only display tray icon if icon preference is not set to "Dock Only" */
 
592
  if (settings.getIconPref() != VidaliaSettings::Dock)
 
593
    _trayIcon.setIcon(QIcon(iconFile));
 
594
#else
 
595
  /* always display tray icon for other platforms */
577
596
  _trayIcon.setIcon(QIcon(iconFile));
 
597
#endif
578
598
}
579
599
 
580
600
/** Respond to a double-click on the tray icon by opening the Control Panel
628
648
 
629
649
  /* Launch the browser */
630
650
  _browserProcess->start(browserExecutable, commandLine);
 
651
  _browserProcess->toForeground();
631
652
}
632
653
 
633
654
/** Starts the web browser and IM client, if appropriately configured */
645
666
    /* BrowserDirectory is not set, but BrowserExecutable is; use this */
646
667
    _browserProcess->setEnvironment(updateBrowserEnv());
647
668
    _browserProcess->start(subprocess, QStringList());
 
669
    _browserProcess->toForeground();
648
670
  }
649
671
 
650
672
  /* Launch the IM client */
995
1017
 
996
1018
  updateTorStatus(Starting);
997
1019
 
 
1020
  // Disable autoconfiguration if there are missing config data
 
1021
  if(settings.autoControlPort()) {
 
1022
    if(settings.getDataDirectory().isEmpty()) {
 
1023
      vWarn("Disabling ControlPort autoconfiguration. DataDirectory is empty!");
 
1024
      settings.setAutoControlPort(false);
 
1025
    }
 
1026
  }
 
1027
 
998
1028
  /* Check if Tor is already running separately */
999
1029
  if(settings.getControlMethod() == ControlMethod::Port) {
1000
1030
    if(!settings.autoControlPort() && net_test_connect(settings.getControlAddress(),
1155
1185
 
1156
1186
    if(tries >= maxtries) {
1157
1187
      vWarn("Couldn't read port.conf file");
1158
 
      connectFailed(QString("Vidalia can't find out how to talk to Tor because it can't access this file: %1\n\nHere's the last error message:\n %2")
1159
 
                    .arg(file.fileName())
1160
 
                    .arg(file.errorString()));
 
1188
      if(_torControl->isRunning()) {
 
1189
        connectFailed(tr("Vidalia can't find out how to talk to Tor because it can't access this file: %1\n\nHere's the last error message:\n%2")
 
1190
                      .arg(file.fileName())
 
1191
                      .arg(file.errorString()));
 
1192
      } else {
 
1193
        vWarn("Tor isn't running!");
 
1194
        connectFailed(tr("It seems Tor has stopped running since Vidalia started it.\n\nSee the Advanced Message Log for more information."));
 
1195
      }
 
1196
 
1161
1197
      return;
1162
1198
    }
1163
1199