Tweaks to page dialog and version page.

This commit is contained in:
Petr Mrázek 2014-06-03 01:34:44 +02:00
parent f485885757
commit 6b3d1101cb
8 changed files with 134 additions and 46 deletions

View File

@ -507,6 +507,8 @@ void MultiMC::initGlobalSettings()
m_settings->registerSetting("ConsoleWindowGeometry", "");
m_settings->registerSetting("SettingsGeometry", "");
m_settings->registerSetting("PagedGeometry", "");
}
void MultiMC::initHttpMetaCache()

View File

@ -25,6 +25,7 @@
#include <QLabel>
#include <QDialogButtonBox>
#include <QGridLayout>
#include <settingsobject.h>
#include "PageDialog_p.h"
#include <gui/widgets/IconLabel.h>
@ -55,6 +56,7 @@ PageDialog::PageDialog(BasePageProviderPtr pageProvider, QWidget *parent) : QDia
MultiMCPlatform::fixWM_CLASS(this);
createUI();
setWindowTitle(pageProvider->dialogTitle());
restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("PagedGeometry").toByteArray()));
m_model = new PageModel(this);
m_proxyModel = new PageEntryFilterModel(this);
@ -111,8 +113,9 @@ void PageDialog::createUI()
m_pageStack->setMargin(0);
m_pageStack->addWidget(new QWidget(this));
QDialogButtonBox *buttons = new QDialogButtonBox(
QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
QDialogButtonBox *buttons =
new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok |
QDialogButtonBox::Apply | QDialogButtonBox::Cancel);
buttons->button(QDialogButtonBox::Ok)->setDefault(true);
connect(buttons->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
@ -149,6 +152,45 @@ void PageDialog::currentChanged(const QModelIndex &current)
}
}
void PageDialog::accept()
{
bool accepted = true;
for(auto page: m_model->pages())
{
accepted &= page->accept();
}
if(accepted)
{
MMC->settings()->set("PagedGeometry", saveGeometry().toBase64());
QDialog::accept();
}
}
void PageDialog::reject()
{
bool rejected = true;
for(auto page: m_model->pages())
{
rejected &= page->reject();
}
if(rejected)
{
MMC->settings()->set("PagedGeometry", saveGeometry().toBase64());
QDialog::reject();
}
}
void PageDialog::apply()
{
for(auto page: m_model->pages())
{
page->apply();
}
}
void PageDialog::closeEvent(QCloseEvent * event)
{
MMC->settings()->set("PagedGeometry", saveGeometry().toBase64());
QDialog::closeEvent(event);
}

View File

@ -36,8 +36,11 @@ private:
void createUI();
private slots:
void apply();
virtual void reject();
virtual void accept();
void currentChanged(const QModelIndex &current);
void showPage(int row);
virtual void closeEvent(QCloseEvent *event);
private:
QSortFilterProxyModel *m_proxyModel;

View File

@ -25,6 +25,18 @@ public:
virtual QString id() = 0;
virtual QString displayName() = 0;
virtual QIcon icon() = 0;
virtual bool accept()
{
return true;
}
virtual bool reject()
{
return true;
}
virtual bool apply()
{
return true;
}
virtual bool shouldDisplay()
{
return true;

View File

@ -79,6 +79,7 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent)
main_model->setSourceModel(m_version.get());
ui->libraryTreeView->setModel(main_model);
ui->libraryTreeView->installEventFilter(this);
ui->libraryTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
connect(ui->libraryTreeView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &VersionPage::versionCurrent);
updateVersionControls();

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>326</height>
<height>475</height>
</rect>
</property>
<property name="windowTitle">
@ -51,6 +51,16 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Selection</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="changeMCVersionBtn">
<property name="text">
@ -58,6 +68,46 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveLibraryUpBtn">
<property name="toolTip">
<string>This isn't implemented yet.</string>
</property>
<property name="text">
<string>Move up</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveLibraryDownBtn">
<property name="toolTip">
<string>This isn't implemented yet.</string>
</property>
<property name="text">
<string>Move down</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeLibraryBtn">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="LineSeparator" name="separator" native="true"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Install</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="forgeBtn">
<property name="toolTip">
@ -83,50 +133,15 @@
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="LineSeparator" name="widget" native="true"/>
</item>
<item>
<widget class="QPushButton" name="reloadLibrariesBtn">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Reload</string>
<string>List</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeLibraryBtn">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveLibraryUpBtn">
<property name="toolTip">
<string>This isn't implemented yet.</string>
</property>
<property name="text">
<string>Move up</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="moveLibraryDownBtn">
<property name="toolTip">
<string>This isn't implemented yet.</string>
</property>
<property name="text">
<string>Move down</string>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@ -140,6 +155,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="reloadLibrariesBtn">
<property name="text">
<string>Reload</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
@ -163,6 +185,12 @@
<extends>QTreeView</extends>
<header>gui/widgets/ModListView.h</header>
</customwidget>
<customwidget>
<class>LineSeparator</class>
<extends>QWidget</extends>
<header>gui/widgets/LineSeparator.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@ -9,10 +9,10 @@ class LineSeparator : public QWidget
public:
/// Create a line separator. orientation is the orientation of the line.
explicit LineSeparator(QWidget *parent, Qt::Orientation orientation = Qt::Vertical);
explicit LineSeparator(QWidget *parent, Qt::Orientation orientation = Qt::Horizontal);
QSize sizeHint() const;
void paintEvent(QPaintEvent *);
void initStyleOption(QStyleOption *option) const;
private:
Qt::Orientation m_orientation = Qt::Vertical;
Qt::Orientation m_orientation = Qt::Horizontal;
};

View File

@ -59,7 +59,7 @@ void ServerStatus::reloadStatus()
void ServerStatus::addLine()
{
layout->addWidget(new LineSeparator(this));
layout->addWidget(new LineSeparator(this, Qt::Vertical));
}
void ServerStatus::addStatus(QString key, QString name)