browserbuttons.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #include "browserbuttons.h"
  2. BrowserButtons::BrowserButtons(QWidget *parent) :
  3. QToolBar(parent)
  4. {
  5. //Frame definition
  6. setMinimumHeight(48);
  7. setMaximumHeight(48);
  8. //Buttons
  9. //prev
  10. tbPrev=new QToolButton();
  11. tbPrev->setDisabled(true);
  12. //up
  13. tbUp=new QToolButton();
  14. //next
  15. tbNext=new QToolButton();
  16. tbNext->setDisabled(true);
  17. //home
  18. tbHome=new QToolButton();
  19. //view
  20. tbView=new QToolButton();
  21. //fullscreen
  22. tbFull=new QToolButton();
  23. tbFull->setCheckable(true);
  24. addWidget(tbPrev);
  25. addWidget(tbUp);
  26. addWidget(tbNext);
  27. addWidget(tbHome);
  28. //setLayout(layout);
  29. }
  30. //Changes some sizes for being displayed on mobile devices
  31. void BrowserButtons::setMobileGUI(){
  32. //Use 48px buttons
  33. tbPrev->setIcon(QIcon(":/icons48/prev"));
  34. tbPrev->setIconSize(QSize(48,48));
  35. tbUp->setIcon(QIcon(":/icons48/up"));
  36. tbUp->setIconSize(QSize(48,48));
  37. tbNext->setIcon(QIcon(":/icons48/next"));
  38. tbNext->setIconSize(QSize(48,48));
  39. tbHome->setIcon(QIcon(":/icons48/home"));
  40. tbHome->setIconSize(QSize(48,48));
  41. tbView->setIcon(QIcon(":/icons48/icon-view"));
  42. tbView->setIconSize(QSize(48,48));
  43. tbFull->setIcon(QIcon(":/icons48/fullscreen"));
  44. tbFull->setIconSize(QSize(48,48));
  45. //tbPrev->setStyleSheet("QToolBar {padding: 0px; background-color: red;}");
  46. tbPrev->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
  47. tbUp->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
  48. tbNext->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
  49. tbHome->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
  50. }
  51. //Adds some extra buttons for desktop
  52. void BrowserButtons::setDesktopGUI(){
  53. //Adding some more buttons for desktop
  54. addSeparator();
  55. //addWidget(tbFull);
  56. addWidget(tbView);
  57. //Use 32px buttons
  58. tbPrev->setIcon(QIcon(":/icons32/prev"));
  59. tbPrev->setIconSize(QSize(32,32));
  60. tbUp->setIcon(QIcon(":/icons32/up"));
  61. tbUp->setIconSize(QSize(32,32));
  62. tbNext->setIcon(QIcon(":/icons32/next"));
  63. tbNext->setIconSize(QSize(32,32));
  64. tbHome->setIcon(QIcon(":/icons32/home"));
  65. tbHome->setIconSize(QSize(32,32));
  66. tbView->setIcon(QIcon(":/icons32/icon-view"));
  67. tbView->setIconSize(QSize(32,32));
  68. tbFull->setIcon(QIcon(":/icons32/fullscreen"));
  69. tbFull->setIconSize(QSize(32,32));
  70. //On desktop we show a text under tool buttons
  71. tbPrev->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  72. tbUp->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  73. tbNext->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  74. tbHome->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  75. tbView->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  76. tbFull->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  77. tbPrev->setText(tr("Back"));
  78. tbUp->setText(tr("Up"));
  79. tbNext->setText(tr("Next"));
  80. tbHome->setText(tr("Home"));
  81. tbView->setText(tr("View"));
  82. tbFull->setText(tr("Maximmize"));
  83. //Exit button
  84. tbExit=new QToolButton();
  85. tbExit->setIcon(QIcon(":/icons32/exit"));
  86. tbExit->setIconSize(QSize(32,32));
  87. /*
  88. QFrame *stretch= new QFrame();
  89. stretch->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
  90. addWidget(stretch);
  91. addWidget(tbExit);*/
  92. }