Skip to content

Commit

Permalink
Bind Plus and Minus keys for Config tab for +\- zoom respectively; A…
Browse files Browse the repository at this point in the history
…llow to change Config and Program Icon sizes independently [BUG-112];
  • Loading branch information
brezerk committed Oct 19, 2017
1 parent c14802d commit 4920bc1
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 36 deletions.
4 changes: 3 additions & 1 deletion ChangeLog
Expand Up @@ -9,7 +9,9 @@ Version 1.3.6
- Ukrainian translation;
- Spanish translation;
- Czech translation;
- Bind Plus and Minus keys for Program tab for +\- zoom respectively [BUT-112];
- Bind Plus and Minus keys for Program tab for +\- zoom respectively [BUG-112];
- Bind Plus and Minus keys for Config tab for +\- zoom respectively [BUG-112];
- Allow to change Config and Program Icon sizes independently [BUG-112];
Documented:
- q4wine prevents user from running winecfg from KRunner even after uninstalling [BUG-98];
Fixed:
Expand Down
2 changes: 2 additions & 0 deletions src/q4wine-gui/widgets/iconlisttoolbar.cpp
Expand Up @@ -90,10 +90,12 @@ void IconListToolbar::createActions(){

zoomIn.reset(new QAction(CoreLib->loadIcon("zoom-in"), tr("Zoom In"), this));
zoomIn->setStatusTip(tr("Zoom In"));
zoomIn->setShortcut(Qt::Key_Plus);
connect(zoomIn.get(), SIGNAL(triggered()), this, SLOT(zoomIn_Click()));

zoomOut.reset(new QAction(CoreLib->loadIcon("zoom-out"), tr("Zoom Out"), this));
zoomOut->setStatusTip(tr("Zoom Out"));
zoomOut->setShortcut(Qt::Key_Minus);
connect(zoomOut.get(), SIGNAL(triggered()), this, SLOT(zoomOut_Click()));

sortAlpha.reset(new QAction(this));
Expand Down
4 changes: 0 additions & 4 deletions src/q4wine-gui/widgets/iconlistwidget.cpp
Expand Up @@ -719,10 +719,6 @@ void IconListWidget::keyPressEvent (QKeyEvent * event ){
this->iconPaste_Click();
} else if (event->key() == Qt::Key_X && event->modifiers() & Qt::ControlModifier) {
this->iconCut_Click();
} else if (event->key() == Qt::Key_Plus) {
this->changeView(2);
} else if (event->key() == Qt::Key_Minus) {
this->changeView(3);
} else {
QListWidget::keyPressEvent(event);
}
Expand Down
75 changes: 47 additions & 28 deletions src/q4wine-gui/widgets/prefixconfigwidget.cpp
Expand Up @@ -58,7 +58,7 @@ PrefixConfigWidget::PrefixConfigWidget(QWidget *parent) :
treeWidget->header()->close();
connect (treeWidget.get(), SIGNAL(currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeWidget_currentItemChanged (QTreeWidgetItem *, QTreeWidgetItem *)));

treeWidget->installEventFilter(this);
//treeWidget->installEventFilter(this);

std::unique_ptr<QToolBar> iconsToolBar (new QToolBar(this));
iconsToolBar->setIconSize(QSize(24, 24));
Expand All @@ -67,8 +67,12 @@ PrefixConfigWidget::PrefixConfigWidget(QWidget *parent) :
connect(searchField.get(), SIGNAL(textChanged(QString)), this, SLOT(searchFilterChange(QString)));

//connect(searchField.get(), SIGNAL(returnPressed()), this, SLOT(appdbSearch_Click()));

iconsToolBar->addAction(searchClear.get());
iconsToolBar->addWidget(searchField.get());
iconsToolBar->addAction(zoomIn.get());
iconsToolBar->addAction(zoomOut.get());
iconsToolBar->addSeparator();
iconsToolBar->addAction(sortAlpha.get());

listWidget.reset(new QListWidget(this));
Expand All @@ -77,8 +81,10 @@ PrefixConfigWidget::PrefixConfigWidget(QWidget *parent) :
listWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
listWidget->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
listWidget->setMovement(QListView::Static);
int nSize = CoreLib->getSetting("IconWidget", "IconSize", false, 32).toInt();
listWidget->setViewMode(QListView::ListMode);
//listWidget->installEventFilter(this);

int nSize = CoreLib->getSetting("WinetricksWidget", "IconSize", false, 32).toInt();
listWidget->setGridSize(QSize());
listWidget->setIconSize(QSize(nSize, nSize));
listWidget->setWrapping(false);
Expand Down Expand Up @@ -146,21 +152,23 @@ PrefixConfigWidget::PrefixConfigWidget(QWidget *parent) :
}

