diff options
author | Arno <am@disconnect.de> | 2011-08-17 21:46:39 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2011-08-17 21:50:21 +0200 |
commit | 7195badbe2ff943d730f7d79ab183acec8ce26c3 (patch) | |
tree | 2618c13868496b2a87a54cf6659e2ea73198171b | |
parent | 94e7da1400e59256f41f72b4592d4a9df1cca5a0 (diff) | |
download | SheMov-7195badbe2ff943d730f7d79ab183acec8ce26c3.tar.gz SheMov-7195badbe2ff943d730f7d79ab183acec8ce26c3.tar.bz2 SheMov-7195badbe2ff943d730f7d79ab183acec8ce26c3.zip |
Center Dialogs on screen
Since I'm now using a tiling window manager dialogs have to center
themselves on the screen. Otherwise they end up at QPoint(0,0). Not very
nice. Subclassed QDialog to SmDialog and converted all dialogs.
-rw-r--r-- | archivetreeview.cpp | 2 | ||||
-rw-r--r-- | archivetreeview.h | 4 | ||||
-rw-r--r-- | configurationdialog.cpp | 3 | ||||
-rw-r--r-- | configurationdialog.h | 5 | ||||
-rw-r--r-- | consistencycheck.cpp | 2 | ||||
-rw-r--r-- | consistencycheck.h | 5 | ||||
-rw-r--r-- | filepropertiesdialog.cpp | 2 | ||||
-rw-r--r-- | filepropertiesdialog.h | 6 | ||||
-rw-r--r-- | filestreewidget.h | 1 | ||||
-rw-r--r-- | helper.cpp | 10 | ||||
-rw-r--r-- | helper.h | 1 | ||||
-rw-r--r-- | mappingtableeditor.cpp | 2 | ||||
-rw-r--r-- | mappingtableeditor.h | 10 | ||||
-rw-r--r-- | mappingtablewidget.cpp | 2 | ||||
-rw-r--r-- | mappingtablewidget.h | 5 | ||||
-rw-r--r-- | seriestreewidget.cpp | 2 | ||||
-rw-r--r-- | seriestreewidget.h | 5 | ||||
-rw-r--r-- | shemov.pro | 6 | ||||
-rw-r--r-- | smdialog.cpp | 15 | ||||
-rw-r--r-- | smdialog.h | 22 | ||||
-rw-r--r-- | statisticsdialog.cpp | 2 | ||||
-rw-r--r-- | statisticsdialog.h | 5 |
22 files changed, 87 insertions, 30 deletions
diff --git a/archivetreeview.cpp b/archivetreeview.cpp index 191081c..cc6e529 100644 --- a/archivetreeview.cpp +++ b/archivetreeview.cpp @@ -420,7 +420,7 @@ void NoCoverMovieView::contextMenuEvent(QContextMenuEvent *e){ //NoCoverMovieDialog -NoCoverMovieDialog::NoCoverMovieDialog(QWidget *parent, Qt::WindowFlags flags) : QDialog(parent, flags){ +NoCoverMovieDialog::NoCoverMovieDialog(QWidget *parent, Qt::WindowFlags flags) : SmDialog(parent, flags){ //model + view mView = new NoCoverMovieView; QStringList headers = QStringList() << "Movie" << "Name" << "Part" << "Id"; diff --git a/archivetreeview.h b/archivetreeview.h index 68b0091..2163fe5 100644 --- a/archivetreeview.h +++ b/archivetreeview.h @@ -13,9 +13,9 @@ #include <QList> #include <QSqlDatabase> #include <QTreeView> -#include <QDialog> #include "smtreemodel.h" +#include "smdialog.h" class SeriesTreeWidget; class FilesTreeWidget; @@ -115,7 +115,7 @@ class NoCoverMovieView : public QTreeView { void contextMenuEvent(QContextMenuEvent *e); }; -class NoCoverMovieDialog : public QDialog { +class NoCoverMovieDialog : public SmDialog { Q_OBJECT public: explicit NoCoverMovieDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); diff --git a/configurationdialog.cpp b/configurationdialog.cpp index c23569c..25908db 100644 --- a/configurationdialog.cpp +++ b/configurationdialog.cpp @@ -39,8 +39,9 @@ #include "configurationdialog.h" #include "programconfigurator.h" #include "smglobals.h" +#include "helper.h" -ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ +ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : SmDialog(parent, f){ //setup mTab = new QTabWidget; QDirModel *model = new QDirModel(this); diff --git a/configurationdialog.h b/configurationdialog.h index a13fb65..946e34b 100644 --- a/configurationdialog.h +++ b/configurationdialog.h @@ -8,9 +8,10 @@ #ifndef CONFIGURATIONDIALOG_H #define CONFIGURATIONDIALOG_H -#include <QDialog> #include <QHash> +#include "smdialog.h" + class QPushButton; class QTabWidget; class QLineEdit; @@ -22,7 +23,7 @@ class QStandardItemModel; class ProgramConfigurator; -class ConfigurationDialog : public QDialog { +class ConfigurationDialog : public SmDialog { Q_OBJECT public: ConfigurationDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); diff --git a/consistencycheck.cpp b/consistencycheck.cpp index 1d5114c..43e06d2 100644 --- a/consistencycheck.cpp +++ b/consistencycheck.cpp @@ -28,7 +28,7 @@ #include "consistencycheck.h" #include "helper.h" -ConsistencyCheck::ConsistencyCheck(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), mChecker(0){ +ConsistencyCheck::ConsistencyCheck(QWidget *parent, Qt::WindowFlags f) : SmDialog(parent, f), mChecker(0){ // setup widget QLabel *okLabel = new QLabel(tr("Ok")); mOkDisplay = new QPlainTextEdit; diff --git a/consistencycheck.h b/consistencycheck.h index f5470e3..b62dfbc 100644 --- a/consistencycheck.h +++ b/consistencycheck.h @@ -8,13 +8,14 @@ #ifndef CONSISTENCYCHECK_H #define CONSISTENCYCHECK_H -#include <QDialog> #include <QThread> #include <QSqlDatabase> #include <QMutex> #include <QStringList> #include <QList> +#include "smdialog.h" + class QPushButton; class QPlainTextEdit; class QLabel; @@ -23,7 +24,7 @@ class QSqlQuery; class QFileInfo; class ConsistencyChecker; -class ConsistencyCheck : public QDialog { +class ConsistencyCheck : public SmDialog { Q_OBJECT public: enum Mode { DbCheck, FsCheck }; diff --git a/filepropertiesdialog.cpp b/filepropertiesdialog.cpp index e7e6a34..60b4ea8 100644 --- a/filepropertiesdialog.cpp +++ b/filepropertiesdialog.cpp @@ -22,7 +22,7 @@ #include "smtreeitem.h" #include "helper.h" -FilePropertiesDialog::FilePropertiesDialog(int seriesPartId, QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ +FilePropertiesDialog::FilePropertiesDialog(int seriesPartId, QWidget *parent, Qt::WindowFlags f) : SmDialog(parent, f){ //tab mTab = new QTabWidget; diff --git a/filepropertiesdialog.h b/filepropertiesdialog.h index 4257f18..d03eb86 100644 --- a/filepropertiesdialog.h +++ b/filepropertiesdialog.h @@ -8,18 +8,20 @@ #ifndef FILEPROPERTIESDIALOG_H #define FILEPROPERTIESDIALOG_H -#include <QDialog> #include <QList> #include <QMap> +#include "smdialog.h" + class QPushButton; class QTreeView; class QLabel; class QTabWidget; class SmTreeModel; class MetadataWidget; +class QShowEvent; -class FilePropertiesDialog : public QDialog +class FilePropertiesDialog : public SmDialog { Q_OBJECT public: diff --git a/filestreewidget.h b/filestreewidget.h index e5505de..940d9de 100644 --- a/filestreewidget.h +++ b/filestreewidget.h @@ -11,7 +11,6 @@ #include <QWidget> #include <QTreeView> #include <QSortFilterProxyModel> -#include <QDialog> typedef QList<QPersistentModelIndex> PersistenModelIndexList; @@ -17,6 +17,10 @@ #include <QPixmap> #include <QTemporaryFile> #include <QProcess> +#include <QRect> +#include <QWidget> +#include <QDesktopWidget> +#include <QApplication> #include <stdio.h> @@ -201,5 +205,11 @@ namespace Helper { bool FileInfoListContains::operator ()(const QFileInfo &info, const QString &file) const { return info.fileName() == file; } + + void centerWidget(QWidget *widget){ + QRect widgetRect = widget->rect(); + widgetRect.moveCenter(qApp->desktop()->screenGeometry().center()); + widget->move(widgetRect.topLeft()); + } } @@ -37,6 +37,7 @@ namespace Helper { public: bool operator()(const QFileInfo &info, const QString &file) const; }; + void centerWidget(QWidget *widget); } #endif diff --git a/mappingtableeditor.cpp b/mappingtableeditor.cpp index a5721d2..83015ef 100644 --- a/mappingtableeditor.cpp +++ b/mappingtableeditor.cpp @@ -21,7 +21,7 @@ #include "mappingtableeditor.h" //widget -MappingTableEditor::MappingTableEditor(const QString &table, QWidget *parent) : QDialog(parent), mTable(table){ +MappingTableEditor::MappingTableEditor(const QString &table, QWidget *parent) : SmDialog(parent), mTable(table){ //caption QString l1String = QString(tr("Edit %1s").arg(mTable)); QLabel *l1 = new QLabel(l1String); diff --git a/mappingtableeditor.h b/mappingtableeditor.h index 124f76e..d372d0b 100644 --- a/mappingtableeditor.h +++ b/mappingtableeditor.h @@ -8,10 +8,13 @@ #ifndef MAPPINGTABLEEDITOR_H #define MAPPINGTABLEEDITOR_H -#include <QDialog> #include <QTreeView> #include <QSqlDatabase> +#include "smdialog.h" +#include "smtreemodel.h" +#include "smtreeitem.h" + class QSqlQuery; class QContextMenuEvent; class QPushButton; @@ -20,10 +23,7 @@ class QAction; class MappingTableEditorView; class MappingTableEditorModel; -#include "smtreemodel.h" -#include "smtreeitem.h" - -class MappingTableEditor : public QDialog { +class MappingTableEditor : public SmDialog { Q_OBJECT public: explicit MappingTableEditor(const QString &table, QWidget *parent = 0); diff --git a/mappingtablewidget.cpp b/mappingtablewidget.cpp index 1fe2a12..a5058d9 100644 --- a/mappingtablewidget.cpp +++ b/mappingtablewidget.cpp @@ -166,7 +166,7 @@ QModelIndex MappingTableItemModel::find(const QString &value) const{ return index(row, 0); } -MappingTableResultDialog::MappingTableResultDialog(const QStringList &results, QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ +MappingTableResultDialog::MappingTableResultDialog(const QStringList &results, QWidget *parent, Qt::WindowFlags f) : SmDialog(parent, f){ mModel = new QStringListModel(results, this); mView = new QTreeView(this); mView->setModel(mModel); diff --git a/mappingtablewidget.h b/mappingtablewidget.h index 02b37c3..2669354 100644 --- a/mappingtablewidget.h +++ b/mappingtablewidget.h @@ -10,7 +10,8 @@ #include <QWidget> #include <QStringListModel> -#include <QDialog> + +#include "smdialog.h" class QTreeView; class QLineEdit; @@ -65,7 +66,7 @@ class MappingTableItemModel : public QStringListModel { QIcon mDecorationIcon; }; -class MappingTableResultDialog : public QDialog { +class MappingTableResultDialog : public SmDialog { Q_OBJECT public: explicit MappingTableResultDialog(const QStringList &results, QWidget *parent = 0, Qt::WindowFlags f = 0); diff --git a/seriestreewidget.cpp b/seriestreewidget.cpp index 5a97587..17b9a90 100644 --- a/seriestreewidget.cpp +++ b/seriestreewidget.cpp @@ -523,7 +523,7 @@ bool SeriesTreeSortModel::filterAcceptsRow(int source_row, const QModelIndex &so return false; } -AddCoverDialog::AddCoverDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ +AddCoverDialog::AddCoverDialog(QWidget *parent, Qt::WindowFlags f) : SmDialog(parent, f){ //File selection QLabel *l1 = new QLabel(tr("Select file")); mFile = new QLineEdit; diff --git a/seriestreewidget.h b/seriestreewidget.h index 9e2e0dc..f68e10c 100644 --- a/seriestreewidget.h +++ b/seriestreewidget.h @@ -11,11 +11,12 @@ #include <QWidget> #include <QTreeView> #include <QSortFilterProxyModel> -#include <QDialog> #include <QSqlDatabase> #include <QHash> #include <QPersistentModelIndex> +#include "smdialog.h" + class QLineEdit; class QPushButton; class QSortFilterProxyModel; @@ -122,7 +123,7 @@ class SeriesTreeSortModel : public QSortFilterProxyModel { virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; }; -class AddCoverDialog : public QDialog { +class AddCoverDialog : public SmDialog { Q_OBJECT public: explicit AddCoverDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); @@ -32,7 +32,8 @@ SOURCES = main.cpp \ hoverwindow.cpp \ consistencycheck.cpp \ seriesmetadatamodel.cpp \ - mappingtableeditor.cpp + mappingtableeditor.cpp \ + smdialog.cpp HEADERS = listitem.h \ filesystemdirproxy.h \ filesystemwidget.h \ @@ -60,6 +61,7 @@ HEADERS = listitem.h \ hoverwindow.h \ consistencycheck.h \ seriesmetadatamodel.h \ - mappingtableeditor.h + mappingtableeditor.h \ + smdialog.h LIBS += -lmagic -lXfixes RESOURCES = shemov.qrc diff --git a/smdialog.cpp b/smdialog.cpp new file mode 100644 index 0000000..064474c --- /dev/null +++ b/smdialog.cpp @@ -0,0 +1,15 @@ +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version + 2 of the License, or (at your option) any later version. +*/ + +#include "smdialog.h" +#include "helper.h" + +SmDialog::SmDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) {} + +void SmDialog::showEvent(QShowEvent *){ + Helper::centerWidget(this); +} diff --git a/smdialog.h b/smdialog.h new file mode 100644 index 0000000..52081db --- /dev/null +++ b/smdialog.h @@ -0,0 +1,22 @@ +/* + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version + 2 of the License, or (at your option) any later version. +*/ + +#ifndef SMDIALOG_H +#define SMDIALOG_H + +#include <QDialog> + +class SmDialog : public QDialog { + Q_OBJECT + public: + explicit SmDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); + + protected: + virtual void showEvent(QShowEvent *); +}; + +#endif // SMDIALOG_H diff --git a/statisticsdialog.cpp b/statisticsdialog.cpp index c25ceee..595811d 100644 --- a/statisticsdialog.cpp +++ b/statisticsdialog.cpp @@ -32,7 +32,7 @@ class GraphWidget; #include "statisticsdialog.h" -StatisticsDialog::StatisticsDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ +StatisticsDialog::StatisticsDialog(QWidget *parent, Qt::WindowFlags f) : SmDialog(parent, f){ QList<QList<QVariant> > data = queryData("SELECT genres.tgenrename, COUNT(seriesparts_genremap.iseriesparts_id) FROM genres, seriesparts_genremap WHERE genres.igenres_id = seriesparts_genremap.igenres_id GROUP BY genres.tgenrename ORDER BY count DESC;"); GraphWidget *genreWidget = new GraphWidget(data, tr("Genre Distribution")); data = queryData("SELECT files.siquality, COUNT(seriesparts.iseriesparts_id) FROM files, seriesparts WHERE files.iseriespart_id = seriesparts.iseriesparts_id AND files.siquality IS NOT NULL GROUP BY files.siquality ORDER by siquality desc;"); diff --git a/statisticsdialog.h b/statisticsdialog.h index 4e7107a..27de9fa 100644 --- a/statisticsdialog.h +++ b/statisticsdialog.h @@ -8,16 +8,17 @@ #ifndef STATISTICSDIALOG_H #define STATISTICSDIALOG_H -#include <QDialog> #include <QList> #include <QVariant> #include <QSize> #include <QFont> #include <QTextDocument> +#include "smdialog.h" + class QPaintEvent; -class StatisticsDialog : public QDialog { +class StatisticsDialog : public SmDialog { Q_OBJECT public: StatisticsDialog(QWidget *parent = 0, Qt::WindowFlags f = 0); |