Skip to content

Commit

Permalink
Make 3rd party repositories scrollable
Browse files Browse the repository at this point in the history
  • Loading branch information
berolinux committed Feb 5, 2022
1 parent 931989a commit cd47dd4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/MainDialog.cpp" line="45"/>
<location filename="../src/MainDialog.cpp" line="48"/>
<source>&amp;OK</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/MainDialog.cpp" line="47"/>
<location filename="../src/MainDialog.cpp" line="50"/>
<source>&amp;Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/MainDialog.cpp" line="174"/>
<location filename="../src/MainDialog.cpp" line="177"/>
<source>Update channel changed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/MainDialog.cpp" line="174"/>
<location filename="../src/MainDialog.cpp" line="177"/>
<source>The update channel has been changed. You probably want to refresh all packages in the graphical package manager or by running &quot;dnf --refresh distro-sync&quot; in a command line.</source>
<translation type="unfinished"></translation>
</message>
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})

qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ../lang/en.ts)

add_executable(om-repo-picker MainDialog.cpp Tools.cpp UpdateChannelPicker.cpp OMRepos.cpp ThirdPartyRepoWidget.cpp ClickableLabel.cpp main.cpp ${QM_FILES})
add_executable(om-repo-picker MainDialog.cpp Tools.cpp UpdateChannelPicker.cpp OMRepos.cpp ThirdPartyRepoWidget.cpp ClickableLabel.cpp FixedWidthScrollArea.cpp main.cpp ${QM_FILES})
target_link_libraries(om-repo-picker Qt5::Widgets Qt5::Core)
install(TARGETS om-repo-picker DESTINATION bin)
7 changes: 7 additions & 0 deletions src/FixedWidthScrollArea.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "FixedWidthScrollArea.h"

void FixedWidthScrollArea::resizeEvent(QResizeEvent *e) {
QScrollArea::resizeEvent(e);
widget()->setFixedWidth(e->size().width());
setMaximumHeight(widget()->height());
}
11 changes: 11 additions & 0 deletions src/FixedWidthScrollArea.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include <QScrollArea>
#include <QResizeEvent>

class FixedWidthScrollArea:public QScrollArea {
Q_OBJECT
public:
FixedWidthScrollArea(QWidget *parent):QScrollArea(parent) {}
protected:
void resizeEvent(QResizeEvent *e) override;
};
7 changes: 5 additions & 2 deletions src/MainDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ MainDialog::MainDialog(QWidget *parent, Qt::WindowFlags f):QDialog(parent,f) {
_layout->addWidget(_omRepos, ++y, 1, 1, 2);

_thirdParty = (thirdPartyRepos[0].name ? new ThirdPartyRepoWidget(this) : nullptr);
if(_thirdParty)
_layout->addWidget(_thirdParty, ++y, 1, 1, 2);
if(_thirdParty) {
_thirdPartyScroller = new FixedWidthScrollArea(this);
_thirdPartyScroller->setWidget(_thirdParty);
_layout->addWidget(_thirdPartyScroller, ++y, 1, 1, 2);
}

_ok = new QPushButton(tr("&OK"), this);
_layout->addWidget(_ok, ++y, 1);
Expand Down
2 changes: 2 additions & 0 deletions src/MainDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "UpdateChannelPicker.h"
#include "OMRepos.h"
#include "ThirdPartyRepoWidget.h"
#include "FixedWidthScrollArea.h"

class MainDialog:public QDialog {
Q_OBJECT
Expand All @@ -24,6 +25,7 @@ public slots:
UpdateChannelPicker * _updateChannel;
QLabel * _topLbl;
OMRepos * _omRepos;
FixedWidthScrollArea *_thirdPartyScroller;
ThirdPartyRepoWidget *_thirdParty;
QPushButton * _ok;
QPushButton * _cancel;
Expand Down

0 comments on commit cd47dd4

Please sign in to comment.