PrefixConfigWidget::~PrefixConfigWidget(){
treeWidget.release();
listWidget.release();
infoName.release();

QSettings settings(APP_SHORT_NAME, "default");
if (splitter->sizes().at(0) != splitter->sizes().at(1)){
QSettings settings(APP_SHORT_NAME, "default");
settings.beginGroup("MainWindow");
settings.setValue("splitterPrefixConfigSize0", splitter->sizes().at(0));
settings.setValue("splitterPrefixConfigSize1", splitter->sizes().at(1));
settings.endGroup();
settings.beginGroup("WinetricksWidget");
settings.setValue("IconSort", this->sort_order);
settings.endGroup();
}

settings.beginGroup("WinetricksWidget");
settings.setValue("IconSort", this->sort_order);
settings.setValue("IconSize", this->listWidget->iconSize().height());
settings.endGroup();

splitter.release();
treeWidget.release();
listWidget.release();
infoName.release();
}

void PrefixConfigWidget::createActions(){
Expand All @@ -185,6 +193,16 @@ void PrefixConfigWidget::createActions(){
sortAlpha->setIcon(CoreLib->loadIcon("view-sort-ascending"));
}

zoomIn.reset(new QAction(CoreLib->loadIcon("zoom-in"), tr("Zoom In"), this));
zoomIn->setStatusTip(tr("Zoom In"));
zoomIn->setShortcut(Qt::Key_Plus);
connect(zoomIn.get(), SIGNAL(triggered()), this, SLOT(zoomIn_Click()));

zoomOut.reset(new QAction(CoreLib->loadIcon("zoom-out"), tr("Zoom Out"), this));
zoomOut->setStatusTip(tr("Zoom Out"));
zoomOut->setShortcut(Qt::Key_Minus);
connect(zoomOut.get(), SIGNAL(triggered()), this, SLOT(zoomOut_Click()));

return;
}

Expand Down Expand Up @@ -342,8 +360,9 @@ void PrefixConfigWidget::keyPressEvent ( QKeyEvent * event ){
if (!item)
return;

if (event->key() == Qt::Key_Return)
if (event->key() == Qt::Key_Return) {
itemDoubleClicked(item);
}
}

void PrefixConfigWidget::currentItemChanged (QListWidgetItem *item, QListWidgetItem *){
Expand Down Expand Up @@ -430,23 +449,6 @@ void PrefixConfigWidget::itemDoubleClicked (QListWidgetItem *item){
return;
}

bool PrefixConfigWidget::eventFilter(QObject *obj, QEvent *event)
{
if (obj == this->treeWidget.get()) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);

if (keyEvent->matches(QKeySequence::Delete)){
return true;
}
} else {
return false;
}
}
// pass the event on to the parent class
return QWidget::eventFilter(obj, event);
}

void PrefixConfigWidget::setPrefix(QString prefix){
this->cbPrefixes.get()->setCurrentIndex(cbPrefixes.get()->findText(prefix));
}
Expand All @@ -456,6 +458,23 @@ void PrefixConfigWidget::searchClear_Click(){
this->get_icons();
}

void PrefixConfigWidget::zoomIn_Click(){
QSize i_size = this->listWidget->iconSize();
if (i_size.height()){
int nSize = i_size.height()+8;
this->listWidget->setIconSize(QSize(nSize, nSize));
}
}

void PrefixConfigWidget::zoomOut_Click(){
QSize i_size = this->listWidget->iconSize();
if (i_size.height()>16){
int nSize = i_size.height()-8;
this->listWidget->setIconSize(QSize(nSize, nSize));
}
}


void PrefixConfigWidget::sortAlpha_Click(){
if (this->sort_order == D_SORT_TYPE_BY_NAME_ASC){
this->sort_order = D_SORT_TYPE_BY_NAME_DSC;
Expand Down
7 changes: 4 additions & 3 deletions src/q4wine-gui/widgets/prefixconfigwidget.h
Expand Up @@ -79,6 +79,8 @@ private slots:
void keyPressEvent ( QKeyEvent * event );
void searchClear_Click();
void sortAlpha_Click();
void zoomIn_Click();
void zoomOut_Click();
void searchFilterChange(QString);
void prefixManage_Click();

Expand All @@ -96,6 +98,8 @@ private slots:
std::unique_ptr<QAction> searchClear;
std::unique_ptr<QAction> sortAlpha;
std::unique_ptr<QLineEdit> searchField;
std::unique_ptr<QAction> zoomIn;
std::unique_ptr<QAction> zoomOut;

std::unique_ptr<QComboBox> cbPrefixes;
std::unique_ptr<QLabel> infoName;
Expand All @@ -116,9 +120,6 @@ private slots:

void get_icons(void);

protected:
bool eventFilter(QObject *obj, QEvent *ev);

};

#endif // CONFIGWIDGET_H

0 comments on commit 4920bc1

Please sign in to comment.