mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-31 15:32:45 +00:00
Reimplemented constentselector view class
This commit is contained in:
parent
17950210fa
commit
f9591ddda6
@ -11,6 +11,9 @@ set(LAUNCHER
|
||||
settings/launchersettings.cpp
|
||||
|
||||
utils/checkablemessagebox.cpp
|
||||
utils/profilescombobox.cpp
|
||||
utils/textinputdialog.cpp
|
||||
utils/lineedit.cpp
|
||||
|
||||
${CMAKE_SOURCE_DIR}/files/launcher/launcher.rc
|
||||
)
|
||||
@ -31,6 +34,9 @@ set(LAUNCHER_HEADER
|
||||
settings/settingsbase.hpp
|
||||
|
||||
utils/checkablemessagebox.hpp
|
||||
utils/profilescombobox.hpp
|
||||
utils/textinputdialog.hpp
|
||||
utils/lineedit.hpp
|
||||
)
|
||||
if(NOT WIN32)
|
||||
LIST(APPEND LAUNCHER_HEADER unshieldthread.hpp)
|
||||
@ -45,7 +51,11 @@ set(LAUNCHER_HEADER_MOC
|
||||
playpage.hpp
|
||||
textslotmsgbox.hpp
|
||||
|
||||
utils/textinputdialog.hpp
|
||||
utils/checkablemessagebox.hpp
|
||||
utils/profilescombobox.hpp
|
||||
utils/lineedit.hpp
|
||||
|
||||
)
|
||||
|
||||
if(NOT WIN32)
|
||||
@ -58,6 +68,7 @@ set(LAUNCHER_UI
|
||||
${CMAKE_SOURCE_DIR}/files/ui/graphicspage.ui
|
||||
${CMAKE_SOURCE_DIR}/files/ui/mainwindow.ui
|
||||
${CMAKE_SOURCE_DIR}/files/ui/playpage.ui
|
||||
${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui
|
||||
)
|
||||
|
||||
source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER})
|
||||
|
@ -5,14 +5,16 @@
|
||||
#include <QCheckBox>
|
||||
#include <QMenu>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QDebug>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
|
||||
#include <components/contentselector/model/esmfile.hpp>
|
||||
|
||||
#include <components/contentselector/view/lineedit.hpp>
|
||||
#include <components/contentselector/model/naturalsort.hpp>
|
||||
#include <components/contentselector/view/profilescombobox.hpp>
|
||||
|
||||
#include "utils/textinputdialog.hpp"
|
||||
#include "utils/profilescombobox.hpp"
|
||||
|
||||
#include "settings/gamesettings.hpp"
|
||||
#include "settings/launchersettings.hpp"
|
||||
@ -25,45 +27,30 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
||||
, mLauncherSettings(launcherSettings)
|
||||
, QWidget(parent)
|
||||
{
|
||||
ui.setupUi (this);
|
||||
|
||||
setObjectName ("DataFilesPage");
|
||||
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget);
|
||||
|
||||
unsigned char flags;
|
||||
|
||||
flags = ContentSelectorView::Flag_Content | ContentSelectorView::Flag_Profile;
|
||||
|
||||
ContentSelectorView::ContentSelector::configure(this, flags);
|
||||
mSelector = &ContentSelectorView::ContentSelector::instance();
|
||||
|
||||
buildView();
|
||||
setupDataFiles();
|
||||
|
||||
|
||||
connect (mSelector, SIGNAL (signalProfileRenamed (QString, QString)),
|
||||
this, SLOT (slotProfileRenamed (QString, QString)));
|
||||
|
||||
connect (mSelector, SIGNAL (signalProfileChangedByUser (QString, QString)),
|
||||
this, SLOT (slotProfileChangedByUser (QString, QString)));
|
||||
|
||||
connect (mSelector, SIGNAL (signalProfileDeleted (QString)),
|
||||
this, SLOT (slotProfileDeleted (QString)));
|
||||
|
||||
connect (mSelector, SIGNAL (signalAddNewProfile (QString)),
|
||||
this, SLOT (slotAddNewProfile (QString)));
|
||||
}
|
||||
|
||||
void DataFilesPage::loadSettings()
|
||||
{
|
||||
QString profileName = mSelector->getProfileText();
|
||||
QString profileName = ui.profilesComboBox->currentText();
|
||||
|
||||
QStringList files = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/game"), Qt::MatchExactly);
|
||||
QStringList addons = mLauncherSettings.values(QString("Profiles/") + profileName + QString("/addon"), Qt::MatchExactly);
|
||||
|
||||
mSelector->clearCheckStates();
|
||||
|
||||
if (files.size() > 0)
|
||||
mSelector->setGameFile(files.at(0));
|
||||
else
|
||||
mSelector->setGameFile();
|
||||
QString gameFile ("");
|
||||
|
||||
if (files.size()>0)
|
||||
gameFile = files.at (0);
|
||||
|
||||
mSelector->setGameFile(gameFile);
|
||||
mSelector->setCheckStates(addons);
|
||||
}
|
||||
|
||||
@ -72,7 +59,7 @@ void DataFilesPage::saveSettings(const QString &profile)
|
||||
QString profileName = profile;
|
||||
|
||||
if (profileName.isEmpty())
|
||||
profileName = mSelector->getProfileText();
|
||||
profileName = ui.profilesComboBox->currentText();
|
||||
|
||||
//retrieve the files selected for the profile
|
||||
ContentSelectorModel::ContentFileList items = mSelector->selectedFiles();
|
||||
@ -83,7 +70,7 @@ void DataFilesPage::saveSettings(const QString &profile)
|
||||
mGameSettings.remove(QString("addon"));
|
||||
|
||||
//set the value of the current profile (not necessarily the profile being saved!)
|
||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), mSelector->getProfileText());
|
||||
mLauncherSettings.setValue(QString("Profiles/currentprofile"), ui.profilesComboBox->currentText());
|
||||
|
||||
foreach(const ContentSelectorModel::EsmFile *item, items) {
|
||||
|
||||
@ -98,39 +85,64 @@ void DataFilesPage::saveSettings(const QString &profile)
|
||||
|
||||
}
|
||||
|
||||
void DataFilesPage::buildView()
|
||||
{
|
||||
ui.verticalLayout->insertWidget (0, mSelector->uiWidget());
|
||||
|
||||
//tool buttons
|
||||
ui.newProfileButton->setToolTip ("Create a new profile");
|
||||
ui.deleteProfileButton->setToolTip ("Delete an existing profile");
|
||||
|
||||
//combo box
|
||||
ui.profilesComboBox->addItem ("Default");
|
||||
ui.profilesComboBox->setPlaceholderText (QString("Select a profile..."));
|
||||
|
||||
// Add the actions to the toolbuttons
|
||||
ui.newProfileButton->setDefaultAction (ui.newProfileAction);
|
||||
ui.deleteProfileButton->setDefaultAction (ui.deleteProfileAction);
|
||||
|
||||
//establish connections
|
||||
connect (ui.profilesComboBox, SIGNAL (currentIndexChanged(int)),
|
||||
this, SLOT (slotProfileChanged(int)));
|
||||
|
||||
connect (ui.profilesComboBox, SIGNAL (profileRenamed(QString, QString)),
|
||||
this, SLOT (slotProfileRenamed(QString, QString)));
|
||||
|
||||
connect (ui.profilesComboBox, SIGNAL (signalProfileChanged(QString, QString)),
|
||||
this, SLOT (slotProfileChangedByUser(QString, QString)));
|
||||
}
|
||||
|
||||
void DataFilesPage::removeProfile(const QString &profile)
|
||||
{
|
||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/game"));
|
||||
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/addon"));
|
||||
}
|
||||
|
||||
void DataFilesPage::changeProfiles(const QString &previous, const QString ¤t, bool savePrevious)
|
||||
void DataFilesPage::setProfile(int index, bool savePrevious)
|
||||
{
|
||||
//abort if no change (typically a duplicate signal)
|
||||
if (previous == current)
|
||||
return;
|
||||
if (index >= -1 && index < ui.profilesComboBox->count())
|
||||
{
|
||||
QString previous = ui.profilesComboBox->itemText(ui.profilesComboBox->currentIndex());
|
||||
QString current = ui.profilesComboBox->itemText(index);
|
||||
|
||||
int index = -1;
|
||||
|
||||
if (!previous.isEmpty())
|
||||
index = mSelector->getProfileIndex(previous);
|
||||
|
||||
// Store the previous profile if it exists
|
||||
if ( (index != -1) && savePrevious)
|
||||
saveSettings(previous);
|
||||
|
||||
loadSettings();
|
||||
setProfile (previous, current, savePrevious);
|
||||
}
|
||||
}
|
||||
|
||||
void DataFilesPage::slotAddNewProfile(const QString &profile)
|
||||
void DataFilesPage::setProfile (const QString &previous, const QString ¤t, bool savePrevious)
|
||||
{
|
||||
saveSettings();
|
||||
mSelector->clearCheckStates();
|
||||
mSelector->addProfile(profile, true);
|
||||
mSelector->setGameFile();
|
||||
saveSettings();
|
||||
//abort if no change (poss. duplicate signal)
|
||||
if (previous == current)
|
||||
return;
|
||||
|
||||
emit signalProfileChanged(mSelector->getProfileIndex(profile));
|
||||
if (!previous.isEmpty() && savePrevious)
|
||||
saveSettings (previous);
|
||||
|
||||
ui.profilesComboBox->setCurrentIndex (ui.profilesComboBox->findText (current));
|
||||
|
||||
loadSettings();
|
||||
|
||||
checkForDefaultProfile();
|
||||
}
|
||||
|
||||
void DataFilesPage::slotProfileDeleted (const QString &item)
|
||||
@ -140,8 +152,8 @@ void DataFilesPage::slotProfileDeleted (const QString &item)
|
||||
|
||||
void DataFilesPage::slotProfileChangedByUser(const QString &previous, const QString ¤t)
|
||||
{
|
||||
changeProfiles(previous, current);
|
||||
emit signalProfileChanged(mSelector->getProfileIndex(current));
|
||||
setProfile(previous, current, true);
|
||||
emit signalProfileChanged (ui.profilesComboBox->findText(current));
|
||||
}
|
||||
|
||||
void DataFilesPage::slotProfileRenamed(const QString &previous, const QString ¤t)
|
||||
@ -160,7 +172,7 @@ void DataFilesPage::slotProfileRenamed(const QString &previous, const QString &c
|
||||
|
||||
void DataFilesPage::slotProfileChanged(int index)
|
||||
{
|
||||
mSelector->setProfile(index);
|
||||
setProfile (index, true);
|
||||
}
|
||||
|
||||
void DataFilesPage::setupDataFiles()
|
||||
@ -178,21 +190,92 @@ void DataFilesPage::setupDataFiles()
|
||||
QStringList profiles = mLauncherSettings.subKeys(QString("Profiles/"));
|
||||
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
|
||||
|
||||
|
||||
foreach (const QString &item, profiles)
|
||||
mSelector->addProfile (item);
|
||||
addProfile (item, false);
|
||||
|
||||
mSelector->addProfile (profile, true);
|
||||
addProfile (profile, true);
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
QAbstractItemModel *DataFilesPage::profilesModel() const
|
||||
void DataFilesPage::on_newProfileAction_triggered()
|
||||
{
|
||||
return mSelector->profilesModel();
|
||||
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this);
|
||||
|
||||
if (newDialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
QString profile = newDialog.getText();
|
||||
|
||||
if (profile.isEmpty())
|
||||
return;
|
||||
|
||||
saveSettings();
|
||||
|
||||
mSelector->clearCheckStates();
|
||||
|
||||
addProfile(profile, true);
|
||||
|
||||
mSelector->setGameFile();
|
||||
|
||||
saveSettings();
|
||||
|
||||
emit signalProfileChanged (ui.profilesComboBox->findText(profile));
|
||||
}
|
||||
|
||||
int DataFilesPage::profilesIndex() const
|
||||
void DataFilesPage::addProfile (const QString &profile, bool setAsCurrent)
|
||||
{
|
||||
return mSelector->getProfileIndex(mSelector->getProfileText());
|
||||
if (profile.isEmpty())
|
||||
return;
|
||||
|
||||
if (ui.profilesComboBox->findText (profile) != -1)
|
||||
return;
|
||||
|
||||
ui.profilesComboBox->addItem (profile);
|
||||
|
||||
if (setAsCurrent)
|
||||
setProfile (ui.profilesComboBox->findText (profile), false);
|
||||
}
|
||||
|
||||
void DataFilesPage::on_deleteProfileAction_triggered()
|
||||
{
|
||||
QString profile = ui.profilesComboBox->currentText();
|
||||
|
||||
if (profile.isEmpty())
|
||||
return;
|
||||
|
||||
if (!showDeleteMessageBox (profile))
|
||||
return;
|
||||
|
||||
// Remove the profile from the combobox
|
||||
ui.profilesComboBox->removeItem (ui.profilesComboBox->findText (profile));
|
||||
|
||||
loadSettings();
|
||||
|
||||
checkForDefaultProfile();
|
||||
}
|
||||
|
||||
void DataFilesPage::checkForDefaultProfile()
|
||||
{
|
||||
//don't allow deleting "Default" profile
|
||||
bool success = (ui.profilesComboBox->currentText() != "Default");
|
||||
|
||||
ui.deleteProfileAction->setEnabled (success);
|
||||
ui.profilesComboBox->setEditEnabled (success);
|
||||
}
|
||||
|
||||
bool DataFilesPage::showDeleteMessageBox (const QString &text)
|
||||
{
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(tr("Delete Profile"));
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||
msgBox.setText(tr("Are you sure you want to delete <b>%0</b>?").arg(text));
|
||||
|
||||
QAbstractButton *deleteButton =
|
||||
msgBox.addButton(tr("Delete"), QMessageBox::ActionRole);
|
||||
|
||||
msgBox.exec();
|
||||
|
||||
return (msgBox.clickedButton() == deleteButton);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef DATAFILESPAGE_H
|
||||
#define DATAFILESPAGE_H
|
||||
|
||||
#include "ui_datafilespage.h"
|
||||
#include <QWidget>
|
||||
#include <QModelIndex>
|
||||
|
||||
@ -12,7 +13,7 @@ class QMenu;
|
||||
class TextInputDialog;
|
||||
class GameSettings;
|
||||
class LauncherSettings;
|
||||
|
||||
class ProfilesComboBox;
|
||||
|
||||
namespace Files { struct ConfigurationManager; }
|
||||
namespace ContentSelectorView { class ContentSelector; }
|
||||
@ -22,32 +23,37 @@ class DataFilesPage : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
ContentSelectorView::ContentSelector *mSelector;
|
||||
Ui::DataFilesPage ui;
|
||||
|
||||
public:
|
||||
DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent = 0);
|
||||
explicit DataFilesPage (Files::ConfigurationManager &cfg, GameSettings &gameSettings,
|
||||
LauncherSettings &launcherSettings, QWidget *parent = 0);
|
||||
|
||||
QAbstractItemModel* profilesModel() const;
|
||||
int profilesIndex() const;
|
||||
QAbstractItemModel* profilesModel() const
|
||||
{ return ui.profilesComboBox->model(); }
|
||||
|
||||
void writeConfig(QString profile = QString());
|
||||
int profilesIndex() const
|
||||
{ return ui.profilesComboBox->currentIndex(); }
|
||||
|
||||
//void writeConfig(QString profile = QString());
|
||||
void saveSettings(const QString &profile = "");
|
||||
void loadSettings();
|
||||
|
||||
signals:
|
||||
void signalProfileChanged(int index);
|
||||
void signalProfileChanged (int index);
|
||||
|
||||
public slots:
|
||||
//void showContextMenu(const QPoint &point);
|
||||
|
||||
void slotProfileChanged (int index);
|
||||
|
||||
private slots:
|
||||
|
||||
void slotAddNewProfile(const QString &profile);
|
||||
void slotProfileChangedByUser(const QString &previous, const QString ¤t);
|
||||
void slotProfileChanged(int);
|
||||
void slotProfileRenamed(const QString &previous, const QString ¤t);
|
||||
void slotProfileDeleted(const QString &item);
|
||||
|
||||
void on_newProfileAction_triggered();
|
||||
void on_deleteProfileAction_triggered();
|
||||
|
||||
private:
|
||||
|
||||
QMenu *mContextMenu;
|
||||
@ -59,11 +65,16 @@ private:
|
||||
|
||||
void setPluginsCheckstates(Qt::CheckState state);
|
||||
|
||||
void buildView();
|
||||
void setupDataFiles();
|
||||
void setupConfig();
|
||||
void readConfig();
|
||||
void setProfile (int index, bool savePrevious);
|
||||
void setProfile (const QString &previous, const QString ¤t, bool savePrevious);
|
||||
void removeProfile (const QString &profile);
|
||||
void changeProfiles(const QString &previous, const QString ¤t, bool savePrevious = true);
|
||||
bool showDeleteMessageBox (const QString &text);
|
||||
void addProfile (const QString &profile, bool setAsCurrent);
|
||||
void checkForDefaultProfile();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -485,7 +485,7 @@ bool MainDialog::setupGameSettings()
|
||||
foreach (const QString path, mGameSettings.getDataDirs()) {
|
||||
QDir dir(path);
|
||||
QStringList filters;
|
||||
filters << "*.esp" << "*.esm";
|
||||
filters << "*.esp" << "*.esm" << "*.omwgame" << "*.omwaddon";
|
||||
|
||||
if (!dir.entryList(filters).isEmpty())
|
||||
dataDirs.append(path);
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include <QToolButton>
|
||||
#include <QStyle>
|
||||
#include "lineedit.hpp"
|
||||
|
||||
#include "comboboxlineedit.hpp"
|
||||
|
||||
ContentSelectorView::ComboBoxLineEdit::ComboBoxLineEdit(QWidget *parent)
|
||||
LineEdit::LineEdit(QWidget *parent)
|
||||
: QLineEdit(parent)
|
||||
{
|
||||
setupClearButton();
|
||||
}
|
||||
|
||||
void LineEdit::setupClearButton()
|
||||
{
|
||||
mClearButton = new QToolButton(this);
|
||||
QPixmap pixmap(":images/clear.png");
|
||||
@ -15,13 +17,9 @@ ContentSelectorView::ComboBoxLineEdit::ComboBoxLineEdit(QWidget *parent)
|
||||
mClearButton->hide();
|
||||
connect(mClearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateClearButton(const QString&)));
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
|
||||
setObjectName(QString("ComboBoxLineEdit"));
|
||||
setStyleSheet(QString("ComboBoxLineEdit { background-color: transparent; padding-right: %1px; } ").arg(mClearButton->sizeHint().width() + frameWidth + 1));
|
||||
}
|
||||
|
||||
void ContentSelectorView::ComboBoxLineEdit::resizeEvent(QResizeEvent *)
|
||||
void LineEdit::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
QSize sz = mClearButton->sizeHint();
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
@ -29,7 +27,7 @@ void ContentSelectorView::ComboBoxLineEdit::resizeEvent(QResizeEvent *)
|
||||
(rect().bottom() + 1 - sz.height())/2);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ComboBoxLineEdit::updateClearButton(const QString& text)
|
||||
void LineEdit::updateClearButton(const QString& text)
|
||||
{
|
||||
mClearButton->setVisible(!text.isEmpty());
|
||||
}
|
@ -11,29 +11,32 @@
|
||||
#define LINEEDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QStyle>
|
||||
#include <QStylePainter>
|
||||
#include <QToolButton>
|
||||
|
||||
class QToolButton;
|
||||
|
||||
namespace ContentSelectorView
|
||||
class LineEdit : public QLineEdit
|
||||
{
|
||||
class LineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
QString mPlaceholderText;
|
||||
QString mPlaceholderText;
|
||||
|
||||
public:
|
||||
LineEdit(QWidget *parent = 0);
|
||||
public:
|
||||
LineEdit(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void updateClearButton(const QString &text);
|
||||
private slots:
|
||||
void updateClearButton(const QString &text);
|
||||
|
||||
protected:
|
||||
QToolButton *mClearButton;
|
||||
|
||||
void setupClearButton();
|
||||
};
|
||||
|
||||
private:
|
||||
QToolButton *mClearButton;
|
||||
};
|
||||
}
|
||||
#endif // LIENEDIT_H
|
||||
|
@ -5,23 +5,17 @@
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "profilescombobox.hpp"
|
||||
#include "comboboxlineedit.hpp"
|
||||
|
||||
ContentSelectorView::ProfilesComboBox::ProfilesComboBox(QWidget *parent) :
|
||||
QComboBox(parent)
|
||||
ProfilesComboBox::ProfilesComboBox(QWidget *parent) :
|
||||
ContentSelectorView::ComboBox(parent)
|
||||
{
|
||||
mValidator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
||||
setEditEnabled(true);
|
||||
setValidator(mValidator);
|
||||
setCompleter(0);
|
||||
|
||||
connect(this, SIGNAL(activated(int)), this,
|
||||
SLOT(slotIndexChangedByUser(int)));
|
||||
|
||||
setInsertPolicy(QComboBox::NoInsert);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ProfilesComboBox::setEditEnabled(bool editable)
|
||||
void ProfilesComboBox::setEditEnabled(bool editable)
|
||||
{
|
||||
if (isEditable() == editable)
|
||||
return;
|
||||
@ -37,6 +31,7 @@ void ContentSelectorView::ProfilesComboBox::setEditEnabled(bool editable)
|
||||
setValidator(mValidator);
|
||||
|
||||
ComboBoxLineEdit *edit = new ComboBoxLineEdit(this);
|
||||
|
||||
setLineEdit(edit);
|
||||
setCompleter(0);
|
||||
|
||||
@ -50,7 +45,7 @@ void ContentSelectorView::ProfilesComboBox::setEditEnabled(bool editable)
|
||||
SIGNAL (signalProfileTextChanged (QString)));
|
||||
}
|
||||
|
||||
void ContentSelectorView::ProfilesComboBox::slotTextChanged(const QString &text)
|
||||
void ProfilesComboBox::slotTextChanged(const QString &text)
|
||||
{
|
||||
QPalette *palette = new QPalette();
|
||||
palette->setColor(QPalette::Text,Qt::red);
|
||||
@ -64,7 +59,7 @@ void ContentSelectorView::ProfilesComboBox::slotTextChanged(const QString &text)
|
||||
}
|
||||
}
|
||||
|
||||
void ContentSelectorView::ProfilesComboBox::slotEditingFinished()
|
||||
void ProfilesComboBox::slotEditingFinished()
|
||||
{
|
||||
QString current = currentText();
|
||||
QString previous = itemText(currentIndex());
|
||||
@ -85,7 +80,7 @@ void ContentSelectorView::ProfilesComboBox::slotEditingFinished()
|
||||
emit(profileRenamed(previous, current));
|
||||
}
|
||||
|
||||
void ContentSelectorView::ProfilesComboBox::slotIndexChangedByUser(int index)
|
||||
void ProfilesComboBox::slotIndexChangedByUser(int index)
|
||||
{
|
||||
if (index == -1)
|
||||
return;
|
||||
@ -94,23 +89,11 @@ void ContentSelectorView::ProfilesComboBox::slotIndexChangedByUser(int index)
|
||||
mOldProfile = currentText();
|
||||
}
|
||||
|
||||
void ContentSelectorView::ProfilesComboBox::paintEvent(QPaintEvent *)
|
||||
ProfilesComboBox::ComboBoxLineEdit::ComboBoxLineEdit (QWidget *parent)
|
||||
: LineEdit (parent)
|
||||
{
|
||||
QStylePainter painter(this);
|
||||
painter.setPen(palette().color(QPalette::Text));
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
|
||||
// draw the combobox frame, focusrect and selected etc.
|
||||
QStyleOptionComboBox opt;
|
||||
initStyleOption(&opt);
|
||||
painter.drawComplexControl(QStyle::CC_ComboBox, opt);
|
||||
|
||||
// draw the icon and text
|
||||
if (!opt.editable && currentIndex() == -1) // <<< we adjust the text displayed when nothing is selected
|
||||
opt.currentText = mPlaceholderText;
|
||||
painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ProfilesComboBox::setPlaceholderText(const QString &text)
|
||||
{
|
||||
mPlaceholderText = text;
|
||||
setObjectName(QString("ComboBoxLineEdit"));
|
||||
setStyleSheet(QString("ComboBoxLineEdit { background-color: transparent; padding-right: %1px; } ").arg(mClearButton->sizeHint().width() + frameWidth + 1));
|
||||
}
|
40
apps/launcher/utils/profilescombobox.hpp
Normal file
40
apps/launcher/utils/profilescombobox.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef PROFILESCOMBOBOX_HPP
|
||||
#define PROFILESCOMBOBOX_HPP
|
||||
|
||||
#include "components/contentselector/view/combobox.hpp"
|
||||
#include "lineedit.hpp"
|
||||
|
||||
class QString;
|
||||
|
||||
class ProfilesComboBox : public ContentSelectorView::ComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
class ComboBoxLineEdit : public LineEdit
|
||||
{
|
||||
public:
|
||||
explicit ComboBoxLineEdit (QWidget *parent = 0);
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
explicit ProfilesComboBox(QWidget *parent = 0);
|
||||
void setEditEnabled(bool editable);
|
||||
|
||||
signals:
|
||||
void signalProfileTextChanged(const QString &item);
|
||||
void signalProfileChanged(const QString &previous, const QString ¤t);
|
||||
void signalProfileChanged(int index);
|
||||
void profileRenamed(const QString &oldName, const QString &newName);
|
||||
|
||||
private slots:
|
||||
|
||||
void slotEditingFinished();
|
||||
void slotIndexChangedByUser(int index);
|
||||
void slotTextChanged(const QString &text);
|
||||
|
||||
private:
|
||||
QString mOldProfile;
|
||||
};
|
||||
#endif // PROFILESCOMBOBOX_HPP
|
@ -7,8 +7,6 @@
|
||||
#include <QValidator>
|
||||
#include <QLabel>
|
||||
|
||||
#include <components/contentselector/view/lineedit.hpp>
|
||||
|
||||
TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWidget *parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
@ -20,7 +18,7 @@ TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWid
|
||||
|
||||
// Line edit
|
||||
QValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
||||
mLineEdit = new ContentSelectorView::LineEdit(this);
|
||||
mLineEdit = new DialogLineEdit(this);
|
||||
mLineEdit->setValidator(validator);
|
||||
mLineEdit->setCompleter(0);
|
||||
|
||||
@ -74,3 +72,16 @@ void TextInputDialog::slotUpdateOkButton(QString text)
|
||||
mLineEdit->setPalette(*palette);
|
||||
}
|
||||
}
|
||||
|
||||
TextInputDialog::DialogLineEdit::DialogLineEdit (QWidget *parent) :
|
||||
LineEdit (parent)
|
||||
{
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
|
||||
setObjectName(QString("LineEdit"));
|
||||
setStyleSheet(QString("LineEdit { padding-right: %1px; } ").arg(mClearButton->sizeHint().width() + frameWidth + 1));
|
||||
QSize msz = minimumSizeHint();
|
||||
setMinimumSize(qMax(msz.width(), mClearButton->sizeHint().height() + frameWidth * 2 + 2),
|
||||
qMax(msz.height(), mClearButton->sizeHint().height() + frameWidth * 2 + 2));
|
||||
|
||||
}
|
@ -3,23 +3,30 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "lineedit.hpp"
|
||||
|
||||
class QDialogButtonBox;
|
||||
|
||||
namespace ContentSelectorView {
|
||||
class LineEdit;
|
||||
}
|
||||
|
||||
class LineEdit;
|
||||
|
||||
class TextInputDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
ContentSelectorView::LineEdit *mLineEdit;
|
||||
class DialogLineEdit : public LineEdit
|
||||
{
|
||||
public:
|
||||
explicit DialogLineEdit (QWidget *parent = 0);
|
||||
};
|
||||
|
||||
DialogLineEdit *mLineEdit;
|
||||
QDialogButtonBox *mButtonBox;
|
||||
|
||||
public:
|
||||
|
||||
explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0);
|
||||
~TextInputDialog () {}
|
||||
|
||||
QString getText() const;
|
||||
|
||||
int exec();
|
@ -44,6 +44,7 @@ opencs_units_noqt (model/tools
|
||||
|
||||
opencs_units (view/doc
|
||||
viewmanager view operations operation subview startup filedialog newgame
|
||||
filewidget adjusterwidget
|
||||
)
|
||||
|
||||
|
||||
@ -122,11 +123,13 @@ opencs_units (view/filter
|
||||
set (OPENCS_US
|
||||
)
|
||||
|
||||
set (OPENCS_RES ../../files/opencs/resources.qrc
|
||||
../../files/launcher/launcher.qrc
|
||||
set (OPENCS_RES ${CMAKE_SOURCE_DIR}/files/opencs/resources.qrc
|
||||
${CMAKE_SOURCE_DIR}/files/launcher/launcher.qrc
|
||||
)
|
||||
|
||||
set (OPENCS_UI ../../files/ui/datafilespage.ui
|
||||
set (OPENCS_UI
|
||||
${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui
|
||||
${CMAKE_SOURCE_DIR}/files/ui/filedialog.ui
|
||||
)
|
||||
|
||||
source_group (opencs FILES ${OPENCS_SRC} ${OPENCS_HDR})
|
||||
|
@ -109,15 +109,13 @@ void CS::Editor::createGame()
|
||||
void CS::Editor::createAddon()
|
||||
{
|
||||
mStartup.hide();
|
||||
|
||||
mFileDialog.newFile();
|
||||
mFileDialog.showDialog (CSVDoc::FileDialog::DialogType_New);
|
||||
}
|
||||
|
||||
void CS::Editor::loadDocument()
|
||||
{
|
||||
mStartup.hide();
|
||||
|
||||
mFileDialog.openFile();
|
||||
mFileDialog.showDialog (CSVDoc::FileDialog::DialogType_Open);
|
||||
}
|
||||
|
||||
void CS::Editor::openFiles()
|
||||
|
@ -12,81 +12,120 @@
|
||||
#include <QGroupBox>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include <components/contentselector/model/esmfile.hpp>
|
||||
#include <components/contentselector/view/lineedit.hpp>
|
||||
#include "components/contentselector/model/esmfile.hpp"
|
||||
#include "components/contentselector/view/contentselector.hpp"
|
||||
#include "filewidget.hpp"
|
||||
#include "adjusterwidget.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
CSVDoc::FileDialog::FileDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
mOpenFileFlags (ContentSelectorView::Flag_Content | ContentSelectorView::Flag_LoadAddon),
|
||||
mNewFileFlags (ContentSelectorView::Flag_Content | ContentSelectorView::Flag_NewAddon)
|
||||
|
||||
QDialog(parent), mSelector (0)
|
||||
{
|
||||
ui.setupUi (this);
|
||||
resize(400, 400);
|
||||
|
||||
setObjectName ("FileDialog");
|
||||
mSelector = new ContentSelectorView::ContentSelector (ui.contentSelectorWidget);
|
||||
}
|
||||
|
||||
void CSVDoc::FileDialog::addFiles(const QString &path)
|
||||
{
|
||||
ContentSelectorView::ContentSelector::addFiles(path);
|
||||
}
|
||||
|
||||
QString CSVDoc::FileDialog::filename()
|
||||
{
|
||||
return ContentSelectorView::ContentSelector::instance().projectFilename();
|
||||
mSelector->addFiles(path);
|
||||
}
|
||||
|
||||
QStringList CSVDoc::FileDialog::selectedFilePaths()
|
||||
{
|
||||
QStringList filePaths;
|
||||
|
||||
foreach (ContentSelectorModel::EsmFile *file, ContentSelectorView::ContentSelector::
|
||||
instance().selectedFiles() )
|
||||
{
|
||||
foreach (ContentSelectorModel::EsmFile *file, mSelector->selectedFiles() )
|
||||
filePaths.append(file->path());
|
||||
}
|
||||
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
void CSVDoc::FileDialog::showDialog()
|
||||
void CSVDoc::FileDialog::showDialog(DialogType dialogType)
|
||||
{
|
||||
mDialogType = dialogType;
|
||||
|
||||
switch (mDialogType)
|
||||
{
|
||||
case DialogType_New:
|
||||
buildNewFileView();
|
||||
break;
|
||||
|
||||
case DialogType_Open:
|
||||
buildOpenFileView();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
show();
|
||||
raise();
|
||||
activateWindow();
|
||||
}
|
||||
|
||||
void CSVDoc::FileDialog::openFile()
|
||||
void CSVDoc::FileDialog::buildNewFileView()
|
||||
{
|
||||
setWindowTitle(tr("Open"));
|
||||
setWindowTitle(tr("Create a new addon"));
|
||||
|
||||
ContentSelectorView::ContentSelector::configure(this, mOpenFileFlags);
|
||||
QPushButton* createButton = ui.projectButtonBox->button (QDialogButtonBox::Ok);
|
||||
createButton->setText ("Create");
|
||||
createButton->setEnabled (false);
|
||||
|
||||
connect (&ContentSelectorView::ContentSelector::instance(),
|
||||
SIGNAL (accepted()), this, SIGNAL (openFiles()));
|
||||
mFileWidget = new FileWidget (this);
|
||||
|
||||
connect (&ContentSelectorView::ContentSelector::instance(),
|
||||
SIGNAL (rejected()), this, SLOT (slotRejected()));
|
||||
mFileWidget->setType (true);
|
||||
mFileWidget->extensionLabelIsVisible(true);
|
||||
|
||||
showDialog();
|
||||
ui.projectGroupBoxLayout->insertWidget (0, mFileWidget);
|
||||
|
||||
connect (mFileWidget, SIGNAL (nameChanged(const QString &, bool)),
|
||||
this, SLOT (slotUpdateCreateButton(const QString &, bool)));
|
||||
|
||||
connect (mSelector, SIGNAL (signalCurrentGamefileIndexChanged (int)),
|
||||
this, SLOT (slotUpdateCreateButton (int)));
|
||||
|
||||
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SIGNAL (createNewFile()));
|
||||
|
||||
connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected()));
|
||||
}
|
||||
|
||||
void CSVDoc::FileDialog::newFile()
|
||||
void CSVDoc::FileDialog::buildOpenFileView()
|
||||
{
|
||||
setWindowTitle(tr("New"));
|
||||
setWindowTitle(tr("Open"));
|
||||
ui.projectGroupBox->setTitle (QString(""));
|
||||
|
||||
ContentSelectorView::ContentSelector::configure(this, mNewFileFlags);
|
||||
|
||||
connect (&ContentSelectorView::ContentSelector::instance(),
|
||||
SIGNAL (accepted()), this, SIGNAL (createNewFile()));
|
||||
|
||||
connect (&ContentSelectorView::ContentSelector::instance(),
|
||||
SIGNAL (rejected()), this, SLOT (slotRejected()));
|
||||
|
||||
showDialog();
|
||||
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SIGNAL (openFiles()));
|
||||
connect (ui.projectButtonBox, SIGNAL (rejected()), this , SIGNAL (rejected()));
|
||||
}
|
||||
|
||||
void CSVDoc::FileDialog::slotRejected()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void CSVDoc::FileDialog::slotUpdateCreateButton (int)
|
||||
{
|
||||
slotUpdateCreateButton (mFileWidget->getName(), true);
|
||||
}
|
||||
|
||||
void CSVDoc::FileDialog::slotUpdateCreateButton(const QString &name, bool)
|
||||
{
|
||||
if (!(mDialogType == DialogType_New))
|
||||
return;
|
||||
|
||||
bool success = (!name.isEmpty() && mSelector->selectedFiles().size() > 0);
|
||||
|
||||
ui.projectButtonBox->button (QDialogButtonBox::Ok)->setEnabled (success);
|
||||
}
|
||||
|
||||
QString CSVDoc::FileDialog::filename() const
|
||||
{
|
||||
if (mDialogType == DialogType_New)
|
||||
return mFileWidget->getName();
|
||||
|
||||
return QString ("");
|
||||
}
|
||||
|
||||
|
@ -3,49 +3,54 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QModelIndex>
|
||||
#include "../../../../components/contentselector/view/contentselector.hpp"
|
||||
|
||||
class QDialogButtonBox;
|
||||
class QSortFilterProxyModel;
|
||||
class QAbstractItemModel;
|
||||
class QPushButton;
|
||||
class QStringList;
|
||||
class QString;
|
||||
class QMenu;
|
||||
class QLabel;
|
||||
#include "ui_filedialog.h"
|
||||
|
||||
class DataFilesModel;
|
||||
class PluginsProxyModel;
|
||||
|
||||
|
||||
|
||||
namespace ContentSelectorView
|
||||
{
|
||||
class LineEdit;
|
||||
class ContentSelector;
|
||||
}
|
||||
|
||||
namespace CSVDoc
|
||||
{
|
||||
class FileWidget;
|
||||
|
||||
class FileDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
unsigned char mOpenFileFlags;
|
||||
unsigned char mNewFileFlags;
|
||||
public:
|
||||
|
||||
enum DialogType
|
||||
{
|
||||
DialogType_New,
|
||||
DialogType_Open
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
ContentSelectorView::ContentSelector *mSelector;
|
||||
Ui::FileDialog ui;
|
||||
DialogType mDialogType;
|
||||
FileWidget *mFileWidget;
|
||||
|
||||
public:
|
||||
explicit FileDialog(QWidget *parent = 0);
|
||||
|
||||
void openFile();
|
||||
void newFile();
|
||||
explicit FileDialog(QWidget *parent = 0);
|
||||
void showDialog (DialogType dialogType);
|
||||
|
||||
void addFiles (const QString &path);
|
||||
|
||||
QString filename();
|
||||
QString filename() const;
|
||||
QStringList selectedFilePaths();
|
||||
|
||||
private:
|
||||
|
||||
void showDialog();
|
||||
void buildNewFileView();
|
||||
void buildOpenFileView();
|
||||
|
||||
signals:
|
||||
|
||||
@ -58,6 +63,9 @@ namespace CSVDoc
|
||||
|
||||
private slots:
|
||||
|
||||
void slotUpdateCreateButton (int);
|
||||
void slotUpdateCreateButton (const QString &, bool);
|
||||
|
||||
};
|
||||
}
|
||||
#endif // FILEDIALOG_HPP
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "components/contentselector/view/filewidget.hpp"
|
||||
#include "components/contentselector/view/adjusterwidget.hpp"
|
||||
#include "filewidget.hpp"
|
||||
#include "adjusterwidget.hpp"
|
||||
|
||||
CSVDoc::NewGameDialogue::NewGameDialogue()
|
||||
{
|
||||
|
@ -74,7 +74,7 @@ add_component_dir (loadinglistener
|
||||
loadinglistener
|
||||
)
|
||||
|
||||
set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/datafilespage.ui
|
||||
set (ESM_UI ${CMAKE_SOURCE_DIR}/files/ui/contentselector.ui
|
||||
)
|
||||
find_package(Qt4 COMPONENTS QtCore QtGui)
|
||||
|
||||
@ -82,11 +82,7 @@ if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
|
||||
add_component_qt_dir (contentselector
|
||||
model/modelitem model/esmfile
|
||||
model/naturalsort model/contentmodel
|
||||
view/profilescombobox view/comboboxlineedit
|
||||
view/lineedit view/contentselector
|
||||
view/filewidget view/adjusterwidget
|
||||
view/textinputdialog
|
||||
|
||||
view/combobox view/contentselector
|
||||
)
|
||||
|
||||
include(${QT_USE_FILE})
|
||||
|
@ -399,6 +399,10 @@ void ContentSelectorModel::ContentModel::addFile(EsmFile *file)
|
||||
beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count());
|
||||
mFiles.append(file);
|
||||
endInsertRows();
|
||||
|
||||
QModelIndex idx = index (mFiles.size() - 2, 0, QModelIndex());
|
||||
|
||||
emit dataChanged (idx, idx);
|
||||
}
|
||||
|
||||
void ContentSelectorModel::ContentModel::addFiles(const QString &path)
|
||||
@ -466,6 +470,7 @@ void ContentSelectorModel::ContentModel::sortFiles()
|
||||
//iterate each file, obtaining a reference to it's gamefiles list
|
||||
for (int i = 0; i < fileCount; i++)
|
||||
{
|
||||
QModelIndex idx1 = index (i, 0, QModelIndex());
|
||||
const QStringList &gamefiles = mFiles.at(i)->gameFiles();
|
||||
//iterate each file after the current file, verifying that none of it's
|
||||
//dependencies appear.
|
||||
@ -474,6 +479,11 @@ void ContentSelectorModel::ContentModel::sortFiles()
|
||||
if (gamefiles.contains(mFiles.at(j)->fileName()))
|
||||
{
|
||||
mFiles.move(j, i);
|
||||
|
||||
QModelIndex idx2 = index (j, 0, QModelIndex());
|
||||
|
||||
emit dataChanged (idx1, idx2);
|
||||
|
||||
movedFiles = true;
|
||||
}
|
||||
}
|
||||
|
39
components/contentselector/view/combobox.cpp
Normal file
39
components/contentselector/view/combobox.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include <QRegExpValidator>
|
||||
#include <QLineEdit>
|
||||
#include <QString>
|
||||
#include <QApplication>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "combobox.hpp"
|
||||
|
||||
ContentSelectorView::ComboBox::ComboBox(QWidget *parent) :
|
||||
QComboBox(parent)
|
||||
{
|
||||
mValidator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore
|
||||
setValidator(mValidator);
|
||||
setCompleter(0);
|
||||
setEnabled (true);
|
||||
|
||||
setInsertPolicy(QComboBox::NoInsert);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ComboBox::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStylePainter painter(this);
|
||||
painter.setPen(palette().color(QPalette::Text));
|
||||
|
||||
// draw the combobox frame, focusrect and selected etc.
|
||||
QStyleOptionComboBox opt;
|
||||
initStyleOption(&opt);
|
||||
painter.drawComplexControl(QStyle::CC_ComboBox, opt);
|
||||
|
||||
// draw the icon and text
|
||||
if (!opt.editable && currentIndex() == -1) // <<< we adjust the text displayed when nothing is selected
|
||||
opt.currentText = mPlaceholderText;
|
||||
painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ComboBox::setPlaceholderText(const QString &text)
|
||||
{
|
||||
mPlaceholderText = text;
|
||||
}
|
30
components/contentselector/view/combobox.hpp
Normal file
30
components/contentselector/view/combobox.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef COMBOBOX_HPP
|
||||
#define COMBOBOX_HPP
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QStylePainter>
|
||||
|
||||
class QString;
|
||||
class QRegExpValidator;
|
||||
|
||||
namespace ContentSelectorView
|
||||
{
|
||||
class ComboBox : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ComboBox (QWidget *parent = 0);
|
||||
|
||||
void setPlaceholderText(const QString &text);
|
||||
|
||||
private:
|
||||
QString mPlaceholderText;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
QRegExpValidator *mValidator;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // COMBOBOX_HPP
|
@ -1,37 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2007 Trolltech ASA <info@trolltech.com>
|
||||
**
|
||||
** Use, modification and distribution is allowed without limitation,
|
||||
** warranty, liability or support of any kind.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LINEEDIT_H
|
||||
#define LINEEDIT_H
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
class QToolButton;
|
||||
|
||||
namespace ContentSelectorView
|
||||
{
|
||||
class ComboBoxLineEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ComboBoxLineEdit(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void updateClearButton(const QString &text);
|
||||
|
||||
private:
|
||||
QToolButton *mClearButton;
|
||||
};
|
||||
}
|
||||
#endif // LIENEDIT_H
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "contentselector.hpp"
|
||||
|
||||
#include "../model/esmfile.hpp"
|
||||
#include "lineedit.hpp"
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
@ -11,45 +10,16 @@
|
||||
#include <QMessageBox>
|
||||
#include <assert.h>
|
||||
|
||||
#include "filewidget.hpp"
|
||||
#include "adjusterwidget.hpp"
|
||||
#include "textinputdialog.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
ContentSelectorView::ContentSelector *ContentSelectorView::ContentSelector::mInstance = 0;
|
||||
QStringList ContentSelectorView::ContentSelector::mFilePaths;
|
||||
|
||||
void ContentSelectorView::ContentSelector::configure(QWidget *subject, unsigned char flags)
|
||||
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
assert(!mInstance);
|
||||
mInstance = new ContentSelector (subject, flags);
|
||||
}
|
||||
|
||||
ContentSelectorView::ContentSelector& ContentSelectorView::ContentSelector::instance()
|
||||
{
|
||||
|
||||
assert(mInstance);
|
||||
return *mInstance;
|
||||
}
|
||||
|
||||
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, unsigned char flags) :
|
||||
QWidget(parent), mFlags (flags),
|
||||
mAdjusterWidget (0), mFileWidget (0),
|
||||
mIgnoreProfileSignal (false)
|
||||
{
|
||||
|
||||
ui.setupUi (this);
|
||||
|
||||
parent->setLayout(new QGridLayout());
|
||||
parent->layout()->addWidget(this);
|
||||
ui.setupUi (parent);
|
||||
|
||||
buildContentModel();
|
||||
buildGameFileView();
|
||||
buildAddonView();
|
||||
buildNewAddonView();
|
||||
buildLoadAddonView();
|
||||
buildProfilesView();
|
||||
|
||||
/*
|
||||
//mContentModel->sort(3); // Sort by date accessed
|
||||
@ -57,16 +27,8 @@ ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent, unsigned
|
||||
*/
|
||||
}
|
||||
|
||||
bool ContentSelectorView::ContentSelector::isFlagged(SelectorFlags flag) const
|
||||
{
|
||||
return (mFlags & flag);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::buildContentModel()
|
||||
{
|
||||
if (!isFlagged (Flag_Content))
|
||||
return;
|
||||
|
||||
mContentModel = new ContentSelectorModel::ContentModel();
|
||||
|
||||
if (mFilePaths.size()>0)
|
||||
@ -83,12 +45,6 @@ void ContentSelectorView::ContentSelector::buildContentModel()
|
||||
|
||||
void ContentSelectorView::ContentSelector::buildGameFileView()
|
||||
{
|
||||
if (!isFlagged (Flag_Content))
|
||||
{
|
||||
ui.gameFileView->setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ui.gameFileView->setVisible (true);
|
||||
|
||||
mGameFileProxyModel = new QSortFilterProxyModel(this);
|
||||
@ -99,19 +55,17 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
|
||||
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
|
||||
ui.gameFileView->setModel(mGameFileProxyModel);
|
||||
|
||||
connect (ui.gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
||||
connect (ui.gameFileView, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
||||
|
||||
connect (ui.gameFileView, SIGNAL (currentIndexChanged (int)),
|
||||
this, SIGNAL (signalCurrentGamefileIndexChanged (int)));
|
||||
|
||||
ui.gameFileView->setCurrentIndex(-1);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::buildAddonView()
|
||||
{
|
||||
if (!isFlagged (Flag_Content))
|
||||
{
|
||||
ui.addonView->setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ui.addonView->setVisible (true);
|
||||
|
||||
mAddonProxyModel = new QSortFilterProxyModel(this);
|
||||
@ -123,91 +77,9 @@ void ContentSelectorView::ContentSelector::buildAddonView()
|
||||
ui.addonView->setModel(mAddonProxyModel);
|
||||
|
||||
connect(ui.addonView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slotAddonTableItemClicked(const QModelIndex &)));
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::buildProfilesView()
|
||||
{
|
||||
if (!isFlagged (Flag_Profile))
|
||||
{
|
||||
ui.profileGroupBox->setVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ui.profileGroupBox->setVisible (true);
|
||||
|
||||
// Add the actions to the toolbuttons
|
||||
ui.newProfileButton->setDefaultAction (ui.newProfileAction);
|
||||
ui.deleteProfileButton->setDefaultAction (ui.deleteProfileAction);
|
||||
|
||||
//enable ui elements
|
||||
ui.profilesComboBox->addItem ("Default");
|
||||
ui.profilesComboBox->setPlaceholderText (QString("Select a profile..."));
|
||||
|
||||
if (!ui.profilesComboBox->isEnabled())
|
||||
ui.profilesComboBox->setEnabled(true);
|
||||
|
||||
if (!ui.deleteProfileAction->isEnabled())
|
||||
ui.deleteProfileAction->setEnabled(true);
|
||||
|
||||
//establish connections
|
||||
connect (ui.profilesComboBox, SIGNAL (currentIndexChanged(int)), this, SLOT(slotCurrentProfileIndexChanged(int)));
|
||||
connect (ui.profilesComboBox, SIGNAL (profileRenamed(QString,QString)), this, SIGNAL(signalProfileRenamed(QString,QString)));
|
||||
connect (ui.profilesComboBox, SIGNAL (signalProfileChanged(QString,QString)), this, SIGNAL(signalProfileChangedByUser(QString,QString)));
|
||||
connect (ui.profilesComboBox, SIGNAL (signalProfileTextChanged(QString)), this, SLOT (slotProfileTextChanged (QString)));
|
||||
|
||||
ui.profileGroupBox->setVisible (true);
|
||||
ui.projectButtonBox->setVisible (false);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::buildLoadAddonView()
|
||||
{
|
||||
if (!isFlagged (Flag_LoadAddon))
|
||||
{
|
||||
if (!isFlagged (Flag_NewAddon))
|
||||
ui.projectGroupBox->setVisible (false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ui.projectGroupBox->setVisible (true);
|
||||
ui.projectCreateButton->setVisible (false);
|
||||
ui.projectGroupBox->setTitle ("");
|
||||
|
||||
connect(ui.projectButtonBox, SIGNAL(accepted()), this, SIGNAL(accepted()));
|
||||
connect(ui.projectButtonBox, SIGNAL(rejected()), this, SIGNAL(rejected()));
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::buildNewAddonView()
|
||||
{
|
||||
if (!isFlagged (Flag_NewAddon))
|
||||
{
|
||||
if (!isFlagged (Flag_LoadAddon))
|
||||
ui.projectGroupBox->setVisible (false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ui.projectGroupBox->setVisible (true);
|
||||
|
||||
mFileWidget = new CSVDoc::FileWidget (this);
|
||||
mAdjusterWidget = new CSVDoc::AdjusterWidget (this);
|
||||
|
||||
mFileWidget->setType(true);
|
||||
mFileWidget->extensionLabelIsVisible(false);
|
||||
|
||||
ui.fileWidgetFrame->layout()->addWidget(mFileWidget);
|
||||
ui.adjusterWidgetFrame->layout()->addWidget(mAdjusterWidget);
|
||||
|
||||
ui.projectButtonBox->setStandardButtons(QDialogButtonBox::Cancel);
|
||||
ui.projectButtonBox->addButton(ui.projectCreateButton, QDialogButtonBox::ActionRole);
|
||||
|
||||
connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)),
|
||||
mAdjusterWidget, SLOT (setName (const QString&, bool)));
|
||||
|
||||
connect (mAdjusterWidget, SIGNAL (stateChanged(bool)), this, SLOT (slotUpdateCreateButton(bool)));
|
||||
|
||||
connect(ui.projectCreateButton, SIGNAL(clicked()), this, SIGNAL(accepted()));
|
||||
connect(ui.projectButtonBox, SIGNAL(rejected()), this, SIGNAL(rejected()));
|
||||
for (int i = 0; i < mAddonProxyModel->rowCount(); ++i)
|
||||
qDebug() << mAddonProxyModel->data(mAddonProxyModel->index(i,0,QModelIndex()));
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::setGameFile(const QString &filename)
|
||||
@ -239,16 +111,6 @@ void ContentSelectorView::ContentSelector::setCheckStates(const QStringList &lis
|
||||
mContentModel->setCheckState(file, Qt::Checked);
|
||||
}
|
||||
|
||||
QString ContentSelectorView::ContentSelector::projectFilename() const
|
||||
{
|
||||
QString filepath = "";
|
||||
|
||||
if (mAdjusterWidget)
|
||||
filepath = QString::fromAscii(mAdjusterWidget->getPath().c_str());
|
||||
|
||||
return filepath;
|
||||
}
|
||||
|
||||
ContentSelectorModel::ContentFileList
|
||||
ContentSelectorView::ContentSelector::selectedFiles() const
|
||||
{
|
||||
@ -261,65 +123,10 @@ ContentSelectorModel::ContentFileList
|
||||
|
||||
void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
||||
{
|
||||
// if the model hasn't been instantiated, queue the path
|
||||
if (!mInstance)
|
||||
mFilePaths.append(path);
|
||||
else
|
||||
{
|
||||
mInstance->mContentModel->addFiles(path);
|
||||
mInstance->ui.gameFileView->setCurrentIndex(-1);
|
||||
}
|
||||
}
|
||||
mContentModel->addFiles(path);
|
||||
|
||||
int ContentSelectorView::ContentSelector::getProfileIndex ( const QString &item) const
|
||||
{
|
||||
return ui.profilesComboBox->findText (item);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::addProfile (const QString &item, bool setAsCurrent)
|
||||
{
|
||||
if (item.isEmpty())
|
||||
return;
|
||||
|
||||
QString previous = ui.profilesComboBox->currentText();
|
||||
|
||||
if (ui.profilesComboBox->findText(item) == -1)
|
||||
ui.profilesComboBox->addItem(item);
|
||||
|
||||
if (setAsCurrent)
|
||||
setProfile (ui.profilesComboBox->findText(item));
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::setProfile(int index)
|
||||
{
|
||||
//programmatic change requires second call to non-signalized "slot" since no signal responses
|
||||
//occur for programmatic changes to the profilesComboBox.
|
||||
if (index >= -1 && index < ui.profilesComboBox->count())
|
||||
{
|
||||
QString previous = ui.profilesComboBox->itemText(ui.profilesComboBox->currentIndex());
|
||||
QString current = ui.profilesComboBox->itemText(index);
|
||||
|
||||
ui.profilesComboBox->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
QString ContentSelectorView::ContentSelector::getProfileText() const
|
||||
{
|
||||
return ui.profilesComboBox->currentText();
|
||||
}
|
||||
|
||||
QAbstractItemModel *ContentSelectorView::ContentSelector::profilesModel() const
|
||||
{
|
||||
return ui.profilesComboBox->model();
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::slotCurrentProfileIndexChanged(int index)
|
||||
{
|
||||
//don't allow deleting "Default" profile
|
||||
bool success = (ui.profilesComboBox->itemText(index) != "Default");
|
||||
|
||||
ui.deleteProfileAction->setEnabled(success);
|
||||
ui.profilesComboBox->setEditEnabled(success);
|
||||
if (ui.gameFileView->currentIndex() != -1)
|
||||
ui.gameFileView->setCurrentIndex(-1);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int index)
|
||||
@ -341,16 +148,6 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
|
||||
|
||||
if (proxy)
|
||||
proxy->setDynamicSortFilter(true);
|
||||
|
||||
slotUpdateCreateButton(true);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::slotProfileTextChanged(const QString &text)
|
||||
{
|
||||
QPushButton *opnBtn = ui.projectButtonBox->button(QDialogButtonBox::Open);
|
||||
|
||||
if (opnBtn->isEnabled())
|
||||
opnBtn->setEnabled (false);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)
|
||||
@ -362,53 +159,3 @@ void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QMode
|
||||
else
|
||||
model->setData(index, Qt::Unchecked, Qt::CheckStateRole);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::slotUpdateCreateButton(bool)
|
||||
{
|
||||
//enable only if a game file is selected and the adjuster widget is non-empty
|
||||
bool validGameFile = (ui.gameFileView->currentIndex() != -1);
|
||||
bool validFilename = false;
|
||||
|
||||
if (mAdjusterWidget)
|
||||
validFilename = mAdjusterWidget->isValid();
|
||||
|
||||
ui.projectCreateButton->setEnabled(validGameFile && validFilename);
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::on_newProfileAction_triggered()
|
||||
{
|
||||
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this);
|
||||
|
||||
if (newDialog.exec() == QDialog::Accepted)
|
||||
emit signalAddNewProfile(newDialog.getText());
|
||||
}
|
||||
|
||||
void ContentSelectorView::ContentSelector::on_deleteProfileAction_triggered()
|
||||
{
|
||||
QString profile = ui.profilesComboBox->currentText();
|
||||
|
||||
if (profile.isEmpty())
|
||||
return;
|
||||
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(tr("Delete Profile"));
|
||||
msgBox.setIcon(QMessageBox::Warning);
|
||||
msgBox.setStandardButtons(QMessageBox::Cancel);
|
||||
msgBox.setText(tr("Are you sure you want to delete <b>%0</b>?").arg(profile));
|
||||
|
||||
QAbstractButton *deleteButton =
|
||||
msgBox.addButton(tr("Delete"), QMessageBox::ActionRole);
|
||||
|
||||
msgBox.exec();
|
||||
|
||||
if (msgBox.clickedButton() != deleteButton)
|
||||
return;
|
||||
|
||||
// Remove the profile from the combobox
|
||||
ui.profilesComboBox->removeItem(ui.profilesComboBox->findText(profile));
|
||||
|
||||
//signal for removal from model
|
||||
emit signalProfileDeleted (profile);
|
||||
|
||||
slotCurrentProfileIndexChanged(ui.profilesComboBox->currentIndex());
|
||||
}
|
||||
|
@ -3,38 +3,19 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "ui_datafilespage.h"
|
||||
#include "ui_contentselector.h"
|
||||
#include "../model/contentmodel.hpp"
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
namespace CSVDoc
|
||||
{
|
||||
class FileWidget;
|
||||
class AdjusterWidget;
|
||||
}
|
||||
namespace ContentSelectorView
|
||||
{
|
||||
enum SelectorFlags
|
||||
{
|
||||
Flag_Content = 0x01, // gamefile combobox & addon list view
|
||||
Flag_NewAddon = 0x02, // enable project button box (Create/Cancel) and file/adjuster widgets
|
||||
Flag_LoadAddon = 0x04, // enable project button box (Open/Cancel)
|
||||
Flag_Profile = 0x08 // enable profile combo box
|
||||
};
|
||||
|
||||
class ContentSelector : public QWidget
|
||||
class ContentSelector : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
unsigned char mFlags;
|
||||
bool mIgnoreProfileSignal;
|
||||
|
||||
static ContentSelector *mInstance;
|
||||
static QStringList mFilePaths;
|
||||
|
||||
CSVDoc::FileWidget *mFileWidget;
|
||||
CSVDoc::AdjusterWidget *mAdjusterWidget;
|
||||
QStringList mFilePaths;
|
||||
|
||||
protected:
|
||||
|
||||
@ -44,64 +25,39 @@ namespace ContentSelectorView
|
||||
|
||||
public:
|
||||
|
||||
explicit ContentSelector(QWidget *parent = 0, unsigned char flags = Flag_Content);
|
||||
explicit ContentSelector(QWidget *parent = 0);
|
||||
|
||||
static void configure(QWidget *subject, unsigned char flags = Flag_Content);
|
||||
static ContentSelector &instance();
|
||||
static void addFiles(const QString &path);
|
||||
void addFiles(const QString &path);
|
||||
|
||||
void clearCheckStates();
|
||||
void setCheckStates (const QStringList &list);
|
||||
ContentSelectorModel::ContentFileList *CheckedItems();
|
||||
|
||||
QString projectFilename() const;
|
||||
ContentSelectorModel::ContentFileList selectedFiles() const;
|
||||
|
||||
QAbstractItemModel *profilesModel() const;
|
||||
void setGameFile (const QString &filename = "");
|
||||
void addProfile (const QString &item, bool setAsCurrent = false);
|
||||
void setProfile (int index);
|
||||
int getProfileIndex (const QString &item) const;
|
||||
QString getProfileText() const;
|
||||
void setGameFile (const QString &filename = QString(""));
|
||||
|
||||
bool isGamefileSelected() const
|
||||
{ return ui.gameFileView->currentIndex() != -1; }
|
||||
|
||||
QWidget *uiWidget() const
|
||||
{ return ui.contentGroupBox; }
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Ui::DataFilesPage ui;
|
||||
Ui::ContentSelector ui;
|
||||
|
||||
void buildContentModel();
|
||||
void buildGameFileView();
|
||||
void buildAddonView();
|
||||
void buildProfilesView();
|
||||
void buildNewAddonView();
|
||||
void buildLoadAddonView();
|
||||
|
||||
bool isFlagged(SelectorFlags flag) const;
|
||||
|
||||
signals:
|
||||
|
||||
void accepted();
|
||||
void rejected();
|
||||
|
||||
void signalCreateButtonClicked();
|
||||
|
||||
void signalProfileRenamed(QString,QString);
|
||||
void signalProfileChangedByUser(QString,QString);
|
||||
void signalProfileDeleted(QString);
|
||||
void signalAddNewProfile(QString);
|
||||
void signalCurrentGamefileIndexChanged (int);
|
||||
|
||||
private slots:
|
||||
|
||||
void slotProfileTextChanged (const QString &text);
|
||||
void slotCurrentProfileIndexChanged(int index);
|
||||
void slotCurrentGameFileIndexChanged(int index);
|
||||
void slotAddonTableItemClicked(const QModelIndex &index);
|
||||
|
||||
void slotUpdateCreateButton (bool);
|
||||
|
||||
// Action slots
|
||||
void on_newProfileAction_triggered();
|
||||
void on_deleteProfileAction_triggered();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,39 +0,0 @@
|
||||
#include <QToolButton>
|
||||
#include <QStyle>
|
||||
#include <QStylePainter>
|
||||
|
||||
#include "lineedit.hpp"
|
||||
|
||||
ContentSelectorView::LineEdit::LineEdit(QWidget *parent)
|
||||
: QLineEdit(parent)
|
||||
{
|
||||
mClearButton = new QToolButton(this);
|
||||
QPixmap pixmap(":images/clear.png");
|
||||
mClearButton->setIcon(QIcon(pixmap));
|
||||
mClearButton->setIconSize(pixmap.size());
|
||||
mClearButton->setCursor(Qt::ArrowCursor);
|
||||
mClearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
|
||||
mClearButton->hide();
|
||||
connect(mClearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateClearButton(const QString&)));
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
|
||||
setObjectName(QString("LineEdit"));
|
||||
setStyleSheet(QString("LineEdit { padding-right: %1px; } ").arg(mClearButton->sizeHint().width() + frameWidth + 1));
|
||||
QSize msz = minimumSizeHint();
|
||||
setMinimumSize(qMax(msz.width(), mClearButton->sizeHint().height() + frameWidth * 2 + 2),
|
||||
qMax(msz.height(), mClearButton->sizeHint().height() + frameWidth * 2 + 2));
|
||||
}
|
||||
|
||||
void ContentSelectorView::LineEdit::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
QSize sz = mClearButton->sizeHint();
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
mClearButton->move(rect().right() - frameWidth - sz.width(),
|
||||
(rect().bottom() + 1 - sz.height())/2);
|
||||
}
|
||||
|
||||
void ContentSelectorView::LineEdit::updateClearButton(const QString& text)
|
||||
{
|
||||
mClearButton->setVisible(!text.isEmpty());
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
#ifndef PROFILESCOMBOBOX_HPP
|
||||
#define PROFILESCOMBOBOX_HPP
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QStylePainter>
|
||||
class QString;
|
||||
class QRegExpValidator;
|
||||
|
||||
namespace ContentSelectorView
|
||||
{
|
||||
class ProfilesComboBox : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ProfilesComboBox(QWidget *parent = 0);
|
||||
void setEditEnabled(bool editable);
|
||||
void setPlaceholderText(const QString &text);
|
||||
// void indexChanged(int index);
|
||||
|
||||
signals:
|
||||
void signalProfileTextChanged(const QString &item);
|
||||
void signalProfileChanged(const QString &previous, const QString ¤t);
|
||||
void signalProfileChanged(int index);
|
||||
void profileRenamed(const QString &oldName, const QString &newName);
|
||||
|
||||
private slots:
|
||||
|
||||
void slotEditingFinished();
|
||||
void slotIndexChangedByUser(int index);
|
||||
void slotTextChanged(const QString &text);
|
||||
|
||||
private:
|
||||
QString mOldProfile;
|
||||
QString mPlaceholderText;
|
||||
QRegExpValidator *mValidator;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // PROFILESCOMBOBOX_HPP
|
111
files/ui/contentselector.ui
Normal file
111
files/ui/contentselector.ui
Normal file
@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ContentSelector</class>
|
||||
<widget class="QWidget" name="ContentSelector">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>518</width>
|
||||
<height>436</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::DefaultContextMenu</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="contentGroupBox">
|
||||
<property name="title">
|
||||
<string>Content</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ContentSelectorView::ComboBox" name="gameFileView">
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableView" name="addonView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::DefaultContextMenu</enum>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropOverwriteMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::MoveAction</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="textElideMode">
|
||||
<enum>Qt::ElideLeft</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ContentSelectorView::ComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>components/contentselector/view/combobox.hpp</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>518</width>
|
||||
<height>436</height>
|
||||
<height>108</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -21,188 +21,7 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="contentGroupBox">
|
||||
<property name="title">
|
||||
<string>Content</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="filterLayout">
|
||||
<item>
|
||||
<widget class="ContentSelectorView::ProfilesComboBox" name="gameFileView">
|
||||
<property name="editable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QTableView" name="addonView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::DefaultContextMenu</enum>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropOverwriteMode">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragDrop</enum>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::MoveAction</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="textElideMode">
|
||||
<enum>Qt::ElideLeft</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder></zorder>
|
||||
<zorder></zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="projectGroupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Project</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="fileWidgetFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="projectCreateButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Create</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="adjusterWidgetFrame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="contentSelectorWidget" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="profileGroupBox">
|
||||
@ -232,9 +51,9 @@
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="ContentSelectorView::ProfilesComboBox" name="profilesComboBox">
|
||||
<widget class="ProfilesComboBox" name="profilesComboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
@ -242,6 +61,9 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Select a profiile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -276,13 +98,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="projectButtonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Open</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="newProfileAction">
|
||||
<property name="icon">
|
||||
@ -332,9 +147,9 @@
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ContentSelectorView::ProfilesComboBox</class>
|
||||
<class>ProfilesComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>components/contentselector/view/profilescombobox.hpp</header>
|
||||
<header>apps/launcher/utils/profilescombobox.hpp</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
73
files/ui/filedialog.ui
Normal file
73
files/ui/filedialog.ui
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FileDialog</class>
|
||||
<widget class="QWidget" name="FileDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>518</width>
|
||||
<height>108</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::DefaultContextMenu</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="contentSelectorWidget" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="projectGroupBox">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Project Name</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="projectGroupBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="projectWidget" native="true">
|
||||
<layout class="QHBoxLayout" name="projectButtonBoxLayout">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="projectButtonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
x
Reference in New Issue
Block a user