#include "AboutDialog.h"
#include "LicenseDialog.h"
+#include "Utils.h"
AboutDialog::AboutDialog (QWidget * parent):
QDialog (parent, Qt::Dialog),
- myLicenseDialog (new LicenseDialog (this))
+ myLicenseDialog ()
{
ui.setupUi (this);
QPushButton * b;
- b = new QPushButton (tr ("C&redits"), this);
- ui.dialogButtons->addButton (b, QDialogButtonBox::ActionRole);
+ b = ui.dialogButtons->addButton (tr ("C&redits"), QDialogButtonBox::ActionRole);
connect (b, SIGNAL (clicked ()), this, SLOT (showCredits ()));
- b = new QPushButton (tr ("&License"), this);
- ui.dialogButtons->addButton (b, QDialogButtonBox::ActionRole);
- connect (b, SIGNAL (clicked ()), myLicenseDialog, SLOT (show ()));
+ b = ui.dialogButtons->addButton (tr ("&License"), QDialogButtonBox::ActionRole);
+ connect (b, SIGNAL (clicked ()), this, SLOT (showLicense ()));
ui.dialogButtons->button (QDialogButtonBox::Close)->setDefault (true);
}
QString::fromUtf8 ("Jordan Lee (Backend; Daemon; GTK+; Qt)\n"
"Michell Livingston (OS X)\n"));
}
+
+void
+AboutDialog::showLicense ()
+{
+ Utils::openDialog (myLicenseDialog, this);
+}
#define QTR_ABOUT_DIALOG_H
#include <QDialog>
+#include <QPointer>
#include "ui_AboutDialog.h"
+class LicenseDialog;
+
class AboutDialog: public QDialog
{
Q_OBJECT
AboutDialog (QWidget * parent = nullptr);
virtual ~AboutDialog () {}
- public slots:
+ private slots:
void showCredits ();
+ void showLicense ();
private:
Ui::AboutDialog ui;
- QDialog * myLicenseDialog;
+ QPointer<LicenseDialog> myLicenseDialog;
};
#endif // QTR_ABOUT_DIALOG_H
#include "OptionsDialog.h"
#include "Prefs.h"
#include "Session.h"
-#include "SessionDialog.h"
#include "TorrentModel.h"
#include "WatchDir.h"
maybeUpdateBlocklist ();
if (!firstTime)
- {
- mySession->restart ();
- }
+ mySession->restart ();
else
- {
- QDialog * d = new SessionDialog (*mySession, *myPrefs, myWindow);
- d->show ();
- }
+ myWindow->openSession ();
if (!myPrefs->getBool (Prefs::USER_HAS_GIVEN_INFORMED_CONSENT))
{
tr_qt_wrap_ui(${PROJECT_NAME}_UI_SOURCES
AboutDialog.ui
DetailsDialog.ui
+ LicenseDialog.ui
MainWindow.ui
MakeDialog.ui
MakeProgressDialog.ui
adjustSize ();
ui.commentBrowser->setMaximumHeight (QWIDGETSIZE_MAX);
- setAttribute (Qt::WA_DeleteOnClose, true);
-
QList<int> initKeys;
initKeys << Prefs::SHOW_TRACKER_SCRAPES
<< Prefs::SHOW_BACKUP_TRACKERS;
* $Id$
*/
-#include <QDialogButtonBox>
-#include <QPlainTextEdit>
-#include <QVBoxLayout>
-
#include "LicenseDialog.h"
LicenseDialog::LicenseDialog (QWidget * parent):
QDialog (parent, Qt::Dialog)
{
- setWindowTitle (tr ("License"));
- resize (400, 300);
- QVBoxLayout * v = new QVBoxLayout (this);
-
- QPlainTextEdit * t = new QPlainTextEdit (this);
- t->setReadOnly (true);
- t->setPlainText (QLatin1String (
- "Copyright 2005-2014. All code is copyrighted by the respective authors.\n"
- "\n"
- "Transmission can be redistributed and/or modified under the terms of the "
- "GNU GPL versions 2 or 3 or by any future license endorsed by Mnemosyne LLC.\n"
- "\n"
- "In addition, linking to and/or using OpenSSL is allowed.\n"
- "\n"
- "This program is distributed in the hope that it will be useful, "
- "but WITHOUT ANY WARRANTY; without even the implied warranty of "
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
- "\n"
- "Some of Transmission's source files have more permissive licenses. "
- "Those files may, of course, be used on their own under their own terms.\n"));
- v->addWidget (t);
-
- QDialogButtonBox * box = new QDialogButtonBox;
- box->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
- box->setOrientation (Qt::Horizontal);
- box->setStandardButtons (QDialogButtonBox::Close);
- v->addWidget (box);
-
- connect (box, SIGNAL (rejected ()), this, SLOT (hide ()));
+ ui.setupUi (this);
}
#include <QDialog>
+#include "ui_LicenseDialog.h"
+
class LicenseDialog: public QDialog
{
Q_OBJECT
public:
LicenseDialog (QWidget * parent = nullptr);
virtual ~LicenseDialog () {}
+
+ private:
+ Ui::LicenseDialog ui;
};
#endif // QTR_LICENSE_DIALOG_H
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>LicenseDialog</class>
+ <widget class="QDialog" name="LicenseDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>License</string>
+ </property>
+ <layout class="QVBoxLayout" name="dialogLayout">
+ <item>
+ <widget class="QPlainTextEdit" name="licenseEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="plainText">
+ <string notr="true">Copyright 2005-2014. All code is copyrighted by the respective authors.
+
+Transmission can be redistributed and/or modified under the terms of the GNU GPL versions 2 or 3 or by any future license endorsed by Mnemosyne LLC.
+
+In addition, linking to and/or using OpenSSL is allowed.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+Some of Transmission's source files have more permissive licenses. Those files may, of course, be used on their own under their own terms.</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="dialogButtons">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Close</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>dialogButtons</sender>
+ <signal>rejected()</signal>
+ <receiver>LicenseDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
#include "TorrentDelegateMin.h"
#include "TorrentFilter.h"
#include "TorrentModel.h"
+#include "Utils.h"
#define PREFS_KEY "prefs-key";
myPrefs (prefs),
myModel (model),
myLastFullUpdateTime (0),
- mySessionDialog (new SessionDialog (session, prefs, this)),
+ mySessionDialog (),
myPrefsDialog (),
- myAboutDialog (new AboutDialog (this)),
- myStatsDialog (new StatsDialog (session, this)),
- myDetailsDialog (0),
+ myAboutDialog (),
+ myStatsDialog (),
+ myDetailsDialog (),
myFilterModel (prefs),
myTorrentDelegate (new TorrentDelegate (this)),
myTorrentDelegateMin (new TorrentDelegateMin (this)),
connect (ui.action_AddURL, SIGNAL (triggered ()), this, SLOT (openURL ()));
connect (ui.action_New, SIGNAL (triggered ()), this, SLOT (newTorrent ()));
connect (ui.action_Preferences, SIGNAL (triggered ()), this, SLOT (openPreferences ()));
- connect (ui.action_Statistics, SIGNAL (triggered ()), myStatsDialog, SLOT (show ()));
+ connect (ui.action_Statistics, SIGNAL (triggered ()), this, SLOT (openStats ()));
connect (ui.action_Donate, SIGNAL (triggered ()), this, SLOT (openDonate ()));
- connect (ui.action_About, SIGNAL (triggered ()), myAboutDialog, SLOT (show ()));
+ connect (ui.action_About, SIGNAL (triggered ()), this, SLOT (openAbout ()));
connect (ui.action_Contents, SIGNAL (triggered ()), this, SLOT (openHelp ()));
connect (ui.action_OpenFolder, SIGNAL (triggered ()), this, SLOT (openFolder ()));
connect (ui.action_CopyMagnetToClipboard, SIGNAL (triggered ()), this, SLOT (copyMagnetLinkToClipboard ()));
connect (ui.action_SetLocation, SIGNAL (triggered ()), this, SLOT (setLocation ()));
connect (ui.action_Properties, SIGNAL (triggered ()), this, SLOT (openProperties ()));
- connect (ui.action_SessionDialog, SIGNAL (triggered ()), mySessionDialog, SLOT (show ()));
+ connect (ui.action_SessionDialog, SIGNAL (triggered ()), this, SLOT (openSession ()));
connect (ui.listView, SIGNAL (activated (QModelIndex)), ui.action_Properties, SLOT (trigger ()));
****/
void
-MainWindow::openPreferences ()
+MainWindow::openSession ()
{
- if (myPrefsDialog.isNull ())
- {
- myPrefsDialog = new PrefsDialog (mySession, myPrefs, this);
- myPrefsDialog->setAttribute (Qt::WA_DeleteOnClose);
- myPrefsDialog->show ();
- }
- else
- {
- myPrefsDialog->raise ();
- myPrefsDialog->activateWindow ();
- }
+ Utils::openDialog (mySessionDialog, mySession, myPrefs, this);
}
void
-MainWindow::onDetailsDestroyed ()
+MainWindow::openPreferences ()
{
- myDetailsDialog = 0;
+ Utils::openDialog (myPrefsDialog, mySession, myPrefs, this);
}
void
MainWindow::openProperties ()
{
- if (myDetailsDialog == 0)
- {
- myDetailsDialog = new DetailsDialog (mySession, myPrefs, myModel, this);
- connect (myDetailsDialog, SIGNAL (destroyed (QObject*)), this, SLOT (onDetailsDestroyed ()));
- }
-
+ Utils::openDialog (myDetailsDialog, mySession, myPrefs, myModel, this);
myDetailsDialog->setIds (getSelectedTorrents ());
- myDetailsDialog->show ();
}
void
mySession.copyMagnetLinkToClipboard (id);
}
+void
+MainWindow::openStats ()
+{
+ Utils::openDialog (myStatsDialog, mySession, this);
+}
+
void
MainWindow::openDonate ()
{
QDesktopServices::openUrl (QUrl (QLatin1String ("http://www.transmissionbt.com/donate.php")));
}
+void
+MainWindow::openAbout ()
+{
+ Utils::openDialog (myAboutDialog, this);
+}
+
void
MainWindow::openHelp ()
{
ui.action_QueueMoveDown->setEnabled (haveSelection);
ui.action_QueueMoveBottom->setEnabled (haveSelection);
- if (myDetailsDialog)
+ if (!myDetailsDialog.isNull ())
myDetailsDialog->setIds (getSelectedTorrents ());
}
MainWindow::wrongAuthentication ()
{
mySession.stop ();
- mySessionDialog->show ();
+ openSession ();
}
/***
class QIcon;
class QMenu;
+class AboutDialog;
class AddData;
-class Prefs;
class DetailsDialog;
+class Prefs;
+class PrefsDialog;
class Session;
+class SessionDialog;
+class StatsDialog;
class TorrentDelegate;
class TorrentDelegateMin;
class TorrentModel;
void refreshActionSensitivitySoon ();
void wrongAuthentication ();
+ void openSession ();
+
protected:
// QWidget
virtual void contextMenuEvent (QContextMenuEvent *);
private slots:
void openPreferences ();
- void onDetailsDestroyed ();
void showTotalRatio ();
void showTotalTransfer ();
void showSessionRatio ();
void refreshPref (int key);
void addTorrents (const QStringList& filenames);
void removeTorrents (const bool deleteFiles);
+ void openStats ();
void openDonate ();
+ void openAbout ();
void openHelp ();
void openFolder ();
void copyMagnetLinkToClipboard ();
Ui_MainWindow ui;
time_t myLastFullUpdateTime;
- QDialog * mySessionDialog;
- QPointer<QDialog> myPrefsDialog;
- QDialog * myAboutDialog;
- QDialog * myStatsDialog;
- DetailsDialog * myDetailsDialog;
+ QPointer<SessionDialog> mySessionDialog;
+ QPointer<PrefsDialog> myPrefsDialog;
+ QPointer<AboutDialog> myAboutDialog;
+ QPointer<StatsDialog> myStatsDialog;
+ QPointer<DetailsDialog> myDetailsDialog;
QSystemTrayIcon myTrayIcon;
TorrentFilter myFilterModel;
TorrentDelegate * myTorrentDelegate;
<property name="leftMargin">
<number>18</number>
</property>
- <item row="0" column="0">
+ <item row="0" column="0" colspan="2">
<widget class="QLabel" name="startCountLabel">
<property name="text">
<string notr="true">...</string>
static QColor getFadedColor (const QColor& color);
+ template<typename DialogT, typename... ArgsT>
+ static void
+ openDialog (QPointer<DialogT>& dialog, ArgsT&&... args)
+ {
+ if (dialog.isNull ())
+ {
+ dialog = new DialogT (std::forward<ArgsT> (args)...);
+ dialog->setAttribute (Qt::WA_DeleteOnClose);
+ dialog->show ();
+ }
+ else
+ {
+ dialog->raise ();
+ dialog->activateWindow ();
+ }
+ }
+
///
/// URLs
///