Implemented combobox for game file selection

actorid
graffy76 12 years ago
parent bfb71f23c9
commit 84e5c2610a

@ -101,7 +101,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews())); connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); //connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter())); connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter()));

@ -41,6 +41,8 @@ FileDialog::FileDialog(QWidget *parent) :
QCheckBox checkBox; QCheckBox checkBox;
unsigned int height = checkBox.sizeHint().height() + 4; unsigned int height = checkBox.sizeHint().height() + 4;
masterView->setModel(mMastersProxyModel);
mastersTable->setModel(mMastersProxyModel); mastersTable->setModel(mMastersProxyModel);
mastersTable->setObjectName("MastersTable"); mastersTable->setObjectName("MastersTable");
mastersTable->setContextMenuPolicy(Qt::CustomContextMenu); mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
@ -83,12 +85,12 @@ FileDialog::FileDialog(QWidget *parent) :
mNameLabel = new QLabel(tr("File Name:"), this); mNameLabel = new QLabel(tr("File Name:"), this);
QRegExpValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9\\s]*$")); QRegExpValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9\\s]*$"));
mNameLineEdit = new LineEdit(this); //mNameLineEdit = new LineEdit(this);
mNameLineEdit->setValidator(validator); //mNameLineEdit->setValidator(validator);
nameLayout->addSpacerItem(spacer); nameLayout->addSpacerItem(spacer);
nameLayout->addWidget(mNameLabel); nameLayout->addWidget(mNameLabel);
nameLayout->addWidget(mNameLineEdit); //nameLayout->addWidget(mNameLineEdit);
mButtonBox = new QDialogButtonBox(this); mButtonBox = new QDialogButtonBox(this);
@ -109,9 +111,9 @@ FileDialog::FileDialog(QWidget *parent) :
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews())); connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
connect(mDataFilesModel, SIGNAL(checkedItemsChanged(QStringList)), this, SLOT(updateOpenButton(QStringList))); connect(mDataFilesModel, SIGNAL(checkedItemsChanged(QStringList)), this, SLOT(updateOpenButton(QStringList)));
connect(mNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString))); //connect(mNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); //connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(pluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(pluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
connect(mastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(mastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
@ -223,7 +225,7 @@ QStringList FileDialog::checkedItemsPaths()
QString FileDialog::fileName() QString FileDialog::fileName()
{ {
return mNameLineEdit->text(); //return mNameLineEdit->text();
} }
void FileDialog::openFile() void FileDialog::openFile()
@ -231,7 +233,7 @@ void FileDialog::openFile()
setWindowTitle(tr("Open")); setWindowTitle(tr("Open"));
mNameLabel->hide(); mNameLabel->hide();
mNameLineEdit->hide(); //mNameLineEdit->hide();
mCreateButton->hide(); mCreateButton->hide();
mButtonBox->removeButton(mCreateButton); mButtonBox->removeButton(mCreateButton);
@ -249,8 +251,8 @@ void FileDialog::newFile()
setWindowTitle(tr("New")); setWindowTitle(tr("New"));
mNameLabel->show(); mNameLabel->show();
mNameLineEdit->clear(); //mNameLineEdit->clear();
mNameLineEdit->show(); //mNameLineEdit->show();
mCreateButton->show(); mCreateButton->show();
mButtonBox->setStandardButtons(QDialogButtonBox::Cancel); mButtonBox->setStandardButtons(QDialogButtonBox::Cancel);

@ -51,7 +51,7 @@ private slots:
private: private:
QLabel *mNameLabel; QLabel *mNameLabel;
LineEdit *mNameLineEdit; //LineEdit *mNameLineEdit;
QPushButton *mCreateButton; QPushButton *mCreateButton;
QDialogButtonBox *mButtonBox; QDialogButtonBox *mButtonBox;

@ -90,3 +90,19 @@ void ProfilesComboBox::slotIndexChanged(int index)
emit(profileChanged(mOldProfile, currentText())); emit(profileChanged(mOldProfile, currentText()));
mOldProfile = itemText(index); mOldProfile = itemText(index);
} }
void ProfilesComboBox::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 = tr("Select a game file...");
painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
}

@ -2,7 +2,7 @@
#define PROFILESCOMBOBOX_HPP #define PROFILESCOMBOBOX_HPP
#include <QComboBox> #include <QComboBox>
#include <QStylePainter>
class QString; class QString;
class QRegExpValidator; class QRegExpValidator;
@ -25,6 +25,9 @@ private slots:
private: private:
QString mOldProfile; QString mOldProfile;
QRegExpValidator *mValidator; QRegExpValidator *mValidator;
protected:
void paintEvent(QPaintEvent *);
}; };
#endif // PROFILESCOMBOBOX_HPP #endif // PROFILESCOMBOBOX_HPP

@ -14,28 +14,12 @@
<item> <item>
<layout class="QHBoxLayout" name="filterLayout"> <layout class="QHBoxLayout" name="filterLayout">
<item> <item>
<spacer name="horizontalSpacer"> <widget class="ProfilesComboBox" name="masterView">
<property name="orientation"> <property name="editable">
<enum>Qt::Horizontal</enum> <bool>false</bool>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="filterLabel">
<property name="text">
<string>Filter:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="LineEdit" name="filterLineEdit"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -151,11 +135,6 @@
</action> </action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>LineEdit</class>
<extends>QLineEdit</extends>
<header location="global">components/fileorderlist/utils/lineedit.hpp</header>
</customwidget>
<customwidget> <customwidget>
<class>ProfilesComboBox</class> <class>ProfilesComboBox</class>
<extends>QComboBox</extends> <extends>QComboBox</extends>

Loading…
Cancel
Save